You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2007/06/25 18:52:15 UTC
svn commit: r550546 [2/2] - in /geronimo/server/trunk:
configs/client-transaction/src/plan/ configs/transaction-jta11/src/plan/
modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/
modules/geronimo-connector-builde...
Modified: geronimo/server/trunk/modules/geronimo-transaction-jta11/src/main/java/org/apache/geronimo/transaction/jta11/GeronimoTransactionManagerJTA11GBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-transaction-jta11/src/main/java/org/apache/geronimo/transaction/jta11/GeronimoTransactionManagerJTA11GBean.java?view=diff&rev=550546&r1=550545&r2=550546
==============================================================================
--- geronimo/server/trunk/modules/geronimo-transaction-jta11/src/main/java/org/apache/geronimo/transaction/jta11/GeronimoTransactionManagerJTA11GBean.java (original)
+++ geronimo/server/trunk/modules/geronimo-transaction-jta11/src/main/java/org/apache/geronimo/transaction/jta11/GeronimoTransactionManagerJTA11GBean.java Mon Jun 25 09:52:11 2007
@@ -17,24 +17,15 @@
package org.apache.geronimo.transaction.jta11;
-import java.util.Collection;
-import java.util.List;
-import java.util.ArrayList;
-
-import javax.transaction.xa.XAException;
import javax.transaction.TransactionSynchronizationRegistry;
+import javax.transaction.xa.XAException;
-import org.apache.geronimo.transaction.manager.XidFactory;
-import org.apache.geronimo.transaction.manager.TransactionLog;
-import org.apache.geronimo.transaction.manager.ResourceManager;
-import org.apache.geronimo.transaction.manager.TransactionManagerImplGBean;
-import org.apache.geronimo.transaction.jta11.GeronimoTransactionManagerJTA11;
-import org.apache.geronimo.gbean.ReferenceCollection;
-import org.apache.geronimo.gbean.ReferenceCollectionListener;
-import org.apache.geronimo.gbean.ReferenceCollectionEvent;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.transaction.manager.TransactionLog;
+import org.apache.geronimo.transaction.manager.TransactionManagerImplGBean;
+import org.apache.geronimo.transaction.manager.XidFactory;
/**
* @version $Rev$ $Date$
@@ -43,40 +34,11 @@
/**
* TODO NOTE!!! this should be called in an unspecified transaction context, but we cannot enforce this restriction!
*/
- public GeronimoTransactionManagerJTA11GBean(int defaultTransactionTimeoutSeconds, XidFactory xidFactory, TransactionLog transactionLog, Collection resourceManagers) throws XAException {
+ public GeronimoTransactionManagerJTA11GBean(int defaultTransactionTimeoutSeconds, XidFactory xidFactory, TransactionLog transactionLog) throws XAException {
super(defaultTransactionTimeoutSeconds == 0 ? DEFAULT_TIMEOUT : defaultTransactionTimeoutSeconds,
xidFactory,
- transactionLog,
- resourceManagers);
- }
-
-
- /**
- * We can track as resources are added into the geronimo kernel.
- *
- * @param resourceManagers
- * @return the original list of resources.
- */
- protected List watchResourceManagers(Collection resourceManagers) {
- if( resourceManagers instanceof ReferenceCollection ) {
- List copy;
- synchronized (resourceManagers) {
- copy = new ArrayList(resourceManagers);
- ((ReferenceCollection)resourceManagers).addReferenceCollectionListener(new ReferenceCollectionListener() {
- public void memberAdded(ReferenceCollectionEvent event) {
- ResourceManager resourceManager = (ResourceManager) event.getMember();
- recoverResourceManager(resourceManager);
- }
-
- public void memberRemoved(ReferenceCollectionEvent event) {
- }
-
- });
- }
- return copy;
- } else {
- return super.watchResourceManagers(resourceManagers);
- }
+ transactionLog
+ );
}
public static final GBeanInfo GBEAN_INFO;
Modified: geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManager.java?view=diff&rev=550546&r1=550545&r2=550546
==============================================================================
--- geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManager.java (original)
+++ geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManager.java Mon Jun 25 09:52:11 2007
@@ -47,8 +47,8 @@
super(defaultTransactionTimeoutSeconds, transactionLog);
}
- public GeronimoTransactionManager(int defaultTransactionTimeoutSeconds, XidFactory xidFactory, TransactionLog transactionLog, Collection resourceManagers) throws XAException {
- super(defaultTransactionTimeoutSeconds, xidFactory, transactionLog, resourceManagers);
+ public GeronimoTransactionManager(int defaultTransactionTimeoutSeconds, XidFactory xidFactory, TransactionLog transactionLog) throws XAException {
+ super(defaultTransactionTimeoutSeconds, xidFactory, transactionLog);
}
/**
Modified: geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManagerGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManagerGBean.java?view=diff&rev=550546&r1=550545&r2=550546
==============================================================================
--- geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManagerGBean.java (original)
+++ geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManagerGBean.java Mon Jun 25 09:52:11 2007
@@ -17,16 +17,10 @@
package org.apache.geronimo.transaction.manager;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
import javax.transaction.xa.XAException;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.ReferenceCollection;
-import org.apache.geronimo.gbean.ReferenceCollectionEvent;
-import org.apache.geronimo.gbean.ReferenceCollectionListener;
import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
/**
@@ -39,41 +33,14 @@
/**
* TODO NOTE!!! this should be called in an unspecified transaction context, but we cannot enforce this restriction!
*/
- public GeronimoTransactionManagerGBean(int defaultTransactionTimeoutSeconds, XidFactory xidFactory, TransactionLog transactionLog, Collection resourceManagers) throws XAException {
+ public GeronimoTransactionManagerGBean(int defaultTransactionTimeoutSeconds, XidFactory xidFactory, TransactionLog transactionLog) throws XAException {
super(defaultTransactionTimeoutSeconds == 0 ? DEFAULT_TIMEOUT : defaultTransactionTimeoutSeconds,
xidFactory,
- transactionLog,
- resourceManagers);
+ transactionLog
+ );
}
- /**
- * We can track as resources are added into the geronimo kernel.
- *
- * @param resourceManagers
- * @return the original list of resources.
- */
- protected List watchResourceManagers(Collection resourceManagers) {
- if( resourceManagers instanceof ReferenceCollection ) {
- List copy;
- synchronized (resourceManagers) {
- copy = new ArrayList(resourceManagers);
- ((ReferenceCollection)resourceManagers).addReferenceCollectionListener(new ReferenceCollectionListener() {
- public void memberAdded(ReferenceCollectionEvent event) {
- ResourceManager resourceManager = (ResourceManager) event.getMember();
- recoverResourceManager(resourceManager);
- }
-
- public void memberRemoved(ReferenceCollectionEvent event) {
- }
-
- });
- }
- return copy;
- } else {
- return super.watchResourceManagers(resourceManagers);
- }
- }
public static final GBeanInfo GBEAN_INFO;
Added: geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverableTransactionManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverableTransactionManager.java?view=auto&rev=550546
==============================================================================
--- geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverableTransactionManager.java (added)
+++ geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverableTransactionManager.java Mon Jun 25 09:52:11 2007
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.transaction.manager;
+
+import javax.transaction.TransactionManager;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public interface RecoverableTransactionManager extends TransactionManager {
+ void recoveryError(Exception e);
+
+ void recoverResourceManager(NamedXAResource xaResource);
+}
Propchange: geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverableTransactionManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverableTransactionManager.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverableTransactionManager.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java?view=diff&rev=550546&r1=550545&r2=550546
==============================================================================
--- geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java (original)
+++ geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java Mon Jun 25 09:52:11 2007
@@ -18,7 +18,6 @@
package org.apache.geronimo.transaction.manager;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -49,7 +48,7 @@
*
* @version $Rev$ $Date$
*/
-public class TransactionManagerImpl implements TransactionManager, UserTransaction, XidImporter, MonitorableTransactionManager {
+public class TransactionManagerImpl implements TransactionManager, UserTransaction, XidImporter, MonitorableTransactionManager, RecoverableTransactionManager {
private static final Log log = LogFactory.getLog(TransactionManagerImpl.class);
protected static final int DEFAULT_TIMEOUT = 600;
protected static final byte[] DEFAULT_TM_ID = new byte[] {71,84,77,73,68};
@@ -62,32 +61,31 @@
private final ConcurrentHashMap associatedTransactions = new ConcurrentHashMap();
private static final Log recoveryLog = LogFactory.getLog("RecoveryController");
final Recovery recovery;
- final Collection resourceManagers;
private final CopyOnWriteArrayList transactionAssociationListeners = new CopyOnWriteArrayList();
private List recoveryErrors = new ArrayList();
public TransactionManagerImpl() throws XAException {
this(DEFAULT_TIMEOUT,
null,
- null,
- null);
+ null
+ );
}
public TransactionManagerImpl(int defaultTransactionTimeoutSeconds) throws XAException {
this(defaultTransactionTimeoutSeconds,
null,
- null,
- null);
+ null
+ );
}
public TransactionManagerImpl(int defaultTransactionTimeoutSeconds, TransactionLog transactionLog) throws XAException {
this(defaultTransactionTimeoutSeconds,
null,
- transactionLog,
- null);
+ transactionLog
+ );
}
- public TransactionManagerImpl(int defaultTransactionTimeoutSeconds, XidFactory xidFactory, TransactionLog transactionLog, Collection resourceManagers) throws XAException {
+ public TransactionManagerImpl(int defaultTransactionTimeoutSeconds, XidFactory xidFactory, TransactionLog transactionLog) throws XAException {
if (defaultTransactionTimeoutSeconds <= 0) {
throw new IllegalArgumentException("defaultTransactionTimeoutSeconds must be positive: attempted value: " + defaultTransactionTimeoutSeconds);
}
@@ -106,21 +104,7 @@
this.xidFactory = new XidFactoryImpl(DEFAULT_TM_ID);
}
- this.resourceManagers = resourceManagers;
recovery = new RecoveryImpl(this.transactionLog, this.xidFactory);
-
- if (resourceManagers != null) {
- recovery.recoverLog();
- List copy = watchResourceManagers(resourceManagers);
- for (Iterator iterator = copy.iterator(); iterator.hasNext();) {
- ResourceManager resourceManager = (ResourceManager) iterator.next();
- recoverResourceManager(resourceManager);
- }
- }
- }
-
- protected List watchResourceManagers(Collection resourceManagers) {
- return new ArrayList(resourceManagers);
}
public Transaction getTransaction() {
@@ -347,27 +331,19 @@
return defaultTransactionTimeoutMilliseconds;
}
- protected void recoverResourceManager(ResourceManager resourceManager) {
- NamedXAResource namedXAResource;
+ //Recovery
+ public void recoveryError(Exception e) {
+ recoveryLog.error(e);
+ recoveryErrors.add(e);
+ }
+
+ public void recoverResourceManager(NamedXAResource xaResource) {
try {
- namedXAResource = resourceManager.getRecoveryXAResources();
- } catch (SystemException e) {
- recoveryLog.error(e);
- recoveryErrors.add(e);
- return;
- }
- if (namedXAResource != null) {
- try {
- recovery.recoverResourceManager(namedXAResource);
- } catch (XAException e) {
- recoveryLog.error(e);
- recoveryErrors.add(e);
- } finally {
- resourceManager.returnResource(namedXAResource);
- }
+ recovery.recoverResourceManager(xaResource);
+ } catch (XAException e) {
+ recoveryError(e);
}
}
-
public Map getExternalXids() {
return new HashMap(recovery.getExternalXids());
Modified: geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionManagerImplGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionManagerImplGBean.java?view=diff&rev=550546&r1=550545&r2=550546
==============================================================================
--- geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionManagerImplGBean.java (original)
+++ geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionManagerImplGBean.java Mon Jun 25 09:52:11 2007
@@ -39,37 +39,8 @@
/**
* TODO NOTE!!! this should be called in an unspecified transaction context, but we cannot enforce this restriction!
*/
- public TransactionManagerImplGBean(int defaultTransactionTimeoutSeconds, XidFactory xidFactory, TransactionLog transactionLog, Collection resourceManagers) throws XAException {
- super(defaultTransactionTimeoutSeconds, xidFactory, transactionLog, resourceManagers);
- }
-
-
- /**
- * We can track as resources are added into the geronimo kernel.
- *
- * @param resourceManagers
- * @return the original list of resources.
- */
- protected List watchResourceManagers(Collection resourceManagers) {
- if( resourceManagers instanceof ReferenceCollection ) {
- List copy;
- synchronized (resourceManagers) {
- copy = new ArrayList(resourceManagers);
- ((ReferenceCollection)resourceManagers).addReferenceCollectionListener(new ReferenceCollectionListener() {
- public void memberAdded(ReferenceCollectionEvent event) {
- ResourceManager resourceManager = (ResourceManager) event.getMember();
- recoverResourceManager(resourceManager);
- }
-
- public void memberRemoved(ReferenceCollectionEvent event) {
- }
-
- });
- }
- return copy;
- } else {
- return super.watchResourceManagers(resourceManagers);
- }
+ public TransactionManagerImplGBean(int defaultTransactionTimeoutSeconds, XidFactory xidFactory, TransactionLog transactionLog) throws XAException {
+ super(defaultTransactionTimeoutSeconds, xidFactory, transactionLog);
}
public static final GBeanInfo GBEAN_INFO;
@@ -80,13 +51,11 @@
infoBuilder.addAttribute("defaultTransactionTimeoutSeconds", int.class, true);
infoBuilder.addReference("XidFactory", XidFactory.class, NameFactory.XID_FACTORY);
infoBuilder.addReference("TransactionLog", TransactionLog.class, NameFactory.TRANSACTION_LOG);
- infoBuilder.addReference("ResourceManagers", ResourceManager.class);//two kinds of things, so specify the type in each pattern.
infoBuilder.setConstructor(new String[]{
"defaultTransactionTimeoutSeconds",
"XidFactory",
- "TransactionLog",
- "ResourceManagers"});
+ "TransactionLog"});
GBEAN_INFO = infoBuilder.getBeanInfo();
}
Modified: geronimo/server/trunk/modules/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/MockResourceManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/MockResourceManager.java?view=diff&rev=550546&r1=550545&r2=550546
==============================================================================
--- geronimo/server/trunk/modules/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/MockResourceManager.java (original)
+++ geronimo/server/trunk/modules/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/MockResourceManager.java Mon Jun 25 09:52:11 2007
@@ -32,12 +32,11 @@
*
* @version $Rev$ $Date$
*/
-public class MockResourceManager implements ResourceManager {
+public class MockResourceManager {
private boolean willCommit;
private Map xids = new HashMap();
private NamedXAResource resources;
- private NamedXAResource returnedResources;
public MockResourceManager(boolean willCommit) {
this.willCommit = willCommit;
@@ -72,15 +71,8 @@
}
}
- public NamedXAResource getRecoveryXAResources() throws SystemException {
- return resources;
+ public void doRecovery(RecoverableTransactionManager transactionManager) throws SystemException {
+ transactionManager.recoverResourceManager(resources);
}
- public void returnResource(NamedXAResource xaResource) {
- returnedResources = xaResource;
- }
-
- public boolean areAllResourcesReturned() {
- return returnedResources != null && returnedResources == resources;
- }
}
Modified: geronimo/server/trunk/modules/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/TransactionManagerImplTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/TransactionManagerImplTest.java?view=diff&rev=550546&r1=550545&r2=550546
==============================================================================
--- geronimo/server/trunk/modules/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/TransactionManagerImplTest.java (original)
+++ geronimo/server/trunk/modules/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/TransactionManagerImplTest.java Mon Jun 25 09:52:11 2007
@@ -45,12 +45,11 @@
TransactionLog transactionLog = new MockLog();
- ReferenceCollection resourceManagers = new TestReferenceCollection();
TransactionManagerImpl tm;
protected void setUp() throws Exception {
tm = new TransactionManagerImplGBean(10,
- new XidFactoryImpl("WHAT DO WE CALL IT?".getBytes()), transactionLog, resourceManagers);
+ new XidFactoryImpl("WHAT DO WE CALL IT?".getBytes()), transactionLog);
}
protected void tearDown() throws Exception {
@@ -260,10 +259,10 @@
tm.prepare(tx);
//recover
tm.recovery.recoverLog();
- resourceManagers.add(rm1);
+ rm1.doRecovery(tm);
assertTrue(r1_2.isCommitted());
assertTrue(!r2_2.isCommitted());
- resourceManagers.add(rm2);
+ rm2.doRecovery(tm);
assertTrue(r2_2.isCommitted());
assertTrue(tm.recovery.localRecoveryComplete());
}
@@ -283,10 +282,10 @@
tm.prepare(tx);
//recover
tm.recovery.recoverLog();
- resourceManagers.add(rm1);
+ rm1.doRecovery(tm);
assertTrue(!r1_2.isCommitted());
assertTrue(!r2_2.isCommitted());
- resourceManagers.add(rm2);
+ rm2.doRecovery(tm);
assertTrue(!r2_2.isCommitted());
//there are no transactions started here, so local recovery is complete
assertTrue(tm.recovery.localRecoveryComplete());
@@ -300,7 +299,7 @@
long timeout = tm.getTransactionTimeoutMilliseconds(0L);
tm.setTransactionTimeout((int)timeout/4000);
tm.begin();
- System.out.println("Test to sleep for" + timeout + " secs");
+ System.out.println("Test to sleep for " + timeout + " millisecs");
Thread.sleep(timeout);
try
{
@@ -313,49 +312,10 @@
// Now test if the default timeout is active
tm.begin();
- System.out.println("Test to sleep for" + (timeout/2) + " secs");
+ System.out.println("Test to sleep for " + (timeout/2) + " millisecs");
Thread.sleep((timeout/2));
tm.commit();
// Its a failure if exception occurs.
}
-
- public void testResourceManagerContract() throws Exception {
- resourceManagers.add(rm1);
- assertTrue(rm1.areAllResourcesReturned());
- }
-
-
- private static class TestReferenceCollection extends ArrayList implements ReferenceCollection {
-
- ReferenceCollectionListener referenceCollectionListener;
-
- public void addReferenceCollectionListener(ReferenceCollectionListener listener) {
- this.referenceCollectionListener = listener;
- }
-
- public void removeReferenceCollectionListener(ReferenceCollectionListener listener) {
- this.referenceCollectionListener = null;
- }
-
- public boolean add(Object o) {
- boolean result = super.add(o);
- if (referenceCollectionListener != null) {
- referenceCollectionListener.memberAdded(new ReferenceCollectionEvent(null, o));
- }
- return result;
- }
-
- public boolean remove(Object o) {
- boolean result = super.remove(o);
- if (referenceCollectionListener != null) {
- referenceCollectionListener.memberRemoved(new ReferenceCollectionEvent(null, o));
- }
- return result;
- }
-
- public ObjectName[] getMemberObjectNames() {return new ObjectName[0];}
-
- }
-
}