Search in sources :

Example 1 with GetClusterInfoResponse

use of com.alipay.sofa.jraft.rhea.cmd.pd.GetClusterInfoResponse in project sofa-jraft by sofastack.

the class DefaultPlacementDriverService method handleGetClusterInfoRequest.

@Override
public void handleGetClusterInfoRequest(final GetClusterInfoRequest request, final RequestProcessClosure<BaseRequest, BaseResponse> closure) {
    final long clusterId = request.getClusterId();
    final GetClusterInfoResponse response = new GetClusterInfoResponse();
    response.setClusterId(clusterId);
    if (!this.isLeader) {
        response.setError(Errors.NOT_LEADER);
        closure.sendResponse(response);
        return;
    }
    try {
        final Cluster cluster = this.metadataStore.getClusterInfo(clusterId);
        response.setValue(cluster);
    } catch (final Throwable t) {
        LOG.error("Failed to handle: {}, {}.", request, StackTraceUtil.stackTrace(t));
        response.setError(Errors.forException(t));
    }
    closure.sendResponse(response);
}
Also used : GetClusterInfoResponse(com.alipay.sofa.jraft.rhea.cmd.pd.GetClusterInfoResponse) Cluster(com.alipay.sofa.jraft.rhea.metadata.Cluster)

Aggregations

GetClusterInfoResponse (com.alipay.sofa.jraft.rhea.cmd.pd.GetClusterInfoResponse)1 Cluster (com.alipay.sofa.jraft.rhea.metadata.Cluster)1