Commit d1c4b65a authored by afreyssin's avatar afreyssin
Browse files

Evolution of the Joram administration functioning: reduces the number of...

Evolution of the Joram administration functioning: reduces the number of messages types, avoids indirection in administration request and reply path.
parent 04c8fd44
......@@ -42,11 +42,11 @@ public final class ConnectionMetaData implements javax.jms.ConnectionMetaData {
/** JMS provider name: Joram */
public final static String providerName = "Joram";
/** Joram's major version number, currently ${major.filter.value} */
public static int providerMajorVersion = 0;//major
public final static int providerMajorVersion;
/** Joram's minor version number, currently ${minor.filter.value} */
public static int providerMinorVersion = 0;//minor
public final static int providerMinorVersion;
/** Joram's implementation version, currently ${build.filter.value}. */
public static String providerVersion = "x.x.x"; // version
public final static String providerVersion;
/** Enumeration of the Joram's JMSX property names */
private final static Vector jmsxProperties = new Vector();
......@@ -54,21 +54,23 @@ public final class ConnectionMetaData implements javax.jms.ConnectionMetaData {
jmsxProperties.add("JMSXDeliveryCount");
jmsxProperties.add("JMSXGroupID");
jmsxProperties.add("JMSXGroupSeq");
getVersion();
}
private static void getVersion() {
// Read version from the package
Package pkg = ConnectionMetaData.class.getPackage();
if (pkg != null) {
String implVersion = pkg.getImplementationVersion();
if (implVersion != null) {
providerVersion = implVersion;
StringTokenizer st = new StringTokenizer(implVersion, ".");
providerMajorVersion = Integer.parseInt((String) st.nextElement());
providerMinorVersion = Integer.parseInt((String) st.nextElement());
}
}
// Read version from the package
Package pkg = ConnectionMetaData.class.getPackage();
String implVersion = null;
if (pkg != null)
implVersion = pkg.getImplementationVersion();
if (implVersion != null) {
providerVersion = implVersion;
StringTokenizer st = new StringTokenizer(implVersion, ".");
providerMajorVersion = Integer.parseInt((String) st.nextElement());
providerMinorVersion = Integer.parseInt((String) st.nextElement());
} else {
providerVersion = "x.x.x";
providerMajorVersion = 0;
providerMinorVersion = 0;
}
}
/**
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2009 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2010 ScalAgent Distributed Technologies
* Copyright (C) 2004 Bull SA
* Copyright (C) 1996 - 2000 Dyade
*
......@@ -50,19 +50,15 @@ import org.objectweb.joram.shared.admin.AdminRequest;
import org.objectweb.joram.shared.admin.CreateDestinationReply;
import org.objectweb.joram.shared.admin.CreateDestinationRequest;
import org.objectweb.joram.shared.admin.DeleteDestination;
import org.objectweb.joram.shared.admin.Monitor_GetDMQSettings;
import org.objectweb.joram.shared.admin.Monitor_GetDMQSettingsRep;
import org.objectweb.joram.shared.admin.Monitor_GetFreeAccess;
import org.objectweb.joram.shared.admin.Monitor_GetFreeAccessRep;
import org.objectweb.joram.shared.admin.Monitor_GetReaders;
import org.objectweb.joram.shared.admin.Monitor_GetStat;
import org.objectweb.joram.shared.admin.Monitor_GetStatRep;
import org.objectweb.joram.shared.admin.Monitor_GetUsersRep;
import org.objectweb.joram.shared.admin.Monitor_GetWriters;
import org.objectweb.joram.shared.admin.SetDestinationDMQ;
import org.objectweb.joram.shared.admin.GetDMQSettingsRequest;
import org.objectweb.joram.shared.admin.GetDMQSettingsReply;
import org.objectweb.joram.shared.admin.GetRightsReply;
import org.objectweb.joram.shared.admin.GetRightsRequest;
import org.objectweb.joram.shared.admin.GetStatsRequest;
import org.objectweb.joram.shared.admin.GetStatsReply;
import org.objectweb.joram.shared.admin.SetDMQRequest;
import org.objectweb.joram.shared.admin.SetReader;
import org.objectweb.joram.shared.admin.SetWriter;
import org.objectweb.joram.shared.admin.UnsetDestinationDMQ;
import org.objectweb.joram.shared.admin.UnsetReader;
import org.objectweb.joram.shared.admin.UnsetWriter;
import org.objectweb.util.monolog.api.BasicLevel;
......@@ -99,26 +95,25 @@ public abstract class Destination extends AdministeredObject implements javax.jm
}
/**
* Check the destination identifier.
* Check the specified destination identifier.
*
* @exception InvalidDestinationException if the destination identifier is invalid.
* @exception Exception if an invalid destination identifier is specified.
*/
public void check() throws InvalidDestinationException {
checkId(getName());
public static final void checkId(String id) throws InvalidDestinationException {
try {
DestinationConstants.checkId(id);
} catch (Exception exc) {
throw new InvalidDestinationException(exc.getMessage());
}
}
/**
* Check the specified destination identifier.
* Check the destination identifier.
*
* @exception InvalidDestinationException if an invalid destination identifier is specified.
* @exception InvalidDestinationException if the destination identifier is invalid.
*/
public static void checkId(String id) throws InvalidDestinationException {
if (id == null)
throw new InvalidDestinationException("Undefined (null) destination identifier.");
if (id.matches("#\\d+\\.\\d+\\.\\d+")) return;
throw new InvalidDestinationException("Bad destination identifier:" + id);
public void check() throws InvalidDestinationException {
checkId(getName());
}
/**
......@@ -615,15 +610,17 @@ public abstract class Destination extends AdministeredObject implements javax.jm
* @exception AdminException If the request fails.
*/
public List getReaders() throws ConnectException, AdminException {
Monitor_GetReaders request = new Monitor_GetReaders(getName());
Monitor_GetUsersRep reply = (Monitor_GetUsersRep) doRequest(request);
GetRightsRequest request = new GetRightsRequest(getName());
GetRightsReply reply = (GetRightsReply) doRequest(request);
Vector list = new Vector();
Hashtable users = reply.getUsers();
String name;
for (Enumeration names = users.keys(); names.hasMoreElements();) {
name = (String) names.nextElement();
list.add(new User(name, (String) users.get(name)));
Hashtable users = reply.getReaders();
if (users != null) {
String name;
for (Enumeration names = users.keys(); names.hasMoreElements();) {
name = (String) names.nextElement();
list.add(new User(name, (String) users.get(name)));
}
}
return list;
}
......@@ -641,13 +638,15 @@ public abstract class Destination extends AdministeredObject implements javax.jm
* @see org.objectweb.joram.client.jms.DestinationMBean#getReaderList()
*/
public List getReaderList() throws ConnectException, AdminException {
Monitor_GetReaders request = new Monitor_GetReaders(getName());
Monitor_GetUsersRep reply = (Monitor_GetUsersRep) doRequest(request);
GetRightsRequest request = new GetRightsRequest(getName());
GetRightsReply reply = (GetRightsReply) doRequest(request);
Vector list = new Vector();
Hashtable users = reply.getUsers();
for (Enumeration names = users.keys(); names.hasMoreElements();) {
list.add(names.nextElement());
Hashtable users = reply.getReaders();
if (users != null) {
for (Enumeration names = users.keys(); names.hasMoreElements();) {
list.add(names.nextElement());
}
}
return list;
}
......@@ -663,15 +662,17 @@ public abstract class Destination extends AdministeredObject implements javax.jm
* @exception AdminException If the request fails.
*/
public List getWriters() throws ConnectException, AdminException {
Monitor_GetWriters request = new Monitor_GetWriters(getName());
Monitor_GetUsersRep reply = (Monitor_GetUsersRep) doRequest(request);
GetRightsRequest request = new GetRightsRequest(getName());
GetRightsReply reply = (GetRightsReply) doRequest(request);
Vector list = new Vector();
Hashtable users = reply.getUsers();
String name;
for (Enumeration names = users.keys(); names.hasMoreElements();) {
name = (String) names.nextElement();
list.add(new User(name, (String) users.get(name)));
Hashtable users = reply.getWriters();
if (users != null) {
String name;
for (Enumeration names = users.keys(); names.hasMoreElements();) {
name = (String) names.nextElement();
list.add(new User(name, (String) users.get(name)));
}
}
return list;
}
......@@ -689,13 +690,15 @@ public abstract class Destination extends AdministeredObject implements javax.jm
* @see org.objectweb.joram.client.jms.DestinationMBean#getWriterList()
*/
public List getWriterList() throws ConnectException, AdminException {
Monitor_GetWriters request = new Monitor_GetWriters(getName());
Monitor_GetUsersRep reply = (Monitor_GetUsersRep) doRequest(request);
GetRightsRequest request = new GetRightsRequest(getName());
GetRightsReply reply = (GetRightsReply) doRequest(request);
Vector list = new Vector();
Hashtable users = reply.getUsers();
for (Enumeration names = users.keys(); names.hasMoreElements();) {
list.add(names.nextElement());
Hashtable users = reply.getWriters();
if (users != null) {
for (Enumeration names = users.keys(); names.hasMoreElements();) {
list.add(names.nextElement());
}
}
return list;
}
......@@ -710,11 +713,10 @@ public abstract class Destination extends AdministeredObject implements javax.jm
* @exception AdminException If the request fails.
*/
public boolean isFreelyReadable() throws ConnectException, AdminException {
Monitor_GetFreeAccess request = new Monitor_GetFreeAccess(getName());
Monitor_GetFreeAccessRep reply;
reply = (Monitor_GetFreeAccessRep) doRequest(request);
GetRightsRequest request = new GetRightsRequest(getName());
GetRightsReply reply = (GetRightsReply) doRequest(request);
return reply.getFreeReading();
return reply.isFreeReading();
}
/**
......@@ -746,11 +748,10 @@ public abstract class Destination extends AdministeredObject implements javax.jm
* @exception AdminException If the request fails.
*/
public boolean isFreelyWriteable() throws ConnectException, AdminException {
Monitor_GetFreeAccess request = new Monitor_GetFreeAccess(getName());
Monitor_GetFreeAccessRep reply;
reply = (Monitor_GetFreeAccessRep) doRequest(request);
GetRightsRequest request = new GetRightsRequest(getName());
GetRightsReply reply = (GetRightsReply) doRequest(request);
return reply.getFreeWriting();
return reply.isFreeWriting();
}
/**
......@@ -782,14 +783,30 @@ public abstract class Destination extends AdministeredObject implements javax.jm
* @exception AdminException If the request fails.
*/
public Queue getDMQ() throws ConnectException, AdminException {
Monitor_GetDMQSettings request = new Monitor_GetDMQSettings(getName());
Monitor_GetDMQSettingsRep reply = (Monitor_GetDMQSettingsRep) doRequest(request);
if (reply.getDMQName() == null) {
return null;
} else {
return new Queue(reply.getDMQName());
String dmqId = getDMQId();
Queue dmq = null;
if (dmqId != null) {
dmq = new Queue(dmqId);
if (wrapper != null)
dmq.setWrapper(wrapper);
}
return dmq;
}
/**
* Monitoring method returning the dead message queue id of this destination,
* null if not set.
* <p>
* The request fails if the destination is deleted server side.
*
* @exception ConnectException If the administration connection is closed or broken.
* @exception AdminException If the request fails.
*/
public String getDMQId() throws ConnectException, AdminException {
GetDMQSettingsRequest request = new GetDMQSettingsRequest(getName());
GetDMQSettingsReply reply = (GetDMQSettingsReply) doRequest(request);
return reply.getDMQName();
}
/**
......@@ -809,30 +826,12 @@ public abstract class Destination extends AdministeredObject implements javax.jm
*/
public void setDMQ(Queue dmq) throws ConnectException, AdminException, InvalidDestinationException {
if (dmq != null) {
dmq.check();
setDMQId(dmq.getName());
} else {
setDMQId(null);
}
}
/**
* Monitoring method returning the dead message queue id of this destination,
* null if not set.
* <p>
* The request fails if the destination is deleted server side.
*
* @exception ConnectException If the administration connection is closed or broken.
* @exception AdminException If the request fails.
*/
public String getDMQId() throws ConnectException, AdminException {
Queue dmq = getDMQ();
if (dmq != null)
return dmq.getName();
else
return null;
}
/**
* Administration method setting or unsetting a dead message queue for this
* destination.
......@@ -849,11 +848,8 @@ public abstract class Destination extends AdministeredObject implements javax.jm
* @throws InvalidDestinationException If the specified destination is invalid.
*/
public void setDMQId(String dmqId) throws ConnectException, AdminException, InvalidDestinationException {
checkId(dmqId);
if (dmqId == null)
doRequest(new UnsetDestinationDMQ(getName()));
else
doRequest(new SetDestinationDMQ(getName(), dmqId));
if (dmqId != null) checkId(dmqId);
doRequest(new SetDMQRequest(getName(), dmqId));
}
public static Destination newInstance(String id,
......@@ -903,8 +899,8 @@ public abstract class Destination extends AdministeredObject implements javax.jm
* @see org.objectweb.joram.client.jms.DestinationMBean#getStatistics()
*/
public Hashtable getStatistics() throws ConnectException, AdminException {
Monitor_GetStat request = new Monitor_GetStat(getName());
Monitor_GetStatRep reply = (Monitor_GetStatRep) doRequest(request);
GetStatsRequest request = new GetStatsRequest(getName());
GetStatsReply reply = (GetStatsReply) doRequest(request);
return reply.getStats();
}
......
......@@ -282,22 +282,15 @@ public class MessageConsumer implements javax.jms.MessageConsumer {
sess.removeMessageListener(mcl, true);
mcl = null;
} else throw new IllegalStateException(
"Message listener not null");
"Message listener not null");
} else {
if (messageListener != null) {
mcl = sess.addMessageListener(
new SingleSessionConsumer(
queueMode,
durableSubscriber,
selector,
targetName,
sess,
messageListener,
sess.getQueueMessageReadMax(),
sess.getTopicActivationThreshold(),
sess.getTopicPassivationThreshold(),
sess.getTopicAckBufferMax(),
sess.getRequestMultiplexer()));
mcl = sess.addMessageListener(new SingleSessionConsumer(queueMode,
durableSubscriber,
selector,
targetName,
sess,
messageListener));
}
// else idempotent
}
......
......@@ -41,17 +41,15 @@ import org.objectweb.joram.shared.admin.GetQueueMessageIds;
import org.objectweb.joram.shared.admin.GetQueueMessageIdsRep;
import org.objectweb.joram.shared.admin.GetQueueMessageRep;
import org.objectweb.joram.shared.admin.ListClusterQueue;
import org.objectweb.joram.shared.admin.Monitor_GetDMQSettings;
import org.objectweb.joram.shared.admin.Monitor_GetDMQSettingsRep;
import org.objectweb.joram.shared.admin.Monitor_GetNbMaxMsg;
import org.objectweb.joram.shared.admin.Monitor_GetNbMaxMsgRep;
import org.objectweb.joram.shared.admin.Monitor_GetNumberRep;
import org.objectweb.joram.shared.admin.Monitor_GetPendingMessages;
import org.objectweb.joram.shared.admin.Monitor_GetPendingRequests;
import org.objectweb.joram.shared.admin.GetDMQSettingsRequest;
import org.objectweb.joram.shared.admin.GetDMQSettingsReply;
import org.objectweb.joram.shared.admin.GetNbMaxMsgRequest;
import org.objectweb.joram.shared.admin.GetNumberReply;
import org.objectweb.joram.shared.admin.GetPendingMessages;
import org.objectweb.joram.shared.admin.GetPendingRequests;
import org.objectweb.joram.shared.admin.RemoveQueueCluster;
import org.objectweb.joram.shared.admin.SetNbMaxMsg;
import org.objectweb.joram.shared.admin.SetQueueThreshold;
import org.objectweb.joram.shared.admin.UnsetQueueThreshold;
import org.objectweb.joram.shared.admin.SetNbMaxMsgRequest;
import org.objectweb.joram.shared.admin.SetThresholdRequest;
/**
* Implements the <code>javax.jms.Queue</code> interface and provides
......@@ -266,10 +264,7 @@ public class Queue extends Destination implements javax.jms.Queue, QueueMBean {
* @exception AdminException If the request fails.
*/
public void setThreshold(int threshold) throws ConnectException, AdminException {
if (threshold == -1)
doRequest(new UnsetQueueThreshold(agentId));
else
doRequest(new SetQueueThreshold(agentId, threshold));
doRequest(new SetThresholdRequest(agentId, threshold));
}
/**
......@@ -281,14 +276,10 @@ public class Queue extends Destination implements javax.jms.Queue, QueueMBean {
* @exception AdminException If the request fails.
*/
public int getThreshold() throws ConnectException, AdminException {
Monitor_GetDMQSettings request = new Monitor_GetDMQSettings(agentId);
Monitor_GetDMQSettingsRep reply;
reply = (Monitor_GetDMQSettingsRep) doRequest(request);
GetDMQSettingsRequest request = new GetDMQSettingsRequest(agentId);
GetDMQSettingsReply reply = (GetDMQSettingsReply) doRequest(request);
if (reply.getThreshold() == null)
return -1;
else
return reply.getThreshold().intValue();
return reply.getThreshold();
}
/**
......@@ -302,7 +293,7 @@ public class Queue extends Destination implements javax.jms.Queue, QueueMBean {
* @exception AdminException If the request fails.
*/
public void setNbMaxMsg(int nbMaxMsg) throws ConnectException, AdminException {
doRequest(new SetNbMaxMsg(agentId, nbMaxMsg));
doRequest(new SetNbMaxMsgRequest(agentId, nbMaxMsg));
}
/**
......@@ -314,10 +305,9 @@ public class Queue extends Destination implements javax.jms.Queue, QueueMBean {
* @exception AdminException If the request fails.
*/
public int getNbMaxMsg() throws ConnectException, AdminException {
Monitor_GetNbMaxMsg request = new Monitor_GetNbMaxMsg(agentId);
Monitor_GetNbMaxMsgRep reply;
reply = (Monitor_GetNbMaxMsgRep) doRequest(request);
return reply.getNbMaxMsg();
GetNbMaxMsgRequest request = new GetNbMaxMsgRequest(agentId);
GetNumberReply reply = (GetNumberReply) doRequest(request);
return reply.getNumber();
}
/**
......@@ -329,9 +319,9 @@ public class Queue extends Destination implements javax.jms.Queue, QueueMBean {
* @exception AdminException If the request fails.
*/
public int getPendingMessages() throws ConnectException, AdminException {
Monitor_GetPendingMessages request = new Monitor_GetPendingMessages(agentId);
Monitor_GetNumberRep reply;
reply = (Monitor_GetNumberRep) doRequest(request);
GetPendingMessages request = new GetPendingMessages(agentId);
GetNumberReply reply;
reply = (GetNumberReply) doRequest(request);
return reply.getNumber();
}
......@@ -345,8 +335,8 @@ public class Queue extends Destination implements javax.jms.Queue, QueueMBean {
* @exception AdminException If the request fails.
*/
public int getPendingRequests() throws ConnectException, AdminException {
Monitor_GetPendingRequests request = new Monitor_GetPendingRequests(agentId);
Monitor_GetNumberRep reply = (Monitor_GetNumberRep) doRequest(request);
GetPendingRequests request = new GetPendingRequests(agentId);
GetNumberReply reply = (GetNumberReply) doRequest(request);
return reply.getNumber();
}
......
......@@ -35,16 +35,14 @@ import org.objectweb.joram.client.jms.admin.AdminException;
import org.objectweb.joram.client.jms.admin.AdminModule;
import org.objectweb.joram.shared.admin.GetSubscriberIds;
import org.objectweb.joram.shared.admin.GetSubscriberIdsRep;
import org.objectweb.joram.shared.admin.Monitor_GetCluster;
import org.objectweb.joram.shared.admin.Monitor_GetClusterRep;
import org.objectweb.joram.shared.admin.Monitor_GetFather;
import org.objectweb.joram.shared.admin.Monitor_GetFatherRep;
import org.objectweb.joram.shared.admin.Monitor_GetNumberRep;
import org.objectweb.joram.shared.admin.Monitor_GetSubscriptions;
import org.objectweb.joram.shared.admin.GetClusterRequest;
import org.objectweb.joram.shared.admin.GetClusterReply;
import org.objectweb.joram.shared.admin.GetFatherRequest;
import org.objectweb.joram.shared.admin.GetFatherReply;
import org.objectweb.joram.shared.admin.GetNumberReply;
import org.objectweb.joram.shared.admin.GetSubscriptionsRequest;
import org.objectweb.joram.shared.admin.SetCluster;
import org.objectweb.joram.shared.admin.SetFather;
import org.objectweb.joram.shared.admin.UnsetCluster;
import org.objectweb.joram.shared.admin.UnsetFather;
/**
* Implements the <code>javax.jms.Topic</code> interface and provides
......@@ -253,8 +251,8 @@ public class Topic extends Destination implements javax.jms.Topic, TopicMBean {
* @exception AdminException If the request fails.
*/
public Topic getHierarchicalFather() throws ConnectException, AdminException {
Monitor_GetFather request = new Monitor_GetFather(agentId);
Monitor_GetFatherRep reply = (Monitor_GetFatherRep) doRequest(request);
GetFatherRequest request = new GetFatherRequest(agentId);
GetFatherReply reply = (GetFatherReply) doRequest(request);
if (reply.getFatherId() == null)
return null;
......@@ -272,8 +270,8 @@ public class Topic extends Destination implements javax.jms.Topic, TopicMBean {
* @exception AdminException If the request fails.
*/
public List getClusterFellows() throws ConnectException, AdminException {
Monitor_GetCluster request = new Monitor_GetCluster(agentId);
Monitor_GetClusterRep reply = (Monitor_GetClusterRep) doRequest(request);
GetClusterRequest request = new GetClusterRequest(agentId);
GetClusterReply reply = (GetClusterReply) doRequest(request);
Vector topics = reply.getTopics();
Vector list = new Vector();
......@@ -293,8 +291,8 @@ public class Topic extends Destination implements javax.jms.Topic, TopicMBean {
* @exception AdminException If the request fails.
*/
public int getSubscriptions() throws ConnectException, AdminException {
Monitor_GetSubscriptions request = new Monitor_GetSubscriptions(agentId);
Monitor_GetNumberRep reply = (Monitor_GetNumberRep) doRequest(request);
GetSubscriptionsRequest request = new GetSubscriptionsRequest(agentId);
GetNumberReply reply = (GetNumberReply) doRequest(request);
return reply.getNumber();
}
......@@ -331,7 +329,7 @@ public class Topic extends Destination implements javax.jms.Topic, TopicMBean {
* @exception AdminException If the request fails.
*/
public void removeFromCluster() throws ConnectException, AdminException {
doRequest(new UnsetCluster(agentId));
doRequest(new SetCluster(agentId, null));
}
/**
......@@ -363,6 +361,6 @@ public class Topic extends Destination implements javax.jms.Topic, TopicMBean {
* @exception AdminException If the request fails.
*/
public void unsetParent() throws ConnectException, AdminException {
doRequest(new UnsetFather(agentId));
doRequest(new SetFather(null, agentId));
}
}
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2004 - 2009 ScalAgent Distributed Technologies
* Copyright (C) 2004 - 2010 ScalAgent Distributed Technologies
* Copyright (C) 2004 Bull SA
* Copyright (C) 2004 France Telecom R&D
*
......@@ -31,7 +31,6 @@ import org.objectweb.joram.shared.admin.*;
import java.net.ConnectException;
/**
* The <code>AdminHelper</code> class is a utility class providing methods
* for building special configurations such as topics cluster or hierarchy,
......@@ -72,7 +71,7 @@ public class AdminHelper {
* @deprecated
*/
public static void unsetClusterLink(Topic topic) throws ConnectException, AdminException {
AdminModule.doRequest(new UnsetCluster(topic.getName()));
AdminModule.doRequest(new SetCluster(topic.getName(), null));
}
/**
......@@ -106,7 +105,7 @@ public class AdminHelper {
* @deprecated
*/
public static void unsetHierarchicalLink(Topic topic) throws ConnectException, AdminException {
AdminModule.doRequest(new UnsetFather(topic.getName()));