use of org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource in project graphdb by neo4j-attic.
the class MasterUtil method packResponseWithoutTransactionStream.
public static <T> Response<T> packResponseWithoutTransactionStream(GraphDatabaseService graphDb, SlaveContext context, T response) {
XaDataSource ds = ((AbstractGraphDatabase) graphDb).getConfig().getTxModule().getXaDataSourceManager().getXaDataSource(Config.DEFAULT_DATA_SOURCE_NAME);
StoreId storeId = ((NeoStoreXaDataSource) ds).getStoreId();
return new Response<T>(response, storeId, TransactionStream.EMPTY);
}
use of org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource in project graphdb by neo4j-attic.
the class Client method getMyStoreId.
protected StoreId getMyStoreId() {
if (myStoreId == null) {
XaDataSource ds = ((AbstractGraphDatabase) graphDb).getConfig().getTxModule().getXaDataSourceManager().getXaDataSource(Config.DEFAULT_DATA_SOURCE_NAME);
myStoreId = ((NeoStoreXaDataSource) ds).getStoreId();
}
return myStoreId;
}
use of org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource in project graphdb by neo4j-attic.
the class UdcExtensionImpl method load.
@Override
protected UdcTimerTask load(KernelData kernel) {
MyConfig configuration = new MyConfig(kernel.getConfig(), loadSystemProperties());
try {
// break if disabled
if (configuration.getBool(UDC_DISABLE_KEY, "false"))
return null;
} catch (Exception e) {
// default: not disabled
}
int firstDelay = DEFAULT_DELAY;
int interval = DEFAULT_INTERVAL;
String hostAddress = DEFAULT_HOST;
String source = null;
try {
firstDelay = configuration.getInt(FIRST_DELAY_CONFIG_KEY, Integer.toString(firstDelay));
} catch (Exception e) {
// fall back to default
}
try {
interval = configuration.getInt(INTERVAL_CONFIG_KEY, Integer.toString(interval));
} catch (Exception e) {
// fall back to default
}
try {
hostAddress = configuration.getString(UDC_HOST_ADDRESS_KEY, hostAddress);
} catch (Exception e) {
// fall back to default
}
try {
source = configuration.getString(UDC_SOURCE_KEY, source);
} catch (Exception e) {
// fall back to default
}
NeoStoreXaDataSource ds = (NeoStoreXaDataSource) kernel.getConfig().getTxModule().getXaDataSourceManager().getXaDataSource("nioneodb");
boolean crashPing = ds.getXaContainer().getLogicalLog().wasNonClean();
String storeId = Long.toHexString(ds.getRandomIdentifier());
String version = kernel.version().getRevision();
if (version.equals(""))
version = kernel.version().getVersion();
UdcTimerTask task = new UdcTimerTask(hostAddress, version, storeId, source, crashPing);
timer.scheduleAtFixedRate(task, firstDelay, interval);
return task;
}
use of org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource 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]));
}
use of org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource in project graphdb by neo4j-attic.
the class MasterUtil method packResponse.
public static <T> Response<T> packResponse(GraphDatabaseService graphDb, SlaveContext context, T response, Predicate<Long> filter) {
List<Triplet<String, Long, TxExtractor>> stream = new ArrayList<Triplet<String, Long, TxExtractor>>();
Set<String> resourceNames = new HashSet<String>();
XaDataSourceManager dsManager = ((AbstractGraphDatabase) graphDb).getConfig().getTxModule().getXaDataSourceManager();
for (Pair<String, Long> txEntry : context.lastAppliedTransactions()) {
String resourceName = txEntry.first();
final XaDataSource dataSource = dsManager.getXaDataSource(resourceName);
if (dataSource == null) {
throw new RuntimeException("No data source '" + resourceName + "' found");
}
resourceNames.add(resourceName);
long masterLastTx = dataSource.getLastCommittedTxId();
for (long txId = txEntry.other() + 1; txId <= masterLastTx; txId++) {
if (filter.accept(txId)) {
final long tx = txId;
TxExtractor extractor = new TxExtractor() {
@Override
public ReadableByteChannel extract() {
try {
return dataSource.getCommittedTransaction(tx);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@Override
public void extract(LogBuffer buffer) {
try {
dataSource.getCommittedTransaction(tx, buffer);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
};
stream.add(Triplet.of(resourceName, txId, extractor));
}
}
}
StoreId storeId = ((NeoStoreXaDataSource) dsManager.getXaDataSource(Config.DEFAULT_DATA_SOURCE_NAME)).getStoreId();
return new Response<T>(response, storeId, TransactionStream.create(resourceNames, stream));
}
Aggregations