@AfterClass public static void tearDown() { CloseHelper.close(channel); IoUtil.deleteIfExists(new File(PATH)); }
/** * Method creating the monitoring MMF */ private void createMonitoringFile() { String monitoringDirName = getMonitoringDirName(); monitoringDir = new File(monitoringDirName); File monitoringFile = new File(monitoringDir, gatewayId); IoUtil.deleteIfExists(monitoringFile); monitorFileWriter.initialize(monitoringFile); }
private void deleteFiles() { deleteIfExists(new File(INDEX_FILE_PATH)); deleteIfExists(writablePath(INDEX_FILE_PATH)); deleteIfExists(passingPath(INDEX_FILE_PATH)); } }
MonitoringFile(final boolean newFile, final CommonConfiguration configuration) { final File file = new File(configuration.monitoringFile()).getAbsoluteFile(); absolutePath = file.getAbsolutePath(); CloseChecker.validate(absolutePath); CloseChecker.onOpen(absolutePath, this); final int length; if (newFile) { IoUtil.deleteIfExists(file); length = configuration.monitoringBuffersLength(); mappedByteBuffer = LoggerUtil.mapNewFile(file, length); } else { if (!file.exists() || !file.canRead() || !file.isFile()) { throw new IllegalStateException("Unable to read from file: " + file); } mappedByteBuffer = IoUtil.mapExistingFile(file, "counters file"); length = mappedByteBuffer.capacity(); } final AtomicBuffer mappedFile = new UnsafeBuffer(mappedByteBuffer); errorBuffer = new UnsafeBuffer(mappedFile, 0, length); }
@Test public void copiesOldSessionContextFile() throws IOException { final File backupLocation = File.createTempFile("sessionContexts", "tmp"); try { final SessionContext aContext = sessionContexts.onLogon(aSession); sessionContexts.onDisconnect(aContext.sessionId()); final byte[] oldData = new byte[BUFFER_SIZE]; buffer.getBytes(0, oldData); sessionContexts.reset(backupLocation); verify(mappedFile).transferTo(backupLocation); } finally { IoUtil.deleteIfExists(backupLocation); } }
@Before public void setUp() { mediaDriver = TestFixtures.launchMediaDriver(); aeronArchive = AeronArchive.connect(); recordingIdLookup = new RecordingIdLookup(new YieldingIdleStrategy(), aeron().countersReader()); aeronArchive.startRecording(CHANNEL, STREAM_ID, SourceLocation.LOCAL); final Aeron aeron = aeron(); publication = aeron.addExclusivePublication(CHANNEL, STREAM_ID); subscription = aeron.addSubscription(CHANNEL, STREAM_ID); final File logFile = logFile(SESSION_ID); IoUtil.deleteIfExists(logFile); newReplayIndex(); query = new ReplayQuery( DEFAULT_LOG_FILE_DIR, DEFAULT_LOGGER_CACHE_NUM_SETS, DEFAULT_LOGGER_CACHE_SET_SIZE, existingBufferFactory, DEFAULT_OUTBOUND_LIBRARY_STREAM, new NoOpIdleStrategy(), aeronArchive, errorHandler, DEFAULT_ARCHIVE_REPLAY_STREAM); returnBuffer(indexBuffer, SESSION_ID); returnBuffer(ByteBuffer.allocate(16 * 1024), SESSION_ID_2); when(newBufferFactory.map(any(), anyInt())).thenReturn(indexBuffer); }