Search in sources :

Example 1 with GetClientStartTimeResult

use of build.buildfarm.v1test.GetClientStartTimeResult in project bazel-buildfarm by bazelbuild.

the class AdminService method getClientStartTime.

@Override
public void getClientStartTime(GetClientStartTimeRequest request, StreamObserver<GetClientStartTimeResult> responseObserver) {
    try {
        GetClientStartTimeResult result = instance.getClientStartTime(request);
        responseObserver.onNext(result);
        responseObserver.onCompleted();
    } catch (Exception e) {
        logger.log(Level.SEVERE, String.format("Could not get client start time for %s.", request.getInstanceName()), e);
        responseObserver.onError(io.grpc.Status.fromThrowable(e).asException());
    }
}
Also used : GetClientStartTimeResult(build.buildfarm.v1test.GetClientStartTimeResult)

Example 2 with GetClientStartTimeResult

use of build.buildfarm.v1test.GetClientStartTimeResult in project bazel-buildfarm by bazelbuild.

the class AdminServiceImpl method getAllContainersUptime.

private Map<String, Long> getAllContainersUptime(List<String> hostNames) {
    ManagedChannel channel = ManagedChannelBuilder.forAddress(deploymentDomain, deploymentPort).usePlaintext().build();
    AdminGrpc.AdminBlockingStub stub = AdminGrpc.newBlockingStub(channel);
    GetClientStartTimeRequest request = GetClientStartTimeRequest.newBuilder().setInstanceName("shard").addAllHostName(hostNames).build();
    GetClientStartTimeResult result = stub.getClientStartTime(request);
    Map<String, Long> allContainersUptime = new HashMap<String, Long>();
    for (GetClientStartTime GetClientStartTime : result.getClientStartTimeList()) {
        allContainersUptime.put(GetClientStartTime.getInstanceName(), GetClientStartTime.getClientStartTime().getSeconds());
    }
    if (channel != null) {
        channel.shutdown();
    }
    return allContainersUptime;
}
Also used : AdminGrpc(build.buildfarm.v1test.AdminGrpc) HashMap(java.util.HashMap) GetClientStartTime(build.buildfarm.v1test.GetClientStartTime) ManagedChannel(io.grpc.ManagedChannel) GetClientStartTimeRequest(build.buildfarm.v1test.GetClientStartTimeRequest) GetClientStartTimeResult(build.buildfarm.v1test.GetClientStartTimeResult)

Aggregations

GetClientStartTimeResult (build.buildfarm.v1test.GetClientStartTimeResult)2 AdminGrpc (build.buildfarm.v1test.AdminGrpc)1 GetClientStartTime (build.buildfarm.v1test.GetClientStartTime)1 GetClientStartTimeRequest (build.buildfarm.v1test.GetClientStartTimeRequest)1 ManagedChannel (io.grpc.ManagedChannel)1 HashMap (java.util.HashMap)1