Java Code Examples for org.apache.zookeeper.server.quorum.QuorumPeer#QuorumServer

The following examples show how to use org.apache.zookeeper.server.quorum.QuorumPeer#QuorumServer . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EnsembleTracker.java    From curator with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
public static String configToConnectionString(QuorumVerifier data) throws Exception
{
    StringBuilder sb = new StringBuilder();
    for ( QuorumPeer.QuorumServer server : data.getAllMembers().values() )
    {
        if ( server.clientAddr == null )
        {
            // Invalid client address configuration in zoo.cfg
            continue;
        }
        if ( sb.length() != 0 )
        {
            sb.append(",");
        }
        String hostAddress;
        if ( server.clientAddr.getAddress().isAnyLocalAddress() )
        {
            hostAddress = Compatibility.getHostAddress(server);
        }
        else
        {
            hostAddress = server.clientAddr.getAddress().getHostAddress();
        }
        sb.append(hostAddress).append(":").append(server.clientAddr.getPort());
    }

    return sb.toString();
}
 
Example 2
Source File: TestReconfiguration.java    From curator with Apache License 2.0 5 votes vote down vote up
private void assertConfig(QuorumVerifier config, Collection<InstanceSpec> instances)
{
    for ( InstanceSpec instance : instances )
    {
        QuorumPeer.QuorumServer quorumServer = config.getAllMembers().get((long)instance.getServerId());
        Assert.assertNotNull(quorumServer, String.format("Looking for %s - found %s", instance.getServerId(), config.getAllMembers()));
        Assert.assertEquals(quorumServer.clientAddr.getPort(), instance.getPort());
    }
}
 
Example 3
Source File: SolrZkServer.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
public Map<Long, QuorumPeer.QuorumServer> getServers() {
  return zkProps.getServers();
}