Java 类org.apache.zookeeper.test.QuorumUtil.PeerStruct 实例源码

项目:fuck_zookeeper    文件:ZxidRolloverTest.java   
@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();
}
项目:fuck_zookeeper    文件:ZxidRolloverTest.java   
/**
 * Ensure the client is able to talk to the server.
 * 
 * @param idx the idx of the server the client is talking to
 */
private void checkClientConnected(int idx) throws Exception {
    ZooKeeper zk = getClient(idx);
    if (zk == null) {
        return;
    }
    try {
        assertNull(zk.exists("/foofoofoo-connected", false));
    } catch (ConnectionLossException e) {
        // second chance...
        // in some cases, leader change in particular, the timing is
        // very tricky to get right in order to assure that the client has
        // disconnected and reconnected. In some cases the client will
        // disconnect, then attempt to reconnect before the server is
        // back, in which case we'll see another connloss on the operation
        // in the try, this catches that case and waits for the server
        // to come back
        PeerStruct peer = qu.getPeer(idx);
        Assert.assertTrue("Waiting for server down", ClientBase.waitForServerUp(
                "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

        assertNull(zk.exists("/foofoofoo-connected", false));
    }
}
项目:fuck_zookeeper    文件:ZxidRolloverTest.java   
private void shutdown(int idx) throws Exception {
    qu.shutdown(idx);

    // leader will shutdown, remaining followers will elect a new leader
    PeerStruct peer = qu.getPeer(idx);
    Assert.assertTrue("Waiting for server down", ClientBase.waitForServerDown(
            "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

    // if idx is the the leader then everyone will get disconnected,
    // otherwise if idx is a follower then just that client will get
    // disconnected
    if (idx == idxLeader) {
        checkClientDisconnected(idx);
        try {
            checkClientsDisconnected();
        } catch (AssertionFailedError e) {
            // the clients may or may not have already reconnected
            // to the recovered cluster, force a check, but ignore
        }
    } else {
        checkClientDisconnected(idx);
    }
}
项目:https-github.com-apache-zookeeper    文件:ZxidRolloverTest.java   
@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();
}
项目:https-github.com-apache-zookeeper    文件:ZxidRolloverTest.java   
/**
 * Ensure the client is able to talk to the server.
 * 
 * @param idx the idx of the server the client is talking to
 */
private void checkClientConnected(int idx) throws Exception {
    ZooKeeper zk = getClient(idx);
    if (zk == null) {
        return;
    }
    try {
        Assert.assertNull(zk.exists("/foofoofoo-connected", false));
    } catch (ConnectionLossException e) {
        // second chance...
        // in some cases, leader change in particular, the timing is
        // very tricky to get right in order to assure that the client has
        // disconnected and reconnected. In some cases the client will
        // disconnect, then attempt to reconnect before the server is
        // back, in which case we'll see another connloss on the operation
        // in the try, this catches that case and waits for the server
        // to come back
        PeerStruct peer = qu.getPeer(idx);
        Assert.assertTrue("Waiting for server down", ClientBase.waitForServerUp(
                "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

        Assert.assertNull(zk.exists("/foofoofoo-connected", false));
    }
}
项目:https-github.com-apache-zookeeper    文件:ZxidRolloverTest.java   
private void shutdown(int idx) throws Exception {
    qu.shutdown(idx);

    // leader will shutdown, remaining followers will elect a new leader
    PeerStruct peer = qu.getPeer(idx);
    Assert.assertTrue("Waiting for server down", ClientBase.waitForServerDown(
            "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

    // if idx is the the leader then everyone will get disconnected,
    // otherwise if idx is a follower then just that client will get
    // disconnected
    if (idx == idxLeader) {
        checkClientDisconnected(idx);
        try {
            checkClientsDisconnected();
        } catch (AssertionError e) {
            // the clients may or may not have already reconnected
            // to the recovered cluster, force a check, but ignore
        }
    } else {
        checkClientDisconnected(idx);
    }
}
项目:ZooKeeper    文件:ZxidRolloverTest.java   
@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();
}
项目:ZooKeeper    文件:ZxidRolloverTest.java   
/**
 * Ensure the client is able to talk to the server.
 * 
 * @param idx the idx of the server the client is talking to
 */
private void checkClientConnected(int idx) throws Exception {
    ZooKeeper zk = getClient(idx);
    if (zk == null) {
        return;
    }
    try {
        assertNull(zk.exists("/foofoofoo-connected", false));
    } catch (ConnectionLossException e) {
        // second chance...
        // in some cases, leader change in particular, the timing is
        // very tricky to get right in order to assure that the client has
        // disconnected and reconnected. In some cases the client will
        // disconnect, then attempt to reconnect before the server is
        // back, in which case we'll see another connloss on the operation
        // in the try, this catches that case and waits for the server
        // to come back
        PeerStruct peer = qu.getPeer(idx);
        Assert.assertTrue("Waiting for server down", ClientBase.waitForServerUp(
                "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

        assertNull(zk.exists("/foofoofoo-connected", false));
    }
}
项目:ZooKeeper    文件:ZxidRolloverTest.java   
private void shutdown(int idx) throws Exception {
    qu.shutdown(idx);

    // leader will shutdown, remaining followers will elect a new leader
    PeerStruct peer = qu.getPeer(idx);
    Assert.assertTrue("Waiting for server down", ClientBase.waitForServerDown(
            "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

    // if idx is the the leader then everyone will get disconnected,
    // otherwise if idx is a follower then just that client will get
    // disconnected
    if (idx == idxLeader) {
        checkClientDisconnected(idx);
        try {
            checkClientsDisconnected();
        } catch (AssertionFailedError e) {
            // the clients may or may not have already reconnected
            // to the recovered cluster, force a check, but ignore
        }
    } else {
        checkClientDisconnected(idx);
    }
}
项目:StreamProcessingInfrastructure    文件:ZxidRolloverTest.java   
@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();
}
项目:StreamProcessingInfrastructure    文件:ZxidRolloverTest.java   
/**
 * Ensure the client is able to talk to the server.
 * 
 * @param idx the idx of the server the client is talking to
 */
private void checkClientConnected(int idx) throws Exception {
    ZooKeeper zk = getClient(idx);
    if (zk == null) {
        return;
    }
    try {
        assertNull(zk.exists("/foofoofoo-connected", false));
    } catch (ConnectionLossException e) {
        // second chance...
        // in some cases, leader change in particular, the timing is
        // very tricky to get right in order to assure that the client has
        // disconnected and reconnected. In some cases the client will
        // disconnect, then attempt to reconnect before the server is
        // back, in which case we'll see another connloss on the operation
        // in the try, this catches that case and waits for the server
        // to come back
        PeerStruct peer = qu.getPeer(idx);
        Assert.assertTrue("Waiting for server down", ClientBase.waitForServerUp(
                "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

        assertNull(zk.exists("/foofoofoo-connected", false));
    }
}
项目:StreamProcessingInfrastructure    文件:ZxidRolloverTest.java   
private void shutdown(int idx) throws Exception {
    qu.shutdown(idx);

    // leader will shutdown, remaining followers will elect a new leader
    PeerStruct peer = qu.getPeer(idx);
    Assert.assertTrue("Waiting for server down", ClientBase.waitForServerDown(
            "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

    // if idx is the the leader then everyone will get disconnected,
    // otherwise if idx is a follower then just that client will get
    // disconnected
    if (idx == idxLeader) {
        checkClientDisconnected(idx);
        try {
            checkClientsDisconnected();
        } catch (AssertionFailedError e) {
            // the clients may or may not have already reconnected
            // to the recovered cluster, force a check, but ignore
        }
    } else {
        checkClientDisconnected(idx);
    }
}
项目:bigstreams    文件:ZxidRolloverTest.java   
@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();
}
项目:bigstreams    文件:ZxidRolloverTest.java   
/**
 * Ensure the client is able to talk to the server.
 * 
 * @param idx the idx of the server the client is talking to
 */
private void checkClientConnected(int idx) throws Exception {
    ZooKeeper zk = getClient(idx);
    if (zk == null) {
        return;
    }
    try {
        assertNull(zk.exists("/foofoofoo-connected", false));
    } catch (ConnectionLossException e) {
        // second chance...
        // in some cases, leader change in particular, the timing is
        // very tricky to get right in order to assure that the client has
        // disconnected and reconnected. In some cases the client will
        // disconnect, then attempt to reconnect before the server is
        // back, in which case we'll see another connloss on the operation
        // in the try, this catches that case and waits for the server
        // to come back
        PeerStruct peer = qu.getPeer(idx);
        Assert.assertTrue("Waiting for server down", ClientBase.waitForServerUp(
                "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

        assertNull(zk.exists("/foofoofoo-connected", false));
    }
}
项目:bigstreams    文件:ZxidRolloverTest.java   
private void shutdown(int idx) throws Exception {
    qu.shutdown(idx);

    // leader will shutdown, remaining followers will elect a new leader
    PeerStruct peer = qu.getPeer(idx);
    Assert.assertTrue("Waiting for server down", ClientBase.waitForServerDown(
            "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

    // if idx is the the leader then everyone will get disconnected,
    // otherwise if idx is a follower then just that client will get
    // disconnected
    if (idx == idxLeader) {
        checkClientDisconnected(idx);
        try {
            checkClientsDisconnected();
        } catch (AssertionFailedError e) {
            // the clients may or may not have already reconnected
            // to the recovered cluster, force a check, but ignore
        }
    } else {
        checkClientDisconnected(idx);
    }
}
项目:zookeeper    文件:ZxidRolloverTest.java   
@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();
}
项目:zookeeper    文件:ZxidRolloverTest.java   
/**
 * Ensure the client is able to talk to the server.
 * 
 * @param idx the idx of the server the client is talking to
 */
private void checkClientConnected(int idx) throws Exception {
    ZooKeeper zk = getClient(idx);
    if (zk == null) {
        return;
    }
    try {
        assertNull(zk.exists("/foofoofoo-connected", false));
    } catch (ConnectionLossException e) {
        // second chance...
        // in some cases, leader change in particular, the timing is
        // very tricky to get right in order to assure that the client has
        // disconnected and reconnected. In some cases the client will
        // disconnect, then attempt to reconnect before the server is
        // back, in which case we'll see another connloss on the operation
        // in the try, this catches that case and waits for the server
        // to come back
        PeerStruct peer = qu.getPeer(idx);
        Assert.assertTrue("Waiting for server down", ClientBase.waitForServerUp(
                "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

        assertNull(zk.exists("/foofoofoo-connected", false));
    }
}
项目:zookeeper    文件:ZxidRolloverTest.java   
private void shutdown(int idx) throws Exception {
    qu.shutdown(idx);

    // leader will shutdown, remaining followers will elect a new leader
    PeerStruct peer = qu.getPeer(idx);
    Assert.assertTrue("Waiting for server down", ClientBase.waitForServerDown(
            "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

    // if idx is the the leader then everyone will get disconnected,
    // otherwise if idx is a follower then just that client will get
    // disconnected
    if (idx == idxLeader) {
        checkClientDisconnected(idx);
        try {
            checkClientsDisconnected();
        } catch (AssertionFailedError e) {
            // the clients may or may not have already reconnected
            // to the recovered cluster, force a check, but ignore
        }
    } else {
        checkClientDisconnected(idx);
    }
}
项目:SecureKeeper    文件:ZxidRolloverTest.java   
@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();
}
项目:SecureKeeper    文件:ZxidRolloverTest.java   
/**
 * Ensure the client is able to talk to the server.
 * 
 * @param idx the idx of the server the client is talking to
 */
private void checkClientConnected(int idx) throws Exception {
    ZooKeeper zk = getClient(idx);
    if (zk == null) {
        return;
    }
    try {
        Assert.assertNull(zk.exists("/foofoofoo-connected", false));
    } catch (ConnectionLossException e) {
        // second chance...
        // in some cases, leader change in particular, the timing is
        // very tricky to get right in order to assure that the client has
        // disconnected and reconnected. In some cases the client will
        // disconnect, then attempt to reconnect before the server is
        // back, in which case we'll see another connloss on the operation
        // in the try, this catches that case and waits for the server
        // to come back
        PeerStruct peer = qu.getPeer(idx);
        Assert.assertTrue("Waiting for server down", ClientBase.waitForServerUp(
                "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

        Assert.assertNull(zk.exists("/foofoofoo-connected", false));
    }
}
项目:SecureKeeper    文件:ZxidRolloverTest.java   
private void shutdown(int idx) throws Exception {
    qu.shutdown(idx);

    // leader will shutdown, remaining followers will elect a new leader
    PeerStruct peer = qu.getPeer(idx);
    Assert.assertTrue("Waiting for server down", ClientBase.waitForServerDown(
            "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

    // if idx is the the leader then everyone will get disconnected,
    // otherwise if idx is a follower then just that client will get
    // disconnected
    if (idx == idxLeader) {
        checkClientDisconnected(idx);
        try {
            checkClientsDisconnected();
        } catch (AssertionError e) {
            // the clients may or may not have already reconnected
            // to the recovered cluster, force a check, but ignore
        }
    } else {
        checkClientDisconnected(idx);
    }
}
项目:SecureKeeper    文件:ZxidRolloverTest.java   
@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();
}
项目:SecureKeeper    文件:ZxidRolloverTest.java   
/**
 * Ensure the client is able to talk to the server.
 * 
 * @param idx the idx of the server the client is talking to
 */
private void checkClientConnected(int idx) throws Exception {
    ZooKeeper zk = getClient(idx);
    if (zk == null) {
        return;
    }
    try {
        Assert.assertNull(zk.exists("/foofoofoo-connected", false));
    } catch (ConnectionLossException e) {
        // second chance...
        // in some cases, leader change in particular, the timing is
        // very tricky to get right in order to assure that the client has
        // disconnected and reconnected. In some cases the client will
        // disconnect, then attempt to reconnect before the server is
        // back, in which case we'll see another connloss on the operation
        // in the try, this catches that case and waits for the server
        // to come back
        PeerStruct peer = qu.getPeer(idx);
        Assert.assertTrue("Waiting for server down", ClientBase.waitForServerUp(
                "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

        Assert.assertNull(zk.exists("/foofoofoo-connected", false));
    }
}
项目:SecureKeeper    文件:ZxidRolloverTest.java   
private void shutdown(int idx) throws Exception {
    qu.shutdown(idx);

    // leader will shutdown, remaining followers will elect a new leader
    PeerStruct peer = qu.getPeer(idx);
    Assert.assertTrue("Waiting for server down", ClientBase.waitForServerDown(
            "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

    // if idx is the the leader then everyone will get disconnected,
    // otherwise if idx is a follower then just that client will get
    // disconnected
    if (idx == idxLeader) {
        checkClientDisconnected(idx);
        try {
            checkClientsDisconnected();
        } catch (AssertionError e) {
            // the clients may or may not have already reconnected
            // to the recovered cluster, force a check, but ignore
        }
    } else {
        checkClientDisconnected(idx);
    }
}
项目:StreamBench    文件:ZxidRolloverTest.java   
@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();
}
项目:StreamBench    文件:ZxidRolloverTest.java   
/**
 * Ensure the client is able to talk to the server.
 * 
 * @param idx the idx of the server the client is talking to
 */
private void checkClientConnected(int idx) throws Exception {
    ZooKeeper zk = getClient(idx);
    if (zk == null) {
        return;
    }
    try {
        assertNull(zk.exists("/foofoofoo-connected", false));
    } catch (ConnectionLossException e) {
        // second chance...
        // in some cases, leader change in particular, the timing is
        // very tricky to get right in order to assure that the client has
        // disconnected and reconnected. In some cases the client will
        // disconnect, then attempt to reconnect before the server is
        // back, in which case we'll see another connloss on the operation
        // in the try, this catches that case and waits for the server
        // to come back
        PeerStruct peer = qu.getPeer(idx);
        Assert.assertTrue("Waiting for server down", ClientBase.waitForServerUp(
                "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

        assertNull(zk.exists("/foofoofoo-connected", false));
    }
}
项目:StreamBench    文件:ZxidRolloverTest.java   
private void shutdown(int idx) throws Exception {
    qu.shutdown(idx);

    // leader will shutdown, remaining followers will elect a new leader
    PeerStruct peer = qu.getPeer(idx);
    Assert.assertTrue("Waiting for server down", ClientBase.waitForServerDown(
            "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

    // if idx is the the leader then everyone will get disconnected,
    // otherwise if idx is a follower then just that client will get
    // disconnected
    if (idx == idxLeader) {
        checkClientDisconnected(idx);
        try {
            checkClientsDisconnected();
        } catch (AssertionFailedError e) {
            // the clients may or may not have already reconnected
            // to the recovered cluster, force a check, but ignore
        }
    } else {
        checkClientDisconnected(idx);
    }
}
项目:LoadBalanced_zk    文件:ZxidRolloverTest.java   
@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();
}
项目:LoadBalanced_zk    文件:ZxidRolloverTest.java   
/**
 * Ensure the client is able to talk to the server.
 * 
 * @param idx the idx of the server the client is talking to
 */
private void checkClientConnected(int idx) throws Exception {
    ZooKeeper zk = getClient(idx);
    if (zk == null) {
        return;
    }
    try {
        assertNull(zk.exists("/foofoofoo-connected", false));
    } catch (ConnectionLossException e) {
        // second chance...
        // in some cases, leader change in particular, the timing is
        // very tricky to get right in order to assure that the client has
        // disconnected and reconnected. In some cases the client will
        // disconnect, then attempt to reconnect before the server is
        // back, in which case we'll see another connloss on the operation
        // in the try, this catches that case and waits for the server
        // to come back
        PeerStruct peer = qu.getPeer(idx);
        Assert.assertTrue("Waiting for server down", ClientBase.waitForServerUp(
                "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

        assertNull(zk.exists("/foofoofoo-connected", false));
    }
}
项目:LoadBalanced_zk    文件:ZxidRolloverTest.java   
private void shutdown(int idx) throws Exception {
    qu.shutdown(idx);

    // leader will shutdown, remaining followers will elect a new leader
    PeerStruct peer = qu.getPeer(idx);
    Assert.assertTrue("Waiting for server down", ClientBase.waitForServerDown(
            "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

    // if idx is the the leader then everyone will get disconnected,
    // otherwise if idx is a follower then just that client will get
    // disconnected
    if (idx == idxLeader) {
        checkClientDisconnected(idx);
        try {
            checkClientsDisconnected();
        } catch (AssertionFailedError e) {
            // the clients may or may not have already reconnected
            // to the recovered cluster, force a check, but ignore
        }
    } else {
        checkClientDisconnected(idx);
    }
}
项目:LoadBalanced_zk    文件:ZxidRolloverTest.java   
@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();
}
项目:LoadBalanced_zk    文件:ZxidRolloverTest.java   
/**
 * Ensure the client is able to talk to the server.
 * 
 * @param idx the idx of the server the client is talking to
 */
private void checkClientConnected(int idx) throws Exception {
    ZooKeeper zk = getClient(idx);
    if (zk == null) {
        return;
    }
    try {
        assertNull(zk.exists("/foofoofoo-connected", false));
    } catch (ConnectionLossException e) {
        // second chance...
        // in some cases, leader change in particular, the timing is
        // very tricky to get right in order to assure that the client has
        // disconnected and reconnected. In some cases the client will
        // disconnect, then attempt to reconnect before the server is
        // back, in which case we'll see another connloss on the operation
        // in the try, this catches that case and waits for the server
        // to come back
        PeerStruct peer = qu.getPeer(idx);
        Assert.assertTrue("Waiting for server down", ClientBase.waitForServerUp(
                "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

        assertNull(zk.exists("/foofoofoo-connected", false));
    }
}
项目:LoadBalanced_zk    文件:ZxidRolloverTest.java   
private void shutdown(int idx) throws Exception {
    qu.shutdown(idx);

    // leader will shutdown, remaining followers will elect a new leader
    PeerStruct peer = qu.getPeer(idx);
    Assert.assertTrue("Waiting for server down", ClientBase.waitForServerDown(
            "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

    // if idx is the the leader then everyone will get disconnected,
    // otherwise if idx is a follower then just that client will get
    // disconnected
    if (idx == idxLeader) {
        checkClientDisconnected(idx);
        try {
            checkClientsDisconnected();
        } catch (AssertionFailedError e) {
            // the clients may or may not have already reconnected
            // to the recovered cluster, force a check, but ignore
        }
    } else {
        checkClientDisconnected(idx);
    }
}
项目:zookeeper-pkg    文件:ZxidRolloverTest.java   
@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();
}
项目:zookeeper-pkg    文件:ZxidRolloverTest.java   
/**
 * Ensure the client is able to talk to the server.
 * 
 * @param idx the idx of the server the client is talking to
 */
private void checkClientConnected(int idx) throws Exception {
    ZooKeeper zk = getClient(idx);
    if (zk == null) {
        return;
    }
    try {
        assertNull(zk.exists("/foofoofoo-connected", false));
    } catch (ConnectionLossException e) {
        // second chance...
        // in some cases, leader change in particular, the timing is
        // very tricky to get right in order to assure that the client has
        // disconnected and reconnected. In some cases the client will
        // disconnect, then attempt to reconnect before the server is
        // back, in which case we'll see another connloss on the operation
        // in the try, this catches that case and waits for the server
        // to come back
        PeerStruct peer = qu.getPeer(idx);
        Assert.assertTrue("Waiting for server down", ClientBase.waitForServerUp(
                "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

        assertNull(zk.exists("/foofoofoo-connected", false));
    }
}
项目:zookeeper-pkg    文件:ZxidRolloverTest.java   
private void shutdown(int idx) throws Exception {
    qu.shutdown(idx);

    // leader will shutdown, remaining followers will elect a new leader
    PeerStruct peer = qu.getPeer(idx);
    Assert.assertTrue("Waiting for server down", ClientBase.waitForServerDown(
            "127.0.0.1:" + peer.clientPort, ClientBase.CONNECTION_TIMEOUT));

    // if idx is the the leader then everyone will get disconnected,
    // otherwise if idx is a follower then just that client will get
    // disconnected
    if (idx == idxLeader) {
        checkClientDisconnected(idx);
        try {
            checkClientsDisconnected();
        } catch (AssertionFailedError e) {
            // the clients may or may not have already reconnected
            // to the recovered cluster, force a check, but ignore
        }
    } else {
        checkClientDisconnected(idx);
    }
}