Esempio n. 1
0
 /**
  * Create and insert the node into the DB
  *
  * @param rng
  * @param id1
  */
 private void genNode(
     Random rng, long id1, ArrayList<Node> nodeLoadBuffer, int bulkLoadBatchSize) {
   int dataLength = (int) nodeDataLength.choose(rng);
   Node node =
       new Node(
           id1,
           LinkStore.DEFAULT_NODE_TYPE,
           System.currentTimeMillis(),
           1,
           nodeDataGen.fill(rng, new byte[dataLength]));
   nodeLoadBuffer.add(node);
   if (nodeLoadBuffer.size() >= bulkLoadBatchSize) {
     loadNodes(nodeLoadBuffer);
     nodeLoadBuffer.clear();
   }
 }
Esempio n. 2
0
  public NodeLoader(
      Properties props,
      Logger logger,
      NodeStore nodeStore,
      Random rng,
      LatencyStats latencyStats,
      PrintStream csvStreamOut,
      int loaderId) {
    super();
    this.props = props;
    this.logger = logger;
    this.nodeStore = nodeStore;
    this.rng = rng;
    this.latencyStats = latencyStats;
    this.loaderId = loaderId;

    double medianDataLength = ConfigUtil.getDouble(props, Config.NODE_DATASIZE);
    nodeDataLength = new LogNormalDistribution();
    nodeDataLength.init(0, NodeStore.MAX_NODE_DATA, medianDataLength, Config.NODE_DATASIZE_SIGMA);

    try {
      nodeDataGen =
          ClassLoadUtil.newInstance(
              ConfigUtil.getPropertyRequired(props, Config.NODE_ADD_DATAGEN), DataGenerator.class);
      nodeDataGen.init(props, Config.NODE_ADD_DATAGEN_PREFIX);
    } catch (ClassNotFoundException ex) {
      logger.error(ex);
      throw new LinkBenchConfigError("Error loading data generator class: " + ex.getMessage());
    }

    debuglevel = ConfigUtil.getDebugLevel(props);
    dbid = ConfigUtil.getPropertyRequired(props, Config.DBID);

    displayFreq_ms = ConfigUtil.getLong(props, Config.DISPLAY_FREQ) * 1000;
    int maxsamples = ConfigUtil.getInt(props, Config.MAX_STAT_SAMPLES);
    this.stats = new SampledStats(loaderId, maxsamples, csvStreamOut);
  }