protected void configureFileBackedBuffer(final MeterConfig config) { // Persistent buffer for in-memory samples try { final boolean deleteFilesOnClose = config.getShutdownSaveMode().equals("save_all_timelines"); final FileBackedBuffer fileBackedBuffer = new FileBackedBuffer(config.getSpoolDir(), "TimelineEventHandler", deleteFilesOnClose, config.getSegmentsSize(), config.getMaxNbSegments()); bind(FileBackedBuffer.class).toInstance(fileBackedBuffer); } catch (IOException e) { throw new RuntimeException(e); } }
private synchronized void purgeFilesAndAccumulators(final DateTime purgeAccumulatorsIfBefore, final DateTime purgeFilesIfBefore) { purgeOldSourcesAndAccumulators(purgeAccumulatorsIfBefore); final Replayer replayer = new Replayer(config.getSpoolDir()); replayer.purgeOldFiles(purgeFilesIfBefore); }
@BeforeMethod(groups = "fast") public void setUp() throws Exception { Assert.assertTrue(basePath.mkdir()); System.setProperty("killbill.usage.timelines.spoolDir", basePath.getAbsolutePath()); System.setProperty("killbill.usage.timelines.length", "60s"); final MeterConfig config = new ConfigurationObjectFactory(System.getProperties()).build(MeterConfig.class); timelineEventHandler = new TimelineEventHandler(config, dao, timelineCoder, sampleCoder, new BackgroundDBChunkWriter(dao, config, internalCallContextFactory), new FileBackedBuffer(config.getSpoolDir(), "TimelineEventHandler", 1024 * 1024, 10)); dao.getOrAddSource(HOST_UUID.toString(), internalCallContext); }
@BeforeMethod(alwaysRun = true) public void setUp() throws Exception { Assert.assertTrue(basePath.mkdir()); System.setProperty("killbill.usage.timelines.spoolDir", basePath.getAbsolutePath()); final MeterConfig config = new ConfigurationObjectFactory(System.getProperties()).build(MeterConfig.class); timelineEventHandler = new TimelineEventHandler(config, dao, timelineCoder, sampleCoder, new BackgroundDBChunkWriter(dao, config, internalCallContextFactory), new FileBackedBuffer(config.getSpoolDir(), "TimelineEventHandler", 1024 * 1024, 10)); dao.getOrAddSource(HOST_UUID.toString(), internalCallContext); eventTypeId = dao.getOrAddEventCategory(EVENT_TYPE, internalCallContext); }