User: user57
Date: 02/02/16 19:34:27
Modified: src/main/org/jboss/ha/framework/server ClusterPartition.java
DistributedReplicantManagerImpl.java
HAPartitionImpl.java
Log:
o logging changes, still needs work garuding debugs and dropping
printStackTrace() usage
o using ServiceMBeanSupport features where it is a subclass, should
use it as a delegate for those that don't sc it.
Revision Changes Path
1.14 +38 -30
jbossmx/src/main/org/jboss/ha/framework/server/ClusterPartition.java
Index: ClusterPartition.java
===================================================================
RCS file:
/cvsroot/jboss/jbossmx/src/main/org/jboss/ha/framework/server/ClusterPartition.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ClusterPartition.java 15 Feb 2002 18:50:15 -0000 1.13
+++ ClusterPartition.java 17 Feb 2002 03:34:27 -0000 1.14
@@ -12,6 +12,8 @@
import java.util.Iterator;
import javax.management.ObjectName;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
import org.javagroups.Channel;
@@ -23,7 +25,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Bill Burke</a>.
* @author <a href="mailto:[EMAIL PROTECTED]">Sacha Labourey</a>.
- * @version $Revision: 1.13 $
+ * @version $Revision: 1.14 $
*
* <p><b>Revisions:</b><br>
*/
@@ -107,9 +109,10 @@
deadlock_detection = doit;
}
- public ObjectName getObjectName (javax.management.MBeanServer server, ObjectName
name) throws javax.management.MalformedObjectNameException
+ protected ObjectName getObjectName(MBeanServer server, ObjectName name)
+ throws MalformedObjectNameException
{
- return OBJECT_NAME;
+ return name == null ? OBJECT_NAME : name;
}
public org.jboss.ha.framework.interfaces.HAPartition getHAPartition ()
@@ -125,56 +128,61 @@
}
- public void createService()
+ protected void createService()
throws Exception
{
- log.info ("Creating JavaGroups JChannel");
+ boolean debug = log.isDebugEnabled();
+
+ if (debug) {
+ log.debug("Creating JavaGroups JChannel");
+ }
+
this.channel = new org.javagroups.JChannel(jgProps);
channel.setOpt(Channel.LOCAL, new Boolean(false));
channel.setOpt(Channel.GET_STATE_EVENTS, new Boolean(true));
channel.setOpt(Channel.AUTO_RECONNECT, new Boolean(true));
channel.setOpt(Channel.AUTO_GETSTATE, new Boolean(true));
+
+ if (debug) {
+ log.debug("Creating HAPartition");
+ }
- log.info("Creating HAPartition...");
partition = new HAPartitionImpl(partitionName, channel, deadlock_detection,
getServer());
+
+ if (debug) {
+ log.debug("Initing HAPartition: " + partition);
+ }
- log.info("...Initing HAPartition...");
partition.init();
- log.info("...HAPartition initialized.");
+
+ if (debug) {
+ log.debug("HAPartition initialized");
+ }
}
- public void startService()
+ protected void startService()
throws Exception
{
- log.info("Starting ClusterPartition: " + partitionName);
+ boolean debug = log.isDebugEnabled();
+
+ if (debug) {
+ log.debug("Starting ClusterPartition: " + partitionName);
+ }
- log.info(" Connecting to channel");
+ log.info("Connecting to channel");
channel.connect(partitionName);
- log.info(" Starting channel");
+ log.info("Starting channel");
partition.startPartition();
-
+
log.info("Started ClusterPartition: " + partitionName);
}
- public void stopService()
+ protected void stopService() throws Exception
{
- try
- {
- log.info("Stopping HAPartition: " + partitionName);
- partition.closePartition();
- log.info("Stopped HAPartition: " + partitionName);
- }
- catch (Exception e)
- {
- log.error("Exception during shutdown", e);
+ if (log.isDebugEnabled()) {
+ log.debug("Stopping HAPartition: " + partitionName);
}
+ partition.closePartition();
}
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
}
1.13 +14 -11
jbossmx/src/main/org/jboss/ha/framework/server/DistributedReplicantManagerImpl.java
Index: DistributedReplicantManagerImpl.java
===================================================================
RCS file:
/cvsroot/jboss/jbossmx/src/main/org/jboss/ha/framework/server/DistributedReplicantManagerImpl.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- DistributedReplicantManagerImpl.java 14 Jan 2002 20:25:26 -0000 1.12
+++ DistributedReplicantManagerImpl.java 17 Feb 2002 03:34:27 -0000 1.13
@@ -28,7 +28,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Bill Burke</a>.
* @author <a href="mailto:[EMAIL PROTECTED]">Sacha Labourey</a>.
- * @version $Revision: 1.12 $
+ * @version $Revision: 1.13 $
*
* <p><b>Revisions:</b><br>
* <p><b>2001/10/31: marcf</b>
@@ -61,10 +61,10 @@
protected HashMap keyListeners = new HashMap();
protected HAPartition partition;
- protected Logger log = null;
+ protected Logger log;
- protected javax.management.MBeanServer mbeanserver = null;
- protected javax.management.ObjectName jmxName = null;
+ protected javax.management.MBeanServer mbeanserver;
+ protected javax.management.ObjectName jmxName;
// Static --------------------------------------------------------
@@ -314,7 +314,10 @@
*/
public void _add(String key, String nodeName, Serializable replicant)
{
- log.info("_add(" + key + ", " + nodeName);
+ if (log.isDebugEnabled()) {
+ log.debug("_add(" + key + ", " + nodeName);
+ }
+
try
{
addReplicant(key, nodeName, replicant);
@@ -401,7 +404,7 @@
HashMap rep = (HashMap)map.get(key);
if (rep == null)
{
- log.info("_adding new HashMap");
+ log.debug("_adding new HashMap");
rep = new HashMap();
map.put(key, rep);
}
@@ -439,7 +442,7 @@
*/
protected void notifyKeyListeners(String key, ArrayList newReplicants)
{
- log.info("notifyKeyListeners");
+ log.debug("notifyKeyListeners");
synchronized(keyListeners)
{
ArrayList listeners = (ArrayList)keyListeners.get(key);
@@ -467,7 +470,7 @@
{
try
{
- log.info("start MergeMembers");
+ log.debug("start MergeMembers");
HashMap notifies = new HashMap();
ArrayList rsp = partition.callMethodOnCluster(SERVICE_NAME,
"lookupLocalReplicants", null, true);
for (int i = 0; i < rsp.size(); i++)
@@ -524,16 +527,16 @@
for (int i = 0; i < deadMembers.size(); i++)
{
String node = deadMembers.elementAt(i).toString();
- log.info("trying to remove deadMember " + node + " for key " +
key);
+ log.debug("trying to remove deadMember " + node + " for key " +
key);
Object removed = replicant.remove(node);
if (removed != null)
{
- log.info(node + " was removed");
+ log.debug(node + " was removed");
modified = true;
}
else
{
- log.info(node + " was NOT removed!!!");
+ log.debug(node + " was NOT removed!!!");
}
}
if (modified)
1.16 +70 -33
jbossmx/src/main/org/jboss/ha/framework/server/HAPartitionImpl.java
Index: HAPartitionImpl.java
===================================================================
RCS file:
/cvsroot/jboss/jbossmx/src/main/org/jboss/ha/framework/server/HAPartitionImpl.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- HAPartitionImpl.java 4 Feb 2002 21:26:48 -0000 1.15
+++ HAPartitionImpl.java 17 Feb 2002 03:34:27 -0000 1.16
@@ -33,7 +33,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Sacha Labourey</a>.
* @author <a href="mailto:[EMAIL PROTECTED]">Bill Burke</a>.
- * @version $Revision: 1.15 $
+ * @version $Revision: 1.16 $
*
* <p><b>Revisions:</b><br>
*/
@@ -51,22 +51,22 @@
protected HashMap rpcHandlers = new HashMap();
protected HashMap stateHandlers = new HashMap();
protected ArrayList listeners = new ArrayList();
- protected Vector members = null;
+ protected Vector members;
protected String partitionName;
protected String nodeName;
protected int timeout = 500;
- protected org.javagroups.JChannel channel = null;
+ protected org.javagroups.JChannel channel;
- protected DistributedReplicantManagerImpl replicantManager = null;
- protected DistributedStateImpl dsManager = null;
+ protected DistributedReplicantManagerImpl replicantManager;
+ protected DistributedStateImpl dsManager;
- protected Logger log = null;
+ protected Logger log;
protected long currentViewId = -1;
- protected MBeanServer server = null;
+ protected MBeanServer server;
// Static --------------------------------------------------------
@@ -81,7 +81,7 @@
public HAPartitionImpl(String partitionName, org.javagroups.JChannel channel,
boolean deadlock_detection) throws Exception
{
super(channel, null, null, new Object(), false); // init RpcDispatcher with a
fake target object
- this.log = Logger.getLogger("HAPartition:" + partitionName);
+ this.log = Logger.getLogger(HAPartitionImpl.class.getName() + "." +
partitionName);
this.channel = channel;
this.partitionName = partitionName;
}
@@ -90,6 +90,8 @@
public void init() throws Exception
{
+ log.info("Initializing");
+
// Subscribe to dHA events comming generated by the org.javagroups. protocol
stack
//
log.debug("setMembershipListener");
@@ -119,7 +121,7 @@
Context ctx = new InitialContext();
this.bind("/HAPartition/" + partitionName, this, HAPartitionImpl.class, ctx);
- log.info("done initing.");
+ log.debug("done initing.");
}
public void startPartition() throws Exception
@@ -131,7 +133,7 @@
log.debug("Get current members");
org.javagroups.View view = channel.getView();
this.members = (Vector)view.getMembers().clone();
- log.info("Num cluster members: " + members.size());
+ log.info("Number of cluster members: " + members.size());
// Update the initial view id
//
@@ -141,9 +143,9 @@
//
boolean rc = channel.getState(null, 8000);
if (rc)
- log.info("State was retrieved successfully");
+ log.debug("State was retrieved successfully");
else
- log.info("State could not be retrieved, (must be first member of group)");
+ log.debug("State could not be retrieved, (must be first member of group)");
// We start now able to start our DRM and DS
//
@@ -156,12 +158,35 @@
log.info("Closing partition " + partitionName);
// Stop the DRM and DS services
//
- try {this.replicantManager.stop();} catch (Exception printed)
{printed.printStackTrace ();}
- try {this.dsManager.stop();} catch (Exception printed)
{printed.printStackTrace();}
+ try {
+ this.replicantManager.stop();
+ }
+ catch (Exception e) {
+ log.error("operation failed", e);
+ }
- try {channel.close();} catch (Exception printed) {printed.printStackTrace();}
+ try {
+ this.dsManager.stop();
+ }
+ catch (Exception e) {
+ log.error("operation failed", e);
+ }
+
+ try {
+ channel.close();
+ }
+ catch (Exception e) {
+ log.error("operation failed", e);
+ }
+
+ InitialContext ctx = new InitialContext();
+ try {
+ ctx.unbind("/HAPartition/" + partitionName);
+ }
+ finally {
+ ctx.close();
+ }
- new InitialContext().unbind("/HAPartition/" + partitionName);
log.info("Partition " + partitionName + " closed.");
}
@@ -171,7 +196,9 @@
//
public Object getState()
{
- log.info("getState called.");
+ boolean debug = log.isDebugEnabled();
+
+ log.debug("getState called.");
try
{
// we now get the sub-state of each HAPartitionStateTransfer subscribers
and
@@ -183,7 +210,7 @@
{
String key = (String)keys.next();
HAPartition.HAPartitionStateTransfer subscriber =
(HAPartition.HAPartitionStateTransfer)stateHandlers.get(key);
- if (log.isDebugEnabled())
+ if (debug)
log.debug("getState for " + key);
state.put(key, subscriber.getCurrentState());
}
@@ -200,10 +227,10 @@
{
try
{
- log.info("setState called");
+ log.debug("setState called");
if (obj == null)
{
- log.info("state is null");
+ log.debug("state is null");
return;
}
@@ -212,7 +239,7 @@
while (keys.hasNext())
{
String key = (String)keys.next();
- log.info("setState for " + key);
+ log.debug("setState for " + key);
Object someState = state.get(key);
HAPartition.HAPartitionStateTransfer subscriber =
(HAPartition.HAPartitionStateTransfer)stateHandlers.get(key);
if (subscriber != null)
@@ -221,7 +248,7 @@
}
else
{
- log.info("There is no stateHandler for: " + key);
+ log.debug("There is no stateHandler for: " + key);
}
}
}
@@ -242,24 +269,28 @@
public void viewAccepted(org.javagroups.View newView)
{
+ boolean debug = log.isDebugEnabled();
+
try
{
// we update the view id
//
this.currentViewId = newView.getVid().getId();
- log.info("new view accepted: " + currentViewId + " (" + newView.getMembers
() + ")");
+ if (debug)
+ log.debug("new view accepted: " + currentViewId + " (" +
newView.getMembers () + ")");
if (this.members == null)
{
// Initial viewAccepted
//
this.members = (Vector)newView.getMembers().clone();
- log.info("ViewAccepted: initial members set");
+ log.debug("ViewAccepted: initial members set");
return;
}
Vector oldMembers = this.members;
Vector allMembers = newView.getMembers();
- log.info("membership changed from " + this.members.size() + " to " +
allMembers.size());
+ if (debug)
+ log.debug("membership changed from " + this.members.size() + " to " +
allMembers.size());
Vector deadMembers = getDeadMembers(oldMembers, allMembers);
Vector newMembers = getNewMembers(oldMembers, allMembers);
this.members = (Vector)allMembers.clone();
@@ -275,11 +306,10 @@
{
((HAPartition.HAMembershipListener)listeners.get(i)).membershipChanged(deadMembers,
newMembers, allMembers);
}
- catch (Exception printed)
+ catch (Exception e)
{
// a problem in a listener should not prevent other members to
receive the new view
- //
- printed.printStackTrace();
+ log.error("a problem in a listener should not prevent other
members to receive the new view", e);
}
}
}
@@ -468,7 +498,9 @@
int idx = methodName.indexOf('.');
String handlerName = methodName.substring(0, idx);
String newMethodName = methodName.substring(idx + 1);
- log.info("Handle: " + methodName);
+ if (log.isDebugEnabled()) {
+ log.debug("Handle: " + methodName);
+ }
// prepare method call
//
@@ -509,7 +541,7 @@
}
catch (javax.naming.NameNotFoundException e)
{
- log.info ("creating Subcontext" + ctxName);
+ log.debug ("creating Subcontext" + ctxName);
ctx = ctx.createSubcontext (ctxName);
}
n = n.getSuffix (1);
@@ -531,18 +563,23 @@
*/
protected Vector getDeadMembers(Vector oldMembers, Vector newMembers)
{
+ boolean debug = log.isDebugEnabled();
+
Vector dead = new Vector();
for (int i=0; i<oldMembers.size ();i++)
{
- log.info("is node " + oldMembers.elementAt(i).toString() + "dead?");
+ if (debug)
+ log.debug("is node " + oldMembers.elementAt(i).toString() + "dead?");
if (!newMembers.contains(oldMembers.elementAt (i)))
{
- log.info("node " + oldMembers.elementAt(i).toString() + "is dead");
+ if (debug)
+ log.debug("node " + oldMembers.elementAt(i).toString() + "is dead");
dead.add(oldMembers.elementAt (i));
}
else
{
- log.info("node " + oldMembers.elementAt(i).toString() + "is NOT dead");
+ if (debug)
+ log.debug("node " + oldMembers.elementAt(i).toString() + "is NOT
dead");
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development