@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])); }
protected void configureSourceDb(final EmbeddedGraphDatabase graphDb) { XaDataSource neoStoreXaDataSource = graphDb .getConfig() .getPersistenceModule() .getPersistenceManager() .getPersistenceSource() .getXaDataSource(); neoStoreXaDataSource.keepLogicalLogs(true); XaDataSourceManager xaDsm = graphDb.getConfig().getTxModule().getXaDataSourceManager(); XaDataSource ds = xaDsm.getXaDataSource("lucene"); ((LuceneDataSource) ds).keepLogicalLogs(true); }
public DefaultUdcInformationCollector( Config config, XaDataSourceManager xadsm, @SuppressWarnings("deprecation") KernelData kernel) { this.config = config; this.kernel = kernel; nodeManager = kernel.graphDatabase().getDependencyResolver().resolveDependency(NodeManager.class); if (xadsm != null) { xadsm.addDataSourceRegistrationListener( new DataSourceRegistrationListener() { @Override public void registeredDataSource(XaDataSource ds) { if (ds instanceof NeoStoreXaDataSource) { crashPing = ds.getXaContainer().getLogicalLog().wasNonClean(); storeId = Long.toHexString(ds.getRandomIdentifier()); } } @Override public void unregisteredDataSource(XaDataSource ds) { if (ds instanceof NeoStoreXaDataSource) { crashPing = false; storeId = null; } } }); } }
byte[] getBranchId(XAResource xaRes) { if (xaRes instanceof XaResource) { byte branchId[] = ((XaResource) xaRes).getBranchId(); if (branchId != null) { return branchId; } } return xaDataSourceManager.getBranchId(xaRes); }
@Override public void start() { for (XaDataSource ds : xaDsm.getAllRegisteredDataSources()) { if (ds.getName().equals(Config.DEFAULT_DATA_SOURCE_NAME)) { // load and verify from PS NameData[] relTypes = null; NameData[] propertyIndexes = null; // beginTx(); relTypes = persistenceManager.loadAllRelationshipTypes(); propertyIndexes = persistenceManager.loadPropertyIndexes(INDEX_COUNT); // commitTx(); addRawRelationshipTypes(relTypes); addPropertyIndexes(propertyIndexes); if (propertyIndexes.length < INDEX_COUNT) { setHasAllpropertyIndexes(true); } } } }
@Override public void start() throws Throwable { // Do recovery on start - all Resources should be registered by now Iterator<List<TxLog.Record>> danglingRecordList = txLog.getDanglingRecords(); boolean danglingRecordFound = danglingRecordList.hasNext(); if (danglingRecordFound) { log.info("Unresolved transactions found, " + "recovery started ..."); msgLog.logMessage("TM non resolved transactions found in " + txLog.getName(), true); // Recover DataSources xaDataSourceManager.recover(danglingRecordList); log.info( "Recovery completed, all transactions have been " + "resolved to a consistent state."); msgLog.logMessage( "Recovery completed, all transactions have been " + "resolved to a consistent state."); } getTxLog().truncate(); }
@Override public void doRecovery() throws Throwable { TransactionResourceManager trm = new TransactionResourceManager() { @Override public void returnXAResource(String rmName, XAResource rmXares) { return; } }; try { for (XaDataSource xaDs : xaDataSourceManager.getAllRegisteredDataSources()) { Current.getTransactionRecovery() .registerResourceManager( xaDs.getName(), xaDs.getXaConnection().getXaResource(), xaDs.getName(), trm); } Current.getTransactionRecovery().startResourceManagerRecovery(); } catch (XAException e) { throw new Error("Error registering xa datasource", e); } }