use of com.netflix.titus.api.model.callmetadata.CallMetadata in project titus-control-plane by Netflix.
the class AggregatingJobServiceGateway method killJob.
@Override
public Completable killJob(String jobId, CallMetadata callMetadata) {
JobId id = JobId.newBuilder().setId(jobId).build();
Observable<Empty> result = jobManagementServiceHelper.findJobInAllCells(jobId, callMetadata).flatMap(response -> singleCellCall(response.getCell(), (client, streamObserver) -> client.killJob(id, streamObserver), callMetadata));
return result.toCompletable();
}
use of com.netflix.titus.api.model.callmetadata.CallMetadata in project titus-control-plane by Netflix.
the class AggregatingLoadbalancerService method addLoadBalancer.
@Override
public Completable addLoadBalancer(AddLoadBalancerRequest request, CallMetadata callMetadata) {
JobId jobId = JobId.newBuilder().setId(request.getJobId()).build();
final Observable<Empty> responseObservable = jobManagementServiceHelper.findJobInAllCells(jobId.getId(), callMetadata).flatMap(response -> singleCellCall(response.getCell(), (client, responseObserver) -> client.addLoadBalancer(request, responseObserver), callMetadata));
return responseObservable.toCompletable();
}
use of com.netflix.titus.api.model.callmetadata.CallMetadata in project titus-control-plane by Netflix.
the class AggregatingLoadbalancerService method removeLoadBalancer.
@Override
public Completable removeLoadBalancer(RemoveLoadBalancerRequest removeLoadBalancerRequest, CallMetadata callMetadata) {
JobId jobId = JobId.newBuilder().setId(removeLoadBalancerRequest.getJobId()).build();
final Observable<Empty> responseObservable = jobManagementServiceHelper.findJobInAllCells(jobId.getId(), callMetadata).flatMap(response -> singleCellCall(response.getCell(), (client, responseObserver) -> client.removeLoadBalancer(removeLoadBalancerRequest, responseObserver), callMetadata));
return responseObservable.toCompletable();
}
use of com.netflix.titus.api.model.callmetadata.CallMetadata in project titus-control-plane by Netflix.
the class SpringCallMetadataInterceptorTest method expectCallMetadataAuthentication.
private com.netflix.titus.api.model.callmetadata.CallMetadata expectCallMetadataAuthentication() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
assertThat(authentication).isNotNull();
assertThat(authentication).isInstanceOf(CallMetadataAuthentication.class);
CallMetadataAuthentication callMetadataAuthentication = (CallMetadataAuthentication) authentication;
CallMetadata callMetadata = callMetadataAuthentication.getCallMetadata();
assertThat(callMetadata).isNotNull();
assertThat(callMetadata.getCallReason()).isEqualTo(MY_REASON);
return callMetadata;
}
use of com.netflix.titus.api.model.callmetadata.CallMetadata in project titus-control-plane by Netflix.
the class SimpleGrpcCallMetadataResolver method resolve.
@Override
public Optional<CallMetadata> resolve() {
if (Context.current() == Context.ROOT) {
// Not in GRPC server call.
return Optional.empty();
}
CallMetadata forwardedCallMetadata = V3HeaderInterceptor.CALL_METADATA_CONTEXT_KEY.get();
Caller directCaller = resolveDirectCallerInternal();
// If we have CallMetadata instance, we can safely ignore other headers, except the direct caller.
if (forwardedCallMetadata != null) {
return Optional.of(forwardedCallMetadata.toBuilder().withCallPath(CollectionsExt.copyAndAdd(forwardedCallMetadata.getCallPath(), directCaller.getId())).withCallers(CollectionsExt.copyAndAdd(forwardedCallMetadata.getCallers(), directCaller)).build());
}
// No CellMetadata in header, so we must built it here.
String callerId = V3HeaderInterceptor.CALLER_ID_CONTEXT_KEY.get();
String callReason = getOrDefault(V3HeaderInterceptor.CALL_REASON_CONTEXT_KEY.get(), "reason not given");
CallMetadata.Builder callMetadataBuilder = CallMetadata.newBuilder().withCallReason(callReason);
if (callerId == null) {
callMetadataBuilder.withCallerId(directCaller.getId()).withCallPath(Collections.singletonList(directCaller.getId())).withCallers(Collections.singletonList(directCaller));
} else {
Caller originalCaller = Caller.newBuilder().withId(callerId).withCallerType(CallerType.parseCallerType(callerId, V3HeaderInterceptor.CALLER_TYPE_CONTEXT_KEY.get())).build();
callMetadataBuilder.withCallerId(callerId).withCallPath(asList(callerId, directCaller.getId())).withCallers(asList(originalCaller, directCaller));
}
return Optional.of(callMetadataBuilder.build());
}
Aggregations