示例#1
0
 /** Public for testing purpose. Do not use. */
 public synchronized void registerDataSource(final XaDataSource dataSource) {
   dataSources.put(dataSource.getName(), dataSource);
   branchIdMapping.put(UTF8.decode(dataSource.getBranchId()), dataSource);
   sourceIdMapping.put(dataSource.getName(), dataSource.getBranchId());
   life.add(dataSource);
   if (life.getStatus().equals(LifecycleStatus.STARTED)) {
     Listeners.notifyListeners(
         dsRegistrationListeners,
         new Listeners.Notification<DataSourceRegistrationListener>() {
           @Override
           public void notify(DataSourceRegistrationListener listener) {
             listener.registeredDataSource(dataSource);
           }
         });
   }
 }
示例#2
0
 public void rotateLogicalLogs() {
   for (XaDataSource dataSource : dataSources.values()) {
     try {
       dataSource.rotateLogicalLog();
     } catch (IOException e) {
       msgLog.logMessage("Couldn't rotate logical log for " + dataSource.getName(), e);
     }
   }
 }
示例#3
0
 @Test
 public void hasAllXaManagerBeans() {
   for (XaDataSource xaDataSource :
       graphDb.getXaDataSourceManager().getAllRegisteredDataSources()) {
     XaResourceInfo info = getByName(xaDataSource.getName());
     assertEquals(
         "wrong branchid for XA data source " + xaDataSource.getName(),
         XaManagerBean.toHexString(xaDataSource.getBranchId()),
         info.getBranchId());
     assertEquals(
         "wrong log version for XA data source " + xaDataSource.getName(),
         xaDataSource.getCurrentLogVersion(),
         info.getLogVersion());
     assertEquals(
         "wrong last tx ID for XA data source " + xaDataSource.getName(),
         xaDataSource.getLastCommittedTxId(),
         info.getLastTxId());
   }
 }
示例#4
0
 @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]));
 }
示例#5
0
 private void getLastCommittedTxs(GraphDatabaseService graphDb) {
   for (XaDataSource ds :
       ((AbstractGraphDatabase) graphDb)
           .getConfig()
           .getTxModule()
           .getXaDataSourceManager()
           .getAllRegisteredDataSources()) {
     lastCommittedTxs.put(ds.getName(), ds.getLastCommittedTxId());
   }
 }
示例#6
0
  @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);
    }
  }
示例#7
0
 @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);
       }
     }
   }
 }