@Test public void testAddDataNode() throws Exception { Field field = BaseFlowGraph.class.getDeclaredField("dataNodeMap"); field.setAccessible(true); Map<String, DataNode> dataNodeMap = (Map<String, DataNode>) field.get(graph); Assert.assertEquals(dataNodeMap.get("node1"), node1); Assert.assertEquals(dataNodeMap.get("node2"), node2); Assert.assertEquals(dataNodeMap.get("node3"), node3); graph.addDataNode(node3c); Assert.assertEquals(graph.getNode("node3"), node3); Assert.assertEquals(graph.getNode("node3"), node3c); Assert.assertTrue(graph.getNode("node3") == node3c); Assert.assertTrue(graph.getNode("node3") != node3); graph.addDataNode(node3); }
@Override public boolean addDataNode(DataNode node) { try { rwLock.writeLock().lock(); Set<FlowEdge> edges = this.nodesToEdges.getOrDefault(node, new HashSet<>()); this.nodesToEdges.put(node, edges); this.dataNodeMap.put(node.getId(), node); } finally { rwLock.writeLock().unlock(); } return true; }
BaseFlowGraph implements FlowGraph { @Override public boolean addDataNode(DataNode node) { try { rwLock.writeLock().lock(); Set<FlowEdge> edges = this.nodesToEdges.getOrDefault(node, new HashSet<>()); this.nodesToEdges.put(node, edges); this.dataNodeMap.put(node.getId(), node); } finally { rwLock.writeLock().unlock(); } return true; } }
BaseFlowGraph implements FlowGraph { @Override public boolean addDataNode(DataNode node) { try { rwLock.writeLock().lock(); Set<FlowEdge> edges = this.nodesToEdges.getOrDefault(node, new HashSet<>()); this.nodesToEdges.put(node, edges); this.dataNodeMap.put(node.getId(), node); } finally { rwLock.writeLock().unlock(); } return true; }  }
BaseFlowGraph implements FlowGraph { @Override public boolean addDataNode(DataNode node) { try { rwLock.writeLock().lock(); Set<FlowEdge> edges = this.nodesToEdges.getOrDefault(node, new HashSet<>()); this.nodesToEdges.put(node, edges); this.dataNodeMap.put(node.getId(), node); } finally { rwLock.writeLock().unlock(); } return true; }  DataNode getNode(String nodeId); @Override boolean addDataNode(DataNode node); @Override boolean addFlowEdge(FlowEdge edge); @Override boolean deleteDataNode(String nodeId); boolean deleteDataNode(DataNode node); @Override boolean deleteFlowEdge(String edgeId); boolean deleteFlowEdge(FlowEdge edge); @Override Set<FlowEdge> getEdges(String nodeId); @Override Set<FlowEdge> getEdges(DataNode node); @Override FlowGraphPath findPath(FlowSpec flowSpec); }
BaseFlowGraph implements FlowGraph { @Override public boolean addDataNode(DataNode node) { try { rwLock.writeLock().lock(); Set<FlowEdge> edges = this.nodesToEdges.getOrDefault(node, new HashSet<>()); this.nodesToEdges.put(node, edges); this.dataNodeMap.put(node.getId(), node); } finally { rwLock.writeLock().unlock(); } return true; }  DataNode getNode(String nodeId); @Override boolean addDataNode(DataNode node); @Override boolean addFlowEdge(FlowEdge edge); @Override boolean deleteDataNode(String nodeId); boolean deleteDataNode(DataNode node); @Override boolean deleteFlowEdge(String edgeId); boolean deleteFlowEdge(FlowEdge edge); @Override Set<FlowEdge> getEdges(String nodeId); @Override Set<FlowEdge> getEdges(DataNode node); @Override FlowGraphPath findPath(FlowSpec flowSpec);  }