Search in sources :

Example 1 with Session

use of org.neo4j.cluster.FreePorts.Session in project neo4j by neo4j.

the class ClusterManager method start.

@Override
public void start() throws Throwable {
    FreePorts.Session session = PORTS.newSession();
    Cluster cluster = clustersProvider.apply(session);
    life = new LifeSupport();
    life.add(new LifecycleAdapter() {

        @Override
        public void shutdown() throws Throwable {
            session.close();
        }
    });
    // Started so instances added here will be started immediately, and in case of exceptions they can be
    // shutdown() or stop()ped properly
    life.start();
    managedCluster = new ManagedCluster(cluster, session);
    life.add(managedCluster);
    availabilityChecks.forEach(managedCluster::await);
    if (initialDatasetCreator != null) {
        initialDatasetCreator.receive(managedCluster.getMaster());
        managedCluster.sync();
    }
}
Also used : FreePorts(org.neo4j.cluster.FreePorts) Session(org.neo4j.cluster.FreePorts.Session) Cluster(org.neo4j.cluster.client.Cluster) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) LifecycleAdapter(org.neo4j.kernel.lifecycle.LifecycleAdapter)

Aggregations

FreePorts (org.neo4j.cluster.FreePorts)1 Session (org.neo4j.cluster.FreePorts.Session)1 Cluster (org.neo4j.cluster.client.Cluster)1 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)1 LifecycleAdapter (org.neo4j.kernel.lifecycle.LifecycleAdapter)1