/** Updates the supplied node record, inserting it into the database if necessary. */ public void updateNode(NodeRecord record) { record.lastUpdated = new Timestamp(System.currentTimeMillis()); store(record); }
/** * Updates {@link NodeRecord#lastUpdated} for the specified node, indicating that the node is * alive and well. */ public void heartbeatNode(String nodeName) { updatePartial( NodeRecord.getKey(nodeName), NodeRecord.LAST_UPDATED, new Timestamp(System.currentTimeMillis())); }
/** Marks the identified node as shut down in its record. */ public void shutdownNode(String nodeName) { updatePartial(NodeRecord.getKey(nodeName), NodeRecord.SHUTDOWN, true); }
@Test public void shouldGrowAFileWhileContinuingToMemoryMapNewRegions() throws Exception { // don't run on windows because memory mapping doesn't work properly there assumeTrue(!osIsWindows()); // given int NUMBER_OF_RECORDS = 1000000; File storeDir = TargetDirectory.forTest(getClass()).makeGraphDbDir(); Config config = new Config( stringMap( mapped_memory_total_size.name(), mmapSize(NUMBER_OF_RECORDS, NodeStore.RECORD_SIZE), Configuration.store_dir.name(), storeDir.getPath()), NodeStore.Configuration.class); DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(); Monitors monitors = new Monitors(); DefaultFileSystemAbstraction fileSystemAbstraction = new DefaultFileSystemAbstraction(); PageCache pageCache = pageCacheRule.getPageCache(fileSystemAbstraction, config); StoreFactory storeFactory = new StoreFactory( config, idGeneratorFactory, pageCache, fileSystemAbstraction, StringLogger.DEV_NULL, monitors); File fileName = new File(storeDir, NeoStore.DEFAULT_NAME + ".nodestore.db"); storeFactory.createEmptyStore( fileName, storeFactory.buildTypeDescriptorAndVersion(NodeStore.TYPE_DESCRIPTOR)); NodeStore nodeStore = new NodeStore( fileName, config, idGeneratorFactory, pageCache, fileSystemAbstraction, StringLogger.DEV_NULL, null, StoreVersionMismatchHandler.THROW_EXCEPTION, monitors); // when int iterations = 2 * NUMBER_OF_RECORDS; long startingId = nodeStore.nextId(); long nodeId = startingId; for (int i = 0; i < iterations; i++) { NodeRecord record = new NodeRecord(nodeId, false, i, 0); record.setInUse(true); nodeStore.updateRecord(record); nodeId = nodeStore.nextId(); } // then NodeRecord record = new NodeRecord(0, false, 0, 0); for (int i = 0; i < iterations; i++) { record.setId(startingId + i); nodeStore.getRecord(i, record); assertTrue("record[" + i + "] should be in use", record.inUse()); assertThat( "record[" + i + "] should have nextRelId of " + i, record.getNextRel(), is((long) i)); } nodeStore.close(); }