本文整理汇总了Java中com.alibaba.rocketmq.common.protocol.body.KVTable类的典型用法代码示例。如果您正苦于以下问题:Java KVTable类的具体用法?Java KVTable怎么用?Java KVTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KVTable类属于com.alibaba.rocketmq.common.protocol.body包,在下文中一共展示了KVTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getKVListByNamespace
import com.alibaba.rocketmq.common.protocol.body.KVTable; //导入依赖的package包/类
public byte[] getKVListByNamespace(final String namespace) {
try {
this.lock.readLock().lockInterruptibly();
try {
HashMap<String, String> kvTable = this.configTable.get(namespace);
if (null != kvTable) {
KVTable table = new KVTable();
table.setTable(kvTable);
return table.encode();
}
}
finally {
this.lock.readLock().unlock();
}
}
catch (InterruptedException e) {
log.error("getKVListByNamespace InterruptedException", e);
}
return null;
}
示例2: list
import com.alibaba.rocketmq.common.protocol.body.KVTable; //导入依赖的package包/类
@Override
public Map<String, Object> list() {
try {
Map<String, Object> resultMap = Maps.newHashMap();
ClusterInfo clusterInfo = mqAdminExt.examineBrokerClusterInfo();
logger.info("op=look_clusterInfo {}", JsonUtil.obj2String(clusterInfo));
Map<String/*brokerName*/, Map<Long/* brokerId */, Object/* brokerDetail */>> brokerServer = Maps.newHashMap();
for (BrokerData brokerData : clusterInfo.getBrokerAddrTable().values()) {
Map<Long, Object> brokerMasterSlaveMap = Maps.newHashMap();
for (Map.Entry<Long/* brokerId */, String/* broker address */> brokerAddr : brokerData.getBrokerAddrs().entrySet()) {
KVTable kvTable = mqAdminExt.fetchBrokerRuntimeStats(brokerAddr.getValue());
// KVTable kvTable = mqAdminExt.fetchBrokerRuntimeStats("127.0.0.1:10911");
brokerMasterSlaveMap.put(brokerAddr.getKey(), kvTable.getTable());
}
brokerServer.put(brokerData.getBrokerName(), brokerMasterSlaveMap);
}
resultMap.put("clusterInfo", clusterInfo);
resultMap.put("brokerServer", brokerServer);
return resultMap;
} catch (Exception err) {
throw Throwables.propagate(err);
}
}
示例3: getKVListByNamespace
import com.alibaba.rocketmq.common.protocol.body.KVTable; //导入依赖的package包/类
public byte[] getKVListByNamespace(final String namespace) {
try {
this.lock.readLock().lockInterruptibly();
try {
HashMap<String, String> kvTable = this.configTable.get(namespace);
if (null != kvTable) {
KVTable table = new KVTable();
table.setTable(kvTable);
return table.encode();
}
} finally {
this.lock.readLock().unlock();
}
} catch (InterruptedException e) {
log.error("getKVListByNamespace InterruptedException", e);
}
return null;
}
示例4: brokerStats
import com.alibaba.rocketmq.common.protocol.body.KVTable; //导入依赖的package包/类
@CmdTrace(cmdClazz = BrokerStatusSubCommand.class)
public Table brokerStats(String brokerAddr) throws Throwable {
Throwable t = null;
DefaultMQAdminExt defaultMQAdminExt = getDefaultMQAdminExt();
try {
defaultMQAdminExt.start();
KVTable kvTable = defaultMQAdminExt.fetchBrokerRuntimeStats(brokerAddr);
TreeMap<String, String> tmp = new TreeMap<String, String>();
tmp.putAll(kvTable.getTable());
return Table.Map2VTable(tmp);
}
catch (Throwable e) {
logger.error(e.getMessage(), e);
t = e;
}
finally {
shutdownDefaultMQAdminExt(defaultMQAdminExt);
}
throw t;
}
示例5: getBrokerRuntimeInfo
import com.alibaba.rocketmq.common.protocol.body.KVTable; //导入依赖的package包/类
public KVTable getBrokerRuntimeInfo(final String addr, final long timeoutMillis)
throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
InterruptedException, MQBrokerException {
RemotingCommand request =
RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_RUNTIME_INFO, null);
RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
return KVTable.decode(response.getBody(), KVTable.class);
}
default:
break;
}
throw new MQBrokerException(response.getCode(), response.getRemark());
}
示例6: getKVListByNamespace
import com.alibaba.rocketmq.common.protocol.body.KVTable; //导入依赖的package包/类
/**
* Name Server: 获取指定Namespace下的所有KV
*/
public KVTable getKVListByNamespace(final String namespace, final long timeoutMillis)
throws RemotingException, MQClientException, InterruptedException {
GetKVListByNamespaceRequestHeader requestHeader = new GetKVListByNamespaceRequestHeader();
requestHeader.setNamespace(namespace);
RemotingCommand request =
RemotingCommand.createRequestCommand(RequestCode.GET_KVLIST_BY_NAMESPACE, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
return KVTable.decode(response.getBody(), KVTable.class);
}
default:
break;
}
throw new MQClientException(response.getCode(), response.getRemark());
}
示例7: getBrokerRuntimeInfo
import com.alibaba.rocketmq.common.protocol.body.KVTable; //导入依赖的package包/类
public KVTable getBrokerRuntimeInfo(final String addr, final long timeoutMillis)
throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
InterruptedException, MQBrokerException {
RemotingCommand request =
RemotingCommand.createRequestCommand(MQRequestCode.GET_BROKER_RUNTIME_INFO_VALUE, null);
RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
switch (response.getCode()) {
case ResponseCode.SUCCESS_VALUE: {
return KVTable.decode(response.getBody(), KVTable.class);
}
default:
break;
}
throw new MQBrokerException(response.getCode(), response.getRemark());
}
示例8: getKVListByNamespace
import com.alibaba.rocketmq.common.protocol.body.KVTable; //导入依赖的package包/类
/**
* Name Server: 获取指定Namespace下的所有KV
*/
public KVTable getKVListByNamespace(final String namespace, final long timeoutMillis)
throws RemotingException, MQClientException, InterruptedException {
GetKVListByNamespaceRequestHeader requestHeader = new GetKVListByNamespaceRequestHeader();
requestHeader.setNamespace(namespace);
RemotingCommand request =
RemotingCommand.createRequestCommand(MQRequestCode.GET_KVLIST_BY_NAMESPACE_VALUE,
requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS_VALUE: {
return KVTable.decode(response.getBody(), KVTable.class);
}
default:
break;
}
throw new MQClientException(response.getCode(), response.getRemark());
}
示例9: execute
import com.alibaba.rocketmq.common.protocol.body.KVTable; //导入依赖的package包/类
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
try {
defaultMQAdminExt.start();
String brokerAddr = commandLine.getOptionValue('b').trim();
//获取broker一些全局统计信息 例如commitlog 全局offset等信息
KVTable kvTable = defaultMQAdminExt.fetchBrokerRuntimeStats(brokerAddr);
TreeMap<String, String> tmp = new TreeMap<String, String>();
tmp.putAll(kvTable.getTable());
Iterator<Entry<String, String>> it = tmp.entrySet().iterator();
while (it.hasNext()) {
Entry<String, String> next = it.next();
System.out.printf("%-32s: %s\n", next.getKey(), next.getValue());
}
}
catch (Exception e) {
e.printStackTrace();
}
finally {
defaultMQAdminExt.shutdown();
}
}
示例10: execute
import com.alibaba.rocketmq.common.protocol.body.KVTable; //导入依赖的package包/类
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
try {
defaultMQAdminExt.start();
String brokerAddr = commandLine.getOptionValue('b').trim();
KVTable kvTable = defaultMQAdminExt.fetchBrokerRuntimeStats(brokerAddr);
TreeMap<String, String> tmp = new TreeMap<String, String>();
tmp.putAll(kvTable.getTable());
Iterator<Entry<String, String>> it = tmp.entrySet().iterator();
while (it.hasNext()) {
Entry<String, String> next = it.next();
System.out.printf("%-32s: %s\n", next.getKey(), next.getValue());
}
}
catch (Exception e) {
e.printStackTrace();
}
finally {
defaultMQAdminExt.shutdown();
}
}
示例11: execute
import com.alibaba.rocketmq.common.protocol.body.KVTable; //导入依赖的package包/类
@Override
public void execute(CommandLine commandLine, Options options) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt();
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
try {
defaultMQAdminExt.start();
String brokerAddr = commandLine.getOptionValue('b').trim();
KVTable kvTable = defaultMQAdminExt.fetchBrokerRuntimeStats(brokerAddr);
// 为了排序
TreeMap<String, String> tmp = new TreeMap<String, String>();
tmp.putAll(kvTable.getTable());
Iterator<Entry<String, String>> it = tmp.entrySet().iterator();
while (it.hasNext()) {
Entry<String, String> next = it.next();
System.out.printf("%-32s: %s\n", next.getKey(), next.getValue());
}
}
catch (Exception e) {
e.printStackTrace();
}
finally {
defaultMQAdminExt.shutdown();
}
}
示例12: getBrokerRuntimeInfo
import com.alibaba.rocketmq.common.protocol.body.KVTable; //导入依赖的package包/类
private RemotingCommand getBrokerRuntimeInfo(ChannelHandlerContext ctx, RemotingCommand request) {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
HashMap<String, String> runtimeInfo = this.prepareRuntimeInfo();
KVTable kvTable = new KVTable();
kvTable.setTable(runtimeInfo);
byte[] body = kvTable.encode();
response.setBody(body);
response.setCode(ResponseCode.SUCCESS);
response.setRemark(null);
return response;
}
示例13: getBrokerRuntimeInfo
import com.alibaba.rocketmq.common.protocol.body.KVTable; //导入依赖的package包/类
private RemotingCommand getBrokerRuntimeInfo(ChannelHandlerContext ctx, RemotingCommand request) {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
HashMap<String, String> runtimeInfo = this.prepareRuntimeInfo();
KVTable kvTable = new KVTable();
kvTable.setTable(runtimeInfo);
byte[] body = kvTable.encode();
response.setBody(body);
response.setCode(ResponseCode.SUCCESS_VALUE);
response.setRemark(null);
return response;
}
示例14: printClusterMoreStats
import com.alibaba.rocketmq.common.protocol.body.KVTable; //导入依赖的package包/类
private void printClusterMoreStats(final DefaultMQAdminExt defaultMQAdminExt) throws RemotingConnectException,
RemotingTimeoutException, RemotingSendRequestException, InterruptedException, MQBrokerException {
ClusterInfo clusterInfoSerializeWrapper = defaultMQAdminExt.examineBrokerClusterInfo();
System.out.printf("%-16s %-32s %14s %14s %14s %14s\n",//
"#Cluster Name",//
"#Broker Name",//
"#InTotalYest",//
"#OutTotalYest",//
"#InTotalToday",//
"#OutTotalToday"//
);
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();
long InTotalYest = 0;
long OutTotalYest = 0;
long InTotalToday = 0;
long OutTotalToday = 0;
try {
KVTable kvTable = defaultMQAdminExt.fetchBrokerRuntimeStats(next1.getValue());
String msgPutTotalYesterdayMorning = kvTable.getTable().get("msgPutTotalYesterdayMorning");
String msgPutTotalTodayMorning = kvTable.getTable().get("msgPutTotalTodayMorning");
String msgPutTotalTodayNow = kvTable.getTable().get("msgPutTotalTodayNow");
String msgGetTotalYesterdayMorning = kvTable.getTable().get("msgGetTotalYesterdayMorning");
String msgGetTotalTodayMorning = kvTable.getTable().get("msgGetTotalTodayMorning");
String msgGetTotalTodayNow = kvTable.getTable().get("msgGetTotalTodayNow");
InTotalYest = Long.parseLong(msgPutTotalTodayMorning) - Long.parseLong(msgPutTotalYesterdayMorning);
OutTotalYest = Long.parseLong(msgGetTotalTodayMorning) - Long.parseLong(msgGetTotalYesterdayMorning);
InTotalToday = Long.parseLong(msgPutTotalTodayNow) - Long.parseLong(msgPutTotalTodayMorning);
OutTotalToday = Long.parseLong(msgGetTotalTodayNow) - Long.parseLong(msgGetTotalTodayMorning);
}
catch (Exception e) {
}
System.out.printf("%-16s %-32s %14d %14d %14d %14d\n",//
clusterName,//
brokerName,//
InTotalYest,//
OutTotalYest,//
InTotalToday,//
OutTotalToday//
);
}
}
}
if (itCluster.hasNext()) {
System.out.println("");
}
}
}
示例15: getKvTable
import com.alibaba.rocketmq.common.protocol.body.KVTable; //导入依赖的package包/类
public KVTable getKvTable() {
return kvTable;
}