use of com.sun.messaging.jmq.jmsserver.service.Service in project openmq by eclipse-ee4j.
the class JMSRA_BrokerProcess method getJMSService.
/**
* Return the named JMS Service that supports 'DIRECT' in-JVM Java EEJMS clients.
*
* @param serviceName The name of the service to return
*
* @throws IllegalStateException if the broker is already stopped
*/
@Override
public JMSService getJMSService(String serviceName) throws IllegalStateException {
ServiceManager sm = Globals.getServiceManager();
Service svc;
IMQService imqSvc;
IMQDirectService imqDirectSvc;
if (sm == null) {
return (null);
}
svc = sm.getService(serviceName);
if (svc == null) {
return (null);
}
if (!(svc instanceof IMQService)) {
return (null);
}
imqSvc = (IMQService) svc;
if (!imqSvc.isDirect()) {
return (null);
}
if (!(imqSvc instanceof IMQDirectService)) {
return (null);
}
imqDirectSvc = (IMQDirectService) imqSvc;
return imqDirectSvc.getJMSService();
}
use of com.sun.messaging.jmq.jmsserver.service.Service in project openmq by eclipse-ee4j.
the class ConnectionUtil method getConnectionInfoList.
/**
* Returns a List of ConnectionInfo for the given service or all services if the passed service is null.
*/
public static List getConnectionInfoList(String service) {
ConnectionManager cm = Globals.getConnectionManager();
List connections, connectionInfoList = new ArrayList();
IMQConnection cxn;
ConnectionInfo cxnInfo;
try {
Service s = null;
if (service != null) {
s = Globals.getServiceManager().getService(service);
/*
* If service object is null, service may not exist or is inactive
*/
if (s == null) {
return (connectionInfoList);
}
}
connections = cm.getConnectionList(s);
} catch (Exception e) {
BrokerResources rb = Globals.getBrokerResources();
Logger logger = Globals.getLogger();
logger.log(Logger.WARNING, rb.getString(rb.W_JMX_FAILED_TO_OBTAIN_CONNECTION_LIST), e);
return (connectionInfoList);
}
if (connections.size() == 0) {
return (connectionInfoList);
}
Iterator iter = connections.iterator();
while (iter.hasNext()) {
cxn = (IMQConnection) iter.next();
cxnInfo = cxn.getConnectionInfo();
connectionInfoList.add(cxnInfo);
}
return (connectionInfoList);
}
use of com.sun.messaging.jmq.jmsserver.service.Service in project openmq by eclipse-ee4j.
the class GetServicesHandler method getServiceInfo.
public static ServiceInfo getServiceInfo(String name) {
ServiceManager sm = Globals.getServiceManager();
ConnectionManager cm = Globals.getConnectionManager();
MetricManager mm = Globals.getMetricManager();
/*
* XXX REVISIT dipol 10/17/00 we should probably put this logic into the ServiceManager so knowledge of property names
* is encapsulated there.
*/
String proto = props.getProperty(SERVICE_PREFIX + name + ".protocoltype");
// Fill in admin service info object
ServiceInfo si = new com.sun.messaging.jmq.util.admin.ServiceInfo();
si.name = name;
si.protocol = proto;
// strange kludge here ...
// if protocol is tcp or tls, it defaults to 0
int default_value = -1;
if (si.protocol != null) {
if (si.protocol.equals("tcp") || si.protocol.equals("tls")) {
default_value = 0;
}
}
si.port = props.getIntProperty(SERVICE_PREFIX + name + "." + proto + ".port", default_value);
if (si.port == 0) {
si.dynamicPort = true;
} else {
si.dynamicPort = false;
}
si.minThreads = props.getIntProperty(SERVICE_PREFIX + name + ".min_threads");
si.maxThreads = props.getIntProperty(SERVICE_PREFIX + name + ".max_threads");
si.type = sm.getServiceType(name);
Service service = sm.getService(name);
if (service != null) {
si.nConnections = cm.getNumConnections(service);
si.state = service.getState();
if (service instanceof IMQService) {
IMQService ss = (IMQService) service;
si.currentThreads = ss.getActiveThreadpool();
si.minThreads = ss.getMinThreadpool();
si.maxThreads = ss.getMaxThreadpool();
// port number that is acutally being used
if (si.port == 0 && ss.getProtocol() != null) {
si.port = ss.getProtocol().getLocalPort();
}
}
if (mm != null) {
si.metrics = mm.getMetricCounters(name);
} else {
si.metrics = null;
}
} else {
// Service is not intitialized
si.state = ServiceState.UNKNOWN;
}
return si;
}
use of com.sun.messaging.jmq.jmsserver.service.Service in project openmq by eclipse-ee4j.
the class DebugHandler method getAllCxnInfo.
private Hashtable getAllCxnInfo(String svc) throws Exception {
Service s = null;
Hashtable debugHash = new Hashtable();
if (svc != null) {
s = Globals.getServiceManager().getService(svc);
debugHash.put("threadPool", getThreadPoolInfo(svc));
debugHash.put("threads", SupportUtil.getAllStackTraces(""));
}
Iterator itr = Globals.getConnectionManager().getConnectionList(s).iterator();
while (itr.hasNext()) {
IMQConnection c = (IMQConnection) itr.next();
debugHash.put(c.getRemoteConnectionString(), c.getDebugState());
}
return debugHash;
}
use of com.sun.messaging.jmq.jmsserver.service.Service in project openmq by eclipse-ee4j.
the class GetConnectionsHandler method handle.
/**
* Handle the incomming administration message.
*
* @param con The Connection the message came in on.
* @param cmd_msg The administration message
* @param cmd_props The properties from the administration message
*/
@Override
public boolean handle(IMQConnection con, Packet cmd_msg, Hashtable cmd_props) {
if (DEBUG) {
logger.log(Logger.DEBUG, this.getClass().getName() + ": " + "GetConnections: " + cmd_props);
}
ConnectionManager cm = Globals.getConnectionManager();
String serviceName = (String) cmd_props.get(MessageType.JMQ_SERVICE_NAME);
Long cxnId = (Long) cmd_props.get(MessageType.JMQ_CONNECTION_ID);
int status = Status.OK;
String errMsg = null;
Vector v = new Vector();
Service s = null;
if (serviceName != null) {
s = Globals.getServiceManager().getService(serviceName);
if (s == null) {
status = Status.NOT_FOUND;
errMsg = rb.getString(rb.X_NO_SUCH_SERVICE, serviceName);
}
}
if (status == Status.OK) {
ConnectionInfo cxnInfo = null;
IMQConnection cxn = null;
if (cxnId != null) {
// Get info for one connection
cxn = (IMQConnection) cm.getConnection(new ConnectionUID(cxnId.longValue()));
if (cxn != null) {
if (DEBUG) {
cxn.dump();
}
cxnInfo = cxn.getConnectionInfo();
v.add(getConnectionInfoHashtable(cxnInfo));
} else {
status = Status.NOT_FOUND;
errMsg = rb.getString(rb.E_NO_SUCH_CONNECTION, String.valueOf(cxnId.longValue()));
}
} else {
// Get info for all connections on a service
List connections = cm.getConnectionList(s);
Iterator itr = connections.iterator();
while (itr.hasNext()) {
cxn = (IMQConnection) itr.next();
cxnInfo = cxn.getConnectionInfo();
v.add(getConnectionInfoHashtable(cxnInfo));
}
}
}
// Send reply
Packet reply = new Packet(con.useDirectBuffers());
reply.setPacketType(PacketType.OBJECT_MESSAGE);
setProperties(reply, MessageType.GET_CONNECTIONS_REPLY, status, errMsg);
setBodyObject(reply, v);
parent.sendReply(con, cmd_msg, reply);
return true;
}
Aggregations