use of org.apache.pulsar.common.api.proto.CommandPartitionedTopicMetadataResponse in project pulsar by apache.
the class ClientCnx method handlePartitionResponse.
@Override
protected void handlePartitionResponse(CommandPartitionedTopicMetadataResponse lookupResult) {
if (log.isDebugEnabled()) {
CommandPartitionedTopicMetadataResponse.LookupType response = lookupResult.hasResponse() ? lookupResult.getResponse() : null;
int partitions = lookupResult.hasPartitions() ? lookupResult.getPartitions() : -1;
log.debug("Received Broker Partition response: {} {} {}", lookupResult.getRequestId(), response, partitions);
}
long requestId = lookupResult.getRequestId();
CompletableFuture<LookupDataResult> requestFuture = getAndRemovePendingLookupRequest(requestId);
if (requestFuture != null) {
if (requestFuture.isCompletedExceptionally()) {
if (log.isDebugEnabled()) {
log.debug("{} Request {} already timed-out", ctx.channel(), lookupResult.getRequestId());
}
return;
}
// Complete future with exception if : Result.response=fail/null
if (!lookupResult.hasResponse() || CommandPartitionedTopicMetadataResponse.LookupType.Failed.equals(lookupResult.getResponse())) {
if (lookupResult.hasError()) {
String message = buildError(lookupResult.getRequestId(), lookupResult.hasMessage() ? lookupResult.getMessage() : null);
checkServerError(lookupResult.getError(), message);
requestFuture.completeExceptionally(getPulsarClientException(lookupResult.getError(), message));
} else {
requestFuture.completeExceptionally(new PulsarClientException.LookupException("Empty lookup response"));
}
} else {
// return LookupDataResult when Result.response = success/redirect
requestFuture.complete(new LookupDataResult(lookupResult.getPartitions()));
}
} else {
log.warn("{} Received unknown request id from server: {}", ctx.channel(), lookupResult.getRequestId());
}
}
use of org.apache.pulsar.common.api.proto.CommandPartitionedTopicMetadataResponse in project pulsar by yahoo.
the class ClientCnx method handlePartitionResponse.
@Override
protected void handlePartitionResponse(CommandPartitionedTopicMetadataResponse lookupResult) {
if (log.isDebugEnabled()) {
CommandPartitionedTopicMetadataResponse.LookupType response = lookupResult.hasResponse() ? lookupResult.getResponse() : null;
int partitions = lookupResult.hasPartitions() ? lookupResult.getPartitions() : -1;
log.debug("Received Broker Partition response: {} {} {}", lookupResult.getRequestId(), response, partitions);
}
long requestId = lookupResult.getRequestId();
CompletableFuture<LookupDataResult> requestFuture = getAndRemovePendingLookupRequest(requestId);
if (requestFuture != null) {
if (requestFuture.isCompletedExceptionally()) {
if (log.isDebugEnabled()) {
log.debug("{} Request {} already timed-out", ctx.channel(), lookupResult.getRequestId());
}
return;
}
// Complete future with exception if : Result.response=fail/null
if (!lookupResult.hasResponse() || CommandPartitionedTopicMetadataResponse.LookupType.Failed.equals(lookupResult.getResponse())) {
if (lookupResult.hasError()) {
String message = buildError(lookupResult.getRequestId(), lookupResult.hasMessage() ? lookupResult.getMessage() : null);
checkServerError(lookupResult.getError(), message);
requestFuture.completeExceptionally(getPulsarClientException(lookupResult.getError(), message));
} else {
requestFuture.completeExceptionally(new PulsarClientException.LookupException("Empty lookup response"));
}
} else {
// return LookupDataResult when Result.response = success/redirect
requestFuture.complete(new LookupDataResult(lookupResult.getPartitions()));
}
} else {
log.warn("{} Received unknown request id from server: {}", ctx.channel(), lookupResult.getRequestId());
}
}
use of org.apache.pulsar.common.api.proto.CommandPartitionedTopicMetadataResponse in project incubator-pulsar by apache.
the class Commands method newPartitionMetadataResponseCommand.
public static BaseCommand newPartitionMetadataResponseCommand(ServerError error, String errorMsg, long requestId) {
BaseCommand cmd = localCmd(Type.PARTITIONED_METADATA_RESPONSE);
CommandPartitionedTopicMetadataResponse response = cmd.setPartitionMetadataResponse().setRequestId(requestId).setError(error).setResponse(CommandPartitionedTopicMetadataResponse.LookupType.Failed);
if (errorMsg != null) {
response.setMessage(errorMsg);
}
return cmd;
}
use of org.apache.pulsar.common.api.proto.CommandPartitionedTopicMetadataResponse in project incubator-pulsar by apache.
the class ClientCnx method handlePartitionResponse.
@Override
protected void handlePartitionResponse(CommandPartitionedTopicMetadataResponse lookupResult) {
if (log.isDebugEnabled()) {
CommandPartitionedTopicMetadataResponse.LookupType response = lookupResult.hasResponse() ? lookupResult.getResponse() : null;
int partitions = lookupResult.hasPartitions() ? lookupResult.getPartitions() : -1;
log.debug("Received Broker Partition response: {} {} {}", lookupResult.getRequestId(), response, partitions);
}
long requestId = lookupResult.getRequestId();
CompletableFuture<LookupDataResult> requestFuture = getAndRemovePendingLookupRequest(requestId);
if (requestFuture != null) {
if (requestFuture.isCompletedExceptionally()) {
if (log.isDebugEnabled()) {
log.debug("{} Request {} already timed-out", ctx.channel(), lookupResult.getRequestId());
}
return;
}
// Complete future with exception if : Result.response=fail/null
if (!lookupResult.hasResponse() || CommandPartitionedTopicMetadataResponse.LookupType.Failed.equals(lookupResult.getResponse())) {
if (lookupResult.hasError()) {
String message = buildError(lookupResult.getRequestId(), lookupResult.hasMessage() ? lookupResult.getMessage() : null);
checkServerError(lookupResult.getError(), message);
requestFuture.completeExceptionally(getPulsarClientException(lookupResult.getError(), message));
} else {
requestFuture.completeExceptionally(new PulsarClientException.LookupException("Empty lookup response"));
}
} else {
// return LookupDataResult when Result.response = success/redirect
requestFuture.complete(new LookupDataResult(lookupResult.getPartitions()));
}
} else {
log.warn("{} Received unknown request id from server: {}", ctx.channel(), lookupResult.getRequestId());
}
}
use of org.apache.pulsar.common.api.proto.CommandPartitionedTopicMetadataResponse in project pulsar by yahoo.
the class Commands method newPartitionMetadataResponseCommand.
public static BaseCommand newPartitionMetadataResponseCommand(ServerError error, String errorMsg, long requestId) {
BaseCommand cmd = localCmd(Type.PARTITIONED_METADATA_RESPONSE);
CommandPartitionedTopicMetadataResponse response = cmd.setPartitionMetadataResponse().setRequestId(requestId).setError(error).setResponse(CommandPartitionedTopicMetadataResponse.LookupType.Failed);
if (errorMsg != null) {
response.setMessage(errorMsg);
}
return cmd;
}
Aggregations