[jboss-cvs] JBossAS SVN: r83001 - trunk/cluster/src/main/org/jboss/ejb/plugins.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jan 16 16:13:15 EST 2009
Author: jiwils
Date: 2009-01-16 16:13:15 -0500 (Fri, 16 Jan 2009)
New Revision: 83001
Modified:
trunk/cluster/src/main/org/jboss/ejb/plugins/CleanShutdownInterceptor.java
Log:
Fix for JBAS-6336. Exception message cleanup.
Modified: trunk/cluster/src/main/org/jboss/ejb/plugins/CleanShutdownInterceptor.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ejb/plugins/CleanShutdownInterceptor.java 2009-01-16 21:12:36 UTC (rev 83000)
+++ trunk/cluster/src/main/org/jboss/ejb/plugins/CleanShutdownInterceptor.java 2009-01-16 21:13:15 UTC (rev 83001)
@@ -72,15 +72,15 @@
// Attributes ----------------------------------------------------
protected Container container = null;
-
+
protected EjbModule ejbModule = null;
protected String ejbModuleName = null;
-
+
private static ThreadLocal<String> currentModule = new ThreadLocal<String>();
-
+
protected boolean allowInvocations = false;
protected boolean allowRemoteInvocations = false;
-
+
protected boolean isDebugEnabled = false;
public long runningInvocations = 0;
@@ -91,7 +91,7 @@
protected ReadWriteLock rwLock = new ReentrantReadWriteLock(true);
// Static --------------------------------------------------------
-
+
private static final String METHOD_INVOCATION_TAG = "WrappingEjbModuleName";
// Constructors --------------------------------------------------
@@ -101,7 +101,7 @@
}
// Public --------------------------------------------------------
-
+
public void onlyAllowLocalInvocations ()
{
if (isDebugEnabled) log.debug ("Only allow local invocation from now on: " + this.container.getServiceName ().toString ());
@@ -117,7 +117,7 @@
purgeRunningInvocations ();
if (isDebugEnabled) log.debug ("... Done: no more remote invocations currently running in this container.");
}
-
+
// Z implementation ----------------------------------------------
// AbstractInterceptor overrides ---------------------------------------------------
@@ -126,20 +126,20 @@
super.create ();
this.allowInvocations = false;
this.allowRemoteInvocations = false;
-
+
this.isDebugEnabled = log.isDebugEnabled ();
-
+
ejbModuleName = ejbModule.getServiceName().toString();
-
+
// we register our inner-class to retrieve STATE notifications from our container
//
AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter ();
filter.enableAttribute ("State");
-
+
this.container.getServer ().
- addNotificationListener (this.container.getEjbModule ().getServiceName (),
- new CleanShutdownInterceptor.StateChangeListener (),
- filter,
+ addNotificationListener (this.container.getEjbModule ().getServiceName (),
+ new CleanShutdownInterceptor.StateChangeListener (),
+ filter,
null);
// we need a way to find all CleanShutDownInterceptor of an EjbModule
@@ -180,7 +180,7 @@
{
String origin = getOrigin (mi);
boolean isAppLocalCall = ejbModuleName.equals (origin);
-
+
if (!this.allowRemoteInvocations && !isAppLocalCall)
// it is a remote call and they are currently forbidden!
//
@@ -189,7 +189,7 @@
throw new GenericClusteringException (GenericClusteringException.COMPLETED_NO,
"This application does not accept remote calls any more");
}
-
+
// we need to acquire the read lock. If we cannot directly, it means
// that the stop/destroy call has gotten the write lock in the meantime
//
@@ -228,7 +228,7 @@
{
if (!isAppLocalCall)
revertOrigin (mi, origin);
-
+
runningHomeInvocations--;
if (!isAppLocalCall) // we only consider remote calls => every local originates from a remote!
rwLock.readLock().unlock();
@@ -236,7 +236,7 @@
}
else
throw new GenericClusteringException (GenericClusteringException.COMPLETED_NO,
- "Container is shuting down on this node");
+ "Container is not allowing invocations as it failed to start or is shutting down");
}
public Object invoke (Invocation mi)
@@ -246,7 +246,7 @@
{
String origin = getOrigin (mi);
boolean isAppLocalCall = ejbModuleName.equals (origin);
-
+
if (!this.allowRemoteInvocations && !isAppLocalCall)
// it is a remote call and they are currently forbidden!
//
@@ -302,7 +302,7 @@
}
else
throw new GenericClusteringException (GenericClusteringException.COMPLETED_NO,
- "Container is shuting down on this node");
+ "Container is not allowing invocations as it failed to start or is shutting down");
}
public Container getContainer ()
@@ -333,7 +333,7 @@
purgeRunningInvocations();
}
-
+
protected void purgeRunningInvocations ()
{
try
@@ -341,43 +341,43 @@
if (this.rwLock.writeLock().tryLock(shutdownTimeout, TimeUnit.MILLISECONDS))
this.rwLock.writeLock().unlock();
else
- log.info ("Possible running invocations not terminated " +
+ log.info ("Possible running invocations not terminated " +
"while leaving the container. Home: " + runningHomeInvocations +
- ". Remote: " + runningInvocations + ".");
+ ". Remote: " + runningInvocations + ".");
}
- catch (Exception e)
+ catch (Exception e)
{
- log.info ("Exception while waiting for running invocations " +
+ log.info ("Exception while waiting for running invocations " +
"to leave container. Home: " + runningHomeInvocations +
- ". Remote: " + runningInvocations + ".", e);
+ ". Remote: " + runningInvocations + ".", e);
}
finally
{
-
+
}
}
-
+
protected String getOrigin (Invocation mi)
{
String value = currentModule.get();
if (log.isTraceEnabled())
log.trace ("GET_ORIGIN: " + value + " in " + this.container.getServiceName ().toString ());
- return value;
+ return value;
}
-
+
protected void setOrigin (Invocation mi)
- {
+ {
currentModule.set(this.ejbModuleName);
}
-
+
protected void revertOrigin (Invocation mi, String origin)
{
-
+
if (log.isTraceEnabled()) log.trace ("Crossing ejbModule border from " + this.ejbModuleName + " to " + origin);
currentModule.set (origin);
}
-
+
// Private -------------------------------------------------------
protected void containerIsAboutToStop ()
@@ -389,19 +389,19 @@
log.debug("Received STOPPING notification after container already set to null; ignoring");
return;
}
-
+
log.debug ("Container about to stop: disabling HA-RMI access to bean from interceptor");
-
+
// This is bad: we should have some kind of code (manager) associated
// with this ejbModule. We mimic this by electing the first ProxyFactoryHA
// as a manager
//
boolean iAmTheManager = !Boolean.TRUE.equals (ejbModule.getModuleData ("ShutdownInterceptorElected"));
-
+
if (iAmTheManager)
{
ejbModule.putModuleData ("ShutdownInterceptorElected", Boolean.TRUE);
-
+
if (isDebugEnabled) log.debug ("Container is about to stop and I am the manager of the first step: blocking remote calls");
// in a first step, all interceptors must refuse/redirect remote invocations
//
@@ -426,34 +426,34 @@
{
if (isDebugEnabled) log.debug ("Container is about to stop but I am not the manager: I don't manage the first step of the process.");
}
-
+
// in a second step, all container, manager or not, will wait that no more invocation
// are running through
// The cycling around other interceptor is managed by the JMX callbacks, not by us
//
waitForNoMoreInvocations ();
}
-
+
// Inner classes -------------------------------------------------
class StateChangeListener implements NotificationListener
{
-
+
public void handleNotification (Notification notification, java.lang.Object handback)
{
if (notification instanceof AttributeChangeNotification)
{
AttributeChangeNotification notif = (AttributeChangeNotification) notification;
int value = ((Integer)notif.getNewValue()).intValue ();
-
+
// Start management is handled by the ProxyFactoryHA, not here
if (value == ServiceMBean.STOPPING)
- {
+ {
containerIsAboutToStop ();
}
}
}
-
+
}
-
+
}
More information about the jboss-cvs-commits
mailing list