// Path: benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/remote/ArchivingMediaDriver.java
// static ArchivingMediaDriver launchArchiveWithEmbeddedDriver()
// {
//     MediaDriver driver = null;
//     Archive archive = null;
//     try
//     {
//         final MediaDriver.Context driverCtx = new MediaDriver.Context()
//             .dirDeleteOnStart(true)
//             .dirDeleteOnShutdown(true)
//             .spiesSimulateConnection(true);
// 
//         driver = MediaDriver.launch(driverCtx);
// 
//         final Archive.Context archiveCtx = new Archive.Context()
//             .aeronDirectoryName(driverCtx.aeronDirectoryName())
//             .deleteArchiveOnStart(true);
// 
//         final int errorCounterId = SystemCounterDescriptor.ERRORS.id();
//         final AtomicCounter errorCounter = null != archiveCtx.errorCounter() ?
//             archiveCtx.errorCounter() : new AtomicCounter(driverCtx.countersValuesBuffer(), errorCounterId);
// 
//         final ErrorHandler errorHandler = null != archiveCtx.errorHandler() ?
//             archiveCtx.errorHandler() : driverCtx.errorHandler();
// 
//         archive = Archive.launch(archiveCtx
//             .mediaDriverAgentInvoker(driver.sharedAgentInvoker())
//             .aeronDirectoryName(driverCtx.aeronDirectoryName())
//             .errorHandler(errorHandler)
//             .errorCounter(errorCounter));
// 
//         return new ArchivingMediaDriver(driver, archive);
//     }
//     catch (final Exception ex)
//     {
//         CloseHelper.quietCloseAll(archive, driver);
//         throw ex;
//     }
// }


import io.aeron.archive.client.AeronArchive;
import org.agrona.IoUtil;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import java.io.File;
import java.util.concurrent.atomic.AtomicBoolean;
import static io.aeron.CommonContext.IPC_CHANNEL;
import static io.aeron.archive.client.AeronArchive.Configuration.RECORDING_EVENTS_CHANNEL_PROP_NAME;
import static io.aeron.archive.client.AeronArchive.Configuration.RECORDING_EVENTS_ENABLED_PROP_NAME;
import static io.aeron.archive.client.AeronArchive.connect;
import static java.lang.System.clearProperty;
import static java.lang.System.setProperty;
import static uk.co.real_logic.benchmarks.aeron.remote.ArchivingMediaDriver.launchArchiveWithEmbeddedDriver;
/*
 * Copyright 2015-2022 Real Logic Limited.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package uk.co.real_logic.benchmarks.aeron.remote;




class LiveRecordingTest extends
    AbstractTest<ArchivingMediaDriver, AeronArchive, LiveRecordingMessageTransceiver, EchoNode>
{
    private File archiveDir;

    @BeforeEach
    void before()
    {
        setProperty(RECORDING_EVENTS_ENABLED_PROP_NAME, "true");
        setProperty(RECORDING_EVENTS_CHANNEL_PROP_NAME, IPC_CHANNEL);
    }

    @AfterEach
    void after()
    {
        clearProperty(RECORDING_EVENTS_ENABLED_PROP_NAME);
        clearProperty(RECORDING_EVENTS_CHANNEL_PROP_NAME);
        IoUtil.delete(archiveDir, true);
    }

    protected EchoNode createNode(
        final AtomicBoolean running, final ArchivingMediaDriver archivingMediaDriver, final AeronArchive aeronArchive)
    {
        return new EchoNode(running, null, aeronArchive.context().aeron(), false);
    }

    protected ArchivingMediaDriver createDriver()
    {
// Path: benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/remote/ArchivingMediaDriver.java
// static ArchivingMediaDriver launchArchiveWithEmbeddedDriver()
// {
//     MediaDriver driver = null;
//     Archive archive = null;
//     try
//     {
//         final MediaDriver.Context driverCtx = new MediaDriver.Context()
//             .dirDeleteOnStart(true)
//             .dirDeleteOnShutdown(true)
//             .spiesSimulateConnection(true);
// 
//         driver = MediaDriver.launch(driverCtx);
// 
//         final Archive.Context archiveCtx = new Archive.Context()
//             .aeronDirectoryName(driverCtx.aeronDirectoryName())
//             .deleteArchiveOnStart(true);
// 
//         final int errorCounterId = SystemCounterDescriptor.ERRORS.id();
//         final AtomicCounter errorCounter = null != archiveCtx.errorCounter() ?
//             archiveCtx.errorCounter() : new AtomicCounter(driverCtx.countersValuesBuffer(), errorCounterId);
// 
//         final ErrorHandler errorHandler = null != archiveCtx.errorHandler() ?
//             archiveCtx.errorHandler() : driverCtx.errorHandler();
// 
//         archive = Archive.launch(archiveCtx
//             .mediaDriverAgentInvoker(driver.sharedAgentInvoker())
//             .aeronDirectoryName(driverCtx.aeronDirectoryName())
//             .errorHandler(errorHandler)
//             .errorCounter(errorCounter));
// 
//         return new ArchivingMediaDriver(driver, archive);
//     }
//     catch (final Exception ex)
//     {
//         CloseHelper.quietCloseAll(archive, driver);
//         throw ex;
//     }
// }


// Path: benchmarks-aeron/src/test/java/uk/co/real_logic/benchmarks/aeron/remote/LiveRecordingTest.java
import io.aeron.archive.client.AeronArchive;
import org.agrona.IoUtil;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import java.io.File;
import java.util.concurrent.atomic.AtomicBoolean;
import static io.aeron.CommonContext.IPC_CHANNEL;
import static io.aeron.archive.client.AeronArchive.Configuration.RECORDING_EVENTS_CHANNEL_PROP_NAME;
import static io.aeron.archive.client.AeronArchive.Configuration.RECORDING_EVENTS_ENABLED_PROP_NAME;
import static io.aeron.archive.client.AeronArchive.connect;
import static java.lang.System.clearProperty;
import static java.lang.System.setProperty;
import static uk.co.real_logic.benchmarks.aeron.remote.ArchivingMediaDriver.launchArchiveWithEmbeddedDriver;

/*
 * Copyright 2015-2022 Real Logic Limited.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package uk.co.real_logic.benchmarks.aeron.remote;




class LiveRecordingTest extends
    AbstractTest<ArchivingMediaDriver, AeronArchive, LiveRecordingMessageTransceiver, EchoNode>
{
    private File archiveDir;

    @BeforeEach
    void before()
    {
        setProperty(RECORDING_EVENTS_ENABLED_PROP_NAME, "true");
        setProperty(RECORDING_EVENTS_CHANNEL_PROP_NAME, IPC_CHANNEL);
    }

    @AfterEach
    void after()
    {
        clearProperty(RECORDING_EVENTS_ENABLED_PROP_NAME);
        clearProperty(RECORDING_EVENTS_CHANNEL_PROP_NAME);
        IoUtil.delete(archiveDir, true);
    }

    protected EchoNode createNode(
        final AtomicBoolean running, final ArchivingMediaDriver archivingMediaDriver, final AeronArchive aeronArchive)
    {
        return new EchoNode(running, null, aeronArchive.context().aeron(), false);
    }

    protected ArchivingMediaDriver createDriver()
    {
        final ArchivingMediaDriver driver = launchArchiveWithEmbeddedDriver();