public LocalState nimbusTopoHistoryStateImpl(Map<String, Object> conf) throws IOException { return new LocalState((masterLocalDir(conf) + FILE_SEPARATOR + "history"), true); } }
public LocalState supervisorStateImpl(Map<String, Object> conf) throws IOException { return new LocalState((ConfigUtils.supervisorLocalDir(conf) + FILE_SEPARATOR + "localstate"), true); }
public static LocalState workerState(Map<String, Object> conf, String id) throws IOException { return new LocalState(workerHeartbeatsRoot(conf, id), false); }
@Override public void prepare(Map<String, Object> topoConf, String schedulerLocalDir) { try { LocalState localState = new LocalState(schedulerLocalDir, true); String supervisorId = localState.getSupervisorId(); if (supervisorId == null) { supervisorId = generateSupervisorId(); localState.setSupervisorId(supervisorId); } this.conf = topoConf; this.supervisorId = supervisorId; } catch (IOException e) { throw new RuntimeException(e); } }
@Test public void testEmptyState() throws IOException { TmpPath tmp_dir = new TmpPath(); String dir = tmp_dir.getPath(); LocalState ls = new LocalState(dir, true); GlobalStreamId gs_a = new GlobalStreamId("a", "a"); FileOutputStream data = FileUtils.openOutputStream(new File(dir, "12345")); FileOutputStream version = FileUtils.openOutputStream(new File(dir, "12345.version")); Assert.assertNull(ls.get("c")); ls.put("a", gs_a); Assert.assertEquals(gs_a, ls.get("a")); } }
@Test public void testLocalState() throws Exception { try (TmpPath dir1_tmp = new TmpPath(); TmpPath dir2_tmp = new TmpPath()) { GlobalStreamId globalStreamId_a = new GlobalStreamId("a", "a"); GlobalStreamId globalStreamId_b = new GlobalStreamId("b", "b"); GlobalStreamId globalStreamId_c = new GlobalStreamId("c", "c"); GlobalStreamId globalStreamId_d = new GlobalStreamId("d", "d"); LocalState ls1 = new LocalState(dir1_tmp.getPath(), true); LocalState ls2 = new LocalState(dir2_tmp.getPath(), true); Assert.assertTrue(ls1.snapshot().isEmpty()); ls1.put("a", globalStreamId_a); ls1.put("b", globalStreamId_b); Map<String, GlobalStreamId> expected = new HashMap<>(); expected.put("a", globalStreamId_a); expected.put("b", globalStreamId_b); Assert.assertEquals(expected, ls1.snapshot()); Assert.assertEquals(expected, new LocalState(dir1_tmp.getPath(), true).snapshot()); Assert.assertTrue(ls2.snapshot().isEmpty()); ls2.put("b", globalStreamId_a); ls2.put("b", globalStreamId_b); ls2.put("b", globalStreamId_c); ls2.put("b", globalStreamId_d); Assert.assertEquals(globalStreamId_d, ls2.get("b")); } }
public LocalStateShim(String localDir) throws IOException { _state = new LocalState(localDir); }
public LocalState supervisorStateImpl(Map conf) throws IOException { return new LocalState((supervisorLocalDir(conf) + FILE_SEPARATOR + "localstate")); }
public static LocalState workerState(Map conf, String id) throws IOException { return new LocalState(workerHeartbeatsRoot(conf, id)); }
public LocalState nimbusTopoHistoryStateImpl(Map conf) throws IOException { return new LocalState((masterLocalDir(conf) + FILE_SEPARATOR + "history")); }
@Override public void prepare(Map stormConf, String schedulerLocalDir) { try { LocalState localState = new LocalState(schedulerLocalDir); String supervisorId = localState.getSupervisorId(); if (supervisorId == null) { supervisorId = generateSupervisorId(); localState.setSupervisorId(supervisorId); } this.conf = stormConf; this.supervisorId = supervisorId; } catch (IOException e) { throw new RuntimeException(e); } }