use of org.apache.rocketmq.common.protocol.body.KVTable in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class MQClientAPIImpl method getKVListByNamespace.
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());
}
use of org.apache.rocketmq.common.protocol.body.KVTable in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class MQClientAPIImpl method getBrokerRuntimeInfo.
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(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), 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());
}
use of org.apache.rocketmq.common.protocol.body.KVTable in project rocketmq by apache.
the class DefaultMQAdminExtTest method testPutKVConfig.
@Test
public void testPutKVConfig() throws RemotingException, MQClientException, InterruptedException {
String topicConfig = defaultMQAdminExt.getKVConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG, "UnitTest");
assertThat(topicConfig).isEqualTo("topicListConfig");
KVTable kvs = defaultMQAdminExt.getKVListByNamespace(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG);
assertThat(kvs.getTable().get("broker-name")).isEqualTo("broker-one");
assertThat(kvs.getTable().get("cluster-name")).isEqualTo("default-cluster");
}
use of org.apache.rocketmq.common.protocol.body.KVTable in project rocketmq by apache.
the class DefaultMQAdminExtTest method testFetchBrokerRuntimeStats.
@Test
public void testFetchBrokerRuntimeStats() throws InterruptedException, MQBrokerException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException {
KVTable brokerStats = defaultMQAdminExt.fetchBrokerRuntimeStats("127.0.0.1:10911");
assertThat(brokerStats.getTable().get("id")).isEqualTo("1234");
assertThat(brokerStats.getTable().get("brokerName")).isEqualTo("default-broker");
}
use of org.apache.rocketmq.common.protocol.body.KVTable in project rocketmq by apache.
the class BrokerStatusSubCommandTest method init.
@BeforeClass
public static void init() throws NoSuchFieldException, IllegalAccessException, InterruptedException, RemotingTimeoutException, MQClientException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
mQClientAPIImpl = mock(MQClientAPIImpl.class);
defaultMQAdminExt = new DefaultMQAdminExt();
defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 1000);
Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance");
field.setAccessible(true);
field.set(defaultMQAdminExtImpl, mqClientInstance);
field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
field.setAccessible(true);
field.set(mqClientInstance, mQClientAPIImpl);
field = DefaultMQAdminExt.class.getDeclaredField("defaultMQAdminExtImpl");
field.setAccessible(true);
field.set(defaultMQAdminExt, defaultMQAdminExtImpl);
KVTable kvTable = new KVTable();
kvTable.setTable(new HashMap<String, String>());
when(mQClientAPIImpl.getBrokerRuntimeInfo(anyString(), anyLong())).thenReturn(kvTable);
}
Aggregations