Neo4j Enterprise

org.neo4j.kernel
Class HAGraphDb

java.lang.Object
  extended by org.neo4j.kernel.AbstractGraphDatabase
      extended by org.neo4j.kernel.HAGraphDb
All Implemented Interfaces:
org.neo4j.com.Client.ConnectionLostHandler, GraphDatabaseService, ResponseReceiver

public class HAGraphDb
extends AbstractGraphDatabase
implements GraphDatabaseService, ResponseReceiver


Nested Class Summary
static class HAGraphDb.BranchedDataPolicy
           
 
Field Summary
static String COPY_FROM_MASTER_TEMP
           
 
Fields inherited from interface org.neo4j.com.Client.ConnectionLostHandler
NO_ACTION
 
Constructor Summary
HAGraphDb(String storeDir, Map<String,String> config)
          Will instantiate its own ZooKeeper broker and ClusterClient
HAGraphDb(String storeDir, Map<String,String> config, BrokerFactory brokerFactory)
          ONLY FOR TESTING Will instantiate its own ClusterClient
HAGraphDb(String storeDir, Map<String,String> config, BrokerFactory brokerFactory, ClusterClient clusterClient)
          ONLY FOR TESTING
 
Method Summary
protected  void close()
           
 Node createNode()
          Creates a new node.
 Broker getBroker()
           
 Config getConfig()
           
 KernelData getKernelData()
           
<T> Collection<T>
getManagementBeans(Class<T> type)
           
 MasterServer getMasterServerIfMaster()
           
 Node getNodeById(long id)
          Looks up a node by id.
 Node getReferenceNode()
          Returns the reference node, which is a "starting point" in the node space.
 Relationship getRelationshipById(long id)
          Looks up a relationship by id.
 org.neo4j.com.SlaveContext getSlaveContext(int eventIdentifier)
          Returns a SlaveContext instance that has eventIdentifier as the event identifier.
 void handle(Exception e)
           
 IndexManager index()
          Returns the IndexManager paired with this graph database service and is the entry point for managing indexes coupled with this database.
 void internalShutdown(boolean rotateLogs)
           
 boolean isMaster()
           
 void newMaster(Exception e)
           
 void pullUpdates()
           
<T> T
receive(org.neo4j.com.Response<T> response)
           
 void reconnect(Exception e)
          Shuts down the broker, invalidating every connection to the zookeeper cluster and starts it again.
protected  void reevaluateMyself(org.neo4j.kernel.impl.nioneo.store.StoreId storeId)
           
 KernelEventHandler registerKernelEventHandler(KernelEventHandler handler)
          Registers handler as a handler for kernel events which are generated from different places in the lifecycle of the kernel.
<T> TransactionEventHandler<T>
registerTransactionEventHandler(TransactionEventHandler<T> handler)
          Registers handler as a handler for transaction events which are generated from different places in the lifecycle of each transaction.
 void shutdownBroker()
           
 String toString()
           
 TransactionBuilder tx()
          Returns a new builder where some aspects of the behavior can be configured.
 KernelEventHandler unregisterKernelEventHandler(KernelEventHandler handler)
          Unregisters handler from the list of kernel event handlers.
<T> TransactionEventHandler<T>
unregisterTransactionEventHandler(TransactionEventHandler<T> handler)
          Unregisters handler from the list of transaction event handlers.
 
Methods inherited from class org.neo4j.kernel.AbstractGraphDatabase
beginTx, createCaches, createStringLogger, getAllNodes, getManagementBean, getMessageLog, getRelationshipTypes, getSingleManagementBean, getStoreDir, isEphemeral, shutdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.neo4j.graphdb.GraphDatabaseService
beginTx, getAllNodes, getRelationshipTypes, shutdown
 

Field Detail

COPY_FROM_MASTER_TEMP

public static final String COPY_FROM_MASTER_TEMP
See Also:
Constant Field Values
Constructor Detail

HAGraphDb

public HAGraphDb(String storeDir,
                 Map<String,String> config)
Will instantiate its own ZooKeeper broker and ClusterClient


HAGraphDb

public HAGraphDb(String storeDir,
                 Map<String,String> config,
                 BrokerFactory brokerFactory)
ONLY FOR TESTING Will instantiate its own ClusterClient


HAGraphDb

public HAGraphDb(String storeDir,
                 Map<String,String> config,
                 BrokerFactory brokerFactory,
                 ClusterClient clusterClient)
ONLY FOR TESTING

Method Detail

getBroker

public Broker getBroker()

pullUpdates

public void pullUpdates()

getConfig

public Config getConfig()
Specified by:
getConfig in class AbstractGraphDatabase

getManagementBeans

public <T> Collection<T> getManagementBeans(Class<T> type)
Specified by:
getManagementBeans in class AbstractGraphDatabase

toString

public String toString()
Overrides:
toString in class AbstractGraphDatabase

reconnect

public void reconnect(Exception e)
Shuts down the broker, invalidating every connection to the zookeeper cluster and starts it again. Should be called in case a ConnectionExpired event is received, this is the equivalent of building the ZK connection from start. Also triggers a master reelect, to make sure that the state ZK ended up in during our absence is respected. The cluster manager is not used outside of startup where this call should not happen and also it doesn't keep a zoo client open - so is no reason to recreate it

Specified by:
reconnect in interface ResponseReceiver

reevaluateMyself

protected void reevaluateMyself(org.neo4j.kernel.impl.nioneo.store.StoreId storeId)

tx

public TransactionBuilder tx()
Description copied from class: AbstractGraphDatabase
Returns a new builder where some aspects of the behavior can be configured. The transaction will ultimately begin when calling TransactionBuilder.begin().

Specified by:
tx in class AbstractGraphDatabase
Returns:
a builder for configuring transaction behavior and ultimately begin a transaction.

createNode

public Node createNode()
Description copied from interface: GraphDatabaseService
Creates a new node.

Specified by:
createNode in interface GraphDatabaseService
Returns:
the created node.

getNodeById

public Node getNodeById(long id)
Description copied from interface: GraphDatabaseService
Looks up a node by id.

Specified by:
getNodeById in interface GraphDatabaseService
Parameters:
id - the id of the node
Returns:
the node with id id if found

getReferenceNode

public Node getReferenceNode()
Description copied from interface: GraphDatabaseService
Returns the reference node, which is a "starting point" in the node space. Usually, a client attaches relationships to this node that leads into various parts of the node space. For more information about common node space organizational patterns, see the design guide at wiki.neo4j.org/content/Design_Guide.

Specified by:
getReferenceNode in interface GraphDatabaseService
Returns:
the reference node

getRelationshipById

public Relationship getRelationshipById(long id)
Description copied from interface: GraphDatabaseService
Looks up a relationship by id.

Specified by:
getRelationshipById in interface GraphDatabaseService
Parameters:
id - the id of the relationship
Returns:
the relationship with id id if found

registerKernelEventHandler

public KernelEventHandler registerKernelEventHandler(KernelEventHandler handler)
Description copied from interface: GraphDatabaseService
Registers handler as a handler for kernel events which are generated from different places in the lifecycle of the kernel. To guarantee proper behaviour the handler should be registered right after the graph database has been started. If the specified handler instance has already been registered this method will do nothing.

Specified by:
registerKernelEventHandler in interface GraphDatabaseService
Parameters:
handler - the handler to receive events about different states in the kernel lifecycle.
Returns:
the handler passed in as the argument.

registerTransactionEventHandler

public <T> TransactionEventHandler<T> registerTransactionEventHandler(TransactionEventHandler<T> handler)
Description copied from interface: GraphDatabaseService
Registers handler as a handler for transaction events which are generated from different places in the lifecycle of each transaction. To guarantee that the handler gets all events properly it shouldn't be registered when the application is running (i.e. in the middle of one or more transactions). If the specified handler instance has already been registered this method will do nothing.

Specified by:
registerTransactionEventHandler in interface GraphDatabaseService
Type Parameters:
T - the type of state object used in the handler, see more documentation about it at TransactionEventHandler.
Parameters:
handler - the handler to receive events about different states in transaction lifecycles.
Returns:
the handler passed in as the argument.

internalShutdown

public void internalShutdown(boolean rotateLogs)

close

protected void close()
Specified by:
close in class AbstractGraphDatabase

unregisterKernelEventHandler

public KernelEventHandler unregisterKernelEventHandler(KernelEventHandler handler)
Description copied from interface: GraphDatabaseService
Unregisters handler from the list of kernel event handlers. If handler hasn't been registered with GraphDatabaseService.registerKernelEventHandler(KernelEventHandler) prior to calling this method an IllegalStateException will be thrown. After a successful call to this method the handler will no longer receive any kernel events.

Specified by:
unregisterKernelEventHandler in interface GraphDatabaseService
Parameters:
handler - the handler to receive events about different states in the kernel lifecycle.
Returns:
the handler passed in as the argument.

unregisterTransactionEventHandler

public <T> TransactionEventHandler<T> unregisterTransactionEventHandler(TransactionEventHandler<T> handler)
Description copied from interface: GraphDatabaseService
Unregisters handler from the list of transaction event handlers. If handler hasn't been registered with GraphDatabaseService.registerTransactionEventHandler(TransactionEventHandler) prior to calling this method an IllegalStateException will be thrown. After a successful call to this method the handler will no longer receive any transaction events.

Specified by:
unregisterTransactionEventHandler in interface GraphDatabaseService
Type Parameters:
T - the type of state object used in the handler, see more documentation about it at TransactionEventHandler.
Parameters:
handler - the handler to receive events about different states in transaction lifecycles.
Returns:
the handler passed in as the argument.

getSlaveContext

public org.neo4j.com.SlaveContext getSlaveContext(int eventIdentifier)
Description copied from interface: org.neo4j.kernel.ha.ResponseReceiver
Returns a SlaveContext instance that has eventIdentifier as the event identifier.

Specified by:
getSlaveContext in interface ResponseReceiver
Parameters:
eventIdentifier - The event identifier of the returned slave context
Returns:
The slave context

receive

public <T> T receive(org.neo4j.com.Response<T> response)
Specified by:
receive in interface ResponseReceiver

handle

public void handle(Exception e)
Specified by:
handle in interface org.neo4j.com.Client.ConnectionLostHandler

newMaster

public void newMaster(Exception e)
Specified by:
newMaster in interface ResponseReceiver

getMasterServerIfMaster

public MasterServer getMasterServerIfMaster()

isMaster

public boolean isMaster()

index

public IndexManager index()
Description copied from interface: GraphDatabaseService
Returns the IndexManager paired with this graph database service and is the entry point for managing indexes coupled with this database.

Specified by:
index in interface GraphDatabaseService
Returns:
the IndexManager for this database.

shutdownBroker

public void shutdownBroker()

getKernelData

public KernelData getKernelData()
Specified by:
getKernelData in class AbstractGraphDatabase

Neo4j Enterprise

Copyright © 2002-2012 The Neo4j Graph Database Project. All Rights Reserved.