Search in sources :

Example 1 with ContainerPlacementMetadataStore

use of org.apache.samza.clustermanager.container.placement.ContainerPlacementMetadataStore in project samza by apache.

the class TestContainerPlacementActions method setup.

@Before
public void setup() throws Exception {
    server = new MockHttpServer("/", 7777, null, new ServletHolder(DefaultServlet.class));
    // Utils Related to Container Placement Metadata store
    CoordinatorStreamStoreTestUtil coordinatorStreamStoreTestUtil = new CoordinatorStreamStoreTestUtil(config);
    coordinatorStreamStore = coordinatorStreamStoreTestUtil.getCoordinatorStreamStore();
    coordinatorStreamStore.init();
    containerPlacementMetadataStore = new ContainerPlacementMetadataStore(coordinatorStreamStore);
    containerPlacementMetadataStore.start();
    // Utils Related to Cluster manager:
    config = new MapConfig(configVals, getConfigWithHostAffinityAndRetries(true, 1, true));
    state = new SamzaApplicationState(JobModelManagerTestUtil.getJobModelManager(getConfig(), 2, server));
    callback = mock(ClusterResourceManager.Callback.class);
    MockClusterResourceManager clusterResourceManager = new MockClusterResourceManager(callback, state);
    FaultDomainManager faultDomainManager = mock(FaultDomainManager.class);
    ClusterManagerConfig clusterManagerConfig = new ClusterManagerConfig(config);
    localityManager = mock(LocalityManager.class);
    when(localityManager.readLocality()).thenReturn(new LocalityModel(ImmutableMap.of("0", new ProcessorLocality("0", "host-1"), "1", new ProcessorLocality("1", "host-2"))));
    containerManager = spy(new ContainerManager(containerPlacementMetadataStore, state, clusterResourceManager, true, false, localityManager, faultDomainManager, config));
    allocatorWithHostAffinity = new MockContainerAllocatorWithHostAffinity(clusterResourceManager, config, state, containerManager);
    cpm = new ContainerProcessManager(clusterManagerConfig, state, new MetricsRegistryMap(), clusterResourceManager, Optional.of(allocatorWithHostAffinity), containerManager, localityManager, false);
}
Also used : ServletHolder(org.eclipse.jetty.servlet.ServletHolder) ContainerPlacementMetadataStore(org.apache.samza.clustermanager.container.placement.ContainerPlacementMetadataStore) LocalityModel(org.apache.samza.job.model.LocalityModel) CoordinatorStreamStoreTestUtil(org.apache.samza.coordinator.metadatastore.CoordinatorStreamStoreTestUtil) ProcessorLocality(org.apache.samza.job.model.ProcessorLocality) ClusterManagerConfig(org.apache.samza.config.ClusterManagerConfig) MockHttpServer(org.apache.samza.testUtils.MockHttpServer) MapConfig(org.apache.samza.config.MapConfig) LocalityManager(org.apache.samza.container.LocalityManager) MetricsRegistryMap(org.apache.samza.metrics.MetricsRegistryMap) Before(org.junit.Before)

Example 2 with ContainerPlacementMetadataStore

use of org.apache.samza.clustermanager.container.placement.ContainerPlacementMetadataStore in project samza by apache.

the class TestContainerAllocatorWithHostAffinity method setup.

@Before
public void setup() throws Exception {
    LocalityManager mockLocalityManager = mock(LocalityManager.class);
    when(mockLocalityManager.readLocality()).thenReturn(new LocalityModel(ImmutableMap.of("0", new ProcessorLocality("0", "abc"))));
    CoordinatorStreamStoreTestUtil coordinatorStreamStoreTestUtil = new CoordinatorStreamStoreTestUtil(config);
    CoordinatorStreamStore coordinatorStreamStore = coordinatorStreamStoreTestUtil.getCoordinatorStreamStore();
    coordinatorStreamStore.init();
    containerPlacementMetadataStore = new ContainerPlacementMetadataStore(coordinatorStreamStore);
    containerPlacementMetadataStore.start();
    containerManager = new ContainerManager(containerPlacementMetadataStore, state, clusterResourceManager, true, false, mockLocalityManager, faultDomainManager, config);
    containerAllocator = new ContainerAllocator(clusterResourceManager, config, state, true, containerManager);
    requestState = new MockContainerRequestState(clusterResourceManager, true);
    Field requestStateField = containerAllocator.getClass().getDeclaredField("resourceRequestState");
    requestStateField.setAccessible(true);
    requestStateField.set(containerAllocator, requestState);
    allocatorThread = new Thread(containerAllocator);
}
Also used : ProcessorLocality(org.apache.samza.job.model.ProcessorLocality) Field(java.lang.reflect.Field) CoordinatorStreamStore(org.apache.samza.coordinator.metadatastore.CoordinatorStreamStore) ContainerPlacementMetadataStore(org.apache.samza.clustermanager.container.placement.ContainerPlacementMetadataStore) LocalityManager(org.apache.samza.container.LocalityManager) LocalityModel(org.apache.samza.job.model.LocalityModel) CoordinatorStreamStoreTestUtil(org.apache.samza.coordinator.metadatastore.CoordinatorStreamStoreTestUtil) Before(org.junit.Before)

Example 3 with ContainerPlacementMetadataStore

use of org.apache.samza.clustermanager.container.placement.ContainerPlacementMetadataStore in project samza by apache.

the class TestContainerAllocatorWithoutHostAffinity method setup.

@Before
public void setup() throws Exception {
    LocalityManager mockLocalityManager = mock(LocalityManager.class);
    when(mockLocalityManager.readLocality()).thenReturn(new LocalityModel(new HashMap<>()));
    CoordinatorStreamStoreTestUtil coordinatorStreamStoreTestUtil = new CoordinatorStreamStoreTestUtil(config);
    CoordinatorStreamStore coordinatorStreamStore = coordinatorStreamStoreTestUtil.getCoordinatorStreamStore();
    coordinatorStreamStore.init();
    containerPlacementMetadataStore = new ContainerPlacementMetadataStore(coordinatorStreamStore);
    containerPlacementMetadataStore.start();
    containerAllocator = new ContainerAllocator(manager, config, state, false, new ContainerManager(containerPlacementMetadataStore, state, manager, false, false, mockLocalityManager, faultDomainManager, config));
    requestState = new MockContainerRequestState(manager, false);
    Field requestStateField = containerAllocator.getClass().getDeclaredField("resourceRequestState");
    requestStateField.setAccessible(true);
    requestStateField.set(containerAllocator, requestState);
    allocatorThread = new Thread(containerAllocator);
}
Also used : Field(java.lang.reflect.Field) CoordinatorStreamStore(org.apache.samza.coordinator.metadatastore.CoordinatorStreamStore) HashMap(java.util.HashMap) ContainerPlacementMetadataStore(org.apache.samza.clustermanager.container.placement.ContainerPlacementMetadataStore) LocalityManager(org.apache.samza.container.LocalityManager) LocalityModel(org.apache.samza.job.model.LocalityModel) CoordinatorStreamStoreTestUtil(org.apache.samza.coordinator.metadatastore.CoordinatorStreamStoreTestUtil) Before(org.junit.Before)

Example 4 with ContainerPlacementMetadataStore

use of org.apache.samza.clustermanager.container.placement.ContainerPlacementMetadataStore in project samza by apache.

the class TestContainerProcessManager method setup.

@Before
public void setup() throws Exception {
    server = new MockHttpServer("/", 7777, null, new ServletHolder(DefaultServlet.class));
    CoordinatorStreamStoreTestUtil coordinatorStreamStoreTestUtil = new CoordinatorStreamStoreTestUtil(config);
    CoordinatorStreamStore coordinatorStreamStore = coordinatorStreamStoreTestUtil.getCoordinatorStreamStore();
    coordinatorStreamStore.init();
    containerPlacementMetadataStore = new ContainerPlacementMetadataStore(coordinatorStreamStore);
    containerPlacementMetadataStore.start();
}
Also used : CoordinatorStreamStore(org.apache.samza.coordinator.metadatastore.CoordinatorStreamStore) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) MockHttpServer(org.apache.samza.testUtils.MockHttpServer) ContainerPlacementMetadataStore(org.apache.samza.clustermanager.container.placement.ContainerPlacementMetadataStore) CoordinatorStreamStoreTestUtil(org.apache.samza.coordinator.metadatastore.CoordinatorStreamStoreTestUtil) Before(org.junit.Before)

Aggregations

ContainerPlacementMetadataStore (org.apache.samza.clustermanager.container.placement.ContainerPlacementMetadataStore)4 CoordinatorStreamStoreTestUtil (org.apache.samza.coordinator.metadatastore.CoordinatorStreamStoreTestUtil)4 Before (org.junit.Before)4 LocalityManager (org.apache.samza.container.LocalityManager)3 CoordinatorStreamStore (org.apache.samza.coordinator.metadatastore.CoordinatorStreamStore)3 LocalityModel (org.apache.samza.job.model.LocalityModel)3 Field (java.lang.reflect.Field)2 ProcessorLocality (org.apache.samza.job.model.ProcessorLocality)2 MockHttpServer (org.apache.samza.testUtils.MockHttpServer)2 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)2 HashMap (java.util.HashMap)1 ClusterManagerConfig (org.apache.samza.config.ClusterManagerConfig)1 MapConfig (org.apache.samza.config.MapConfig)1 MetricsRegistryMap (org.apache.samza.metrics.MetricsRegistryMap)1