Search in sources :

Example 1 with GetKVListByNamespaceRequestHeader

use of org.apache.rocketmq.common.protocol.header.namesrv.GetKVListByNamespaceRequestHeader in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class DefaultRequestProcessor method getKVListByNamespace.

/**
 * 获取一个Namespace下的所有kv
 */
private RemotingCommand getKVListByNamespace(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetKVListByNamespaceRequestHeader requestHeader = (GetKVListByNamespaceRequestHeader) request.decodeCommandCustomHeader(GetKVListByNamespaceRequestHeader.class);
    byte[] jsonValue = this.namesrvController.getKvConfigManager().getKVListByNamespace(requestHeader.getNamespace());
    if (null != jsonValue) {
        response.setBody(jsonValue);
        response.setCode(ResponseCode.SUCCESS);
        response.setRemark(null);
        return response;
    }
    response.setCode(ResponseCode.QUERY_NOT_FOUND);
    response.setRemark("No config item, Namespace: " + requestHeader.getNamespace());
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetKVListByNamespaceRequestHeader(org.apache.rocketmq.common.protocol.header.namesrv.GetKVListByNamespaceRequestHeader)

Example 2 with GetKVListByNamespaceRequestHeader

use of org.apache.rocketmq.common.protocol.header.namesrv.GetKVListByNamespaceRequestHeader 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());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) KVTable(org.apache.rocketmq.common.protocol.body.KVTable) GetKVListByNamespaceRequestHeader(org.apache.rocketmq.common.protocol.header.namesrv.GetKVListByNamespaceRequestHeader) MQClientException(org.apache.rocketmq.client.exception.MQClientException)

Example 3 with GetKVListByNamespaceRequestHeader

use of org.apache.rocketmq.common.protocol.header.namesrv.GetKVListByNamespaceRequestHeader in project rocketmq by apache.

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());
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) KVTable(org.apache.rocketmq.common.protocol.body.KVTable) GetKVListByNamespaceRequestHeader(org.apache.rocketmq.common.protocol.header.namesrv.GetKVListByNamespaceRequestHeader) MQClientException(org.apache.rocketmq.client.exception.MQClientException)

Example 4 with GetKVListByNamespaceRequestHeader

use of org.apache.rocketmq.common.protocol.header.namesrv.GetKVListByNamespaceRequestHeader in project rocketmq by apache.

the class DefaultRequestProcessor method getKVListByNamespace.

private RemotingCommand getKVListByNamespace(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetKVListByNamespaceRequestHeader requestHeader = (GetKVListByNamespaceRequestHeader) request.decodeCommandCustomHeader(GetKVListByNamespaceRequestHeader.class);
    byte[] jsonValue = this.namesrvController.getKvConfigManager().getKVListByNamespace(requestHeader.getNamespace());
    if (null != jsonValue) {
        response.setBody(jsonValue);
        response.setCode(ResponseCode.SUCCESS);
        response.setRemark(null);
        return response;
    }
    response.setCode(ResponseCode.QUERY_NOT_FOUND);
    response.setRemark("No config item, Namespace: " + requestHeader.getNamespace());
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) GetKVListByNamespaceRequestHeader(org.apache.rocketmq.common.protocol.header.namesrv.GetKVListByNamespaceRequestHeader)

Aggregations

GetKVListByNamespaceRequestHeader (org.apache.rocketmq.common.protocol.header.namesrv.GetKVListByNamespaceRequestHeader)4 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)4 MQClientException (org.apache.rocketmq.client.exception.MQClientException)2 KVTable (org.apache.rocketmq.common.protocol.body.KVTable)2