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;
  }
Example #2
0
  @Test
  public void shouldMoveAwayInvalidRrdFile() throws IOException {
    // Given
    String expected = new File(testDirectory.directory(), "rrd-test").getAbsolutePath();
    addProperty(Configurator.RRDB_LOCATION_PROPERTY_KEY, expected);

    TestableRrdFactory factory = createRrdFactory();
    createInvalidRrdFile(expected);

    // When
    RrdDbWrapper rrdDbAndSampler = factory.createRrdDbAndSampler(db, new NullJobScheduler());

    // Then
    assertSubdirectoryExists("rrd-test-invalid", factory.directoryUsed);

    rrdDbAndSampler.close();
  }
 @After
 public void shutdownDatabase() throws Throwable {
   try {
     rrdDb.close();
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
   this.database.shutdown();
 }
  @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);
  }