Example #1
0
  public org.neo4j.server.database.RrdDbWrapper createRrdDbAndSampler(
      final Database db, JobScheduler scheduler) throws IOException {
    NodeManager nodeManager =
        db.getGraph().getDependencyResolver().resolveDependency(NodeManager.class);

    Sampleable[] primitives = {
      new NodeIdsInUseSampleable(nodeManager),
      new PropertyCountSampleable(nodeManager),
      new RelationshipCountSampleable(nodeManager)
    };

    Sampleable[] usage = {};

    final String rrdPath =
        config.getString(RRDB_LOCATION_PROPERTY_KEY, getDefaultRrdFile(db.getGraph()));
    final RrdDbWrapper rrdb =
        createRrdb(rrdPath, isEphemereal(db.getGraph()), join(primitives, usage));

    scheduler.scheduleAtFixedRate(
        new RrdJob(new RrdSamplerImpl(rrdb.get(), primitives)),
        RRD_THREAD_NAME + "[primitives]",
        SECONDS.toMillis(0),
        SECONDS.toMillis(3));

    return rrdb;
  }
  @Before
  public void setUp() throws Exception {
    database =
        new WrappedDatabase(
            (AbstractGraphDatabase) new TestGraphDatabaseFactory().newImpermanentDatabase());

    rrdDb =
        new RrdFactory(new SystemConfiguration(), DEV_NULL).createRrdDbAndSampler(database, this);

    output =
        new EntityOutputFormat(new JsonFormat(), URI.create("http://peteriscool.com:6666/"), null);
    monitorService = new MonitorService(rrdDb.get(), output);
  }