Search in sources :

Example 6 with DefaultCellInfoResolver

use of com.netflix.titus.federation.service.DefaultCellInfoResolver in project titus-control-plane by Netflix.

the class ApplicationCellRouterTest method jobToCellAffinity.

@Test
public void jobToCellAffinity() {
    JobDescriptor withCellAffinity = APP_2.toBuilder().putAttributes(JobAttributes.JOB_PARAMETER_ATTRIBUTES_CELL_REQUEST, "cell2").build();
    TitusFederationConfiguration titusFederationConfiguration = mock(TitusFederationConfiguration.class);
    when(titusFederationConfiguration.getCells()).thenReturn("cell1=hostName1:7001;cell2=hostName2:7002");
    when(titusFederationConfiguration.getRoutingRules()).thenReturn("cell1=(app1.*|app2.*);cell2=(app3.*)");
    CellInfoResolver cellInfoResolver = new DefaultCellInfoResolver(titusFederationConfiguration);
    ApplicationCellRouter cellRouter = new ApplicationCellRouter(cellInfoResolver, titusFederationConfiguration);
    assertThat(cellRouter.routeKey(withCellAffinity).get().getName()).isEqualTo("cell2");
}
Also used : TitusFederationConfiguration(com.netflix.titus.federation.startup.TitusFederationConfiguration) CellInfoResolver(com.netflix.titus.federation.service.CellInfoResolver) DefaultCellInfoResolver(com.netflix.titus.federation.service.DefaultCellInfoResolver) JobDescriptor(com.netflix.titus.grpc.protogen.JobDescriptor) DefaultCellInfoResolver(com.netflix.titus.federation.service.DefaultCellInfoResolver) Test(org.junit.Test)

Example 7 with DefaultCellInfoResolver

use of com.netflix.titus.federation.service.DefaultCellInfoResolver in project titus-control-plane by Netflix.

the class ApplicationCellRouterTest method cellsWithNoRulesCanExist.

@Test
public void cellsWithNoRulesCanExist() {
    TitusFederationConfiguration titusFederationConfiguration = mock(TitusFederationConfiguration.class);
    when(titusFederationConfiguration.getCells()).thenReturn("cell1=hostName1:7001;cell2=hostName2:7002");
    when(titusFederationConfiguration.getRoutingRules()).thenReturn("cell1=(app1.*|app2.*)");
    CellInfoResolver cellInfoResolver = new DefaultCellInfoResolver(titusFederationConfiguration);
    ApplicationCellRouter cellRouter = new ApplicationCellRouter(cellInfoResolver, titusFederationConfiguration);
    Cell cell = cellRouter.routeKey(APP_2).get();
    assertThat(cell.getName()).isEqualTo("cell1");
}
Also used : TitusFederationConfiguration(com.netflix.titus.federation.startup.TitusFederationConfiguration) CellInfoResolver(com.netflix.titus.federation.service.CellInfoResolver) DefaultCellInfoResolver(com.netflix.titus.federation.service.DefaultCellInfoResolver) DefaultCellInfoResolver(com.netflix.titus.federation.service.DefaultCellInfoResolver) Cell(com.netflix.titus.api.federation.model.Cell) Test(org.junit.Test)

Aggregations

CellInfoResolver (com.netflix.titus.federation.service.CellInfoResolver)7 DefaultCellInfoResolver (com.netflix.titus.federation.service.DefaultCellInfoResolver)7 TitusFederationConfiguration (com.netflix.titus.federation.startup.TitusFederationConfiguration)7 Test (org.junit.Test)7 Cell (com.netflix.titus.api.federation.model.Cell)2 JobDescriptor (com.netflix.titus.grpc.protogen.JobDescriptor)2