private void loadNodes(ArrayList<Node> nodeLoadBuffer) { long actualIds[] = null; long timestart = System.nanoTime(); try { actualIds = nodeStore.bulkAddNodes(dbid, nodeLoadBuffer); long timetaken = (System.nanoTime() - timestart); nodesLoaded += nodeLoadBuffer.size(); // Check that expected ids were allocated assert (actualIds.length == nodeLoadBuffer.size()); for (int i = 0; i < actualIds.length; i++) { if (nodeLoadBuffer.get(i).id != actualIds[i]) { logger.warn( "Expected ID of node: " + nodeLoadBuffer.get(i).id + " != " + actualIds[i] + " the actual ID"); } } nodeLoadBuffer.clear(); // convert to microseconds stats.addStats(LinkBenchOp.LOAD_NODE_BULK, timetaken / 1000, false); latencyStats.recordLatency(loaderId, LinkBenchOp.LOAD_NODE_BULK, timetaken); if (nodesLoaded >= nextReport) { double totalTimeTaken = (System.currentTimeMillis() - startTime_ms) / 1000.0; logger.debug( String.format( "Loader #%d: %d/%d nodes loaded at %f nodes/sec", loaderId, nodesLoaded, totalNodes, nodesLoaded / totalTimeTaken)); nextReport += REPORT_INTERVAL; } } catch (Throwable e) { // Catch exception if any long endtime2 = System.nanoTime(); long timetaken2 = (endtime2 - timestart) / 1000; logger.error("Error: " + e.getMessage(), e); stats.addStats(LinkBenchOp.LOAD_NODE_BULK, timetaken2, true); nodeStore.clearErrors(loaderId); nodeLoadBuffer.clear(); return; } }
private void displayAndResetStats() { long now = System.currentTimeMillis(); stats.displayStats(lastDisplayTime_ms, now, Arrays.asList(LinkBenchOp.LOAD_NODE_BULK)); stats.resetSamples(); lastDisplayTime_ms = now; }