use of com.sun.messaging.jmq.util.DestMetricsCounters in project openmq by eclipse-ee4j.
the class CmdRunner method runMetrics.
private int runMetrics(BrokerCmdProperties brokerCmdProps) {
BrokerAdmin broker;
BrokerCmdPrinter bcp;
String commandArg;
long sleepTime;
int metricType, metricSamples;
broker = init();
commandArg = brokerCmdProps.getCommandArg();
sleepTime = brokerCmdProps.getMetricInterval();
metricType = getMetricType(brokerCmdProps);
metricSamples = brokerCmdProps.getMetricSamples();
if (CMDARG_SERVICE.equals(commandArg)) {
bcp = setupMetricTitle(commandArg, metricType);
if (broker == null) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_METRICS_SVC_FAIL));
return (1);
}
boolean force = brokerCmdProps.forceModeSet();
if (!force)
broker = promptForAuthentication(broker);
String svcName = brokerCmdProps.getTargetName();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_METRICS_SVC));
printServiceInfo();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_SPECIFY_BKR));
printBrokerInfo(broker);
try {
MetricCounters previousMetrics = null;
int rowsPrinted = 0;
connectToBroker(broker);
while (true) {
broker.sendGetMetricsMessage(svcName);
MetricCounters mc = (MetricCounters) broker.receiveGetMetricsReplyMessage();
if (mc == null) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_METRICS_SVC_FAIL));
return (1);
}
addOneMetricRow(metricType, bcp, mc, previousMetrics);
if ((rowsPrinted % 20) == 0) {
bcp.print();
} else {
bcp.print(false);
}
bcp.clear();
previousMetrics = mc;
rowsPrinted++;
if (metricSamples > 0) {
if (metricSamples == rowsPrinted) {
break;
}
}
try {
Thread.sleep(sleepTime * 1000);
} catch (InterruptedException ie) {
Globals.stdErrPrintln(ie.toString());
}
}
Globals.stdOutPrintln("");
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_METRICS_SVC_SUC));
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_METRICS_SVC_FAIL));
return (1);
}
} else if (CMDARG_BROKER.equals(commandArg)) {
if (broker == null) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_METRICS_BKR_FAIL));
return (1);
}
bcp = setupMetricTitle(commandArg, metricType);
boolean force = brokerCmdProps.forceModeSet();
if (!force)
broker = promptForAuthentication(broker);
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_METRICS_BKR));
printBrokerInfo(broker);
try {
MetricCounters previousMetrics = null;
int rowsPrinted = 0;
connectToBroker(broker);
while (true) {
broker.sendGetMetricsMessage(null);
MetricCounters mc = (MetricCounters) broker.receiveGetMetricsReplyMessage();
if (mc == null) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_METRICS_BKR_FAIL));
return (1);
}
addOneMetricRow(metricType, bcp, mc, previousMetrics);
if ((rowsPrinted % 20) == 0) {
bcp.print();
} else {
bcp.print(false);
}
bcp.clear();
previousMetrics = mc;
rowsPrinted++;
if (metricSamples > 0) {
if (metricSamples == rowsPrinted) {
break;
}
}
try {
Thread.sleep(sleepTime * 1000);
} catch (InterruptedException ie) {
Globals.stdErrPrintln(ie.toString());
}
}
Globals.stdOutPrintln("");
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_METRICS_BKR_SUC));
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_METRICS_BKR_FAIL));
return (1);
}
} else if (CMDARG_DESTINATION.equals(commandArg)) {
String destName;
int destTypeMask;
destName = brokerCmdProps.getTargetName();
destTypeMask = getDestTypeMask(brokerCmdProps);
bcp = setupDestMetricTitle(commandArg, metricType, destTypeMask);
if (broker == null) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_METRICS_DST_FAIL));
return (1);
}
boolean force = brokerCmdProps.forceModeSet();
if (!force)
broker = promptForAuthentication(broker);
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_METRICS_DST));
printDestinationInfo();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_SPECIFY_BKR));
printBrokerInfo(broker);
try {
DestMetricsCounters previousMetrics = null;
int rowsPrinted = 0;
connectToBroker(broker);
while (true) {
broker.sendGetMetricsMessage(destName, destTypeMask);
DestMetricsCounters mc = (DestMetricsCounters) broker.receiveGetMetricsReplyMessage();
if (mc == null) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_METRICS_DST_FAIL));
return (1);
}
addOneDestMetricRow(metricType, destTypeMask, bcp, mc, previousMetrics);
if ((rowsPrinted % 20) == 0) {
bcp.print();
} else {
bcp.print(false);
}
bcp.clear();
previousMetrics = mc;
rowsPrinted++;
if (metricSamples > 0) {
if (metricSamples == rowsPrinted) {
break;
}
}
try {
Thread.sleep(sleepTime * 1000);
} catch (InterruptedException ie) {
Globals.stdErrPrintln(ie.toString());
}
}
Globals.stdOutPrintln("");
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_METRICS_DST_SUC));
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_METRICS_DST_FAIL));
return (1);
}
}
if (broker.isConnected()) {
broker.close();
}
return (0);
}
use of com.sun.messaging.jmq.util.DestMetricsCounters in project openmq by eclipse-ee4j.
the class Queue method getMetrics.
@Override
public DestMetricsCounters getMetrics() {
DestMetricsCounters dmc = super.getMetrics();
synchronized (this) {
// current # of active consumers
dmc.setActiveConsumers(activeConsumerCnt);
// current # of failover consumers
// only applies to queues
dmc.setFailoverConsumers(failoverConsumerCnt);
// max # of active consumers
dmc.setHWActiveConsumers(hwActiveCount);
// max # of failover consumers
dmc.setHWFailoverConsumers(hwFailoverCount);
// avg active consumer
dmc.setAvgActiveConsumers((int) activeAverage);
// avg failover consumer
dmc.setAvgFailoverConsumers((int) failoverAverage);
}
return dmc;
}
use of com.sun.messaging.jmq.util.DestMetricsCounters in project openmq by eclipse-ee4j.
the class Destination method readObject.
/**
* handles transient data when class is deserialized
*/
private void readObject(java.io.ObjectInputStream ois) throws IOException, ClassNotFoundException {
ois.defaultReadObject();
logger = Globals.getLogger();
br = Globals.getBrokerResources();
DL = Globals.getDestinationList();
currentChangeRecordInfo = Collections.synchronizedMap(new HashMap<Integer, ChangeRecordInfo>());
producerFlow = new ProducerFlow();
isDMQ = DestType.isDMQ(type);
if (!isDMQ) {
expireReaper = new MsgExpirationReaper();
}
dest_inited = false;
loaded = false;
destvalid = true;
sizeLock = new Object();
size = 0;
remoteSize = 0;
bytes = 0L;
remoteBytes = 0L;
destMessages = new SimpleNFLHashMap<>();
destMessagesInRemoving = new HashMap();
_removeMessageLock = new Object();
consumers = new SimpleNFLHashMap();
producers = new SimpleNFLHashMap();
if (maxConsumerLimit > DestinationList.UNLIMITED) {
consumers.setCapacity(maxConsumerLimit);
}
if (maxProducerLimit > DestinationList.UNLIMITED) {
producers.setCapacity(maxProducerLimit);
}
filter = new DestFilter();
unloadfilter = new UnloadFilter();
dmc = new DestMetricsCounters();
stored = true;
setMaxPrefetch(maxPrefetch);
logsuffix = "";
queueRemoteLock = new Object();
queueRemoteLockThread = null;
// when loading a stored destination, we must
// set the behavior first OR we will not be notified
// that the destination is full IF it already exceeds
// its limits
handleLimitBehavior(limit);
if (memoryLimit != null) {
setByteCapacity(memoryLimit);
}
if (countLimit > 0) {
setCapacity(countLimit);
}
if (msgSizeLimit != null) {
setMaxByteSize(msgSizeLimit);
}
if (!isDMQ) {
deliveryTimeTimer = new MessageDeliveryTimeTimer(this);
}
updateProducerBatch(false);
if (clientReconnectInterval > 0) {
synchronized (this) {
if (clientReconnectInterval > 0) {
reconnectReaper = new ReconnectReaperTask(getDestinationUID(), clientReconnectInterval);
try {
timer.schedule(reconnectReaper, clientReconnectInterval);
} catch (IllegalStateException ex) {
logger.logStack(Logger.INFO, BrokerResources.E_INTERNAL_BROKER_ERROR, "Can not reschedule task, timer has " + "been canceled, the broker is probably " + "shutting down", ex);
}
}
}
}
logger.log(Logger.DEBUG, "Loading Stored destination " + this + " connectionUID=" + id);
}
Aggregations