com.alibaba.rocketmq.common.protocol.body.KVTable Java Examples
The following examples show how to use
com.alibaba.rocketmq.common.protocol.body.KVTable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KVConfigManager.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 6 votes |
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; }
Example #2
Source File: KVConfigManager.java From RocketMQ-Master-analyze with Apache License 2.0 | 6 votes |
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; }
Example #3
Source File: KVConfigManager.java From rocketmq with Apache License 2.0 | 6 votes |
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; }
Example #4
Source File: BrokerService.java From rocketmq with Apache License 2.0 | 6 votes |
@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; }
Example #5
Source File: ClusterServiceImpl.java From rocket-console with Apache License 2.0 | 6 votes |
@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); } }
Example #6
Source File: BrokerStatusSubCommand.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 5 votes |
@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(); } }
Example #7
Source File: BrokerStatusSubCommand.java From RocketMQ-Master-analyze with Apache License 2.0 | 5 votes |
@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(); } }
Example #8
Source File: BrokerStatusSubCommand.java From rocketmq with Apache License 2.0 | 5 votes |
@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(); } }
Example #9
Source File: MQAdminExtImpl.java From rocket-console with Apache License 2.0 | 4 votes |
@Override public KVTable getKVListByNamespace(String namespace) throws RemotingException, MQClientException, InterruptedException { return MQAdminInstance.threadLocalMQAdminExt().getKVListByNamespace(namespace); }
Example #10
Source File: MQAdminExtImpl.java From rocket-console with Apache License 2.0 | 4 votes |
@Override public KVTable fetchBrokerRuntimeStats(String brokerAddr) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException { return MQAdminInstance.threadLocalMQAdminExt().fetchBrokerRuntimeStats(brokerAddr); }
Example #11
Source File: RegisterBrokerResult.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 4 votes |
public void setKvTable(KVTable kvTable) { this.kvTable = kvTable; }
Example #12
Source File: ClusterListSubCommand.java From rocketmq with Apache License 2.0 | 4 votes |
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(""); } } }
Example #13
Source File: RegisterBrokerResult.java From rocketmq with Apache License 2.0 | 4 votes |
public KVTable getKvTable() { return kvTable; }
Example #14
Source File: RegisterBrokerResult.java From rocketmq with Apache License 2.0 | 4 votes |
public void setKvTable(KVTable kvTable) { this.kvTable = kvTable; }
Example #15
Source File: RegisterBrokerResult.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 4 votes |
public KVTable getKvTable() { return kvTable; }
Example #16
Source File: ClusterListSubCommand.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 4 votes |
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(""); } } }
Example #17
Source File: ClusterListSubCommand.java From RocketMQ-Master-analyze with Apache License 2.0 | 4 votes |
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(""); } } }
Example #18
Source File: RegisterBrokerResult.java From RocketMQ-Master-analyze with Apache License 2.0 | 4 votes |
public KVTable getKvTable() { return kvTable; }
Example #19
Source File: RegisterBrokerResult.java From RocketMQ-Master-analyze with Apache License 2.0 | 4 votes |
public void setKvTable(KVTable kvTable) { this.kvTable = kvTable; }