public LSWorkerHeartbeat getWorkerHeartBeat() { return (LSWorkerHeartbeat) get(LS_WORKER_HEARTBEAT); }
public Map<String, Integer> getApprovedWorkers() { LSApprovedWorkers lsApprovedWorkers = (LSApprovedWorkers) get(LS_APPROVED_WORKERS); if (null != lsApprovedWorkers) { return lsApprovedWorkers.get_approved_workers(); } return null; }
public Map<Integer, LocalAssignment> getLocalAssignmentsMap() { LSSupervisorAssignments assignments = (LSSupervisorAssignments) get(LS_LOCAL_ASSIGNMENTS); if (null != assignments) { return assignments.get_assignments(); } return null; }
public List<LSTopoHistory> getTopoHistoryList() { LSTopoHistoryList lsTopoHistoryListWrapper = (LSTopoHistoryList) get(LS_TOPO_HISTORY); if (null != lsTopoHistoryListWrapper) { return lsTopoHistoryListWrapper.get_topo_history(); } return null; }
public String getSupervisorId() { LSSupervisorId lsSupervisorId = (LSSupervisorId) get(LS_ID); if (null != lsSupervisorId) { return lsSupervisorId.get_supervisor_id(); } return null; }
public void addTopologyHistory(LSTopoHistory lsTopoHistory) { LSTopoHistoryList lsTopoHistoryListWrapper = (LSTopoHistoryList) get(LS_TOPO_HISTORY); List<LSTopoHistory> currentTopoHistoryList = new ArrayList<>(); if (null != lsTopoHistoryListWrapper) { currentTopoHistoryList.addAll(lsTopoHistoryListWrapper.get_topo_history()); } currentTopoHistoryList.add(lsTopoHistory); put(LS_TOPO_HISTORY, new LSTopoHistoryList(currentTopoHistoryList)); }
/** * Remove topologies from local state which are older than cutOffAge. * * @param cutOffAge */ public void filterOldTopologies(long cutOffAge) { LSTopoHistoryList lsTopoHistoryListWrapper = (LSTopoHistoryList) get(LS_TOPO_HISTORY); List<LSTopoHistory> filteredTopoHistoryList = new ArrayList<>(); if (null != lsTopoHistoryListWrapper) { for (LSTopoHistory topoHistory : lsTopoHistoryListWrapper.get_topo_history()) { if (topoHistory.get_time_stamp() > cutOffAge) { filteredTopoHistoryList.add(topoHistory); } } } put(LS_TOPO_HISTORY, new LSTopoHistoryList(filteredTopoHistoryList)); }
@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 LSWorkerHeartbeat getWorkerHeartBeat() { return (LSWorkerHeartbeat) get(LS_WORKER_HEARTBEAT); }
public String getSupervisorId() { LSSupervisorId lsSupervisorId = (LSSupervisorId) get(LS_ID); if (null != lsSupervisorId) { return lsSupervisorId.get_supervisor_id(); } return null; }
public Map<Integer, LocalAssignment> getLocalAssignmentsMap() { LSSupervisorAssignments assignments = (LSSupervisorAssignments) get(LS_LOCAL_ASSIGNMENTS); if (null != assignments) { return assignments.get_assignments(); } return null; }
public List<LSTopoHistory> getTopoHistoryList() { LSTopoHistoryList lsTopoHistoryListWrapper = (LSTopoHistoryList) get(LS_TOPO_HISTORY); if (null != lsTopoHistoryListWrapper) { return lsTopoHistoryListWrapper.get_topo_history(); } return null; }
public Map<String, Integer> getApprovedWorkers() { LSApprovedWorkers lsApprovedWorkers = (LSApprovedWorkers) get(LS_APPROVED_WORKERS); if (null != lsApprovedWorkers) { return lsApprovedWorkers.get_approved_workers(); } return null; }
public String get(String key) { TBase tBase = _state.get(key); if (tBase != null) { JavaObject jo = ((JavaObject) tBase); ComponentObject co = ComponentObject.java_object(jo); List<JavaObjectArg> l = jo.get_args_list(); if (l != null && l.size() >= 0 && l.get(0) != null) { return l.get(0).get_string_arg(); } } return null; }
public void addTopologyHistory(LSTopoHistory lsTopoHistory) { LSTopoHistoryList lsTopoHistoryListWrapper = (LSTopoHistoryList) get(LS_TOPO_HISTORY); List<LSTopoHistory> currentTopoHistoryList = new ArrayList<>(); if (null != lsTopoHistoryListWrapper) { currentTopoHistoryList.addAll(lsTopoHistoryListWrapper.get_topo_history()); } currentTopoHistoryList.add(lsTopoHistory); put(LS_TOPO_HISTORY, new LSTopoHistoryList(currentTopoHistoryList)); }
/** * Remove topologies from local state which are older than cutOffAge. * @param cutOffAge */ public void filterOldTopologies(long cutOffAge) { LSTopoHistoryList lsTopoHistoryListWrapper = (LSTopoHistoryList) get(LS_TOPO_HISTORY); List<LSTopoHistory> filteredTopoHistoryList = new ArrayList<>(); if (null != lsTopoHistoryListWrapper) { for (LSTopoHistory topoHistory : lsTopoHistoryListWrapper.get_topo_history()) { if (topoHistory.get_time_stamp() > cutOffAge) { filteredTopoHistoryList.add(topoHistory); } } } put(LS_TOPO_HISTORY, new LSTopoHistoryList(filteredTopoHistoryList)); }