Java Code Examples for org.agrona.IoUtil#delete()

The following examples show how to use org.agrona.IoUtil#delete() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArchiveLoggingAgentTest.java    From aeron with Apache License 2.0 6 votes vote down vote up
private void before(final String enabledEvents, final EnumSet<ArchiveEventCode> expectedEvents)
{
    System.setProperty(EventLogAgent.READER_CLASSNAME_PROP_NAME, StubEventLogReaderAgent.class.getName());
    System.setProperty(EventConfiguration.ENABLED_ARCHIVE_EVENT_CODES_PROP_NAME, enabledEvents);
    AgentTests.beforeAgent();

    latch = new CountDownLatch(expectedEvents.size());
    LOGGED_EVENTS.clear();
    WAIT_LIST.addAll(expectedEvents.stream().map(ArchiveEventLogger::toEventCodeId).collect(toSet()));

    testDir = Paths.get(IoUtil.tmpDirName(), "archive-test").toFile();
    if (testDir.exists())
    {
        IoUtil.delete(testDir, false);
    }
}
 
Example 2
Source File: CTestMediaDriver.java    From aeron with Apache License 2.0 6 votes vote down vote up
public void close()
{
    try
    {
        terminateDriver();
        if (!aeronMediaDriverProcess.waitFor(10, TimeUnit.SECONDS))
        {
            aeronMediaDriverProcess.destroyForcibly();
            throw new RuntimeException("Failed to shutdown cleaning, forcing close");
        }

        if (null != driverOutputConsumer)
        {
            driverOutputConsumer.exitCode(context.aeronDirectoryName(), aeronMediaDriverProcess.exitValue());
        }
    }
    catch (final InterruptedException ex)
    {
        throw new RuntimeException("Interrupted while waiting for shutdown", ex);
    }

    IoUtil.delete(new File(context.aeronDirectoryName()), false);
}
 
Example 3
Source File: FixBenchmarkServer.java    From artio with Apache License 2.0 6 votes vote down vote up
private static EngineConfiguration engineConfiguration()
{
    final String acceptorLogs = "acceptor_logs";
    final File dir = new File(acceptorLogs);
    if (dir.exists())
    {
        IoUtil.delete(dir, false);
    }

    final EngineConfiguration configuration = new EngineConfiguration();
    configuration.printAeronStreamIdentifiers(true);
    configuration.authenticationStrategy((logon) -> !REJECT_LOGON);

    return configuration
        .bindTo("localhost", BenchmarkConfiguration.PORT)
        .libraryAeronChannel(AERON_CHANNEL)
        .logFileDir(acceptorLogs)
        .logInboundMessages(LOG_INBOUND_MESSAGES)
        .logOutboundMessages(LOG_OUTBOUND_MESSAGES)
        .framerIdleStrategy(idleStrategy());
}
 
Example 4
Source File: SystemTestUtil.java    From artio with Apache License 2.0 5 votes vote down vote up
public static void delete(final String dirPath)
{
    final File dir = new File(dirPath);
    if (dir.exists())
    {
        IoUtil.delete(dir, false);
    }
}
 
Example 5
Source File: TestFixtures.java    From artio with Apache License 2.0 5 votes vote down vote up
public static void cleanupMediaDriver(final ArchivingMediaDriver mediaDriver)
{
    if (mediaDriver != null)
    {
        final String aeronDirectoryName = closeMediaDriver(mediaDriver);

        final File directory = new File(aeronDirectoryName);
        if (directory.exists())
        {
            CloseChecker.validate(aeronDirectoryName);
            IoUtil.delete(directory, false);
        }
    }
}
 
Example 6
Source File: FixLibraryCleanupTest.java    From artio with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldCleanupLibraryIfNoAeronCNCFile()
{
    final LibraryConfiguration configuration = newLibraryConfiguration();

    // Ensure that we test the CNC file not found path
    IoUtil.delete(new File(configuration.aeronContext().aeronDirectoryName()), true);

    shouldCleanupLibraryIfItCannotConnect(configuration);
}
 
Example 7
Source File: StressUtil.java    From artio with Apache License 2.0 5 votes vote down vote up
static void cleanupOldLogFileDir(final EngineConfiguration configuration)
{
    IoUtil.delete(new File(configuration.logFileDir()), true);

    final File tmpDir = new File(optimalTmpDirName());
    for (final File file : tmpDir.listFiles(file -> file.getName().contains("fix-library-")))
    {
        IoUtil.delete(file, false);
    }
}
 
Example 8
Source File: ClusterBackup.java    From aeron with Apache License 2.0 5 votes vote down vote up
/**
 * Delete the cluster directory.
 */
public void deleteDirectory()
{
    if (null != clusterDir)
    {
        IoUtil.delete(clusterDir, false);
    }
}
 
Example 9
Source File: DriverLoggingAgentTest.java    From aeron with Apache License 2.0 5 votes vote down vote up
@AfterEach
public void after()
{
    AgentTests.afterAgent();

    LOGGED_EVENTS.clear();
    WAIT_LIST.clear();

    if (testDir != null && testDir.exists())
    {
        IoUtil.delete(testDir, false);
    }
}
 
Example 10
Source File: FileStoreLogFactoryTest.java    From aeron with Apache License 2.0 5 votes vote down vote up
@AfterEach
public void cleanupFiles()
{
    CloseHelper.close(rawLog);
    CloseHelper.close(fileStoreLogFactory);
    IoUtil.delete(DATA_DIR, false);
}
 
Example 11
Source File: RecordingSessionTest.java    From aeron with Apache License 2.0 5 votes vote down vote up
@AfterEach
public void after()
{
    IoUtil.unmap(mockLogBufferMapped.byteBuffer());
    CloseHelper.close(mockLogBufferChannel);
    IoUtil.delete(archiveDir, false);
    IoUtil.delete(termFile, false);
}
 
Example 12
Source File: DriverLoggingAgentTest.java    From aeron with Apache License 2.0 5 votes vote down vote up
private void before(final String enabledEvents, final EnumSet<DriverEventCode> expectedEvents)
{
    System.setProperty(EventLogAgent.READER_CLASSNAME_PROP_NAME, StubEventLogReaderAgent.class.getName());
    System.setProperty(EventConfiguration.ENABLED_EVENT_CODES_PROP_NAME, enabledEvents);
    AgentTests.beforeAgent();

    latch = new CountDownLatch(expectedEvents.size());
    WAIT_LIST.addAll(expectedEvents.stream().map(DriverEventCode::id).collect(toSet()));

    testDir = Paths.get(IoUtil.tmpDirName(), "driver-test").toFile();
    if (testDir.exists())
    {
        IoUtil.delete(testDir, false);
    }
}
 
Example 13
Source File: MultiDestinationCastTest.java    From aeron with Apache License 2.0 4 votes vote down vote up
@AfterEach
public void closeEverything()
{
    CloseHelper.closeAll(clientB, clientA, driverB, driverA);
    IoUtil.delete(new File(ROOT_DIR), true);
}
 
Example 14
Source File: ChannelEndpointStatusTest.java    From aeron with Apache License 2.0 4 votes vote down vote up
@AfterEach
public void after()
{
    CloseHelper.closeAll(clientC, clientB, clientA, driverB, driverA);
    IoUtil.delete(new File(ROOT_DIR), true);
}
 
Example 15
Source File: ArchiveToolTests.java    From aeron with Apache License 2.0 4 votes vote down vote up
@AfterEach
void after()
{
    IoUtil.delete(archiveDir, false);
}
 
Example 16
Source File: CatalogTest.java    From aeron with Apache License 2.0 4 votes vote down vote up
@AfterEach
void after()
{
    IoUtil.delete(archiveDir, false);
}
 
Example 17
Source File: DataCollectorTest.java    From aeron with Apache License 2.0 4 votes vote down vote up
@Test
void copyUsingTestInfo(final @TempDir Path tempDir, final TestInfo testInfo) throws Exception
{
    final Path buildDir = Paths.get("build/test/source").toAbsolutePath();
    createDirectories(buildDir);

    try
    {
        final Path rootDir = tempDir.resolve("copy-root");
        final Path my1 = createFile(tempDir.resolve("my.txt"));
        final Path myDir1 = createDirectories(tempDir.resolve("my-dir"));
        createFile(myDir1.resolve("some1.txt"));

        final Path dir11 = createDirectories(tempDir.resolve("path1/dir1"));
        final Path dir12 = createDirectories(tempDir.resolve("path1/dir2"));
        final Path dir13 = createDirectories(tempDir.resolve("path1/dir2/dir3"));
        createFile(tempDir.resolve("path1/do_not_copy.txt"));
        createFile(dir11.resolve("file11.txt"));
        createFile(dir12.resolve("file12.txt"));
        createFile(dir13.resolve("file13.txt"));

        final Path my2 = createFile(dir13.resolve("my.txt"));
        final Path dir21 = createDirectories(tempDir.resolve("path2/dir1"));
        final Path dir22 = createDirectories(tempDir.resolve("path2/dir2"));
        final Path dir23 = createDirectories(tempDir.resolve("path2/dir3"));
        createFile(dir21.resolve("file21.txt"));
        createFile(dir22.resolve("file22.txt"));
        createFile(dir23.resolve("file23.txt"));

        final Path dir31 = createDirectories(buildDir.resolve("dir1"));
        final Path dir32 = createDirectories(buildDir.resolve("dir2"));
        final Path dir33 = createDirectories(buildDir.resolve("dir2/dir3"));
        createFile(dir31.resolve("file31.txt"));
        createFile(dir32.resolve("file32.txt"));
        createFile(dir33.resolve("file33.txt"));

        final Path my3 = createFile(buildDir.resolve("my.txt"));
        final Path myDir2 = createDirectories(buildDir.resolve("my-dir"));
        createFile(myDir2.resolve("some2.txt"));

        final DataCollector dataCollector = new DataCollector(rootDir);
        dataCollector.add(my1);
        dataCollector.add(my1);
        dataCollector.add(my2);
        dataCollector.add(dir11);
        dataCollector.add(dir12);
        dataCollector.add(dir13);
        dataCollector.add(dir21);
        dataCollector.add(dir22);
        dataCollector.add(dir23);
        dataCollector.add(dir31);
        dataCollector.add(dir32);
        dataCollector.add(dir33);
        dataCollector.add(my3);
        dataCollector.add(myDir1);
        dataCollector.add(myDir2);

        dataCollector.dumpData(testInfo);

        final String testClass = testInfo.getTestClass().get().getName();
        final String testMethod = testInfo.getTestMethod().get().getName();
        final Path destination = rootDir.resolve(testClass + "-" + testMethod);

        assertTrue(exists(destination));
        assertTrue(exists(destination.resolve("my.txt")));
        assertTrue(exists(destination.resolve("my-dir/some1.txt")));
        assertTrue(exists(destination.resolve("path1/dir1/file11.txt")));
        assertTrue(exists(destination.resolve("path1/dir2/file12.txt")));
        assertTrue(exists(destination.resolve("path1/dir2/dir3/file13.txt")));
        assertTrue(exists(destination.resolve("path1/dir2/dir3/my.txt")));
        assertTrue(exists(destination.resolve("path2/dir1/file21.txt")));
        assertTrue(exists(destination.resolve("path2/dir2/file22.txt")));
        assertTrue(exists(destination.resolve("path2/dir3/file23.txt")));
        assertTrue(exists(destination.resolve("source/dir1/file31.txt")));
        assertTrue(exists(destination.resolve("source/dir2/file32.txt")));
        assertTrue(exists(destination.resolve("source/dir2/dir3/file33.txt")));
        assertTrue(exists(destination.resolve("source/my.txt")));
        assertTrue(exists(destination.resolve("source/my-dir/some2.txt")));
        assertFalse(exists(destination.resolve("path1/do_not_copy.txt")));
    }
    finally
    {
        IoUtil.delete(buildDir.toFile(), false);
    }
}
 
Example 18
Source File: CommonContext.java    From aeron with Apache License 2.0 4 votes vote down vote up
/**
 * Delete the current Aeron directory, throwing errors if not possible.
 */
public void deleteAeronDirectory()
{
    IoUtil.delete(aeronDirectory, false);
}
 
Example 19
Source File: ReplaySessionTest.java    From aeron with Apache License 2.0 4 votes vote down vote up
@AfterEach
public void after()
{
    IoUtil.delete(archiveDir, false);
}
 
Example 20
Source File: SampleServer.java    From artio with Apache License 2.0 4 votes vote down vote up
public static void cleanupOldLogFileDir(final EngineConfiguration configuration)
{
    IoUtil.delete(new File(configuration.logFileDir()), true);
}