Search in sources :

Example 1 with GrpcConfiguration

use of com.netflix.titus.federation.startup.GrpcConfiguration in project titus-control-plane by Netflix.

the class AggregatingLoadBalancerServiceTest 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 AnonymousCallMetadataResolver anonymousCallMetadataResolver = new AnonymousCallMetadataResolver();
    final AggregatingCellClient aggregatingCellClient = new AggregatingCellClient(connector);
    service = new AggregatingLoadbalancerService(connector, anonymousCallMetadataResolver, grpcConfiguration, aggregatingCellClient, new AggregatingJobManagementServiceHelper(aggregatingCellClient, grpcConfiguration));
}
Also used : HashMap(java.util.HashMap) ManagedChannel(io.grpc.ManagedChannel) Cell(com.netflix.titus.api.federation.model.Cell) AnonymousCallMetadataResolver(com.netflix.titus.runtime.endpoint.metadata.AnonymousCallMetadataResolver) GrpcConfiguration(com.netflix.titus.federation.startup.GrpcConfiguration) Before(org.junit.Before)

Example 2 with GrpcConfiguration

use of com.netflix.titus.federation.startup.GrpcConfiguration in project titus-control-plane by Netflix.

the class FallbackJobServiceGatewayTest method setUp.

@Before
public void setUp() {
    stackName = UUID.randomUUID().toString();
    GrpcConfiguration grpcConfiguration = mock(GrpcConfiguration.class);
    when(grpcConfiguration.getRequestTimeoutMs()).thenReturn(GRPC_REQUEST_TIMEOUT_MS);
    when(grpcConfiguration.getPrimaryFallbackTimeoutMs()).thenReturn(GRPC_PRIMARY_FALLBACK_TIMEOUT_MS);
    when(fedConfig.getStack()).thenReturn(stackName);
    when(fedConfig.getCells()).thenReturn("one=1;two=2");
    when(fedConfig.getRoutingRules()).thenReturn("one=(app1.*|app2.*);two=(app3.*)");
    CellInfoResolver cellInfoResolver = new DefaultCellInfoResolver(fedConfig);
    ApplicationCellRouter cellRouter = new ApplicationCellRouter(cellInfoResolver, fedConfig);
    cells = cellInfoResolver.resolve();
    cellToServiceMap = ImmutableMap.of(cells.get(0), cellOne, cells.get(1), cellTwo);
    RemoteFederationConnector fedConnector = mock(RemoteFederationConnector.class);
    when(fedConnector.getChannel()).thenReturn(remoteFederationRule.getChannel());
    CellConnector cellConnector = mock(CellConnector.class);
    when(cellConnector.getChannels()).thenReturn(cellToServiceMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, cellPairEntry -> cellPairEntry.getValue().getChannel())));
    when(cellConnector.getChannelForCell(any(Cell.class))).thenAnswer(invocation -> Optional.ofNullable(cellToServiceMap.get(invocation.<Cell>getArgument(0))).map(GrpcServerRule::getChannel));
    final AggregatingCellClient aggregatingCellClient = new AggregatingCellClient(cellConnector);
    aggregatingJobServiceGateway = new AggregatingJobServiceGateway(grpcConfiguration, fedConfig, cellConnector, cellRouter, aggregatingCellClient, new AggregatingJobManagementServiceHelper(aggregatingCellClient, grpcConfiguration), titusRuntime);
    remoteJobServiceGateway = new RemoteJobServiceGateway(fedConfig, fedConnector, cellRouter, grpcConfiguration);
    fallbackJobServiceGateway = new FallbackJobServiceGateway(titusRuntime, fedConfig, remoteJobServiceGateway, aggregatingJobServiceGateway);
    clock = Clocks.test();
    dataGenerator = new ServiceDataGenerator(clock, TASKS_IN_GENERATED_JOBS);
}
Also used : ApplicationCellRouter(com.netflix.titus.federation.service.router.ApplicationCellRouter) Cell(com.netflix.titus.api.federation.model.Cell) GrpcConfiguration(com.netflix.titus.federation.startup.GrpcConfiguration) Before(org.junit.Before)

Example 3 with GrpcConfiguration

use of com.netflix.titus.federation.startup.GrpcConfiguration 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);
}
Also used : HashMap(java.util.HashMap) ManagedChannel(io.grpc.ManagedChannel) Cell(com.netflix.titus.api.federation.model.Cell) GrpcConfiguration(com.netflix.titus.federation.startup.GrpcConfiguration) Before(org.junit.Before)

Example 4 with GrpcConfiguration

use of com.netflix.titus.federation.startup.GrpcConfiguration 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);
}
Also used : HashMap(java.util.HashMap) ManagedChannel(io.grpc.ManagedChannel) Cell(com.netflix.titus.api.federation.model.Cell) AnonymousCallMetadataResolver(com.netflix.titus.runtime.endpoint.metadata.AnonymousCallMetadataResolver) GrpcConfiguration(com.netflix.titus.federation.startup.GrpcConfiguration) Before(org.junit.Before)

Example 5 with GrpcConfiguration

use of com.netflix.titus.federation.startup.GrpcConfiguration in project titus-control-plane by Netflix.

the class AggregatingJobServiceGatewayTest method setUp.

@Before
public void setUp() {
    stackName = UUID.randomUUID().toString();
    GrpcConfiguration grpcConfiguration = mock(GrpcConfiguration.class);
    when(grpcConfiguration.getRequestTimeoutMs()).thenReturn(GRPC_REQUEST_TIMEOUT_MS);
    when(grpcConfiguration.getPrimaryFallbackTimeoutMs()).thenReturn(GRPC_PRIMARY_FALLBACK_TIMEOUT_MS);
    when(titusFederationConfiguration.getStack()).thenReturn(stackName);
    when(titusFederationConfiguration.getCells()).thenReturn("one=1;two=2");
    when(titusFederationConfiguration.getRoutingRules()).thenReturn("one=(app1.*|app2.*);two=(app3.*)");
    CellInfoResolver cellInfoResolver = new DefaultCellInfoResolver(titusFederationConfiguration);
    ApplicationCellRouter cellRouter = new ApplicationCellRouter(cellInfoResolver, titusFederationConfiguration);
    cells = cellInfoResolver.resolve();
    cellToServiceMap = ImmutableMap.of(cells.get(0), cellOne, cells.get(1), cellTwo);
    RemoteFederationConnector fedConnector = mock(RemoteFederationConnector.class);
    when(fedConnector.getChannel()).thenReturn(remoteFederationRule.getChannel());
    CellConnector cellConnector = mock(CellConnector.class);
    when(cellConnector.getChannels()).thenReturn(cellToServiceMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, cellPairEntry -> cellPairEntry.getValue().getChannel())));
    when(cellConnector.getChannelForCell(any(Cell.class))).thenAnswer(invocation -> Optional.ofNullable(cellToServiceMap.get(invocation.<Cell>getArgument(0))).map(GrpcServerRule::getChannel));
    final AggregatingCellClient aggregatingCellClient = new AggregatingCellClient(cellConnector);
    service = new AggregatingJobServiceGateway(grpcConfiguration, titusFederationConfiguration, cellConnector, cellRouter, aggregatingCellClient, new AggregatingJobManagementServiceHelper(aggregatingCellClient, grpcConfiguration), titusRuntime);
    clock = Clocks.test();
    dataGenerator = new ServiceDataGenerator(clock, TASKS_IN_GENERATED_JOBS);
}
Also used : ApplicationCellRouter(com.netflix.titus.federation.service.router.ApplicationCellRouter) Cell(com.netflix.titus.api.federation.model.Cell) GrpcConfiguration(com.netflix.titus.federation.startup.GrpcConfiguration) Before(org.junit.Before)

Aggregations

Cell (com.netflix.titus.api.federation.model.Cell)6 GrpcConfiguration (com.netflix.titus.federation.startup.GrpcConfiguration)6 Before (org.junit.Before)6 ApplicationCellRouter (com.netflix.titus.federation.service.router.ApplicationCellRouter)3 AnonymousCallMetadataResolver (com.netflix.titus.runtime.endpoint.metadata.AnonymousCallMetadataResolver)3 ManagedChannel (io.grpc.ManagedChannel)3 HashMap (java.util.HashMap)3 TitusFederationConfiguration (com.netflix.titus.federation.startup.TitusFederationConfiguration)1