Package org.nasutekds.server.replication.common

Examples of org.nasutekds.server.replication.common.ChangeNumber


   */
  @Test(dataProvider = "changeNumberData")
  public void serverStateReloadTest(ChangeNumber cn)
  throws Exception
  {
    ChangeNumber cn1, cn3;
    cn1 = new ChangeNumber(cn.getTime()+1,cn.getSeqnum(),cn.getServerId());
    cn3 = new ChangeNumber(cn1.getTime(),cn1.getSeqnum(),(cn1.getServerId()+1));

    ServerState state1 = new ServerState();
    state1.update(cn1);
    state1.update(cn3);

View Full Code Here


  public void adjustTest()
  {
    ChangeNumberGenerator generator =
      new ChangeNumberGenerator(5, TimeThread.getTime());

    ChangeNumber cn = generator.newChangeNumber();

    ChangeNumber cn1 =
      new ChangeNumber(cn.getTime() + 5000, cn.getSeqnum(), 6);
    generator.adjust(cn1);

    ChangeNumber cn2 = generator.newChangeNumber();

    assertTrue((cn2.compareTo(cn1)>0),
        "ChangeNumberGenerator generated an earlier ChangeNumber "
        + " after calling the adjust method.");
  }
View Full Code Here

  public void adjustSameMilliTest()
  {
    ChangeNumberGenerator generator =
      new ChangeNumberGenerator(5, TimeThread.getTime());

    ChangeNumber cn = generator.newChangeNumber();

    ChangeNumber cn1 =
      new ChangeNumber(cn.getTime(), cn.getSeqnum() + 10, 6);
    generator.adjust(cn1);

    ChangeNumber cn2 = generator.newChangeNumber();

    assertTrue((cn2.compareTo(cn1)>0),
        "ChangeNumberGenerator generated an earlier ChangeNumber "
        + " after calling the adjust method.");
  }
View Full Code Here

   */
  @Test
  public void adjustRollingSeqnum()
  {
    ServerState state = new ServerState();
    ChangeNumber cn1 = new ChangeNumber(TimeThread.getTime(), Integer.MAX_VALUE, 5);
    state.update(cn1);

    ChangeNumberGenerator generator = new ChangeNumberGenerator(5, state);

    ChangeNumber cn2 = generator.newChangeNumber();

    assertTrue(cn2.getSeqnum() == 0);
    assertTrue(cn2.getTime()>cn1.getTime());
  }
View Full Code Here

    String entryuuid =
         attrs.get(0).iterator().next().getValue().toString();

    // A change on a first server.
    long changeTime = TimeThread.getTime();
    ChangeNumber t1 = new ChangeNumber(changeTime,  03);

    // A change on a second server.
    changeTime++;
    ChangeNumber t2 = new ChangeNumber(changeTime,  04);

    // Simulate the ordering t2:replace:B followed by t1:add:A that
    updateMonitorCount(baseDn, monitorAttr);

    // Replay a replace of a value B at time t2 on a second server.
    Attribute attr = Attributes.create(attrType, "B");
    Modification mod = new Modification(ModificationType.REPLACE, attr);
    List<Modification> mods = new ArrayList<Modification>(1);
    mods.add(mod);
    ModifyMsg modMsg = new ModifyMsg(t2, dn1, mods, entryuuid);
    broker.publish(modMsg);

    Thread.sleep(2000);

    // Replay an add of a value A at time t1 on a first server.
    attr = Attributes.create(attrType, "A");
    mod = new Modification(ModificationType.ADD, attr);
    mods = new ArrayList<Modification>(1);
    mods.add(mod);
    modMsg = new ModifyMsg(t1, dn1, mods, entryuuid);
    broker.publish(modMsg);

    Thread.sleep(2000);

    // Read the entry to see how the conflict was resolved.
    entry = DirectoryServer.getEntry(dn1);
    attrs = entry.getAttribute(attrType);
    String attrValue1 =
         attrs.get(0).iterator().next().getValue().toString();

    // the value should be the last (time t2) value added
    assertEquals(attrValue1, "B");
    assertEquals(getMonitorDelta(), 1);

    // Simulate the ordering t2:delete:displayname followed by
    // t1:replace:displayname
    // A change on a first server.
    changeTime++;
    t1 = new ChangeNumber(changeTime,  03);

    // A change on a second server.
    changeTime++;
    t2 = new ChangeNumber(changeTime,  04);

    // Simulate the ordering t2:delete:displayname followed by t1:replace:A
    updateMonitorCount(baseDn, monitorAttr);

    // Replay an delete of attribute displayname at time t2 on a second server.
View Full Code Here

    // before the deleted is replayed gets renamed correctly.
    //

    // add domain1 entry with 2 children : domain2 and domain3
    addEntry(domain1);
    ChangeNumber olderCn = gen.newChangeNumber();
    Thread.sleep(1000);
    domain1uid = getEntryUUID(DN.decode(domain1dn));
    addEntry(domain2);
    domain2uid = getEntryUUID(DN.decode(domain2dn));
    addEntry(domain3);
    domain3uid = getEntryUUID(DN.decode(domain3dn));
    DN conflictDomain2dn = DN.decode(
        "entryUUID = " + domain2uid + "+dc=domain2,ou=people," + TEST_ROOT_DN_STRING);
    DN conflictDomain3dn = DN.decode(
        "entryUUID = " + domain3uid + "+dc=domain3,ou=people," + TEST_ROOT_DN_STRING);

    updateMonitorCount(baseDn, unresolvedMonitorAttr);
    AlertCount = DummyAlertHandler.getAlertCount();

    // delete domain1
    delMsg = new DeleteMsg(domain1dn, olderCn, domain1uid);
    broker.publish(delMsg);

    // check that the domain1 has correctly been deleted
    assertNull(getEntry(DN.decode(domain1dn), 10000, false),
        "The DELETE replication message was not replayed");

    // check that domain2 and domain3 have been renamed
    assertNotNull(getEntry(conflictDomain2dn, 1000, true),
        "The conflicting entries were not created");
    assertNotNull(getEntry(conflictDomain3dn, 1000, true),
        "The conflicting entries were not created");

    // check that the 2 conflicting entries have been correctly marked
    assertTrue(checkEntryHasAttribute(conflictDomain2dn,
        LDAPReplicationDomain.DS_SYNC_CONFLICT, domain2dn, 1000, true));
    assertTrue(checkEntryHasAttribute(conflictDomain3dn,
        LDAPReplicationDomain.DS_SYNC_CONFLICT, domain3dn, 1000, true));

    // check that unresolved conflict count has been incremented
    assertEquals(getMonitorDelta(), 1);

    // Check that an administrative alert was generated
    // because the conflict has not been automatically resolved.
    assertEquals(DummyAlertHandler.getAlertCount(), AlertCount+2,
        "An alert was incorrectly generated when resolving conflicts");


    // delete the resulting entries for the next test
    delEntry(conflictDomain2dn);
    delEntry(conflictDomain3dn);


    //
    // Check that when a delete is replayed over an entry which has child
    // those child are also deleted
    //
    // add domain1 entry with 2 children : domain2 and domain3
    addEntry(domain1);
    domain1uid = getEntryUUID(DN.decode(domain1dn));
    addEntry(domain2);
    domain2uid = getEntryUUID(DN.decode(domain2dn));
    ChangeNumber addCn =  addEntry(domain3);
    gen.adjust(addCn);
    domain3uid = getEntryUUID(DN.decode(domain3dn));

    updateMonitorCount(baseDn, unresolvedMonitorAttr);
    AlertCount = DummyAlertHandler.getAlertCount();
View Full Code Here

   * Create Update Message Data
   */
  @DataProvider(name = "updateMessageData")
  public Object[][] createUpdateMessageData() {

    ChangeNumber cn1 = new ChangeNumber(101);
    ChangeNumber cn2 = new ChangeNumber(TimeThread.getTime(), 12345);

    //
    // Create the update message
    InternalClientConnection connection =
        InternalClientConnection.getRootConnection();
View Full Code Here

  @DataProvider(name="createReplServerStartData")
  public Object [][] createReplServerStartData() throws Exception
  {
    String baseDN = "o=test";
    ServerState state = new ServerState();
    state.update(new ChangeNumber((long)0, 0,0));
    Object[] set1 = new Object[] {1, baseDN, 0, "localhost:8989", state, 0L, (byte)0, 0};

    baseDN = "dc=example,dc=com";
    state = new ServerState();
    state.update(new ChangeNumber((long)75, 5,263));
    Object[] set2 = new Object[] {16, baseDN, 100, "anotherHost:1025", state, 1245L, (byte)25, 3456};

    return new Object [][] { set1, set2 };
  }
View Full Code Here

    operationalAttributes.add(attr);
    HashMap<AttributeType,List<Attribute>> opList=
      new HashMap<AttributeType,List<Attribute>>();
    opList.put(attr.getAttributeType(), operationalAttributes);

    ChangeNumber cn = new ChangeNumber(TimeThread.getTime(), 123, 45);

    AddMsg msg = new AddMsg(cn, rawDN, "thisIsaUniqueID", "parentUniqueId",
                            objectClass, userAttributes,
                            operationalAttributes);
View Full Code Here

  @Test(dataProvider = "createDeleteData")
  public void deleteMsgTestVLASTV1(String rawDN, boolean isAssured, AssuredMode assuredMode,
    byte safeDataLevel, List<Attribute> entryAttrList)
  throws Exception
  {
    ChangeNumber cn = new ChangeNumber(TimeThread.getTime(), 123, 45);
    DeleteMsg msg = new DeleteMsg(rawDN, cn, "thisIsaUniqueID");

    msg.setAssured(isAssured);
    msg.setAssuredMode(assuredMode);
    msg.setSafeDataLevel(safeDataLevel);
View Full Code Here

TOP

Related Classes of org.nasutekds.server.replication.common.ChangeNumber

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.