org.neo4j.kernel.ha
Class MasterClient

java.lang.Object
  extended by org.neo4j.com.Client<Master>
      extended by org.neo4j.kernel.ha.MasterClient
All Implemented Interfaces:
org.jboss.netty.channel.ChannelPipelineFactory, Master

public class MasterClient
extends Client<Master>
implements Master

The Master a slave should use to communicate with its master. It serializes requests and sends them to the master, more specifically MasterServer (which delegates to MasterImpl on the master side.


Nested Class Summary
protected static class MasterClient.AcquireLockSerializer
           
static class MasterClient.HaRequestType
           
 
Field Summary
protected static Deserializer<LockResult> LOCK_RESULT_DESERIALIZER
           
 
Fields inherited from class org.neo4j.com.Client
DEFAULT_MAX_NUMBER_OF_CONCURRENT_CHANNELS_PER_CLIENT, DEFAULT_READ_RESPONSE_TIMEOUT_SECONDS, NO_STORE_ID_GETTER
 
Constructor Summary
MasterClient(String hostNameOrIp, int port, org.neo4j.kernel.AbstractGraphDatabase graphDb, int readTimeoutSeconds, int maxConcurrentChannels)
           
 
Method Summary
 Response<LockResult> acquireGraphReadLock(SlaveContext context)
           
 Response<LockResult> acquireGraphWriteLock(SlaveContext context)
           
 Response<LockResult> acquireNodeReadLock(SlaveContext context, long... nodes)
           
 Response<LockResult> acquireNodeWriteLock(SlaveContext context, long... nodes)
           
 Response<LockResult> acquireRelationshipReadLock(SlaveContext context, long... relationships)
           
 Response<LockResult> acquireRelationshipWriteLock(SlaveContext context, long... relationships)
           
 Response<IdAllocation> allocateIds(org.neo4j.kernel.IdType idType)
           
 Response<Long> commitSingleResourceTransaction(SlaveContext context, String resource, TxExtractor txGetter)
           
 Response<Void> copyStore(SlaveContext context, StoreWriter writer)
           
 Response<Integer> createRelationshipType(SlaveContext context, String name)
           
 Response<Void> finishTransaction(SlaveContext context, boolean success)
           
 Response<org.neo4j.helpers.Pair<Integer,Long>> getMasterIdForCommittedTx(long txId, org.neo4j.kernel.impl.nioneo.store.StoreId storeId)
          Gets the master id for a given txId, also a checksum for that tx.
 Response<Void> initializeTx(SlaveContext context)
          Called when the first write operation of lock is performed for a transaction.
 Response<Void> pullUpdates(SlaveContext context)
           
protected static IdAllocation readIdAllocation(org.jboss.netty.buffer.ChannelBuffer buffer)
           
 void rollbackOngoingTransactions(SlaveContext context)
           
protected  boolean shouldCheckStoreId(RequestType<Master> type)
           
 
Methods inherited from class org.neo4j.com.Client
closeChannel, getInternalProtocolVersion, getMyStoreId, getPipeline, readTransactionStreamHeader, readTransactionStreams, releaseChannel, sendRequest, sendRequest, shutdown, storeIdGetterForDb, writeContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.neo4j.kernel.ha.Master
shutdown
 

Field Detail

LOCK_RESULT_DESERIALIZER

protected static final Deserializer<LockResult> LOCK_RESULT_DESERIALIZER
Constructor Detail

MasterClient

public MasterClient(String hostNameOrIp,
                    int port,
                    org.neo4j.kernel.AbstractGraphDatabase graphDb,
                    int readTimeoutSeconds,
                    int maxConcurrentChannels)
Method Detail

shouldCheckStoreId

protected boolean shouldCheckStoreId(RequestType<Master> type)
Overrides:
shouldCheckStoreId in class Client<Master>

allocateIds

public Response<IdAllocation> allocateIds(org.neo4j.kernel.IdType idType)
Specified by:
allocateIds in interface Master

createRelationshipType

public Response<Integer> createRelationshipType(SlaveContext context,
                                                String name)
Specified by:
createRelationshipType in interface Master

initializeTx

public Response<Void> initializeTx(SlaveContext context)
Description copied from interface: Master
Called when the first write operation of lock is performed for a transaction.

Specified by:
initializeTx in interface Master

acquireNodeWriteLock

public Response<LockResult> acquireNodeWriteLock(SlaveContext context,
                                                 long... nodes)
Specified by:
acquireNodeWriteLock in interface Master

acquireNodeReadLock

public Response<LockResult> acquireNodeReadLock(SlaveContext context,
                                                long... nodes)
Specified by:
acquireNodeReadLock in interface Master

acquireRelationshipWriteLock

public Response<LockResult> acquireRelationshipWriteLock(SlaveContext context,
                                                         long... relationships)
Specified by:
acquireRelationshipWriteLock in interface Master

acquireRelationshipReadLock

public Response<LockResult> acquireRelationshipReadLock(SlaveContext context,
                                                        long... relationships)
Specified by:
acquireRelationshipReadLock in interface Master

acquireGraphWriteLock

public Response<LockResult> acquireGraphWriteLock(SlaveContext context)
Specified by:
acquireGraphWriteLock in interface Master

acquireGraphReadLock

public Response<LockResult> acquireGraphReadLock(SlaveContext context)
Specified by:
acquireGraphReadLock in interface Master

commitSingleResourceTransaction

public Response<Long> commitSingleResourceTransaction(SlaveContext context,
                                                      String resource,
                                                      TxExtractor txGetter)
Specified by:
commitSingleResourceTransaction in interface Master

finishTransaction

public Response<Void> finishTransaction(SlaveContext context,
                                        boolean success)
Specified by:
finishTransaction in interface Master

rollbackOngoingTransactions

public void rollbackOngoingTransactions(SlaveContext context)

pullUpdates

public Response<Void> pullUpdates(SlaveContext context)
Specified by:
pullUpdates in interface Master

getMasterIdForCommittedTx

public Response<org.neo4j.helpers.Pair<Integer,Long>> getMasterIdForCommittedTx(long txId,
                                                                                org.neo4j.kernel.impl.nioneo.store.StoreId storeId)
Description copied from interface: Master
Gets the master id for a given txId, also a checksum for that tx.

Specified by:
getMasterIdForCommittedTx in interface Master
Parameters:
txId - the transaction id to get the data for.
storeId - clients store id.
Returns:
the master id for a given txId, also a checksum for that tx.

copyStore

public Response<Void> copyStore(SlaveContext context,
                                StoreWriter writer)
Specified by:
copyStore in interface Master

readIdAllocation

protected static IdAllocation readIdAllocation(org.jboss.netty.buffer.ChannelBuffer buffer)


Copyright © 2011 The Neo4j Graph Database Project. All Rights Reserved.