Search in sources :

Example 6 with ResourceIsolationInterface

use of org.apache.storm.container.ResourceIsolationInterface in project storm by apache.

the class BasicContainerTest method testSubstChildOpts.

@Test
public void testSubstChildOpts() throws Exception {
    String workerId = "w-01";
    String topoId = "s-01";
    int supervisorPort = 6628;
    int port = 9999;
    int memOnheap = 512;
    int memOffheap = 256;
    LocalAssignment la = new LocalAssignment();
    la.set_topology_id(topoId);
    Map<String, Object> superConf = new HashMap<>();
    AdvancedFSOps ops = mock(AdvancedFSOps.class);
    when(ops.doRequiredTopoFilesExist(superConf, topoId)).thenReturn(true);
    LocalState ls = mock(LocalState.class);
    ResourceIsolationInterface iso = mock(ResourceIsolationInterface.class);
    MockBasicContainer mc = new MockBasicContainer(ContainerType.LAUNCH, superConf, "SUPERVISOR", supervisorPort, port, la, iso, ls, workerId, new StormMetricsRegistry(), new HashMap<>(), ops, "profile");
    assertListEquals(Arrays.asList("-Xloggc:/tmp/storm/logs/gc.worker-9999-s-01-w-01-9999.log", "-Xms256m", "-Xmx512m", "-XX:MaxDirectMemorySize=256m"), mc.substituteChildopts("-Xloggc:/tmp/storm/logs/gc.worker-%ID%-%TOPOLOGY-ID%-%WORKER-ID%-%WORKER-PORT%.log -Xms256m -Xmx%HEAP-MEM%m -XX:MaxDirectMemorySize=%OFF-HEAP-MEM%m", memOnheap, memOffheap));
    assertListEquals(Arrays.asList("-Xloggc:/tmp/storm/logs/gc.worker-9999-s-01-w-01-9999.log", "-Xms256m", "-Xmx512m"), mc.substituteChildopts(Arrays.asList("-Xloggc:/tmp/storm/logs/gc.worker-%ID%-%TOPOLOGY-ID%-%WORKER-ID%-%WORKER-PORT%.log", "-Xms256m", "-Xmx%HEAP-MEM%m"), memOnheap, memOffheap));
    assertListEquals(Collections.emptyList(), mc.substituteChildopts(null));
}
Also used : HashMap(java.util.HashMap) StormMetricsRegistry(org.apache.storm.metric.StormMetricsRegistry) LocalAssignment(org.apache.storm.generated.LocalAssignment) LocalState(org.apache.storm.utils.LocalState) ResourceIsolationInterface(org.apache.storm.container.ResourceIsolationInterface) Test(org.junit.Test)

Example 7 with ResourceIsolationInterface

use of org.apache.storm.container.ResourceIsolationInterface in project storm by apache.

the class BasicContainerTest method testRecovery.

@Test
public void testRecovery() throws Exception {
    final String topoId = "test_topology";
    final String workerId = "myWorker";
    final int supervisorPort = 6628;
    final int port = 8080;
    LocalAssignment la = new LocalAssignment();
    la.set_topology_id(topoId);
    Map<String, Integer> workerState = new HashMap<String, Integer>();
    workerState.put(workerId, port);
    LocalState ls = mock(LocalState.class);
    when(ls.getApprovedWorkers()).thenReturn(workerState);
    Map<String, Object> superConf = new HashMap<>();
    AdvancedFSOps ops = mock(AdvancedFSOps.class);
    when(ops.doRequiredTopoFilesExist(superConf, topoId)).thenReturn(true);
    ResourceIsolationInterface iso = mock(ResourceIsolationInterface.class);
    MockBasicContainer mc = new MockBasicContainer(ContainerType.RECOVER_FULL, superConf, "SUPERVISOR", supervisorPort, port, la, iso, ls, null, new StormMetricsRegistry(), new HashMap<>(), ops, "profile");
    assertEquals(workerId, mc.workerId);
}
Also used : HashMap(java.util.HashMap) StormMetricsRegistry(org.apache.storm.metric.StormMetricsRegistry) LocalAssignment(org.apache.storm.generated.LocalAssignment) LocalState(org.apache.storm.utils.LocalState) ResourceIsolationInterface(org.apache.storm.container.ResourceIsolationInterface) Test(org.junit.Test)

Example 8 with ResourceIsolationInterface

use of org.apache.storm.container.ResourceIsolationInterface in project storm by apache.

the class BasicContainerTest method testCreateNewWorkerId.

@Test
public void testCreateNewWorkerId() throws Exception {
    final String topoId = "test_topology";
    final int supervisorPort = 6628;
    final int port = 8080;
    LocalAssignment la = new LocalAssignment();
    la.set_topology_id(topoId);
    Map<String, Object> superConf = new HashMap<>();
    AdvancedFSOps ops = mock(AdvancedFSOps.class);
    when(ops.doRequiredTopoFilesExist(superConf, topoId)).thenReturn(true);
    LocalState ls = mock(LocalState.class);
    ResourceIsolationInterface iso = mock(ResourceIsolationInterface.class);
    MockBasicContainer mc = new MockBasicContainer(ContainerType.LAUNCH, superConf, "SUPERVISOR", supervisorPort, port, la, iso, ls, null, new StormMetricsRegistry(), new HashMap<>(), ops, "profile");
    // null worker id means generate one...
    assertNotNull(mc.workerId);
    verify(ls).getApprovedWorkers();
    Map<String, Integer> expectedNewState = new HashMap<String, Integer>();
    expectedNewState.put(mc.workerId, port);
    verify(ls).setApprovedWorkers(expectedNewState);
}
Also used : HashMap(java.util.HashMap) StormMetricsRegistry(org.apache.storm.metric.StormMetricsRegistry) LocalAssignment(org.apache.storm.generated.LocalAssignment) LocalState(org.apache.storm.utils.LocalState) ResourceIsolationInterface(org.apache.storm.container.ResourceIsolationInterface) Test(org.junit.Test)

Aggregations

ResourceIsolationInterface (org.apache.storm.container.ResourceIsolationInterface)8 HashMap (java.util.HashMap)6 LocalAssignment (org.apache.storm.generated.LocalAssignment)6 StormMetricsRegistry (org.apache.storm.metric.StormMetricsRegistry)6 Test (org.junit.Test)6 LocalState (org.apache.storm.utils.LocalState)4 File (java.io.File)2 StringWriter (java.io.StringWriter)2 HashSet (java.util.HashSet)1 DefaultResourceIsolationManager (org.apache.storm.container.DefaultResourceIsolationManager)1 Yaml (org.yaml.snakeyaml.Yaml)1