Package org.I0Itec.zkclient

Examples of org.I0Itec.zkclient.ZkClient


  }

  @SuppressWarnings("unchecked")
  private Map<String, Set<Watcher>> getExistsWatches(Client client) {
    InteractionProtocol protocol = (InteractionProtocol) ClassUtil.getPrivateFieldValue(client, "_protocol");
    ZkClient zkClient = protocol.getZkClient();
    ZkConnection zkConnection = (ZkConnection) ClassUtil.getPrivateFieldValue(zkClient, "_connection");
    ZooKeeper zookeeper = zkConnection.getZookeeper();
    Object watchManager = ClassUtil.getPrivateFieldValue(zookeeper, "watchManager");
    Map<String, Set<Watcher>> existWatches = (Map<String, Set<Watcher>>) ClassUtil.getPrivateFieldValue(watchManager,
            "existWatches");
View Full Code Here


public class UpgradeAction05_06Test extends AbstractZkTest {

  @Test
  @SuppressWarnings("deprecation")
  public void testPreserveIndices() throws Exception {
    ZkClient zkClientForWriables = new ZkClient(_zk.getZkConf().getZKServers(), 5000, 5000, new WriteableZkSerializer(
            net.sf.katta.index.IndexMetaData.class));
    String indexName = "index1";
    net.sf.katta.index.IndexMetaData oldIndexMD = new net.sf.katta.index.IndexMetaData("indexPath", "analyzer", 2,
            net.sf.katta.index.IndexMetaData.IndexState.DEPLOYED);
    String oldIndicesPath = UpgradeAction05_06.getOldIndicesPath(_zk.getZkConf());
    zkClientForWriables.createPersistent(oldIndicesPath);
    zkClientForWriables.createPersistent(oldIndicesPath + "/" + indexName, oldIndexMD);
    zkClientForWriables.close();

    UpgradeAction05_06 upgradeAction = new UpgradeAction05_06();
    upgradeAction.upgrade(_protocol);

    assertEquals(1, _protocol.getIndices().size());
View Full Code Here

  @Test(timeout = 7000)
  public void testLifecycle() throws Exception {
    int GATEWAY_PORT = 2190;
    Gateway gateway = new Gateway(GATEWAY_PORT, _zk.getServerPort());
    gateway.start();
    ZkClient zkClient = new ZkClient("localhost:" + GATEWAY_PORT);

    InteractionProtocol protocol = new InteractionProtocol(zkClient, _zk.getZkConf());
    final AtomicInteger connectCount = new AtomicInteger();
    final AtomicInteger disconnectCount = new AtomicInteger();
    final Object mutex = new Object();

    protocol.registerComponent(new ConnectedComponent() {
      @Override
      public void disconnect() {
        disconnectCount.incrementAndGet();
        synchronized (mutex) {
          mutex.notifyAll();
        }
      }

      @Override
      public void reconnect() {
        connectCount.incrementAndGet();
        synchronized (mutex) {
          mutex.notifyAll();
        }
      }
    });
    synchronized (mutex) {
      gateway.stop();
      mutex.wait();
      gateway.start();
      mutex.wait();
      gateway.stop();
      mutex.wait();
      gateway.start();
      mutex.wait();
    }
    zkClient.close();
    assertEquals(2, connectCount.get());
    assertEquals(2, connectCount.get());
    gateway.stop();
  }
View Full Code Here

    masterOperation.nodeOperationsComplete(mock(MasterContext.class), Collections.EMPTY_LIST);
  }

  @Test(timeout = 15000)
  public void testWatchDogCleanup() throws Exception {
    ZkClient zkClientSpy = spy(_zk.getZkClient());
    MasterQueue queue = new MasterQueue(zkClientSpy, getRootPath());
    MasterOperation masterOperation = mock(MasterOperation.class);
    String elementName = queue.add(masterOperation);

    List<OperationId> operationIds = new ArrayList<OperationId>();
View Full Code Here

    final ZkConfiguration gatewayConf = new ZkConfiguration();
    gatewayConf.setZKRootPath(_zk.getZkConf().getZkRootPath());
    gatewayConf.setZKServers("localhost:" + GATEWAY_PORT);
    Gateway gateway = new Gateway(GATEWAY_PORT, _zk.getServerPort());
    gateway.start();
    final ZkClient zkGatewayClient = ZkKattaUtil.startZkClient(gatewayConf, 30000);
    InteractionProtocol gatewayProtocol = new InteractionProtocol(zkGatewayClient, gatewayConf);
    FileUtil.deleteFolder(new NodeConfiguration().getShardFolder());
    final Node node = new Node(gatewayProtocol, new LuceneServer());
    node.start();

    // check node-master link
    master.start();
    TestUtil.waitUntilLeaveSafeMode(master);
    TestUtil.waitUntilNumberOfLiveNode(_protocol, 1);
    assertEquals(1, _protocol.getLiveNodes().size());

    // now break the node connection
    gateway.stop();
    TestUtil.waitUntilNumberOfLiveNode(_protocol, 0);

    // now fix the node connection
    gateway.start();
    TestUtil.waitUntilNumberOfLiveNode(_protocol, 1);

    // cleanup
    node.shutdown();
    master.shutdown();
    zkGatewayClient.close();
    gateway.stop();
  }
View Full Code Here

  public int getServerPort() {
    return PORT;
  }

  public ZkClient createZkClient() {
    return new ZkClient("localhost:" + PORT);
  }
View Full Code Here

            for (String backup : backups) {
                address.append(",");
                address.append(appendDefaultPort(backup));
            }
        }
        zkClient = new ZkClient(address.toString());
        zkClient.subscribeStateChanges(new IZkStateListener() {
            public void handleStateChanged(KeeperState state) throws Exception {
                ZookeeperRegistry.this.zkState = state;
            }
            public void handleNewSession() throws Exception {
View Full Code Here

  @Test
  public void test_createEnsemble() {
    classUnderTest.setZkConnection(zkConnection);
    classUnderTest.setEnsemble("127.0.0.1:21811");
    ZkClient zkClient = null;
    try {
      classUnderTest.afterPropertiesSet();
      zkClient = classUnderTest.getObject();
      assertNotNull("target object is null", zkClient);
      zkClient.close();
    } catch (final Exception e) {
      throw new IllegalStateException(e);
    } finally {
      if (null != zkClient) {
        zkClient.close();
      }
    }
  }
View Full Code Here

  @Test
  public void test_createZkConnection() throws Exception {
    classUnderTest.setZkConnection(zkConnection);
    classUnderTest.afterPropertiesSet();
    final ZkClient zkClient = classUnderTest.getObject();
    assertNotNull("target object is null", zkClient);
  }
View Full Code Here

    classUnderTest.setZkConnection(zkConnection);
    classUnderTest.setConnectionTimeout(CONNECTION_TIMEOUT);
    classUnderTest.setSessionTimeout(SESSION_TIMEOUT);
    classUnderTest.setSerializer(serializer);
    classUnderTest.afterPropertiesSet();
    final ZkClient zkClient = classUnderTest.getObject();
    assertNotNull("target object is null", zkClient);
  }
View Full Code Here

TOP

Related Classes of org.I0Itec.zkclient.ZkClient

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.