Package org.nasutekds.server.replication.protocol

Examples of org.nasutekds.server.replication.protocol.ModifyMsg


      // See if the client has received the msg
      ReplicationMsg msg = broker.receive();
      assertTrue(msg instanceof ModifyMsg,
      "The received replication message is not a MODIFY msg : " + msg);
      ModifyMsg modMsg = (ModifyMsg) msg;

      modMsg.createOperation(connection);
      assertTrue(DN.decode(modMsg.getDn()).compareTo(personEntry.getDN()) == 0,
      "The received MODIFY replication message is not for the excepted DN : " + modMsg);

      // Modify the entry DN
      DN newDN = DN.decode("uid= new person,ou=People," + TEST_ROOT_DN_STRING) ;
      ModifyDNOperationBasis modDNOp = new ModifyDNOperationBasis(connection,
          InternalClientConnection.nextOperationID(), InternalClientConnection
          .nextMessageID(), null, personEntry.getDN(), RDN
          .decode("uid=new person"), true, DN
          .decode("ou=People," + TEST_ROOT_DN_STRING));
      modDNOp.run();
      assertTrue(DirectoryServer.entryExists(newDN),
      "The MOD_DN operation didn't create the new person entry");
      assertFalse(DirectoryServer.entryExists(personEntry.getDN()),
      "The MOD_DN operation didn't delete the old person entry");

      // See if the client has received the msg
      msg = broker.receive();
      assertTrue(msg instanceof ModifyDNMsg,
      "The received replication message is not a MODIFY DN msg : " + msg);
      ModifyDNMsg moddnMsg = (ModifyDNMsg) msg;
      moddnMsg.createOperation(connection);

      assertTrue(DN.decode(moddnMsg.getDn()).compareTo(personEntry.getDN()) == 0,
      "The received MODIFY_DN message is not for the excepted DN : " + moddnMsg);

      // Delete the entry
      DeleteOperationBasis delOp = new DeleteOperationBasis(connection,
          InternalClientConnection.nextOperationID(), InternalClientConnection
          .nextMessageID(), null, DN
          .decode("uid= new person,ou=People," + TEST_ROOT_DN_STRING));
      delOp.run();
      assertFalse(DirectoryServer.entryExists(newDN),
      "Unable to delete the new person Entry");

      // See if the client has received the msg
      msg = broker.receive();
      assertTrue(msg instanceof DeleteMsg,
      "The received replication message is not a MODIFY DN msg : " + msg);
      DeleteMsg delMsg = (DeleteMsg) msg;
      delMsg.createOperation(connection);
      assertTrue(DN.decode(delMsg.getDn()).compareTo(DN
          .decode("uid= new person,ou=People," + TEST_ROOT_DN_STRING)) == 0,
      "The received DELETE message is not for the excepted DN : " + delMsg);

      /*
       * Now check that when we send message to the ReplicationServer
       * and that they are received and correctly replayed by the server.
       *
       * Start by testing the Add message reception
       */
      AddMsg addMsg = new AddMsg(gen.newChangeNumber(),
          personWithUUIDEntry.getDN().toString(),
          user1entryUUID, baseUUID,
          personWithUUIDEntry.getObjectClassAttribute(),
          personWithUUIDEntry.getAttributes(), new ArrayList<Attribute>());
      if (assured)
        addMsg.setAssured(true);
      broker.publish(addMsg);

      /*
       * Check that the entry has been created in the local DS.
       */
      Entry resultEntry = getEntry(personWithUUIDEntry.getDN(), 10000, true);
      assertNotNull(resultEntry,
      "The send ADD replication message was not applied for "+personWithUUIDEntry.getDN().toString());

      /*
       * Test the reception of Modify Msg
       */
      modMsg = new ModifyMsg(gen.newChangeNumber(), personWithUUIDEntry.getDN(),
          mods, user1entryUUID);
      if (assured)
        modMsg.setAssured(true);
      broker.publish(modMsg);

      boolean found = checkEntryHasAttribute(personWithUUIDEntry.getDN(),
          "telephonenumber", "01 02 45", 10000, true);

      if (found == false)
        fail("The modification has not been correctly replayed.");

      // Test that replication is able to add attribute that do
      // not exist in the schema.
      List<Modification> invalidMods = generatemods("badattribute", "value");
      modMsg = new ModifyMsg(gen.newChangeNumber(), personWithUUIDEntry.getDN(),
          invalidMods, user1entryUUID);
      if (assured)
        modMsg.setAssured(true);
      broker.publish(modMsg);

      found = checkEntryHasAttribute(
          personWithUUIDEntry.getDN(), "badattribute", "value", 10000, true);
      if (found == false)
View Full Code Here


        Attribute attr1 = Attributes.create("description", "new value");
        Modification mod1 = new Modification(ModificationType.REPLACE, attr1);
        List<Modification> mods = new ArrayList<Modification>();
        mods.add(mod1);
        cn = new ChangeNumber(time, ts++, brokerIds[0]);
        ModifyMsg modMsg = new ModifyMsg(cn, DN
            .decode("o=example," + TEST_ROOT_DN_STRING), mods, "fakeuniqueid");
        broker1.publish(modMsg);

        // - ModifyDN
        cn = new ChangeNumber(time, ts++, brokerIds[0]);
        ModifyDNOperationBasis op = new ModifyDNOperationBasis(connection, 1, 1, null, DN
            .decode("o=example," + TEST_ROOT_DN_STRING), RDN.decode("o=example2"), true,
            null);
        op.setAttachment(SYNCHROCONTEXT, new ModifyDnContext(cn, "uniqueid",
        "newparentId"));
        LocalBackendModifyDNOperation localOp =
          new LocalBackendModifyDNOperation(op);
        ModifyDNMsg modDNMsg = new ModifyDNMsg(localOp);
        broker1.publish(modDNMsg);

        if (itest > 0)
        {
          socket.close();

          SortedSet<String> servers = new TreeSet<String>();
          servers.add("localhost:"+changelogPorts[0]);
          ReplServerFakeConfiguration conf =
            new ReplServerFakeConfiguration(changelogPorts[1], null, 0,
                                           changelogIds[1], 0, 0, null);
          changelogs[1] = new ReplicationServer(conf);

          // Connect broker 2 to changelog2
          broker2 = openReplicationSession(DN.decode(TEST_ROOT_DN_STRING),
              brokerIds[1], 100, changelogPorts[1], 2000, !emptyOldChanges);
          assertTrue(broker2.isConnected());
        }

        // - Check msg receives by broker, through changeLog2
        while (ts > 1)
        {
          ReplicationMsg msg2;
          try
          {
            msg2 = broker2.receive();
            if (msg2 == null)
              break;
            broker2.updateWindowAfterReplay();
          }
          catch (Exception e)
          {
            fail("Broker receive failed: " + e.getMessage() + "#Msg:" + ts + "#itest:" + itest);
            break;
          }

          if (msg2 instanceof DeleteMsg)
          {
            DeleteMsg delMsg2 = (DeleteMsg) msg2;
            if (delMsg2.toString().equals(delMsg.toString()))
              ts--;
          }
          else if (msg2 instanceof AddMsg)
          {
            AddMsg addMsg2 = (AddMsg) msg2;
            if (addMsg2.toString().equals(addMsg.toString()))
              ts--;
          }
          else if (msg2 instanceof ModifyMsg)
          {
            ModifyMsg modMsg2 = (ModifyMsg) msg2;
            if (modMsg.equals(modMsg2))
              ts--;
          }
          else if (msg2 instanceof ModifyDNMsg)
          {
View Full Code Here

       mods.add(mod2);
       mods.add(mod3);

       cn = new ChangeNumber(time, ts++, serverId);
       DN dn = DN.decode("o=example,"+suffix);
       ModifyMsg modMsg = new ModifyMsg(cn, dn,
           mods, "fakeuniqueid");
       l.add(modMsg);

       // Modify DN
       cn = new ChangeNumber(time, ts++, serverId);
View Full Code Here

         Attribute attr1 = Attributes.create("description", "new value");
         Modification mod1 = new Modification(ModificationType.REPLACE, attr1);
         List<Modification> mods = new ArrayList<Modification>();
         mods.add(mod1);
         cn = new ChangeNumber(time, ts++, brokerIds[0]);
         ModifyMsg modMsg = new ModifyMsg(cn, DN
             .decode("o=example," + TEST_ROOT_DN_STRING), mods, "fakeuniqueid");
         broker1.publish(modMsg);

         // - Check msg received by broker, through changeLog2

         while (ts > 1)
         {
           ReplicationMsg msg2;
           try
           {
             msg2 = broker2.receive();
             if (msg2 == null)
               break;
             broker2.updateWindowAfterReplay();
           }
           catch (Exception e)
           {
             fail("Broker receive failed: " + e.getMessage() + "#Msg: " + ts);
             break;
           }

           if (msg2 instanceof AddMsg)
           {
             AddMsg addMsg2 = (AddMsg) msg2;
             if (addMsg2.toString().equals(addMsg.toString()))
               ts--;
           }
           else if (msg2 instanceof ModifyMsg)
           {
             ModifyMsg modMsg2 = (ModifyMsg) msg2;
             if (modMsg.equals(modMsg2))
               ts--;
           }
           else
           {
View Full Code Here

      ChangeNumber cn3 = new ChangeNumber(TimeThread.getTime(), ts++, 1201);
      Attribute attr1 = Attributes.create("description", "new value");
      Modification mod1 = new Modification(ModificationType.REPLACE, attr1);
      List<Modification> mods = new ArrayList<Modification>();
      mods.add(mod1);
      ModifyMsg modMsg = new ModifyMsg(cn3, DN
          .decode("uid="+tn+"3," + TEST_ROOT_DN_STRING), mods, tn+"uuid3");
      server01.publish(modMsg);
      debugInfo(tn, " publishes " + modMsg.getChangeNumber());

      // Publish modDN
      DN newSuperior = DN.decode(TEST_ROOT_DN_STRING2);
      ChangeNumber cn4 = new ChangeNumber(TimeThread.getTime(), ts++, 1201);
      ModifyDNOperationBasis op = new ModifyDNOperationBasis(connection, 1, 1, null,
View Full Code Here

      ChangeNumber cn3 = new ChangeNumber(TimeThread.getTime(), ts++, 1201);
      Attribute attr1 = Attributes.create("description", "new value");
      Modification mod1 = new Modification(ModificationType.REPLACE, attr1);
      List<Modification> mods = new ArrayList<Modification>();
      mods.add(mod1);
      ModifyMsg modMsg = new ModifyMsg(cn3, DN
          .decode("uid="+tn+"3," + TEST_ROOT_DN_STRING), mods, user1entryUUID);
      server01.publish(modMsg);
      debugInfo(tn, " publishes " + modMsg.getChangeNumber());

      // Publish modDN
      ChangeNumber cn4 = new ChangeNumber(TimeThread.getTime(), ts++, 1201);
      ModifyDNOperationBasis op = new ModifyDNOperationBasis(connection, 1, 1, null,
          DN.decode("uid="+tn+"4," + TEST_ROOT_DN_STRING), // entryDN
View Full Code Here

   * {@inheritDoc}
   */
  @Override
  public ReplicationMsg generateMessage()
  {
    return new ModifyMsg(super.getChangeNumber(), dn, mods, entryuuid);
  }
View Full Code Here

          {
            if (op instanceof ModifyOperation)
            {
              ModifyOperation newOp = (ModifyOperation) op;
              dependency = remotePendingChanges.checkDependencies(newOp);
              ModifyMsg modifyMsg = (ModifyMsg) msg;
              done = solveNamingConflict(newOp, modifyMsg);
            } else if (op instanceof DeleteOperation)
            {
              DeleteOperation newOp = (DeleteOperation) op;
              dependency = remotePendingChanges.checkDependencies(newOp);
View Full Code Here

                     stringUID(sequence),
                     entry.getObjectClassAttribute(),
                     entry.getAttributes(), null );
        broker.publish(addMsg);

        ModifyMsg modifyMsg =
          new ModifyMsg(gen.newChangeNumber(), DN.decode(addDn),
                        generatemods("description", "test"),
                        stringUID(sequence+1));
        broker.publish(modifyMsg);
      }
View Full Code Here

TOP

Related Classes of org.nasutekds.server.replication.protocol.ModifyMsg

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.