OPENDJ-1116 Introduce abstraction for the changelog DB
Remainder of r9504: changed changeNumber from int to long.
| | |
| | | * @param changeNumber The provided change number. |
| | | */ |
| | | public ECLUpdateMsg(LDAPUpdateMsg updateMsg, MultiDomainServerState cookie, |
| | | String baseDN, int changeNumber) |
| | | String baseDN, long changeNumber) |
| | | { |
| | | this.cookie = cookie; |
| | | this.baseDN = baseDN; |
| | |
| | | { |
| | | byte[] byteCookie = String.valueOf(cookie).getBytes("UTF-8"); |
| | | byte[] byteBaseDN = String.valueOf(baseDN).getBytes("UTF-8"); |
| | | // FIXME JNR Changing line below to use long would require a protocol |
| | | // FIXME JNR Changing the line below to use long would require a protocol |
| | | // version change. Leave it like this for now until the need arises. |
| | | byte[] byteChangeNumber = |
| | | Integer.toString((int) changeNumber).getBytes("UTF-8"); |
| | |
| | | * When eclRequestType = FROM_CHANGE_NUMBER, specifies the provided change |
| | | * number first and last - [CHANGELOG]. |
| | | */ |
| | | private int firstChangeNumber = -1; |
| | | private int lastChangeNumber = -1; |
| | | private long firstChangeNumber = -1; |
| | | private long lastChangeNumber = -1; |
| | | |
| | | /** |
| | | * When eclRequestType = EQUALS_REPL_CHANGE_NUMBER, specifies the provided |
| | |
| | | eclRequestType = Short.valueOf(new String(in, pos, length, "UTF-8")); |
| | | pos += length +1; |
| | | |
| | | // sequenceNumber |
| | | length = getNextLength(in, pos); |
| | | firstChangeNumber = Integer.valueOf(new String(in, pos, length, "UTF-8")); |
| | | pos += length +1; |
| | | |
| | | // stopSequenceNumber |
| | | length = getNextLength(in, pos); |
| | | lastChangeNumber = Integer.valueOf(new String(in, pos, length, "UTF-8")); |
| | | pos += length +1; |
| | | |
| | | // replication CSN |
| | | length = getNextLength(in, pos); |
| | | String csnStr = new String(in, pos, length, "UTF-8"); |
| | | csn = new CSN(new String(in, pos, length, "UTF-8")); |
| | | pos += length + 1; |
| | | csn = new CSN(csnStr); |
| | | |
| | | // persistentSearch mode |
| | | length = getNextLength(in, pos); |
| | |
| | | crossDomainServerState = new String(in, pos, length, "UTF-8"); |
| | | pos += length + 1; |
| | | |
| | | // operation id |
| | | length = getNextLength(in, pos); |
| | | operationId = new String(in, pos, length, "UTF-8"); |
| | | pos += length + 1; |
| | |
| | | try |
| | | { |
| | | byte[] byteMode = toBytes(eclRequestType); |
| | | byte[] byteChangeNumber = toBytes(firstChangeNumber); |
| | | byte[] byteStopChangeNumber = toBytes(lastChangeNumber); |
| | | // FIXME JNR Changing the lines below to use long would require a protocol |
| | | // version change. Leave it like this for now until the need arises. |
| | | byte[] byteChangeNumber = toBytes((int) firstChangeNumber); |
| | | byte[] byteStopChangeNumber = toBytes((int) lastChangeNumber); |
| | | byte[] byteCSN = csn.toString().getBytes("UTF-8"); |
| | | byte[] bytePsearch = toBytes(isPersistent); |
| | | byte[] byteGeneralizedState = toBytes(crossDomainServerState); |
| | |
| | | * Getter on the changer number start. |
| | | * @return the changer number start. |
| | | */ |
| | | public int getFirstChangeNumber() |
| | | public long getFirstChangeNumber() |
| | | { |
| | | return firstChangeNumber; |
| | | } |
| | |
| | | * Getter on the changer number stop. |
| | | * @return the change number stop. |
| | | */ |
| | | public int getLastChangeNumber() |
| | | public long getLastChangeNumber() |
| | | { |
| | | return lastChangeNumber; |
| | | } |
| | |
| | | * Setter on the first changer number (as defined by [CHANGELOG]). |
| | | * @param firstChangeNumber the provided first change number. |
| | | */ |
| | | public void setFirstChangeNumber(int firstChangeNumber) |
| | | public void setFirstChangeNumber(long firstChangeNumber) |
| | | { |
| | | this.firstChangeNumber = firstChangeNumber; |
| | | } |
| | |
| | | * Setter on the last changer number (as defined by [CHANGELOG]). |
| | | * @param lastChangeNumber the provided last change number. |
| | | */ |
| | | public void setLastChangeNumber(int lastChangeNumber) |
| | | public void setLastChangeNumber(long lastChangeNumber) |
| | | { |
| | | this.lastChangeNumber = lastChangeNumber; |
| | | } |
| | |
| | | ResultCode.UNAVAILABLE_CRITICAL_EXTENSION, |
| | | ERR_CONTROL_INSUFFICIENT_ACCESS_RIGHTS.get(oid)); |
| | | } |
| | | else |
| | | { |
| | | // We don't want to process this non-critical control, so remove it. |
| | | removeRequestControl(c); |
| | | continue; |
| | | } |
| | | // We don't want to process this non-critical control, so remove it. |
| | | removeRequestControl(c); |
| | | continue; |
| | | } |
| | | |
| | | if (oid.equals(OID_ECL_COOKIE_EXCHANGE_CONTROL)) |
| | |
| | | { |
| | | return getFilter().matchesEntry(entry); |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create an ECL entry from a provided ECL msg. |
| | | * |
| | |
| | | addAttributeByType(ATTR_SUBSCHEMA_SUBENTRY_LC, ATTR_SUBSCHEMA_SUBENTRY_LC, |
| | | ConfigConstants.DN_DEFAULT_SCHEMA_ROOT, uAttrs, operationalAttrs); |
| | | |
| | | // numSubordinates |
| | | addAttributeByType("numsubordinates", "numSubordinates", "0", uAttrs, |
| | | operationalAttrs); |
| | | |
| | | // hasSubordinates |
| | | addAttributeByType("hassubordinates", "hasSubordinates", "false", uAttrs, |
| | | operationalAttrs); |
| | | |
| | | // entryDN |
| | | addAttributeByType("entrydn", "entryDN", dnString, uAttrs, |
| | | operationalAttrs); |
| | | |
| | |
| | | String format = dateFormat.format(new Date(csn.getTime())); |
| | | addAttributeByType("changetime", "changeTime", format, uAttrs, |
| | | operationalAttrs); |
| | | |
| | | addAttributeByType("changetype", "changeType", changetype, uAttrs, |
| | | operationalAttrs); |
| | | |
| | | addAttributeByType("targetdn", "targetDN", targetDN.toNormalizedString(), |
| | | uAttrs, operationalAttrs); |
| | | |
| | |
| | | |
| | | addAttributeByType("replicationcsn", "replicationCSN", csn |
| | | .toString(), uAttrs, operationalAttrs); |
| | | |
| | | addAttributeByType("replicaidentifier", "replicaIdentifier", Integer |
| | | .toString(csn.getServerId()), uAttrs, operationalAttrs); |
| | | |
| | |
| | | // Here is the only binary operation we know how to optimize |
| | | Collection<SearchFilter> comps = sf.getFilterComponents(); |
| | | SearchFilter sfs[] = comps.toArray(new SearchFilter[0]); |
| | | int l1 = -1; |
| | | int f1 = -1; |
| | | int l2 = -1; |
| | | int f2 = -1; |
| | | long l1 = -1; |
| | | long f1 = -1; |
| | | long l2 = -1; |
| | | long f2 = -1; |
| | | StartECLSessionMsg m1; |
| | | StartECLSessionMsg m2; |
| | | if (sfs.length > 0) |
| | |
| | | debugInfo(tn, "Ending test successfully"); |
| | | } |
| | | |
| | | private int ECLCompatWriteReadAllOps(int firstChangeNumber) |
| | | throws Exception |
| | | private int ECLCompatWriteReadAllOps(long firstChangeNumber) throws Exception |
| | | { |
| | | String tn = "ECLCompatWriteReadAllOps/" + firstChangeNumber; |
| | | debugInfo(tn, "Starting test\n\n"); |
| | |
| | | } |
| | | |
| | | private void assertEntries(List<SearchResultEntry> entries, |
| | | int firstChangeNumber, String tn, LDIFWriter ldifWriter, |
| | | long firstChangeNumber, String tn, LDIFWriter ldifWriter, |
| | | String user1entryUUID, CSN... csns) throws Exception |
| | | { |
| | | debugAndWriteEntries(ldifWriter, entries, tn); |
| | |
| | | } |
| | | } |
| | | |
| | | private void assertDnEquals(SearchResultEntry resultEntry, int changeNumber, int i) |
| | | private void assertDnEquals(SearchResultEntry resultEntry, long changeNumber, int i) |
| | | { |
| | | String actualDN = resultEntry.getDN().toNormalizedString(); |
| | | String expectedDN = "changenumber=" + (changeNumber + i) + ",cn=changelog"; |
| | | assertThat(actualDN).isEqualToIgnoringCase(expectedDN); |
| | | } |
| | | |
| | | private void ECLCompatReadFrom(int firstChangeNumber) throws Exception |
| | | private void ECLCompatReadFrom(long firstChangeNumber) throws Exception |
| | | { |
| | | String tn = "ECLCompatReadFrom/" + firstChangeNumber; |
| | | debugInfo(tn, "Starting test\n\n"); |
| | |
| | | * Process similar search as but only check that there's no control returned |
| | | * as part of the entry. |
| | | */ |
| | | private void ECLCompatNoControl(int firstChangeNumber) throws Exception |
| | | private void ECLCompatNoControl(long firstChangeNumber) throws Exception |
| | | { |
| | | String tn = "ECLCompatNoControl/" + firstChangeNumber; |
| | | debugInfo(tn, "Starting test\n\n"); |
| | |
| | | * @param lastChangeNumber |
| | | * the higher limit |
| | | */ |
| | | private void ECLCompatReadFromTo(int firstChangeNumber, int lastChangeNumber) throws Exception |
| | | private void ECLCompatReadFromTo(long firstChangeNumber, long lastChangeNumber) throws Exception |
| | | { |
| | | String tn = "ECLCompatReadFromTo/" + firstChangeNumber + "/" + lastChangeNumber; |
| | | debugInfo(tn, "Starting test\n\n"); |
| | |
| | | } |
| | | |
| | | private StartECLSessionMsg evaluateSearchParameters(DN baseDN, |
| | | int firstChangeNumber, int lastChangeNumber, String filterString) throws Exception |
| | | long firstChangeNumber, long lastChangeNumber, String filterString) throws Exception |
| | | { |
| | | final StartECLSessionMsg startCLmsg = new StartECLSessionMsg(); |
| | | ECLSearchOperation.evaluateSearchParameters(startCLmsg, baseDN, |
| | |
| | | CSN csn = new CSN(TimeThread.getTime(), 123, 45); |
| | | op.setAttachment(SYNCHROCONTEXT, new DeleteContext(csn, "uniqueid")); |
| | | DeleteMsg delmsg = new DeleteMsg(op); |
| | | int changeNumber = 21; |
| | | long changeNumber = 21; |
| | | |
| | | String baseDN = "dc=example,dc=com"; |
| | | |
| | |
| | | * Test TopologyMsg encoding and decoding. |
| | | */ |
| | | @Test(enabled=true,dataProvider = "createTopologyData") |
| | | public void topologyMsgTest(List<DSInfo> dsList, List<RSInfo> rsList, |
| | | Set<String> attrs) |
| | | public void topologyMsgTest(List<DSInfo> dsList, List<RSInfo> rsList, Set<String> attrs) |
| | | throws Exception |
| | | { |
| | | TopologyMsg msg = new TopologyMsg(dsList, rsList); |
| | |
| | | * Test StartSessionMsg encoding and decoding. |
| | | */ |
| | | @Test() |
| | | public void startECLSessionMsgTest() |
| | | throws Exception |
| | | public void startECLSessionMsgTest() throws Exception |
| | | { |
| | | // data |
| | | CSN csn = new CSN(TimeThread.getTime(), 123, 45); |
| | |
| | | |
| | | @Test(enabled=false,dataProvider = "createAddData") |
| | | public void addMsgPerfs(String rawDN, boolean isAssured, AssuredMode assuredMode, |
| | | byte safeDataLevel, List<Attribute> entryAttrList) |
| | | throws Exception |
| | | byte safeDataLevel, List<Attribute> entryAttrList) throws Exception |
| | | { |
| | | Map<ObjectClass, String> objectClassList = new HashMap<ObjectClass, String>(); |
| | | objectClassList.put(DirectoryServer.getObjectClass("organization"), "organization"); |
| | | |
| | | Attribute attr = Attributes.create("o", "com"); |
| | | Map<AttributeType, List<Attribute>> userAttList = new HashMap<AttributeType, List<Attribute>>(); |
| | | userAttList.put(attr.getAttributeType(), newList(attr)); |
| | | |
| | | |
| | | attr = Attributes.create("creatorsname", "dc=creator"); |
| | | Map<AttributeType, List<Attribute>> opList = new HashMap<AttributeType,List<Attribute>>(); |
| | | opList.put(attr.getAttributeType(), newList(attr)); |
| | | |
| | | CSN csn = new CSN(TimeThread.getTime(), 123, 45); |
| | | DN dn = DN.decode(rawDN); |
| | | |
| | | long createop = 0; |
| | | long createmsgfromop = 0; |
| | | long encodemsg = 0; |
| | |
| | | long buildnew = 0; |
| | | long t1,t2,t3,t31,t4,t5,t6 = 0; |
| | | |
| | | Map<ObjectClass, String> objectClassList = |
| | | new HashMap<ObjectClass, String>(); |
| | | objectClassList.put(DirectoryServer.getObjectClass("organization"), |
| | | "organization"); |
| | | |
| | | Attribute attr = Attributes.create("o", "com"); |
| | | List<Attribute> userAttributes = newList(attr); |
| | | Map<AttributeType, List<Attribute>> userAttList = |
| | | new HashMap<AttributeType, List<Attribute>>(); |
| | | userAttList.put(attr.getAttributeType(), userAttributes); |
| | | |
| | | |
| | | attr = Attributes.create("creatorsname", "dc=creator"); |
| | | List<Attribute> operationalAttributes = newList(attr); |
| | | Map<AttributeType, List<Attribute>> opList = |
| | | new HashMap<AttributeType,List<Attribute>>(); |
| | | opList.put(attr.getAttributeType(), operationalAttributes); |
| | | |
| | | CSN csn = new CSN(TimeThread.getTime(), 123, 45); |
| | | DN dn = DN.decode(rawDN); |
| | | |
| | | for (int i=1;i<perfRep;i++) |
| | | { |
| | | t1 = System.nanoTime(); |
| | |
| | | } |
| | | |
| | | @Test(enabled=false,dataProvider = "createModifyData") |
| | | public void modMsgPerfs(CSN csn, |
| | | String rawdn, List<Modification> mods, |
| | | boolean isAssured, AssuredMode assuredMode, |
| | | byte safeDataLevel, List<Attribute> entryAttrList) |
| | | throws Exception |
| | | public void modMsgPerfs(CSN csn, String rawdn, List<Modification> mods, |
| | | boolean isAssured, AssuredMode assuredMode, byte safeDataLevel, |
| | | List<Attribute> entryAttrList) throws Exception |
| | | { |
| | | CSN csn2 = new CSN(TimeThread.getTime(), 123, 45); |
| | | DN dn = DN.decode(rawdn); |
| | | |
| | | long createop = 0; |
| | | long createmsgfromop = 0; |
| | | long encodemsg = 0; |
| | |
| | | long buildnew = 0; |
| | | long t1,t2,t3,t31,t4,t5,t6 = 0; |
| | | |
| | | CSN csn2 = new CSN(TimeThread.getTime(), 123, 45); |
| | | DN dn = DN.decode(rawdn); |
| | | |
| | | for (int i=1;i<perfRep;i++) |
| | | { |
| | | t1 = System.nanoTime(); |