• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CountdownWatcher类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.zookeeper.test.ClientBase.CountdownWatcher的典型用法代码示例。如果您正苦于以下问题:Java CountdownWatcher类的具体用法?Java CountdownWatcher怎么用?Java CountdownWatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CountdownWatcher类属于org.apache.zookeeper.test.ClientBase包,在下文中一共展示了CountdownWatcher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setUp

import org.apache.zookeeper.test.ClientBase.CountdownWatcher; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    LOG.info("STARTING " + getName());

    // set the snap count to something low so that we force log rollover
    // and verify that is working as part of the epoch rollover.
    SyncRequestProcessor.setSnapCount(7);

    qu = new QuorumUtil(1);
    startAll();

    for (int i = 0; i < zkClients.length; i++) {
        zkClientWatchers[i] = new CountdownWatcher();
        PeerStruct peer = qu.getPeer(i + 1);
        zkClients[i] = new ZooKeeper(
                "127.0.0.1:" + peer.clientPort,
                ClientTest.CONNECTION_TIMEOUT, zkClientWatchers[i]);
    }
    waitForClientsConnected();
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:21,代码来源:ZxidRolloverTest.java


示例2: testSessionEstablishment

import org.apache.zookeeper.test.ClientBase.CountdownWatcher; //导入依赖的package包/类
/**
 * Tests a situation when client firstly connects to a read-only server and
 * then connects to a majority server. Transition should be transparent for
 * the user.
 */
@Test(timeout = 90000)
public void testSessionEstablishment() throws Exception {
    qu.shutdown(2);

    CountdownWatcher watcher = new CountdownWatcher();
    ZooKeeper zk = new ZooKeeper(qu.getConnString(), CONNECTION_TIMEOUT,
            watcher, true);
    watcher.waitForConnected(CONNECTION_TIMEOUT);
    Assert.assertSame("should be in r/o mode", States.CONNECTEDREADONLY, zk
            .getState());
    long fakeId = zk.getSessionId();

    watcher.reset();
    qu.start(2);
    Assert.assertTrue("waiting for server up", ClientBase.waitForServerUp(
            "127.0.0.1:" + qu.getPeer(2).clientPort, CONNECTION_TIMEOUT));
    watcher.waitForConnected(CONNECTION_TIMEOUT);
    zk.create("/test", "test".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
            CreateMode.PERSISTENT);
    Assert.assertFalse("fake session and real session have same id", zk
            .getSessionId() == fakeId);

    zk.close();
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:30,代码来源:ReadOnlyModeTest.java


示例3: setUp

import org.apache.zookeeper.test.ClientBase.CountdownWatcher; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    System.setProperty("zookeeper.admin.enableServer", "false");

    // set the snap count to something low so that we force log rollover
    // and verify that is working as part of the epoch rollover.
    SyncRequestProcessor.setSnapCount(7);

    qu = new QuorumUtil(1);
    startAll();

    for (int i = 0; i < zkClients.length; i++) {
        zkClientWatchers[i] = new CountdownWatcher();
        PeerStruct peer = qu.getPeer(i + 1);
        zkClients[i] = new ZooKeeper(
                "127.0.0.1:" + peer.clientPort,
                ClientTest.CONNECTION_TIMEOUT, zkClientWatchers[i]);
    }
    waitForClientsConnected();
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:21,代码来源:ZxidRolloverTest.java


示例4: testAuthLearnerServer

import org.apache.zookeeper.test.ClientBase.CountdownWatcher; //导入依赖的package包/类
/**
 * Test to verify that servers are able to form quorum.
 * peer0 -> quorum.auth.enableSasl=true, quorum.auth.learnerRequireSasl=true, quorum.auth.serverRequireSasl=true
 * peer1 -> quorum.auth.enableSasl=true, quorum.auth.learnerRequireSasl=true, quorum.auth.serverRequireSasl=true
 */
@Test(timeout = 30000)
public void testAuthLearnerServer() throws Exception {
    Map<String, String> authConfigs = new HashMap<String, String>();
    authConfigs.put(QuorumAuth.QUORUM_SASL_AUTH_ENABLED, "true");
    authConfigs.put(QuorumAuth.QUORUM_SERVER_SASL_AUTH_REQUIRED, "true");
    authConfigs.put(QuorumAuth.QUORUM_LEARNER_SASL_AUTH_REQUIRED, "true");

    String connectStr = startQuorum(2, authConfigs, 2, false);
    CountdownWatcher watcher = new CountdownWatcher();
    ZooKeeper zk = new ZooKeeper(connectStr, ClientBase.CONNECTION_TIMEOUT,
            watcher);
    watcher.waitForConnected(ClientBase.CONNECTION_TIMEOUT);
    zk.create("/foo", new byte[0], Ids.OPEN_ACL_UNSAFE,
            CreateMode.PERSISTENT);
    zk.close();
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:22,代码来源:QuorumAuthUpgradeTest.java


示例5: testValidCredentials

import org.apache.zookeeper.test.ClientBase.CountdownWatcher; //导入依赖的package包/类
/**
 * Test to verify that server is able to start with valid credentials
 */
@Test(timeout = 30000)
public void testValidCredentials() throws Exception {
    Map<String, String> authConfigs = new HashMap<String, String>();
    authConfigs.put(QuorumAuth.QUORUM_SASL_AUTH_ENABLED, "true");
    authConfigs.put(QuorumAuth.QUORUM_SERVER_SASL_AUTH_REQUIRED, "true");
    authConfigs.put(QuorumAuth.QUORUM_LEARNER_SASL_AUTH_REQUIRED, "true");

    String connectStr = startQuorum(3, authConfigs, 3, false);
    CountdownWatcher watcher = new CountdownWatcher();
    zk = new ZooKeeper(connectStr, ClientBase.CONNECTION_TIMEOUT, watcher);
    watcher.waitForConnected(ClientBase.CONNECTION_TIMEOUT);
    for (int i = 0; i < 10; i++) {
        zk.create("/" + i, new byte[0], Ids.OPEN_ACL_UNSAFE,
                CreateMode.PERSISTENT);
    }
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:20,代码来源:QuorumDigestAuthTest.java


示例6: testSaslNotRequiredWithInvalidCredentials

import org.apache.zookeeper.test.ClientBase.CountdownWatcher; //导入依赖的package包/类
/**
 * Test to verify that server is able to start with invalid credentials if
 * the configuration is set to quorum.auth.serverRequireSasl=false.
 * Quorum will talk each other even if the authentication is not succeeded
 */
@Test(timeout = 30000)
public void testSaslNotRequiredWithInvalidCredentials() throws Exception {
    Map<String, String> authConfigs = new HashMap<String, String>();
    authConfigs.put(QuorumAuth.QUORUM_LEARNER_SASL_LOGIN_CONTEXT, "QuorumLearnerInvalid");
    authConfigs.put(QuorumAuth.QUORUM_SASL_AUTH_ENABLED, "false");
    authConfigs.put(QuorumAuth.QUORUM_SERVER_SASL_AUTH_REQUIRED, "false");
    String connectStr = startQuorum(3, authConfigs, 3, false);
    CountdownWatcher watcher = new CountdownWatcher();
    zk = new ZooKeeper(connectStr, ClientBase.CONNECTION_TIMEOUT, watcher);
    watcher.waitForConnected(ClientBase.CONNECTION_TIMEOUT);
    for (int i = 0; i < 10; i++) {
        zk.create("/" + i, new byte[0], Ids.OPEN_ACL_UNSAFE,
                CreateMode.PERSISTENT);
    }
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:21,代码来源:QuorumDigestAuthTest.java


示例7: testObserverWithValidCredentials

import org.apache.zookeeper.test.ClientBase.CountdownWatcher; //导入依赖的package包/类
/**
 * Test to verify that Observer server is able to join quorum.
 */
@Test(timeout = 30000)
public void testObserverWithValidCredentials() throws Exception {
    Map<String, String> authConfigs = new HashMap<String, String>();
    authConfigs.put(QuorumAuth.QUORUM_SASL_AUTH_ENABLED, "true");
    authConfigs.put(QuorumAuth.QUORUM_SERVER_SASL_AUTH_REQUIRED, "true");
    authConfigs.put(QuorumAuth.QUORUM_LEARNER_SASL_AUTH_REQUIRED, "true");

    // Starting auth enabled 5-node cluster. 3-Participants and 2-Observers.
    int totalServerCount = 5;
    int observerCount = 2;
    String connectStr = startQuorum(totalServerCount, observerCount,
            authConfigs, totalServerCount);
    CountdownWatcher watcher = new CountdownWatcher();
    zk = new ZooKeeper(connectStr.toString(), ClientBase.CONNECTION_TIMEOUT,
            watcher);
    watcher.waitForConnected(ClientBase.CONNECTION_TIMEOUT);
    zk.create("/myTestRoot", new byte[0], Ids.OPEN_ACL_UNSAFE,
            CreateMode.PERSISTENT);
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:23,代码来源:QuorumDigestAuthTest.java


示例8: testValidCredentials

import org.apache.zookeeper.test.ClientBase.CountdownWatcher; //导入依赖的package包/类
/**
 * Test to verify that server is able to start with valid credentials
 */
@Test(timeout = 120000)
public void testValidCredentials() throws Exception {
    String serverPrincipal = hostServerPrincipal.substring(0, hostServerPrincipal.lastIndexOf("@"));
    Map<String, String> authConfigs = new HashMap<String, String>();
    authConfigs.put(QuorumAuth.QUORUM_SASL_AUTH_ENABLED, "true");
    authConfigs.put(QuorumAuth.QUORUM_SERVER_SASL_AUTH_REQUIRED, "true");
    authConfigs.put(QuorumAuth.QUORUM_LEARNER_SASL_AUTH_REQUIRED, "true");
    authConfigs.put(QuorumAuth.QUORUM_KERBEROS_SERVICE_PRINCIPAL, serverPrincipal);
    String connectStr = startQuorum(3, authConfigs, 3, true);
    CountdownWatcher watcher = new CountdownWatcher();
    ZooKeeper zk = new ZooKeeper(connectStr, ClientBase.CONNECTION_TIMEOUT, watcher);
    watcher.waitForConnected(ClientBase.CONNECTION_TIMEOUT);
    for (int i = 0; i < 10; i++) {
        zk.create("/" + i, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    }
    zk.close();
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:21,代码来源:QuorumKerberosHostBasedAuthTest.java


示例9: testValidCredentials

import org.apache.zookeeper.test.ClientBase.CountdownWatcher; //导入依赖的package包/类
/**
 * Test to verify that server is able to start with valid credentials
 */
@Test(timeout = 120000)
public void testValidCredentials() throws Exception {
    String serverPrincipal = KerberosTestUtils.getServerPrincipal();
    serverPrincipal = serverPrincipal.substring(0, serverPrincipal.lastIndexOf("@"));
    Map<String, String> authConfigs = new HashMap<String, String>();
    authConfigs.put(QuorumAuth.QUORUM_SASL_AUTH_ENABLED, "true");
    authConfigs.put(QuorumAuth.QUORUM_SERVER_SASL_AUTH_REQUIRED, "true");
    authConfigs.put(QuorumAuth.QUORUM_LEARNER_SASL_AUTH_REQUIRED, "true");
    authConfigs.put(QuorumAuth.QUORUM_KERBEROS_SERVICE_PRINCIPAL, serverPrincipal);
    String connectStr = startQuorum(3, authConfigs, 3, true);
    CountdownWatcher watcher = new CountdownWatcher();
    ZooKeeper zk = new ZooKeeper(connectStr, ClientBase.CONNECTION_TIMEOUT, watcher);
    watcher.waitForConnected(ClientBase.CONNECTION_TIMEOUT);
    for (int i = 0; i < 10; i++) {
        zk.create("/" + i, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    }
    zk.close();
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:22,代码来源:QuorumKerberosAuthTest.java


示例10: testSessionEstablishment

import org.apache.zookeeper.test.ClientBase.CountdownWatcher; //导入依赖的package包/类
/**
 * Tests a situation when client firstly connects to a read-only server and
 * then connects to a majority server. Transition should be transparent for
 * the user.
 */
@Test
public void testSessionEstablishment() throws Exception {
    qu.shutdown(2);

    CountdownWatcher watcher = new CountdownWatcher();
    ZooKeeper zk = new ZooKeeper(qu.getConnString(), CONNECTION_TIMEOUT,
            watcher, true);
    watcher.waitForConnected(CONNECTION_TIMEOUT);
    Assert.assertSame("should be in r/o mode", States.CONNECTEDREADONLY, zk
            .getState());
    long fakeId = zk.getSessionId();

    watcher.reset();
    qu.start(2);
    Assert.assertTrue("waiting for server up", ClientBase.waitForServerUp(
            "127.0.0.1:" + qu.getPeer(2).clientPort, CONNECTION_TIMEOUT));
    watcher.waitForConnected(CONNECTION_TIMEOUT);
    zk.create("/test", "test".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
            CreateMode.PERSISTENT);
    Assert.assertFalse("fake session and real session have same id", zk
            .getSessionId() == fakeId);

    zk.close();
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:30,代码来源:ReadOnlyModeTest.java


示例11: setUp

import org.apache.zookeeper.test.ClientBase.CountdownWatcher; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    LOG.info("STARTING " + getName());

    // set the snap count to something low so that we force log rollover
    // and verify that is working as part of the epoch rollover.
    SyncRequestProcessor.setSnapCount(7);

    qu = new QuorumUtil(1);
    startAll();

    for (int i = 0; i < zkClients.length; i++) {
        zkClientWatchers[i] = new CountdownWatcher();
        int followerPort = qu.getPeer(i+1).peer.getClientPort();
        zkClients[i] = new ZooKeeper(
                "127.0.0.1:" + followerPort,
                ClientTest.CONNECTION_TIMEOUT, zkClientWatchers[i]);
    }
    waitForClients();
}
 
开发者ID:prodigeni,项目名称:zookeeper.dsc,代码行数:21,代码来源:ZxidRolloverTest.java


示例12: createClient

import org.apache.zookeeper.test.ClientBase.CountdownWatcher; //导入依赖的package包/类
private static DisconnectableZooKeeper createClient(int port,
        CountdownWatcher watcher)
    throws IOException, TimeoutException, InterruptedException
{
    DisconnectableZooKeeper zk = new DisconnectableZooKeeper(
            "127.0.0.1:" + port, ClientBase.CONNECTION_TIMEOUT, watcher);

    watcher.waitForConnected(CONNECTION_TIMEOUT);
    return zk;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:11,代码来源:FollowerResyncConcurrencyTest.java


示例13: createTestableClient

import org.apache.zookeeper.test.ClientBase.CountdownWatcher; //导入依赖的package包/类
private static TestableZooKeeper createTestableClient(
    CountdownWatcher watcher, String hp)
    throws IOException, TimeoutException, InterruptedException
{
    TestableZooKeeper zk = new TestableZooKeeper(
            hp, ClientBase.CONNECTION_TIMEOUT, watcher);

    watcher.waitForConnected(CONNECTION_TIMEOUT);
    return zk;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:11,代码来源:FollowerResyncConcurrencyTest.java


示例14: testMultiTransaction

import org.apache.zookeeper.test.ClientBase.CountdownWatcher; //导入依赖的package包/类
/**
 * Test write operations using multi request.
 */
@Test(timeout = 90000)
public void testMultiTransaction() throws Exception {
    CountdownWatcher watcher = new CountdownWatcher();
    ZooKeeper zk = new ZooKeeper(qu.getConnString(), CONNECTION_TIMEOUT,
            watcher, true);
    watcher.waitForConnected(CONNECTION_TIMEOUT); // ensure zk got connected

    final String data = "Data to be read in RO mode";
    final String node1 = "/tnode1";
    final String node2 = "/tnode2";
    zk.create(node1, data.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
            CreateMode.PERSISTENT);

    watcher.reset();
    qu.shutdown(2);
    watcher.waitForConnected(CONNECTION_TIMEOUT);
    Assert.assertEquals("Should be in r-o mode", States.CONNECTEDREADONLY,
            zk.getState());

    // read operation during r/o mode
    String remoteData = new String(zk.getData(node1, false, null));
    Assert.assertEquals("Failed to read data in r-o mode", data, remoteData);

    try {
        Transaction transaction = zk.transaction();
        transaction.setData(node1, "no way".getBytes(), -1);
        transaction.create(node2, data.getBytes(),
                ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        transaction.commit();
        Assert.fail("Write operation using multi-transaction"
                + " api has succeeded during RO mode");
    } catch (NotReadOnlyException e) {
        // ok
    }

    Assert.assertNull("Should have created the znode:" + node2,
            zk.exists(node2, false));
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:42,代码来源:ReadOnlyModeTest.java


示例15: testReadOnlyClient

import org.apache.zookeeper.test.ClientBase.CountdownWatcher; //导入依赖的package包/类
/**
 * Basic test of read-only client functionality. Tries to read and write
 * during read-only mode, then regains a quorum and tries to write again.
 */
@Test(timeout = 90000)
public void testReadOnlyClient() throws Exception {
    CountdownWatcher watcher = new CountdownWatcher();
    ZooKeeper zk = new ZooKeeper(qu.getConnString(), CONNECTION_TIMEOUT,
            watcher, true);
    watcher.waitForConnected(CONNECTION_TIMEOUT); // ensure zk got connected

    final String data = "Data to be read in RO mode";
    final String node = "/tnode";
    zk.create(node, data.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
            CreateMode.PERSISTENT);

    watcher.reset();
    qu.shutdown(2);
    watcher.waitForConnected(CONNECTION_TIMEOUT);

    // read operation during r/o mode
    String remoteData = new String(zk.getData(node, false, null));
    Assert.assertEquals(data, remoteData);

    try {
        zk.setData(node, "no way".getBytes(), -1);
        Assert.fail("Write operation has succeeded during RO mode");
    } catch (NotReadOnlyException e) {
        // ok
    }

    watcher.reset();
    qu.start(2);
    Assert.assertTrue("waiting for server up", ClientBase.waitForServerUp(
            "127.0.0.1:" + qu.getPeer(2).clientPort, CONNECTION_TIMEOUT));
    watcher.waitForConnected(CONNECTION_TIMEOUT);
    zk.setData(node, "We're in the quorum now".getBytes(), -1);

    zk.close();
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:41,代码来源:ReadOnlyModeTest.java


示例16: testFollowersStartAfterLeader

import org.apache.zookeeper.test.ClientBase.CountdownWatcher; //导入依赖的package包/类
/** 
 * See ZOOKEEPER-790 for details 
 * */
@Test
public void testFollowersStartAfterLeader() throws Exception {
    QuorumUtil qu = new QuorumUtil(1);
    CountdownWatcher watcher = new CountdownWatcher();
    qu.startQuorum();
    
    int index = 1;
    while(qu.getPeer(index).peer.leader == null) {
        index++;
    }
    
    ZooKeeper zk = new ZooKeeper(
            "127.0.0.1:" + qu.getPeer((index == 1)?2:1).peer.getClientPort(),
            ClientBase.CONNECTION_TIMEOUT, watcher);
    watcher.waitForConnected(CONNECTION_TIMEOUT);
    
    // break the quorum
    qu.shutdown(index);

    // Wait until we disconnect to proceed
    watcher.waitForDisconnected(CONNECTION_TIMEOUT);
    
    // try to reestablish the quorum
    qu.start(index);

    try{
        watcher.waitForConnected(30000);      
    } catch(TimeoutException e) {
        Assert.fail("client could not connect to reestablished quorum: giving up after 30+ seconds.");
    }

    zk.close();

    qu.tearDown();
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:39,代码来源:FollowerTest.java


示例17: testMultiToFollower

import org.apache.zookeeper.test.ClientBase.CountdownWatcher; //导入依赖的package包/类
/**
 * Tests if a multiop submitted to a non-leader propagates to the leader properly
 * (see ZOOKEEPER-1124).
 * 
 * The test works as follows. It has a client connect to a follower and submit a multiop
 * to the follower. It then verifies that the multiop successfully gets committed by the leader.
 *
 * Without the fix in ZOOKEEPER-1124, this fails with a ConnectionLoss KeeperException.
 */
@Test
public void testMultiToFollower() throws Exception {
    QuorumUtil qu = new QuorumUtil(1);
    CountdownWatcher watcher = new CountdownWatcher();
    qu.startQuorum();
    
    int index = 1;
    while(qu.getPeer(index).peer.leader == null) {
        index++;
    }
    
    ZooKeeper zk = new ZooKeeper(
            "127.0.0.1:" + qu.getPeer((index == 1)?2:1).peer.getClientPort(),
            ClientBase.CONNECTION_TIMEOUT, watcher);
    watcher.waitForConnected(CONNECTION_TIMEOUT);
    
    List<OpResult> results = new ArrayList<OpResult>();

    results = zk.multi(Arrays.asList(
            Op.create("/multi0", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
            Op.create("/multi1", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
            Op.create("/multi2", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT)
            ));
    zk.getData("/multi0", false, null);
    zk.getData("/multi1", false, null);
    zk.getData("/multi2", false, null);

    zk.close();

    qu.tearDown();
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:41,代码来源:FollowerTest.java


示例18: testClientConnectionRequestDuringStartupWithNIOServerCnxn

import org.apache.zookeeper.test.ClientBase.CountdownWatcher; //导入依赖的package包/类
/**
 * Test case for
 * {@link https://issues.apache.org/jira/browse/ZOOKEEPER-2383}.
 */
@Test(timeout = 30000)
public void testClientConnectionRequestDuringStartupWithNIOServerCnxn()
        throws Exception {
    tmpDir = ClientBase.createTmpDir();
    ClientBase.setupTestEnv();

    startSimpleZKServer(startupDelayLatch);
    SimpleZooKeeperServer simplezks = (SimpleZooKeeperServer) zks;
    Assert.assertTrue(
            "Failed to invoke zks#startup() method during server startup",
            simplezks.waitForStartupInvocation(10));

    CountdownWatcher watcher = new CountdownWatcher();
    ZooKeeper zkClient = new ZooKeeper(HOSTPORT,
            ClientBase.CONNECTION_TIMEOUT, watcher);

    Assert.assertFalse(
            "Since server is not fully started, zks#createSession() shouldn't be invoked",
            simplezks.waitForSessionCreation(5));

    LOG.info(
            "Decrements the count of the latch, so that server will proceed with startup");
    startupDelayLatch.countDown();

    Assert.assertTrue("waiting for server being up ", ClientBase
            .waitForServerUp(HOSTPORT, ClientBase.CONNECTION_TIMEOUT));

    Assert.assertTrue(
            "Failed to invoke zks#createSession() method during client session creation",
            simplezks.waitForSessionCreation(5));
    watcher.waitForConnected(ClientBase.CONNECTION_TIMEOUT);
    zkClient.close();
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:38,代码来源:ZooKeeperServerStartupTest.java


示例19: testFollowersStartAfterLeader

import org.apache.zookeeper.test.ClientBase.CountdownWatcher; //导入依赖的package包/类
/** 
 * See ZOOKEEPER-790 for details 
 * */
@Test
public void testFollowersStartAfterLeader() throws Exception {
    qu = new QuorumUtil(1);
    CountdownWatcher watcher = new CountdownWatcher();
    qu.startQuorum();

    int index = 1;
    while(qu.getPeer(index).peer.leader == null)
        index++;

    // break the quorum
    qu.shutdown(index);
    
    // try to reestablish the quorum
    qu.start(index);
    
    // Connect the client after services are restarted (otherwise we would get
    // SessionExpiredException as the previous local session was not persisted).
    ZooKeeper zk = new ZooKeeper(
            "127.0.0.1:" + qu.getPeer((index == 1)?2:1).peer.getClientPort(),
            ClientBase.CONNECTION_TIMEOUT, watcher);

    try{
        watcher.waitForConnected(CONNECTION_TIMEOUT);      
    } catch(TimeoutException e) {
        Assert.fail("client could not connect to reestablished quorum: giving up after 30+ seconds.");
    }

    zk.close();
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:34,代码来源:QuorumTest.java


示例20: testMultiToFollower

import org.apache.zookeeper.test.ClientBase.CountdownWatcher; //导入依赖的package包/类
/**
 * Tests if a multiop submitted to a non-leader propagates to the leader properly
 * (see ZOOKEEPER-1124).
 * 
 * The test works as follows. It has a client connect to a follower and submit a multiop
 * to the follower. It then verifies that the multiop successfully gets committed by the leader.
 *
 * Without the fix in ZOOKEEPER-1124, this fails with a ConnectionLoss KeeperException.
 */
@Test
public void testMultiToFollower() throws Exception {
    qu = new QuorumUtil(1);
    CountdownWatcher watcher = new CountdownWatcher();
    qu.startQuorum();

    int index = 1;
    while(qu.getPeer(index).peer.leader == null)
        index++;

    ZooKeeper zk = new ZooKeeper(
            "127.0.0.1:" + qu.getPeer((index == 1)?2:1).peer.getClientPort(),
            ClientBase.CONNECTION_TIMEOUT, watcher);
    watcher.waitForConnected(CONNECTION_TIMEOUT);

    zk.multi(Arrays.asList(
            Op.create("/multi0", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
            Op.create("/multi1", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
            Op.create("/multi2", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT)
            ));
    zk.getData("/multi0", false, null);
    zk.getData("/multi1", false, null);
    zk.getData("/multi2", false, null);

    zk.close();
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:36,代码来源:QuorumTest.java



注:本文中的org.apache.zookeeper.test.ClientBase.CountdownWatcher类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FMLFingerprintViolationEvent类代码示例发布时间:2022-05-22
下一篇:
Java Zip64Mode类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap