use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.
the class DestinationUtil method resumeAllDestinations.
public static void resumeAllDestinations() {
Iterator[] itrs = Globals.getDestinationList().getAllDestinations(null);
// PART
Iterator itr = itrs[0];
while (itr.hasNext()) {
Destination d = (Destination) itr.next();
if (d.isPaused()) {
d.resumeDestination();
}
}
}
use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.
the class DestinationUtil method compactAllDestinations.
public static void compactAllDestinations() throws BrokerException {
Iterator[] itrs = Globals.getDestinationList().getAllDestinations(null);
// PART
Iterator itr = itrs[0];
boolean docompact = true;
String errMsg = null;
BrokerResources rb = Globals.getBrokerResources();
while (itr.hasNext()) {
// make sure all are paused
Destination d = (Destination) itr.next();
/*
* Skip internal, admin, or temp destinations. Skipping temp destinations may need to be revisited.
*/
if (d.isInternal() || d.isAdmin() || d.isTemporary()) {
continue;
}
if (!d.isPaused()) {
docompact = false;
String msg = rb.getString(rb.E_SOME_DESTINATIONS_NOT_PAUSED);
errMsg = rb.getString(rb.X_COMPACT_DSTS_EXCEPTION, msg);
throw (new BrokerException(errMsg));
}
}
if (docompact) {
itrs = Globals.getDestinationList().getAllDestinations(null);
itr = itrs[0];
while (itr.hasNext()) {
Destination d = (Destination) itr.next();
/*
* Skip internal, admin, or temp destinations. Skipping temp destinations may need to be revisited.
*/
if (d.isInternal() || d.isAdmin() || d.isTemporary()) {
continue;
}
d.compact();
}
}
}
use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.
the class ConsumerUtil method getDestinationNames.
private static String[] getDestinationNames(ConsumerUID cid) {
Consumer con = Consumer.getConsumer(cid);
String[] ret = null;
if (con == null) {
return (null);
}
ArrayList<String> al = new ArrayList<>();
Set dests = con.getUniqueDestinations();
if (dests == null) {
return null;
}
Iterator itr = dests.iterator();
while (itr.hasNext()) {
Destination dest = (Destination) itr.next();
al.add(dest.getDestinationName());
}
if (al.size() > 0) {
ret = new String[al.size()];
ret = al.toArray(ret);
}
return (ret);
}
use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.
the class ConsumerUtil method getDestination.
public static Destination getDestination(ConsumerUID cid) {
Consumer con = Consumer.getConsumer(cid);
Destination d = null;
if (con != null) {
d = con.getFirstDestination();
}
return (d);
}
use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.
the class Agent method loadAllMBeans.
private void loadAllMBeans() throws MalformedObjectNameException, ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException {
ObjectName objName;
/*
* Create 'one-only' MBeans in MQ as defined in 'oneOnlyMBeans' table.
*/
for (int i = 0; i < oneOnlyMBeans.length; ++i) {
ObjectName mbeanName = new ObjectName(oneOnlyMBeans[i][1]);
String mbeanClassName = mbeansPkgName + "." + oneOnlyMBeans[i][0];
Object mbean = null;
try {
mbean = Class.forName(mbeanClassName).getDeclaredConstructor().newInstance();
agentRegisterMBean(mbean, mbeanName);
} catch (Exception e) {
String name;
if (mbean instanceof MQMBeanReadOnly) {
MQMBeanReadOnly mqmb = (MQMBeanReadOnly) mbean;
name = mqmb.getMBeanName();
} else {
name = mbeanName.toString();
}
logger.log(Logger.WARNING, rb.getString(rb.W_JMX_REGISTER_MBEAN_EXCEPTION, name), e);
}
}
bkrMon = new BrokerMonitor();
objName = new ObjectName(MQObjectName.BROKER_MONITOR_MBEAN_NAME);
agentRegisterMBean(bkrMon, objName);
svcMgrMon = new ServiceManagerMonitor();
objName = new ObjectName(MQObjectName.SERVICE_MANAGER_MONITOR_MBEAN_NAME);
agentRegisterMBean(svcMgrMon, objName);
dstMgrMon = new DestinationManagerMonitor();
objName = new ObjectName(MQObjectName.DESTINATION_MANAGER_MONITOR_MBEAN_NAME);
agentRegisterMBean(dstMgrMon, objName);
cxnMgrMon = new ConnectionManagerMonitor();
objName = new ObjectName(MQObjectName.CONNECTION_MANAGER_MONITOR_MBEAN_NAME);
agentRegisterMBean(cxnMgrMon, objName);
conMgrMon = new ConsumerManagerMonitor();
objName = new ObjectName(MQObjectName.CONSUMER_MANAGER_MONITOR_MBEAN_NAME);
agentRegisterMBean(conMgrMon, objName);
prdMgrMon = new ProducerManagerMonitor();
objName = new ObjectName(MQObjectName.PRODUCER_MANAGER_MONITOR_MBEAN_NAME);
agentRegisterMBean(prdMgrMon, objName);
txnMgrMon = new TransactionManagerMonitor();
objName = new ObjectName(MQObjectName.TRANSACTION_MANAGER_MONITOR_MBEAN_NAME);
agentRegisterMBean(txnMgrMon, objName);
clsMon = new ClusterMonitor();
objName = new ObjectName(MQObjectName.CLUSTER_MONITOR_MBEAN_NAME);
agentRegisterMBean(clsMon, objName);
logMon = new LogMonitor();
objName = new ObjectName(MQObjectName.LOG_MONITOR_MBEAN_NAME);
agentRegisterMBean(logMon, objName);
if (msgMBeansEnabled()) {
msgMgrMon = new MessageManagerMonitor();
objName = new ObjectName(MESSAGE_MANAGER_MONITOR_MBEAN_NAME);
agentRegisterMBean(msgMgrMon, objName);
msgMgrCon = new MessageManagerConfig();
objName = new ObjectName(MESSAGE_MANAGER_CONFIG_MBEAN_NAME);
agentRegisterMBean(msgMgrCon, objName);
}
/*
* Create DestinationMonitor MBeans
*/
List dests = DestinationUtil.getVisibleDestinations();
if (dests.size() != 0) {
for (int i = 0; i < dests.size(); i++) {
Destination d = (Destination) dests.get(i);
registerDestination(d);
}
}
/*
* Create ServiceMonitor MBeans
*/
List svcs = ServiceUtil.getVisibleServiceNames();
Iterator iter = svcs.iterator();
while (iter.hasNext()) {
String service = (String) iter.next();
registerService(service);
}
/*
* Create MLet MBean if broker is imq.jmx.mlet.enabled is set
*/
if (mletEnabled()) {
try {
ObjectName mletName = new ObjectName(MQMLET_MBEAN_NAME);
mqMLet = new MLet();
agentRegisterMBean(mqMLet, mletName);
logger.log(Logger.INFO, "MLET: Registering MLet MBean");
} catch (Exception e) {
String name = "MQMLet";
logger.log(Logger.WARNING, rb.getString(rb.W_JMX_REGISTER_MBEAN_EXCEPTION, name), e);
}
if (mqMLet != null) {
String url = getMLetFileURL();
if ((url != null) && (!url.equals(""))) {
try {
logger.log(Logger.INFO, "MLET: Loading MBeans from MLet file: " + url);
Set loadedMBeans = mqMLet.getMBeansFromURL(url);
if (loadedMBeans != null) {
Iterator mb = loadedMBeans.iterator();
while (mb.hasNext()) {
Object obj = mb.next();
if (obj instanceof ObjectInstance) {
ObjectInstance objInst = (ObjectInstance) obj;
logger.log(Logger.INFO, "MLET: Loaded MBean [objectname=" + objInst.getObjectName().toString() + ", class=" + objInst.getClassName() + "]");
} else if (obj instanceof Throwable) {
Throwable thr = (Throwable) obj;
logger.log(Logger.WARNING, "MLET: Failed to load MBean: " + thr);
} else {
logger.log(Logger.WARNING, "MLET: Unknown object type returned by MLet MBean creation: " + obj);
}
}
}
} catch (Exception e) {
logger.log(Logger.WARNING, "Exception caught while loading MBeans via MQMLet", e);
}
}
}
}
}
Aggregations