Examples of ReplicationMsg


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

       */
      DeleteMsg msg =
        new DeleteMsg("o=example," + TEST_ROOT_DN_STRING, firstChangeNumberServer1,
                      "uid");
      server1.publish(msg);
      ReplicationMsg msg2 = server2.receive();
      server2.updateWindowAfterReplay();
      if (msg2 instanceof DeleteMsg)
      {
        DeleteMsg del = (DeleteMsg) msg2;
        assertTrue(del.toString().equals(msg.toString()),
            "ReplicationServer basic : incorrect message body received.");
      }
      else
        fail("ReplicationServer basic : incorrect message type received: " +
          msg2.getClass().toString() + ": content: " + msg2.toString());

      /*
       * Send and receive a second Delete Msg
       */
      msg = new DeleteMsg(TEST_ROOT_DN_STRING, secondChangeNumberServer1, "uid");
      server1.publish(msg);
      msg2 = server2.receive();
      server2.updateWindowAfterReplay();
      if (msg2 instanceof DeleteMsg)
      {
        DeleteMsg del = (DeleteMsg) msg2;
        assertTrue(del.toString().equals(msg.toString()),
            "ReplicationServer basic : incorrect message body received.");
      }
      else
        fail("ReplicationServer basic : incorrect message type received: " +
          msg2.getClass().toString() + ": content: " + msg2.toString());

      /*
       * Send and receive a Delete Msg from server 2 to server 1
       */
      msg =
        new DeleteMsg("o=example," + TEST_ROOT_DN_STRING, firstChangeNumberServer2,
                      "other-uid");
      server2.publish(msg);
      msg2 = server1.receive();
      server1.updateWindowAfterReplay();
      if (msg2 instanceof DeleteMsg)
      {
        DeleteMsg del = (DeleteMsg) msg2;
        assertTrue(del.toString().equals(msg.toString()),
            "ReplicationServer basic : incorrect message body received.");
      }
      else
        fail("ReplicationServer basic : incorrect message type received: " +
          msg2.getClass().toString() + ": content: " + msg2.toString());

      /*
       * Send and receive a second Delete Msg
       */
      msg = new DeleteMsg(TEST_ROOT_DN_STRING, secondChangeNumberServer2, "uid");
      server2.publish(msg);
      msg2 = server1.receive();
      server1.updateWindowAfterReplay();
      if (msg2 instanceof DeleteMsg)
      {
        DeleteMsg del = (DeleteMsg) msg2;
        assertTrue(del.toString().equals(msg.toString()),
            "ReplicationServer basic : incorrect message body received.");
      }
      else
        fail("ReplicationServer basic : incorrect message type received: " +
          msg2.getClass().toString() + ": content: " + msg2.toString());

      debugInfo("Ending changelogBasic");
    }
    finally
    {
View Full Code Here

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

        openReplicationSession(DN.decode(TEST_ROOT_DN_STRING)3,
                             100, replicationServerPort, 1000, false);

      assertTrue(broker.isConnected());

      ReplicationMsg msg2 = broker.receive();
      broker.updateWindowAfterReplay();
      if (!(msg2 instanceof DeleteMsg))
        fail("ReplicationServer basic transmission failed:" + msg2);
      else
      {
View Full Code Here

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

    try {
      broker =
        openReplicationSession(DN.decode(TEST_ROOT_DN_STRING)3,
                             100, replicationServerPort, 5000, state);

      ReplicationMsg msg2 = broker.receive();
      broker.updateWindowAfterReplay();
      if (!(msg2 instanceof DeleteMsg))
      {
        fail("ReplicationServer basic transmission failed:" + msg2);
      }
View Full Code Here

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

        }

        // - Check msg receives by broker, through changeLog2
        while (ts > 1)
        {
          ReplicationMsg msg2;
          try
          {
            msg2 = broker2.receive();
            if (msg2 == null)
              break;
View Full Code Here

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

        new StartSessionMsg(ServerStatus.NORMAL_STATUS,
        new ArrayList<String>());
      session.publish(startSessionMsg);

      // Read the TopologyMsg that should come back.
      ReplicationMsg repMsg = session.receive();
      assertTrue(repMsg instanceof TopologyMsg);

      // close the session
      session.close();
View Full Code Here

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

         // - 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
           {
             fail("ReplicationServer transmission failed: no expected message" +
               " class: " + msg2);
             break;
           }
         }
         // Check that everything expected has been received
         assertTrue(ts == 1, "Broker2 did not receive the complete set of"
             + " expected messages: #msg received " + ts);

         // Then change the config to remove replicationServer[1] from
         // the configuration of replicationServer[0]

         SortedSet<String> servers = new TreeSet<String>();
         // Configure replicationServer[0] to be disconnected from ReplicationServer[1]
         ReplServerFakeConfiguration conf =
           new ReplServerFakeConfiguration(changelogPorts[0], "changelogDb0", 0,
                                          changelogIds[0], 0, 100, servers);
         changelogs[0].applyConfigurationChange(conf) ;
         // Sleep a while to be sure disconnection occurs
         sleep(1000);

         // We expect the receive to end because of a timeout : the link between RS1 & RS2
         // should be distroyed by the new configuration

         // Send 1 update and check that RS[1] does not receive the message after the timeout
         try
         {
           // - Del
           cn = new ChangeNumber(time, ts++, brokerIds[0]);
           DeleteMsg delMsg = new DeleteMsg("o=example," + TEST_ROOT_DN_STRING, cn, user1entryUUID);
           broker1.publish(delMsg);
           // Should receive some TopologyMsg messages for disconnection
           // between the 2 RSs
           ReplicationMsg msg = null;
           while (true)
           {
             msg = broker2.receive();
             if (msg instanceof TopologyMsg)
             {
View Full Code Here

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

      count = 0;
      try
      {
        while (true)
        {
          ReplicationMsg msg = broker.receive();
          if (msg instanceof UpdateMsg)
          {
            numMsgRcv++;
            broker.updateWindowAfterReplay();
          }
View Full Code Here

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

   * @param msgType Class of the message we are waiting for.
   * @return The expected message if it comes in time or fails (assertion).
   */
  protected static ReplicationMsg waitForSpecificMsg(ProtocolSession session, String msgType) {

    ReplicationMsg replMsg = null;

    int timeOut = 5000; // 5 seconds max to wait for the desired message
    long startTime = System.currentTimeMillis();
    long curTime = startTime;
    int nMsg = 0;
    while ((curTime - startTime) <= timeOut)
    {
      try
      {
        replMsg = session.receive();
      } catch (Exception ex)
      {
        fail("Exception waiting for " + msgType + " message : " +
          ex.getClass().getName()  + " : " + ex.getMessage());
      }
      // Get message type
      String rcvMsgType = replMsg.getClass().getName();
      if (rcvMsgType.equals(msgType))
      {
        // Ok, got it, let's return the expected message
        return replMsg;
      }
View Full Code Here

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

   * @param msgType Class of the message we are waiting for.
   * @return The expected message if it comes in time or fails (assertion).
   */
  protected static ReplicationMsg waitForSpecificMsg(ReplicationBroker broker, String msgType) {

    ReplicationMsg replMsg = null;

    int timeOut = 5000; // 5 seconds max to wait for the desired message
    long startTime = System.currentTimeMillis();
    long curTime = startTime;
    int nMsg = 0;
    while ((curTime - startTime) <= timeOut)
    {
      try
      {
        replMsg = broker.receive();
      } catch (Exception ex)
      {
        fail("Exception waiting for " + msgType + " message : " +
          ex.getClass().getName()  + " : " + ex.getMessage());
      }
      // Get message type
      String rcvMsgType = replMsg.getClass().getName();
      if (rcvMsgType.equals(msgType))
      {
        // Ok, got it, let's return the expected message
        return replMsg;
      }
View Full Code Here

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

          DN.decode("cn=changelog"), 3333,
          100, replicationServerPort,brokerSessionTimeout, false);
      assertTrue(server3.isConnected());

      // Test broker1 receives only Done
      ReplicationMsg msg;
      int msgc=0;
      do
      {
        msg = server1.receive();
        msgc++;
      }
      while(!(msg instanceof DoneMsg));
      assertTrue(msgc==1,
          "Ending " + tn + " with incorrect message number :" +
          msg.getClass().getCanonicalName());
      assertTrue(msg instanceof DoneMsg,
      "Ending " + tn + " with incorrect message type :" +
      msg.getClass().getCanonicalName());

      // Test broker2 receives only Done
      msgc=0;
      do
      {
        msg = server2.receive();
        msgc++;
      }
      while(!(msg instanceof DoneMsg));
      assertTrue(msgc==1,
          "Ending " + tn + " with incorrect message number :" +
          msg.getClass().getCanonicalName());
      assertTrue(msg instanceof DoneMsg,
      "Ending " + tn + " with incorrect message type :" +
      msg.getClass().getCanonicalName());

      // Test broker3 receives only Done
      msgc=0;
      do
      {
        msg = server3.receive();
        msgc++;
      }
      while(!(msg instanceof DoneMsg));
      assertTrue(msgc==1,
          "Ending " + tn + " with incorrect message number :" +
          msg.getClass().getCanonicalName());
      assertTrue(msg instanceof DoneMsg,
      "Ending " + tn + " with incorrect message type :" +
      msg.getClass().getCanonicalName());

      server1.stop();
      server2.stop();
      server3.stop();
      debugInfo(tn, "Ending test successfully\n\n");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.