| | |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.replication.server.changelog.api.CNIndexRecord; |
| | | import org.opends.server.replication.server.changelog.api.ChangelogException; |
| | | import org.opends.server.replication.server.changelog.api.*; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private long changeNumber; |
| | | private CNIndexRecord record; |
| | | private ChangeNumberIndexRecord record; |
| | | |
| | | /** |
| | | * Creates a record to be stored in the DraftCNDB. |
| | |
| | | } |
| | | |
| | | /** |
| | | * Decode and returns a {@link CNIndexRecord}. |
| | | * Decode and returns a {@link ChangeNumberIndexRecord}. |
| | | * |
| | | * @param changeNumber |
| | | * @param data |
| | | * the provided byte array. |
| | | * @return the decoded {@link CNIndexRecord} |
| | | * @return the decoded {@link ChangeNumberIndexRecord} |
| | | * @throws ChangelogException |
| | | * when a problem occurs. |
| | | */ |
| | | private CNIndexRecord decodeData(long changeNumber, byte[] data) |
| | | private ChangeNumberIndexRecord decodeData(long changeNumber, byte[] data) |
| | | throws ChangelogException |
| | | { |
| | | try |
| | |
| | | String stringData = new String(data, "UTF-8"); |
| | | String[] str = stringData.split(FIELD_SEPARATOR, 3); |
| | | final DN baseDN = DN.decode(str[1]); |
| | | return new CNIndexRecord(changeNumber, str[0], baseDN, new CSN(str[2])); |
| | | final CSN csn = new CSN(str[2]); |
| | | return new ChangeNumberIndexRecord(changeNumber, str[0], baseDN, csn); |
| | | } |
| | | catch (UnsupportedEncodingException e) |
| | | { |
| | |
| | | /** |
| | | * Getter for the decoded record. |
| | | * |
| | | * @return the {@link CNIndexRecord} record. |
| | | * @return the {@link ChangeNumberIndexRecord} record. |
| | | * @throws ChangelogException |
| | | * when a problem occurs. |
| | | */ |
| | | public CNIndexRecord getRecord() throws ChangelogException |
| | | public ChangeNumberIndexRecord getRecord() throws ChangelogException |
| | | { |
| | | if (record == null) |
| | | record = decodeData(changeNumber, getData()); |