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));
}
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);
}
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);
}
Aggregations