public static XARecoveryModule getRegisteredXARecoveryModule () { if (registeredXARecoveryModule == null) { RecoveryManager recMan = RecoveryManager.manager(); Vector recoveryModules = recMan.getModules(); if (recoveryModules != null) { Enumeration modules = recoveryModules.elements(); while (modules.hasMoreElements()) { RecoveryModule m = (RecoveryModule) modules.nextElement(); if (m instanceof XARecoveryModule) { registeredXARecoveryModule = (XARecoveryModule) m; break; } } } } return registeredXARecoveryModule; }
/** * Terminate and cleanup the recovery manager. There is no going back from this. This is a * synchronous operation so return means that the recovery has completed. * * @throws IllegalStateException if the recovery manager has been shutdown. */ public final void terminate () { terminate(false); }
/** * Obtain a reference to the RecoveryManager singleton. If it hasn't * been created yet then it will be. The manager can be created in a * management mode defined by the parameter. * * @param mode the management mode for the manager. * * @throws IllegalArgumentException thrown if the manager has already been * created in a different mode to that requested. * * @return the manager. */ public static synchronized final RecoveryManager manager (int mode) throws IllegalArgumentException { if (_recoveryManager == null) _recoveryManager = new RecoveryManager(mode); else { if (_recoveryManager.mode() != mode) throw new IllegalArgumentException(); } return _recoveryManager; }
private void removeOrphanFilter() { if (orphanFilter == null) { return; } final RecoveryManager recoveryManager = RecoveryManager.manager(); for (RecoveryModule recoveryModule : recoveryManager.getModules()) { if (recoveryModule instanceof XARecoveryModule) { ((XARecoveryModule) recoveryModule).removeXAResourceOrphanFilter(orphanFilter); } } }
private boolean wasResourceContactedByRecoveryModule(final String jndiName) { final Vector<RecoveryModule> recoveryModules = RecoveryManager.manager().getModules(); for (final RecoveryModule recoveryModule : recoveryModules) { if (recoveryModule instanceof XARecoveryModule) { return ((XARecoveryModule) recoveryModule).getContactedJndiNames().contains(jndiName); } } return false; }
/** * * @return a bound server socket corresponding to the recovery manager * @throws IOException if the host name is unknown or the endpoint has already been bound */ public ServerSocket getServerSocket () throws IOException { synchronized (_socketLock) { if (_socket == null) { _socket = new ServerSocket(RecoveryManager.getRecoveryManagerPort(), Utility.BACKLOG, RecoveryManager.getRecoveryManagerHost()); recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryPort(_socket.getLocalPort()); } return _socket; } }
boolean useListener = recoveryPropertyManager.getRecoveryEnvironmentBean().isRecoveryListener(); if (useListener && isRecoveryManagerEndPointInUse()) tsLogger.i18NLogger.fatal_recovery_fail(RecoveryManager.getRecoveryManagerHost().getHostAddress(), Integer.toString(RecoveryManager.getRecoveryManagerPort())); tsLogger.i18NLogger.info_recovery_socketready( Integer.toString(_periodicRecovery.getServerSocket().getLocalPort()));
manager = manager(); manager = manager(); manager.waitForTermination();
@BeforeClass public static void beforeClass() throws Exception { RecoveryEnvironmentBean recoveryEnvironmentBean = recoveryPropertyManager.getRecoveryEnvironmentBean(); // Ensure that test XAR is recoverable by adding the test XAResourceRecovery ArrayList<String> rcvClassNames = new ArrayList<>(); rcvClassNames.add(XATestResourceXARecovery.class.getName()); jtaPropertyManager.getJTAEnvironmentBean().setXaResourceRecoveryClassNames(rcvClassNames); recoveryEnvironmentBean.setRecoveryBackoffPeriod(1); // use a short interval between passes recoveryEnvironmentBean.setRecoveryListener(true); // configure the RecoveryMonitor manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT); manager.addModule(new XARecoveryModule()); // we only need to test the XARecoveryModule manager.startRecoveryManagerThread(); // start periodic recovery }
/** * Obtain a client connection to the recovery manager * * @return a bound client socket connection to the recovery manager * @throws IOException */ public static Socket getClientSocket () throws IOException { Socket socket = new Socket(getRecoveryManagerHost(), getRecoveryManagerPort()); tsLogger.i18NLogger.info_recovery_RecoveryManager_4(socket.getInetAddress().getHostAddress(), Integer.toString(socket.getLocalPort())); return socket; }
private void addDeserializerAndOrphanFilter() { final RecoveryManager recoveryManager = RecoveryManager.manager(); for (RecoveryModule recoveryModule : recoveryManager.getModules()) { if (recoveryModule instanceof XARecoveryModule) { orphanFilter = new InboundBridgeOrphanFilter(); ((XARecoveryModule) recoveryModule).addXAResourceOrphanFilter(orphanFilter); ((XARecoveryModule) recoveryModule).addSerializableXAResourceDeserializer(new InboundBridge()); } } }
@Test public void test() { recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(1); System.setProperty("com.arjuna.ats.jta.xaRecoveryNode", "1"); System.setProperty("XAResourceRecovery1", "com.hp.mwtests.ts.jta.recovery.DummyXARecoveryResource"); RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT); manager.scan(); manager.scan(); System.clearProperty("com.arjuna.ats.jta.xaRecoveryNode"); System.clearProperty("XAResourceRecovery1"); } }
@Test public void test() throws NotSupportedException, SystemException, IllegalStateException, RollbackException, SecurityException, HeuristicMixedException, HeuristicRollbackException, NamingException { arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreType(JDBCStore.class.getName()); arjPropertyManager.getObjectStoreEnvironmentBean().setJdbcAccess(TestJDBCAccess.class.getName()); javax.transaction.TransactionManager tm = TransactionManager.transactionManager(); tm.begin(); tm.getTransaction().enlistResource(new DummyXAResource()); tm.getTransaction().enlistResource(new DummyXAResource()); tm.commit(); assertTrue(commitCount == 1); FAULT_JDBC = true; jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(Arrays.asList(new String[] { "1" })); jtaPropertyManager.getJTAEnvironmentBean().setXaResourceOrphanFilters(Arrays.asList(new XAResourceOrphanFilter[] { new com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter(), new com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter() })); jtaPropertyManager.getJTAEnvironmentBean().setXaResourceRecoveries(Arrays.asList(new XAResourceRecovery[] { new DummyXAResourceRecovery() })); jtaPropertyManager.getJTAEnvironmentBean().setOrphanSafetyInterval(1); recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(2); recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryModules(Arrays.asList(new RecoveryModule[] { new XARecoveryModule() })); RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT); manager.scan(); assertFalse(rollbackCalled); }
public void create() { String tag = ConfigurationInfo.getSourceId(); jbossatxLogger.i18NLogger.info_jta_RecoveryManagerService_create(tag); RecoveryManager.delayRecoveryManagerThread(); // listener (if any) is created here: _recoveryManager = RecoveryManager.manager(); }
/** * Force a recovery scan now. This is a blocking operation * and will only return once the recovery scan has completed. * * @throws IllegalStateException if the recovery manager has been shutdown. */ public final void scan () { checkState(); _theImple.scan(); }
/** * Start the recovery manager thread. * * @throws IllegalStateException if the recovery manager has been shutdown. */ public void startRecoveryManagerThread() { checkState(); _theImple.start() ; }
public void addSerializableXAResourceDeserializer(SerializableXAResourceDeserializer serializableXAResourceDeserializer) { XARecoveryModule xaRecoveryModule = null; for(RecoveryModule recoveryModule : ((Vector<RecoveryModule>)_recoveryManager.getModules())) { if(recoveryModule instanceof XARecoveryModule) { xaRecoveryModule = (XARecoveryModule)recoveryModule; break; } } if(xaRecoveryModule == null) { throw new IllegalStateException(jbossatxLogger.i18NLogger.get_jta_RecoveryManagerService_norecoverymodule()); } xaRecoveryModule.addSerializableXAResourceDeserializer(serializableXAResourceDeserializer); } }
/** * Remove a recovery module from the system. * * @param module The module to remove. * @param waitOnScan true if the remove operation should wait for any in-progress scan to complete * @throws IllegalStateException if the recovery manager has been shutdown. */ public final void removeModule (RecoveryModule module, boolean waitOnScan) { checkState(); _theImple.removeModule(module, waitOnScan); }
/** * Obtain a snapshot list of available recovery modules. * * @return a snapshot list of the currently installed recovery modules * @throws IllegalStateException if the recovery manager has been shutdown. */ public final Vector<RecoveryModule> getModules () { checkState(); return _theImple.getModules(); }