Package com.linkedin.databus.client.pub

Examples of com.linkedin.databus.client.pub.TestDatabusClientNode$DummyClient


    @Test
    public void testRelocateWithInterveningClientLoginRejected()
  throws Exception
    {
  String newNodeHost = "newNode";
  DummyClient client = createClientToRelocate(newNodeHost);
  DummyClient otherClient = createDummyClient("foo");
  SgsTestNode newNode = additionalNodes.get(newNodeHost);
  try {
      int newPort = newNode.getAppPort();
      assertFalse(otherClient.connect(newPort).login());
      client.relocate(newPort, true, true);
      checkBindings(1);
      client.assertDisconnectedCallbackNotInvoked();
  } finally {
      client.disconnect();
View Full Code Here


    public void testRelocateWithLoginPreemptedAfterRelocate()
  throws Exception
    {
  String newNodeHost = "newNode";
  allowNewLogin = true// enable login preemption on new node
  DummyClient client = createClientToRelocate(newNodeHost);
  DummyClient otherClient = createDummyClient("foo");
  SgsTestNode newNode = additionalNodes.get(newNodeHost);
  try {
      int newPort = newNode.getAppPort();
      client.relocate(newPort, true, true);
      assertTrue(otherClient.connect(newPort).login());
      checkBindings(1);
      client.assertDisconnectedCallbackInvoked(false);
  } finally {
      client.disconnect();
  }
View Full Code Here

    public void testRelocateWithRedirect()
  throws Exception
    {
  String host2 = "host2";
  String host3 = "host3";
  DummyClient client = createClientToRelocate(host2);
  addNodes(host3);
  SgsTestNode node2 = additionalNodes.get(host2);
  SgsTestNode node3 = additionalNodes.get(host3);
  identityAssigner.moveIdentity("foo", node2.getNodeId(),
       node3.getNodeId());
  int objectCount = getObjectCount();
  client.relocate(node2.getAppPort(), true, false);
  waitForExpectedObjectCount(
      objectCount - MANAGED_OBJECTS_PER_SESSION);
  checkBindings(0);
  client.assertDisconnectedCallbackInvoked(false);
    }
View Full Code Here

    @Test
    public void testOldNodeFailsDuringRelocateToNewNode()
  throws Exception
    {
  String newNodeHost = "newNode";
  DummyClient client = createClientToRelocate(newNodeHost);
  int objectCount = getObjectCount();
  checkBindings(1);
  try {
      // Simulate oldNode crashing by having client not connect to
      // newNode by the timeout period.
      Thread.sleep(WAIT_TIME);
      assertEquals(objectCount - MANAGED_OBJECTS_PER_SESSION,
       getObjectCount());
      checkBindings(0);
      client.assertDisconnectedCallbackInvoked(false);
  } finally {
      client.disconnect();
  }
    }
View Full Code Here

    @Test
    public void testNewNodeFailsDuringRelocateToNewNode()
  throws Exception
    {
  String newNodeHost = "newNode";
  DummyClient client = createClientToRelocate(newNodeHost);
  checkBindings(1);
  try {
      // Shutdown new node, and wait before checking if
      // session's persistent data has been cleaned up.
      SgsTestNode newNode = additionalNodes.get(newNodeHost);
      newNode.shutdown(false);
      Thread.sleep(WAIT_TIME);
      checkBindings(0);
      client.assertDisconnectedCallbackInvoked(false);
  } finally {
      client.disconnect();
  }
    }
View Full Code Here

    @Test
    public void testClientSendDuringSuspendMessages() throws Exception {
  String newNodeHost = "newNode";
  int numMessages = 4;
  DummyClient client = createClientAndReassignIdentity(newNodeHost, true);
  try {
      client.waitForSuspendMessages();
      for (int i = 0; i < numMessages; i++) {
    MessageBuffer buf = new MessageBuffer(4);
    buf.putInt(i);
    client.sendMessage(buf.getBuffer(), false);
      }
      Thread.sleep(1000);
      client.sendSuspendMessagesComplete();
      SgsTestNode newNode = additionalNodes.get(newNodeHost);
      client.waitForRelocationNotification(newNode.getAppPort());
      client.validateMessageSequence(
    client.sessionListenerReceivedMessages, numMessages, 0);
      assertTrue(client.clientReceivedMessages.isEmpty());
      client.relocate(newNode.getAppPort(), true, true);
      client.waitForClientToReceiveExpectedMessages(numMessages);
      client.validateMessageSequence(
    client.clientReceivedMessages, numMessages, 0);
      assertTrue(client.sessionListenerReceivedMessages.isEmpty());
  } finally {
      client.disconnect();
  }
    }
View Full Code Here

    @Test
    public void testClientSendAfterSuspendMessages() throws Exception {
  String newNodeHost = "newNode";
  int numMessages = 4;
  DummyClient client = createClientAndReassignIdentity(newNodeHost, true);
  try {
      client.waitForSuspendMessages();
      client.sendSuspendMessagesComplete();
      for (int i = 0; i < numMessages; i++) {
    MessageBuffer buf = new MessageBuffer(4);
    buf.putInt(i);
    client.sendMessage(buf.getBuffer(), false);
      }
      SgsTestNode newNode = additionalNodes.get(newNodeHost);
      client.waitForRelocationNotification(newNode.getAppPort());
      // Make sure that all messages received after the suspend was
      // completed have been dropped.
      assertTrue(client.sessionListenerReceivedMessages.isEmpty());
      assertTrue(client.clientReceivedMessages.isEmpty());
      client.relocate(newNode.getAppPort(), true, true);
      assertTrue(client.sessionListenerReceivedMessages.isEmpty());
      assertTrue(client.clientReceivedMessages.isEmpty());
  } finally {
      client.disconnect();
  }
    }
View Full Code Here

  String newNodeHost, boolean setWaitForSuspendMessages)
  throws Exception
    {
  final String name = "foo";
  addNodes(newNodeHost);
  DummyClient client = createDummyClient(name);
  if (setWaitForSuspendMessages) {
      client.setWaitForSuspendMessages();
  }
  assertTrue(client.connect(serverNode.getAppPort()).login());
  SgsTestNode newNode = additionalNodes.get(newNodeHost);
  System.err.println("reassigning identity:" + name +
         " from server node to host: " +
         newNodeHost);
  identityAssigner.
View Full Code Here

     * </ul>
     */
    private DummyClient createClientToRelocate(String newNodeHost)
  throws Exception
    {
  DummyClient client =
      createClientAndReassignIdentity(newNodeHost, false);
  SgsTestNode newNode = additionalNodes.get(newNodeHost);
  client.waitForRelocationNotification(newNode.getAppPort());
  return client;
    }
View Full Code Here

    }

    @Test
    public void testRelocateClientSession() throws Exception {
  String newNodeHost = "newNode";
  DummyClient client = createClientToRelocate(newNodeHost);
  int objectCount = getObjectCount();
  try {
      SgsTestNode newNode = additionalNodes.get(newNodeHost);
      client.relocate(newNode.getAppPort(), true, true);
      // need to wait here to get the true object count to make sure
      // that objects and bindings aren't cleaned up.
      Thread.sleep(WAIT_TIME);
      assertEquals(objectCount, getObjectCount());
      checkBindings(1);
      client.assertDisconnectedCallbackNotInvoked();
  } finally {
      client.disconnect();
  }
    }
View Full Code Here

TOP

Related Classes of com.linkedin.databus.client.pub.TestDatabusClientNode$DummyClient

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.