org.neo4j.com
Class MasterUtil

java.lang.Object
  extended by org.neo4j.com.MasterUtil

public class MasterUtil
extends Object


Nested Class Summary
static interface MasterUtil.TxHandler
           
 
Field Summary
static Predicate<Long> ALL
           
static MasterUtil.TxHandler NO_ACTION
           
 
Constructor Summary
MasterUtil()
           
 
Method Summary
static
<T> void
applyReceivedTransactions(Response<T> response, GraphDatabaseService graphDb, MasterUtil.TxHandler txHandler)
           
static Response<Void> getTransactions(GraphDatabaseService graphDb, String dataSourceName, long startTx, long endTx)
          Given a data source name, a start and an end tx, this method extracts these transactions (inclusive) in a transaction stream and encapsulates them in a Response object, ready to be returned to the slave.
static
<T> Response<T>
packResponse(GraphDatabaseService graphDb, SlaveContext context, T response, Predicate<Long> filter)
          After having created the response for a slave, this method compares its context against the local (master's) context and creates a transaction stream containing all the transactions the slave does not currently have.
static
<T> Response<T>
packResponseWithoutTransactionStream(GraphDatabaseService graphDb, SlaveContext context, T response)
           
static SlaveContext.Tx[] rotateLogs(GraphDatabaseService graphDb)
           
static SlaveContext rotateLogsAndStreamStoreFiles(GraphDatabaseService graphDb, boolean includeLogicalLogs, StoreWriter writer)
           
static MasterUtil.TxHandler txHandlerForFullCopy()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL

public static final Predicate<Long> ALL

NO_ACTION

public static final MasterUtil.TxHandler NO_ACTION
Constructor Detail

MasterUtil

public MasterUtil()
Method Detail

rotateLogs

public static SlaveContext.Tx[] rotateLogs(GraphDatabaseService graphDb)

rotateLogsAndStreamStoreFiles

public static SlaveContext rotateLogsAndStreamStoreFiles(GraphDatabaseService graphDb,
                                                         boolean includeLogicalLogs,
                                                         StoreWriter writer)

packResponse

public static <T> Response<T> packResponse(GraphDatabaseService graphDb,
                                           SlaveContext context,
                                           T response,
                                           Predicate<Long> filter)
After having created the response for a slave, this method compares its context against the local (master's) context and creates a transaction stream containing all the transactions the slave does not currently have. This way every response returned acts as an update for the slave.

Type Parameters:
T - The type of the response
Parameters:
graphDb - The graph database to use
context - The slave context
response - The response being packed
filter - A Predicate to apply on each txid, selecting only those that evaluate to true
Returns:
The response, packed with the latest transactions

getTransactions

public static Response<Void> getTransactions(GraphDatabaseService graphDb,
                                             String dataSourceName,
                                             long startTx,
                                             long endTx)
Given a data source name, a start and an end tx, this method extracts these transactions (inclusive) in a transaction stream and encapsulates them in a Response object, ready to be returned to the slave.

Parameters:
graphDb - The graph database to use
dataSourceName - The name of the data source to extract transactions from
startTx - The first tx in the returned stream
endTx - The last tx in the returned stream
Returns:
A Response object containing a transaction stream with the requested transactions from the specified data source.

packResponseWithoutTransactionStream

public static <T> Response<T> packResponseWithoutTransactionStream(GraphDatabaseService graphDb,
                                                                   SlaveContext context,
                                                                   T response)

applyReceivedTransactions

public static <T> void applyReceivedTransactions(Response<T> response,
                                                 GraphDatabaseService graphDb,
                                                 MasterUtil.TxHandler txHandler)
                                      throws IOException
Throws:
IOException

txHandlerForFullCopy

public static MasterUtil.TxHandler txHandlerForFullCopy()


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