@Test public void testSetNodeProperty() throws Exception { GraphDatabaseService db = setUpDb(); NodeManager nodeManager = new NodeManager(); NodeManager.globalNodeCache.invalidateAll(); DataNodeManager.dataCache.invalidateAll(); DataNodeManager dataNodeManager = new DataNodeManager(); Transaction tx1 = db.beginTx(); Node a = nodeManager.getOrCreateNode(dataNodeManager, "a", db); tx1.success(); Assert.assertNotNull(a); String expected = "success"; nodeManager.setNodeProperty(a.getId(), "test", expected, db); Transaction tx = db.beginTx(); String actual = (String)NodeManager.getNodeFromGlobalCache(a.getId()).get("test"); tx.success(); Assert.assertEquals(expected, actual); }
public boolean setNodeProperty(Long id, String key, Object value, GraphDatabaseService graphDb) { boolean success = true; Map<String, Object> node = globalNodeCache.getIfPresent(id); if(node == null) { success = addNodeToCache((gdb, cache) -> getNodeHashMap(id, gdb, cache), graphDb); if(success) node = globalNodeCache.getIfPresent(id); } if (node != null) { node.put(key, value); } Transaction tx = graphDb.beginTx(); graphDb.getNodeById(id).setProperty(key, value); tx.success(); tx.close(); return success; }
NodeManager { public boolean setNodeProperty(Long id, String key, Object value, GraphDatabaseService graphDb) { boolean success = true; Map<String, Object> node = globalNodeCache.getIfPresent(id); if(node == null) { success = addNodeToCache((gdb, cache) -> getNodeHashMap(id, gdb, cache), graphDb); if(success) node = globalNodeCache.getIfPresent(id); } if (node != null) { node.put(key, value); } Transaction tx = graphDb.beginTx(); graphDb.getNodeById(id).setProperty(key, value); tx.success(); tx.close(); return success; } }
NodeManager { public boolean setNodeProperty(Long id, String key, Object value, GraphDatabaseService graphDb) { boolean success = true; Map<String, Object> node = globalNodeCache.getIfPresent(id); if(node == null) { success = addNodeToCache((gdb, cache) -> getNodeHashMap(id, gdb, cache), graphDb); if(success) node = globalNodeCache.getIfPresent(id); } if (node != null) { node.put(key, value); } Transaction tx = graphDb.beginTx(); graphDb.getNodeById(id).setProperty(key, value); tx.success(); tx.close(); return success; } NodeManager(); }
NodeManager { public boolean setNodeProperty(Long id, String key, Object value, GraphDatabaseService graphDb) { boolean success = true; Map<String, Object> node = globalNodeCache.getIfPresent(id); if(node == null) { success = addNodeToCache((gdb, cache) -> getNodeHashMap(id, gdb, cache), graphDb); if(success) node = globalNodeCache.getIfPresent(id); } if (node != null) { node.put(key, value); } Transaction tx = graphDb.beginTx(); graphDb.getNodeById(id).setProperty(key, value); tx.success(); tx.close(); return success; } NodeManager(); static Map<String, Object> getNodeFromGlobalCache(Long id); Node getOrCreateNode(Manager manager, String key, GraphDatabaseService db); Map<String, Object> getNodeAsMap(Long id, GraphDatabaseService graphDb); Object getNodeProperty(Long id, String key, GraphDatabaseService graphDb); boolean setNodeProperty(Long id, String key, Object value, GraphDatabaseService graphDb); }
NodeManager { public boolean setNodeProperty(Long id, String key, Object value, GraphDatabaseService graphDb) { boolean success = true; Map<String, Object> node = globalNodeCache.getIfPresent(id); if(node == null) { success = addNodeToCache((gdb, cache) -> getNodeHashMap(id, gdb, cache), graphDb); if(success) node = globalNodeCache.getIfPresent(id); } if (node != null) { node.put(key, value); } Transaction tx = graphDb.beginTx(); graphDb.getNodeById(id).setProperty(key, value); tx.success(); tx.close(); return success; } NodeManager(); static Map<String, Object> getNodeFromGlobalCache(Long id); Node getOrCreateNode(Manager manager, String key, GraphDatabaseService db); Map<String, Object> getNodeAsMap(Long id, GraphDatabaseService graphDb); Object getNodeProperty(Long id, String key, GraphDatabaseService graphDb); boolean setNodeProperty(Long id, String key, Object value, GraphDatabaseService graphDb); static final Cache<Long, HashMap<String, Object>> globalNodeCache; }