use of com.netflix.titus.api.federation.model.Cell in project titus-control-plane by Netflix.
the class RemoteJobServiceGateway method createJob.
@Override
public Observable<String> createJob(JobDescriptor jobDescriptor, CallMetadata callMetadata) {
// We want to know where the job would have been routed so remote federation can compare it to its own routing
// decision.
Cell cell = cellRouter.routeKey(jobDescriptor).orElse(unknownCell);
String federatedJobId = UUID.randomUUID().toString();
JobDescriptor jd = addAttributes(jobDescriptor.toBuilder(), federatedJobId, cell.getName()).build();
return createRequestObservable(emitter -> {
StreamObserver<JobId> streamObserver = GrpcUtil.createClientResponseObserver(emitter, jobId -> emitter.onNext(jobId.getId()), emitter::onError, emitter::onCompleted);
wrap(remoteClient, callMetadata, grpcConfiguration.getRequestTimeoutMs()).createJob(jd, streamObserver);
}, grpcConfiguration.getRequestTimeoutMs());
}
use of com.netflix.titus.api.federation.model.Cell in project titus-control-plane by Netflix.
the class ApplicationCellRouterTest method rulesWithNonConfiguredCellsAreIgnored.
@Test
public void rulesWithNonConfiguredCellsAreIgnored() {
TitusFederationConfiguration titusFederationConfiguration = mock(TitusFederationConfiguration.class);
when(titusFederationConfiguration.getCells()).thenReturn("cell1=hostName1:7001;cell2=hostName2:7002");
when(titusFederationConfiguration.getRoutingRules()).thenReturn("cell1=(app1.*|app2.*);cell2=(app3.*);cell3=(app4.*)");
CellInfoResolver cellInfoResolver = new DefaultCellInfoResolver(titusFederationConfiguration);
ApplicationCellRouter cellRouter = new ApplicationCellRouter(cellInfoResolver, titusFederationConfiguration);
Cell cell = cellRouter.routeKey(APP_4).get();
// no rules default to first
assertThat(cell.getName()).isEqualTo("cell1");
}
use of com.netflix.titus.api.federation.model.Cell in project titus-control-plane by Netflix.
the class AggregatingJobServiceGateway method createJob.
@Override
public Observable<String> createJob(JobDescriptor jobDescriptor, CallMetadata callMetadata) {
Cell cell = router.routeKey(jobDescriptor).orElse(null);
if (cell == null) {
// This should never happen in a correctly setup system.
return Observable.error(new IllegalStateException("Internal system error. Routing rule not found"));
}
logger.debug("Routing JobDescriptor {} to Cell {}", jobDescriptor, cell);
Optional<JobManagementServiceStub> optionalClient = CellConnectorUtil.toStub(cell, cellConnector, JobManagementServiceGrpc::newStub);
if (!optionalClient.isPresent()) {
return Observable.error(TitusServiceException.cellNotFound(cell.getName()));
}
JobManagementServiceStub client = optionalClient.get();
JobDescriptor.Builder jobDescriptorBuilder = addStackName(jobDescriptor.toBuilder());
jobDescriptorBuilder = removeFederationAttributes(jobDescriptorBuilder);
jobDescriptorBuilder = addRoutingCell(jobDescriptorBuilder, cell);
JobDescriptor jd = jobDescriptorBuilder.build();
return createRequestObservable(emitter -> {
StreamObserver<JobId> streamObserver = GrpcUtil.createClientResponseObserver(emitter, jobId -> emitter.onNext(jobId.getId()), emitter::onError, emitter::onCompleted);
wrap(client, callMetadata).createJob(jd, streamObserver);
}, grpcConfiguration.getRequestTimeoutMs());
}
use of com.netflix.titus.api.federation.model.Cell in project titus-control-plane by Netflix.
the class AggregatingAutoScalingTestBase method setUp.
@Before
public void setUp() {
CellConnector connector = mock(CellConnector.class);
Map<Cell, ManagedChannel> cellMap = new HashMap<>();
cellMap.put(new Cell("one", "1"), cellOne.getChannel());
cellMap.put(new Cell("two", "2"), cellTwo.getChannel());
when(connector.getChannels()).thenReturn(cellMap);
when(connector.getChannelForCell(any())).then(invocation -> Optional.ofNullable(cellMap.get(invocation.getArgument(0))));
GrpcConfiguration grpcConfiguration = mock(GrpcConfiguration.class);
when(grpcConfiguration.getRequestTimeoutMs()).thenReturn(1000L);
final AggregatingCellClient aggregatingCellClient = new AggregatingCellClient(connector);
service = new AggregatingAutoScalingService(connector, grpcConfiguration, new AggregatingJobManagementServiceHelper(aggregatingCellClient, grpcConfiguration), aggregatingCellClient);
}
use of com.netflix.titus.api.federation.model.Cell in project titus-control-plane by Netflix.
the class AggregatingHealthServiceTest method setup.
@Before
public void setup() {
Map<Cell, ManagedChannel> cellMap = new HashMap<>();
cellMap.put(new Cell("one", "1"), cellOne.getChannel());
cellMap.put(new Cell("two", "2"), cellTwo.getChannel());
when(connector.getChannels()).thenReturn(cellMap);
when(connector.getChannelForCell(any())).then(invocation -> Optional.ofNullable(cellMap.get(invocation.getArgument(0))));
GrpcConfiguration grpcConfiguration = mock(GrpcConfiguration.class);
when(grpcConfiguration.getRequestTimeoutMs()).thenReturn(1000L);
AnonymousCallMetadataResolver anonymousCallMetadataResolver = new AnonymousCallMetadataResolver();
AggregatingCellClient aggregatingCellClient = new AggregatingCellClient(connector);
service = new AggregatingHealthService(aggregatingCellClient, anonymousCallMetadataResolver, grpcConfiguration);
}
Aggregations