use of org.apache.rocketmq.client.exception.MQBrokerException in project rocketmq by apache.
the class ClusterListSubCommand method printClusterBaseInfo.
private void printClusterBaseInfo(final DefaultMQAdminExt defaultMQAdminExt) throws RemotingConnectException, RemotingTimeoutException, RemotingSendRequestException, InterruptedException, MQBrokerException {
ClusterInfo clusterInfoSerializeWrapper = defaultMQAdminExt.examineBrokerClusterInfo();
System.out.printf("%-16s %-22s %-4s %-22s %-16s %19s %19s %10s %5s %6s%n", "#Cluster Name", "#Broker Name", "#BID", "#Addr", "#Version", "#InTPS(LOAD)", "#OutTPS(LOAD)", "#PCWait(ms)", "#Hour", "#SPACE");
Iterator<Map.Entry<String, Set<String>>> itCluster = clusterInfoSerializeWrapper.getClusterAddrTable().entrySet().iterator();
while (itCluster.hasNext()) {
Map.Entry<String, Set<String>> next = itCluster.next();
String clusterName = next.getKey();
TreeSet<String> brokerNameSet = new TreeSet<String>();
brokerNameSet.addAll(next.getValue());
for (String brokerName : brokerNameSet) {
BrokerData brokerData = clusterInfoSerializeWrapper.getBrokerAddrTable().get(brokerName);
if (brokerData != null) {
Iterator<Map.Entry<Long, String>> itAddr = brokerData.getBrokerAddrs().entrySet().iterator();
while (itAddr.hasNext()) {
Map.Entry<Long, String> next1 = itAddr.next();
double in = 0;
double out = 0;
String version = "";
String sendThreadPoolQueueSize = "";
String pullThreadPoolQueueSize = "";
String sendThreadPoolQueueHeadWaitTimeMills = "";
String pullThreadPoolQueueHeadWaitTimeMills = "";
String pageCacheLockTimeMills = "";
String earliestMessageTimeStamp = "";
String commitLogDiskRatio = "";
try {
KVTable kvTable = defaultMQAdminExt.fetchBrokerRuntimeStats(next1.getValue());
String putTps = kvTable.getTable().get("putTps");
String getTransferedTps = kvTable.getTable().get("getTransferedTps");
sendThreadPoolQueueSize = kvTable.getTable().get("sendThreadPoolQueueSize");
pullThreadPoolQueueSize = kvTable.getTable().get("pullThreadPoolQueueSize");
sendThreadPoolQueueSize = kvTable.getTable().get("sendThreadPoolQueueSize");
pullThreadPoolQueueSize = kvTable.getTable().get("pullThreadPoolQueueSize");
sendThreadPoolQueueHeadWaitTimeMills = kvTable.getTable().get("sendThreadPoolQueueHeadWaitTimeMills");
pullThreadPoolQueueHeadWaitTimeMills = kvTable.getTable().get("pullThreadPoolQueueHeadWaitTimeMills");
pageCacheLockTimeMills = kvTable.getTable().get("pageCacheLockTimeMills");
earliestMessageTimeStamp = kvTable.getTable().get("earliestMessageTimeStamp");
commitLogDiskRatio = kvTable.getTable().get("commitLogDiskRatio");
version = kvTable.getTable().get("brokerVersionDesc");
{
String[] tpss = putTps.split(" ");
if (tpss.length > 0) {
in = Double.parseDouble(tpss[0]);
}
}
{
String[] tpss = getTransferedTps.split(" ");
if (tpss.length > 0) {
out = Double.parseDouble(tpss[0]);
}
}
} catch (Exception e) {
e.printStackTrace();
}
double hour = 0.0;
double space = 0.0;
if (earliestMessageTimeStamp != null && earliestMessageTimeStamp.length() > 0) {
long mills = System.currentTimeMillis() - Long.valueOf(earliestMessageTimeStamp);
hour = mills / 1000.0 / 60.0 / 60.0;
}
if (commitLogDiskRatio != null && commitLogDiskRatio.length() > 0) {
space = Double.valueOf(commitLogDiskRatio);
}
System.out.printf("%-16s %-22s %-4s %-22s %-16s %19s %19s %10s %5s %6s%n", clusterName, brokerName, next1.getKey(), next1.getValue(), version, String.format("%9.2f(%s,%sms)", in, sendThreadPoolQueueSize, sendThreadPoolQueueHeadWaitTimeMills), String.format("%9.2f(%s,%sms)", out, pullThreadPoolQueueSize, pullThreadPoolQueueHeadWaitTimeMills), pageCacheLockTimeMills, String.format("%2.2f", hour), String.format("%.4f", space));
}
}
}
if (itCluster.hasNext()) {
System.out.printf("");
}
}
}
use of org.apache.rocketmq.client.exception.MQBrokerException in project rocketmq by apache.
the class StatsAllSubCommand method printTopicDetail.
public static void printTopicDetail(final DefaultMQAdminExt admin, final String topic, final boolean activeTopic) throws RemotingException, MQClientException, InterruptedException, MQBrokerException {
TopicRouteData topicRouteData = admin.examineTopicRouteInfo(topic);
GroupList groupList = admin.queryTopicConsumeByWho(topic);
double inTPS = 0;
long inMsgCntToday = 0;
for (BrokerData bd : topicRouteData.getBrokerDatas()) {
String masterAddr = bd.getBrokerAddrs().get(MixAll.MASTER_ID);
if (masterAddr != null) {
try {
BrokerStatsData bsd = admin.viewBrokerStatsData(masterAddr, BrokerStatsManager.TOPIC_PUT_NUMS, topic);
inTPS += bsd.getStatsMinute().getTps();
inMsgCntToday += compute24HourSum(bsd);
} catch (Exception e) {
}
}
}
if (groupList != null && !groupList.getGroupList().isEmpty()) {
for (String group : groupList.getGroupList()) {
double outTPS = 0;
long outMsgCntToday = 0;
for (BrokerData bd : topicRouteData.getBrokerDatas()) {
String masterAddr = bd.getBrokerAddrs().get(MixAll.MASTER_ID);
if (masterAddr != null) {
try {
String statsKey = String.format("%s@%s", topic, group);
BrokerStatsData bsd = admin.viewBrokerStatsData(masterAddr, BrokerStatsManager.GROUP_GET_NUMS, statsKey);
outTPS += bsd.getStatsMinute().getTps();
outMsgCntToday += compute24HourSum(bsd);
} catch (Exception e) {
}
}
}
long accumulate = 0;
try {
ConsumeStats consumeStats = admin.examineConsumeStats(group, topic);
if (consumeStats != null) {
accumulate = consumeStats.computeTotalDiff();
if (accumulate < 0) {
accumulate = 0;
}
}
} catch (Exception e) {
}
if (!activeTopic || (inMsgCntToday > 0) || (outMsgCntToday > 0)) {
System.out.printf("%-32s %-32s %12d %11.2f %11.2f %14d %14d%n", UtilAll.frontStringAtLeast(topic, 32), UtilAll.frontStringAtLeast(group, 32), accumulate, inTPS, outTPS, inMsgCntToday, outMsgCntToday);
}
}
} else {
if (!activeTopic || (inMsgCntToday > 0)) {
System.out.printf("%-32s %-32s %12d %11.2f %11s %14d %14s%n", UtilAll.frontStringAtLeast(topic, 32), "", 0, inTPS, "", inMsgCntToday, "NO_CONSUMER");
}
}
}
use of org.apache.rocketmq.client.exception.MQBrokerException in project rocketmq by apache.
the class QueryMsgByIdSubCommand method sendMsg.
private void sendMsg(final DefaultMQAdminExt defaultMQAdminExt, final DefaultMQProducer defaultMQProducer, final String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
try {
MessageExt msg = defaultMQAdminExt.viewMessage(msgId);
if (msg != null) {
// resend msg by id
System.out.printf("prepare resend msg. originalMsgId=%s", msgId);
SendResult result = defaultMQProducer.send(msg);
System.out.printf("%s", result);
} else {
System.out.printf("no message. msgId=%s", msgId);
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.apache.rocketmq.client.exception.MQBrokerException in project rocketmq by apache.
the class DefaultMQProducerImpl method send.
public void send(Message msg, MessageQueue mq, SendCallback sendCallback, long timeout) throws MQClientException, RemotingException, InterruptedException {
this.makeSureStateOK();
Validators.checkMessage(msg, this.defaultMQProducer);
if (!msg.getTopic().equals(mq.getTopic())) {
throw new MQClientException("message's topic not equal mq's topic", null);
}
try {
this.sendKernelImpl(msg, mq, CommunicationMode.ASYNC, sendCallback, null, timeout);
} catch (MQBrokerException e) {
throw new MQClientException("unknown exception", e);
}
}
use of org.apache.rocketmq.client.exception.MQBrokerException in project rocketmq by apache.
the class DefaultMQProducerImpl method sendOneway.
/**
* KERNEL ONEWAY -------------------------------------------------------
*/
public void sendOneway(Message msg, MessageQueue mq) throws MQClientException, RemotingException, InterruptedException {
this.makeSureStateOK();
Validators.checkMessage(msg, this.defaultMQProducer);
try {
this.sendKernelImpl(msg, mq, CommunicationMode.ONEWAY, null, null, this.defaultMQProducer.getSendMsgTimeout());
} catch (MQBrokerException e) {
throw new MQClientException("unknown exception", e);
}
}
Aggregations