Search in sources :

Example 1 with MaxGraphCtrlServiceBlockingStub

use of com.alibaba.maxgraph.rpc.MaxGraphCtrlServiceGrpc.MaxGraphCtrlServiceBlockingStub in project GraphScope by alibaba.

the class RpcConnector method showProcessList.

public void showProcessList(TimelyResultProcessor resultProcessor) throws Exception {
    MaxGraphCtrlServiceBlockingStub stub = randomCtrlStub(getTargetExecutorAddrs().get(0));
    ShowProcessListResponse resp = stub.showProcessList(ShowProcessListRequest.newBuilder().build());
    List<QueryResult> processNameList = Lists.newArrayList();
    for (RunningQuery runningQuery : resp.getQueriesList()) {
        processNameList.add(new PropertyValueResult(runningQuery.getQueryId() + "[" + runningQuery.getScript() + "][" + runningQuery.getElapsedNano() / 1000000 + "ms]"));
    }
    ListResult listResult = new ListResult(processNameList);
    resultProcessor.process(listResult);
    resultProcessor.finish();
}
Also used : ListResult(com.alibaba.maxgraph.result.ListResult) QueryResult(com.alibaba.maxgraph.sdkcommon.graph.QueryResult) MaxGraphCtrlServiceBlockingStub(com.alibaba.maxgraph.rpc.MaxGraphCtrlServiceGrpc.MaxGraphCtrlServiceBlockingStub) PropertyValueResult(com.alibaba.maxgraph.result.PropertyValueResult)

Example 2 with MaxGraphCtrlServiceBlockingStub

use of com.alibaba.maxgraph.rpc.MaxGraphCtrlServiceGrpc.MaxGraphCtrlServiceBlockingStub in project GraphScope by alibaba.

the class RpcConnector method cancelDataflowByFront.

public void cancelDataflowByFront(int frontId, List<Endpoint> serverList) throws Exception {
    for (Endpoint entry : serverList) {
        IpPort address = IpPort.fromCtrlAndAsyncEndpoint(entry);
        ManagedChannel randomChannel = channels.get(address).get(RandomUtils.nextInt(0, channelCount)).getRight();
        MaxGraphCtrlServiceBlockingStub stub = MaxGraphCtrlServiceGrpc.newBlockingStub(randomChannel);
        CancelDataflowResponse resp = stub.cancelDataflowByFront(GremlinService.CancelDataflowByFrontRequest.newBuilder().setFrontId(frontId).build());
        if (!resp.getSuccess()) {
            throw new RuntimeException("request cancelDataflowByFront to server " + address + " by frontend " + frontId + " fail: " + resp.getMessage());
        }
    }
}
Also used : Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint) MaxGraphCtrlServiceBlockingStub(com.alibaba.maxgraph.rpc.MaxGraphCtrlServiceGrpc.MaxGraphCtrlServiceBlockingStub) ManagedChannel(io.grpc.ManagedChannel)

Example 3 with MaxGraphCtrlServiceBlockingStub

use of com.alibaba.maxgraph.rpc.MaxGraphCtrlServiceGrpc.MaxGraphCtrlServiceBlockingStub in project GraphScope by alibaba.

the class RpcConnector method hasCancelDataFlowByFrontCompleted.

public boolean hasCancelDataFlowByFrontCompleted(int frontId, List<Endpoint> serverList) throws Exception {
    for (Endpoint entry : serverList) {
        IpPort address = IpPort.fromCtrlAndAsyncEndpoint(entry);
        ManagedChannel randomChannel = channels.get(address).get(RandomUtils.nextInt(0, channelCount)).getRight();
        MaxGraphCtrlServiceBlockingStub stub = MaxGraphCtrlServiceGrpc.newBlockingStub(randomChannel);
        ShowProcessListResponse resp = stub.showProcessList(ShowProcessListRequest.newBuilder().build());
        // resp.getQueriesList());
        for (RunningQuery runningQuery : resp.getQueriesList()) {
            if (runningQuery.getFrontId() == frontId) {
                return false;
            }
        }
    }
    return true;
}
Also used : Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint) MaxGraphCtrlServiceBlockingStub(com.alibaba.maxgraph.rpc.MaxGraphCtrlServiceGrpc.MaxGraphCtrlServiceBlockingStub) ManagedChannel(io.grpc.ManagedChannel)

Example 4 with MaxGraphCtrlServiceBlockingStub

use of com.alibaba.maxgraph.rpc.MaxGraphCtrlServiceGrpc.MaxGraphCtrlServiceBlockingStub in project GraphScope by alibaba.

the class RpcConnector method cancelDataflow.

public void cancelDataflow(TimelyResultProcessor resultProcessor, String queryId) throws Exception {
    List<Endpoint> executorAddrList = getTargetExecutorAddrs();
    String logMsg = new String("");
    boolean isSuccess = false;
    for (int i = 0; i < executorAddrList.size(); i++) {
        MaxGraphCtrlServiceBlockingStub stub = randomCtrlStub(executorAddrList.get(i));
        CancelDataflowResponse resp = stub.cancelDataflow(CancelDataflowRequest.newBuilder().setQueryId(queryId).build());
        if (resp.getSuccess()) {
            isSuccess = true;
            logMsg = String.format("Cancel %s in worker %d success.", queryId, i);
        } else {
            logMsg = String.format("Cancel %s in worker %d failed.", queryId, i);
        }
        LOG.info(logMsg);
    }
    String resultMsg;
    if (isSuccess) {
        resultMsg = "Cancel success.";
    } else {
        resultMsg = "Cancel failed.";
    }
    resultProcessor.process(new PropertyValueResult(resultMsg));
    resultProcessor.finish();
}
Also used : Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint) MaxGraphCtrlServiceBlockingStub(com.alibaba.maxgraph.rpc.MaxGraphCtrlServiceGrpc.MaxGraphCtrlServiceBlockingStub) PropertyValueResult(com.alibaba.maxgraph.result.PropertyValueResult) ByteString(com.google.protobuf.ByteString) Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint)

Aggregations

MaxGraphCtrlServiceBlockingStub (com.alibaba.maxgraph.rpc.MaxGraphCtrlServiceGrpc.MaxGraphCtrlServiceBlockingStub)4 Endpoint (com.alibaba.maxgraph.sdkcommon.client.Endpoint)3 PropertyValueResult (com.alibaba.maxgraph.result.PropertyValueResult)2 ManagedChannel (io.grpc.ManagedChannel)2 ListResult (com.alibaba.maxgraph.result.ListResult)1 QueryResult (com.alibaba.maxgraph.sdkcommon.graph.QueryResult)1 ByteString (com.google.protobuf.ByteString)1