Package org.neo4j.kernel.ha.zookeeper

Examples of org.neo4j.kernel.ha.zookeeper.ClusterManager


        return toReturn;
    }

    private static String getMasterServerInCluster( String from )
    {
        ClusterManager clusterManager = new ClusterManager( from );
        Pair<String, Integer> masterServer = null;
        try
        {
            clusterManager.waitForSyncConnected();
            Machine master = clusterManager.getMaster();
            masterServer = master.getServer();
            if ( masterServer != null )
            {
                int backupPort = clusterManager.getBackupPort( master.getMachineId() );
                return String.format( ServerAddressFormat,
                        masterServer.first(), backupPort );
            }
            throw new ComException(
                    "Master couldn't be found from cluster managed by " + from );
        }
        finally
        {
            clusterManager.shutdown();
        }
    }
View Full Code Here


    private void await( ZooKeeper[] keepers, long timeout, TimeUnit unit )
    {
        timeout = System.currentTimeMillis() + unit.toMillis( timeout );
        do
        {
            ClusterManager cm = null;
            try
            {
                cm = new ClusterManager( getConnectionString() );
                cm.waitForSyncConnected();
                break;
            }
            catch ( Exception e )
            {
                e.printStackTrace();
                // ok retry
            }
            finally
            {
                if ( cm != null )
                {
                    try
                    {
                        cm.shutdown();
                    }
                    catch ( Throwable t )
                    {
                        t.printStackTrace();
                    }
View Full Code Here

public class DumpZooInfo
{
    public static void main( String[] args )
    {
        ClusterManager clusterManager = new ClusterManager( "localhost" );
        clusterManager.waitForSyncConnected();
        System.out.println( "Master is " + clusterManager.getCachedMaster() );
        System.out.println( "Connected slaves" );
        for ( Machine info : clusterManager.getConnectedSlaves() )
        {
            System.out.println( "\t" + info );
        }
//        System.out.println( "Disconnected slaves" );
//        for ( Machine info : clusterManager.getDisconnectedSlaves() )
//        {
//            System.out.println( "\t" + info );
//        }
        clusterManager.shutdown();
    }
View Full Code Here

TOP

Related Classes of org.neo4j.kernel.ha.zookeeper.ClusterManager

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.