use of org.neo4j.com.SlaveContext in project graphdb by neo4j-attic.
the class HighlyAvailableGraphDatabase method getSlaveContext.
@Override
public SlaveContext getSlaveContext(int eventIdentifier) {
XaDataSourceManager localDataSourceManager = getConfig().getTxModule().getXaDataSourceManager();
Collection<XaDataSource> dataSources = localDataSourceManager.getAllRegisteredDataSources();
@SuppressWarnings("unchecked") Pair<String, Long>[] txs = new Pair[dataSources.size()];
int i = 0;
for (XaDataSource dataSource : dataSources) {
txs[i++] = Pair.of(dataSource.getName(), dataSource.getLastCommittedTxId());
}
return new SlaveContext(machineId, eventIdentifier, txs);
}
use of org.neo4j.com.SlaveContext in project graphdb by neo4j-attic.
the class HighlyAvailableGraphDatabase method copyStoreFromMaster.
private void copyStoreFromMaster(Pair<Master, Machine> master) throws Exception {
msgLog.logMessage("Copying store from master");
Response<Void> response = master.first().copyStore(new SlaveContext(machineId, 0, new Pair[0]), new ToFileStoreWriter(storeDir));
EmbeddedGraphDatabase tempDb = new EmbeddedGraphDatabase(storeDir);
try {
MasterUtil.applyReceivedTransactions(response, tempDb, MasterUtil.txHandlerForFullCopy());
} finally {
tempDb.shutdown();
}
msgLog.logMessage("Done copying store from master");
}
use of org.neo4j.com.SlaveContext in project graphdb by neo4j-attic.
the class BackupImpl method fullBackup.
public Response<Void> fullBackup(StoreWriter writer) {
SlaveContext context = MasterUtil.rotateLogsAndStreamStoreFiles(graphDb, writer);
writer.done();
return MasterUtil.packResponse(graphDb, context, null, MasterUtil.ALL);
}
use of org.neo4j.com.SlaveContext in project graphdb by neo4j-attic.
the class OnlineBackup method slaveContextOf.
@SuppressWarnings("unchecked")
private SlaveContext slaveContextOf(GraphDatabaseService graphDb) {
XaDataSourceManager dsManager = ((AbstractGraphDatabase) graphDb).getConfig().getTxModule().getXaDataSourceManager();
List<Pair<String, Long>> txs = new ArrayList<Pair<String, Long>>();
for (XaDataSource ds : dsManager.getAllRegisteredDataSources()) {
txs.add(Pair.of(ds.getName(), ds.getLastCommittedTxId()));
}
return new SlaveContext(0, 0, txs.toArray(new Pair[0]));
}
use of org.neo4j.com.SlaveContext in project graphdb by neo4j-attic.
the class MasterImpl method makeSureThereIsAtLeastOneKernelTx.
private SlaveContext makeSureThereIsAtLeastOneKernelTx(SlaveContext context) {
Collection<Pair<String, Long>> txs = new ArrayList<Pair<String, Long>>();
for (Pair<String, Long> txEntry : context.lastAppliedTransactions()) {
String resourceName = txEntry.first();
XaDataSource dataSource = graphDbConfig.getTxModule().getXaDataSourceManager().getXaDataSource(resourceName);
if (dataSource instanceof NeoStoreXaDataSource) {
if (txEntry.other() == 1 || txEntry.other() < dataSource.getLastCommittedTxId()) {
// copying
return context;
}
// Put back slave one tx so that it gets one transaction
txs.add(Pair.of(resourceName, dataSource.getLastCommittedTxId() - 1));
// System.out.println( "Pushed in one extra tx " + dataSource.getLastCommittedTxId() );
} else {
txs.add(Pair.of(resourceName, dataSource.getLastCommittedTxId()));
}
}
return new SlaveContext(context.machineId(), context.getEventIdentifier(), txs.toArray(new Pair[0]));
}
Aggregations