org.neo4j.kernel.ha.zookeeper
Class AbstractZooKeeperManager
java.lang.Object
org.neo4j.kernel.ha.zookeeper.AbstractZooKeeperManager
- Direct Known Subclasses:
- ZooClient, ZooKeeperClusterClient
public abstract class AbstractZooKeeperManager
- extends Object
Contains basic functionality for a ZooKeeper manager, f.ex. how to get
the current master in the cluster.
|
Method Summary |
protected String |
asRootPath(org.neo4j.kernel.impl.nioneo.store.StoreId storeId)
|
protected org.neo4j.helpers.Pair<Master,Machine> |
bootstrap()
|
protected Map<Integer,ZooKeeperMachine> |
getAllMachines(boolean wait)
|
protected Map<Integer,ZooKeeperMachine> |
getAllMachines(boolean wait,
org.neo4j.kernel.ha.zookeeper.AbstractZooKeeperManager.WaitMode mode)
|
protected Map<Integer,ZooKeeperMachine> |
getAllMachinesInner(boolean wait,
org.neo4j.kernel.ha.zookeeper.AbstractZooKeeperManager.WaitMode mode)
|
org.neo4j.helpers.Pair<Master,Machine> |
getCachedMaster()
|
protected org.neo4j.kernel.impl.nioneo.store.StoreId |
getClusterStoreId(org.apache.zookeeper.ZooKeeper keeper,
String clusterName)
|
protected Machine |
getHaServer(int machineId,
boolean wait)
|
protected Iterable<Machine> |
getHaServers()
|
protected ZooKeeperMachine |
getMasterBasedOn(Collection<ZooKeeperMachine> machines)
|
protected Master |
getMasterClientToMachine(Machine master)
|
protected org.neo4j.helpers.Pair<Master,Machine> |
getMasterFromZooKeeper(boolean wait,
boolean allowChange)
Tries to discover the master from the zookeeper information. |
protected abstract int |
getMyMachineId()
|
protected int |
getNumberOfServers()
|
abstract String |
getRoot()
|
protected String |
getSequenceNr()
|
String |
getServers()
|
protected int |
getSessionTimeout()
|
protected org.neo4j.kernel.impl.nioneo.store.StoreId |
getStoreId()
|
abstract org.apache.zookeeper.ZooKeeper |
getZooKeeper(boolean sync)
|
protected int |
idFromPath(String path)
|
protected void |
invalidateMaster()
|
protected org.neo4j.helpers.Pair<Integer,Integer> |
parseChild(String child)
|
protected org.neo4j.helpers.Pair<Long,Integer> |
readDataRepresentingInstance(String path)
|
protected Machine |
readHaServer(int machineId,
boolean wait)
|
protected void |
refreshHaServers()
|
void |
shutdown()
|
void |
waitForSyncConnected()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HA_SERVERS_CHILD
protected static final String HA_SERVERS_CHILD
- See Also:
- Constant Field Values
FLUSH_REQUESTED_CHILD
protected static final String FLUSH_REQUESTED_CHILD
- See Also:
- Constant Field Values
COMPATIBILITY_CHILD
protected static final String COMPATIBILITY_CHILD
- See Also:
- Constant Field Values
STOP_FLUSHING
protected static final int STOP_FLUSHING
- See Also:
- Constant Field Values
cachedMaster
protected volatile org.neo4j.helpers.Pair<Master,Machine> cachedMaster
msgLog
protected final org.neo4j.kernel.impl.util.StringLogger msgLog
NO_MASTER
protected static final Master NO_MASTER
NO_MASTER_MACHINE_PAIR
public static final org.neo4j.helpers.Pair<Master,Machine> NO_MASTER_MACHINE_PAIR
AbstractZooKeeperManager
public AbstractZooKeeperManager(String servers,
org.neo4j.kernel.impl.util.StringLogger msgLog,
int sessionTimeout,
MasterClientFactory clientFactory)
asRootPath
protected String asRootPath(org.neo4j.kernel.impl.nioneo.store.StoreId storeId)
getSequenceNr
protected String getSequenceNr()
getClusterStoreId
protected org.neo4j.kernel.impl.nioneo.store.StoreId getClusterStoreId(org.apache.zookeeper.ZooKeeper keeper,
String clusterName)
getSessionTimeout
protected int getSessionTimeout()
getZooKeeper
public abstract org.apache.zookeeper.ZooKeeper getZooKeeper(boolean sync)
getRoot
public abstract String getRoot()
parseChild
protected org.neo4j.helpers.Pair<Integer,Integer> parseChild(String child)
readDataRepresentingInstance
protected org.neo4j.helpers.Pair<Long,Integer> readDataRepresentingInstance(String path)
throws InterruptedException,
org.apache.zookeeper.KeeperException
- Throws:
InterruptedException
org.apache.zookeeper.KeeperException
invalidateMaster
protected void invalidateMaster()
getMasterFromZooKeeper
protected org.neo4j.helpers.Pair<Master,Machine> getMasterFromZooKeeper(boolean wait,
boolean allowChange)
- Tries to discover the master from the zookeeper information. Will return
a
Pair of a Master and the Machine it resides
on. If the new master is different than the current then the current is
invalidated and if allowChange is set to true then the a connection to
the new master is established otherwise a NO_MASTER is returned.
- Parameters:
wait - Whether to wait for a sync connected eventallowChange - If to connect to the new master
- Returns:
- The master machine pair, possibly a NO_MASTER_MACHINE_PAIR
bootstrap
protected org.neo4j.helpers.Pair<Master,Machine> bootstrap()
getStoreId
protected org.neo4j.kernel.impl.nioneo.store.StoreId getStoreId()
getMasterClientToMachine
protected Master getMasterClientToMachine(Machine master)
getMyMachineId
protected abstract int getMyMachineId()
getCachedMaster
public org.neo4j.helpers.Pair<Master,Machine> getCachedMaster()
getMasterBasedOn
protected ZooKeeperMachine getMasterBasedOn(Collection<ZooKeeperMachine> machines)
getAllMachines
protected Map<Integer,ZooKeeperMachine> getAllMachines(boolean wait)
getAllMachines
protected Map<Integer,ZooKeeperMachine> getAllMachines(boolean wait,
org.neo4j.kernel.ha.zookeeper.AbstractZooKeeperManager.WaitMode mode)
getAllMachinesInner
protected Map<Integer,ZooKeeperMachine> getAllMachinesInner(boolean wait,
org.neo4j.kernel.ha.zookeeper.AbstractZooKeeperManager.WaitMode mode)
getHaServer
protected Machine getHaServer(int machineId,
boolean wait)
refreshHaServers
protected void refreshHaServers()
throws org.apache.zookeeper.KeeperException
- Throws:
org.apache.zookeeper.KeeperException
getHaServers
protected Iterable<Machine> getHaServers()
getNumberOfServers
protected int getNumberOfServers()
readHaServer
protected Machine readHaServer(int machineId,
boolean wait)
shutdown
public void shutdown()
waitForSyncConnected
public final void waitForSyncConnected()
getServers
public String getServers()
idFromPath
protected int idFromPath(String path)
Copyright © 2002-2012 The Neo4j Graph Database Project. All Rights Reserved.