Search in sources :

Example 16 with ClusterMarkFile

use of io.aeron.cluster.service.ClusterMarkFile in project aeron by real-logic.

the class ClusterTool method openServiceMarkFiles.

private static ClusterMarkFile[] openServiceMarkFiles(final File clusterDir, final Consumer<String> logger) {
    String[] clusterMarkFileNames = clusterDir.list((dir, name) -> name.startsWith(ClusterMarkFile.SERVICE_FILENAME_PREFIX) && name.endsWith(ClusterMarkFile.FILE_EXTENSION));
    if (null == clusterMarkFileNames) {
        clusterMarkFileNames = ArrayUtil.EMPTY_STRING_ARRAY;
    }
    final ClusterMarkFile[] clusterMarkFiles = new ClusterMarkFile[clusterMarkFileNames.length];
    for (int i = 0, length = clusterMarkFiles.length; i < length; i++) {
        clusterMarkFiles[i] = new ClusterMarkFile(clusterDir, clusterMarkFileNames[i], System::currentTimeMillis, TIMEOUT_MS, logger);
    }
    return clusterMarkFiles;
}
Also used : ClusterMarkFile(io.aeron.cluster.service.ClusterMarkFile)

Example 17 with ClusterMarkFile

use of io.aeron.cluster.service.ClusterMarkFile in project aeron by real-logic.

the class ClusterTool method describe.

/**
 * Print out the descriptors in the {@link ClusterMarkFile}s.
 *
 * @param out              to print the output to.
 * @param serviceMarkFiles to query.
 */
public static void describe(final PrintStream out, final ClusterMarkFile[] serviceMarkFiles) {
    for (final ClusterMarkFile serviceMarkFile : serviceMarkFiles) {
        printTypeAndActivityTimestamp(out, serviceMarkFile);
        out.println(serviceMarkFile.decoder());
        serviceMarkFile.close();
    }
}
Also used : ClusterMarkFile(io.aeron.cluster.service.ClusterMarkFile)

Example 18 with ClusterMarkFile

use of io.aeron.cluster.service.ClusterMarkFile in project aeron by real-logic.

the class ClusterTool method listMembers.

/**
 * Print out a list of the current members of the cluster.
 *
 * @param out        to print the output to.
 * @param clusterDir where the cluster is running.
 */
public static void listMembers(final PrintStream out, final File clusterDir) {
    if (markFileExists(clusterDir) || TIMEOUT_MS > 0) {
        try (ClusterMarkFile markFile = openMarkFile(clusterDir, System.out::println)) {
            final ClusterMembership clusterMembership = new ClusterMembership();
            final long timeoutMs = Math.max(TimeUnit.SECONDS.toMillis(1), TIMEOUT_MS);
            if (queryClusterMembers(markFile, timeoutMs, clusterMembership)) {
                out.println("currentTimeNs=" + clusterMembership.currentTimeNs + ", leaderMemberId=" + clusterMembership.leaderMemberId + ", memberId=" + clusterMembership.memberId + ", activeMembers=" + clusterMembership.activeMembers + ", passiveMembers=" + clusterMembership.passiveMembers);
            } else {
                out.println("timeout waiting for response from node");
            }
        }
    } else {
        out.println(ClusterMarkFile.FILENAME + " does not exist.");
    }
}
Also used : ClusterMarkFile(io.aeron.cluster.service.ClusterMarkFile)

Example 19 with ClusterMarkFile

use of io.aeron.cluster.service.ClusterMarkFile in project aeron by real-logic.

the class SystemTestWatcher method printClusterMarkFileErrors.

private void printClusterMarkFileErrors(final List<Path> paths, final String fileDescription) {
    for (final Path path : paths) {
        try (ClusterMarkFile clusterMarkFile = openClusterMarkFile(path)) {
            final AtomicBuffer buffer = clusterMarkFile.errorBuffer();
            System.out.printf("%n%n%s file %s%n", fileDescription, path);
            final int distinctErrorCount = ErrorLogReader.read(buffer, this::printObservationCallback);
            System.out.format("%d distinct errors observed.%n", distinctErrorCount);
        }
    }
}
Also used : Path(java.nio.file.Path) ClusterMarkFile(io.aeron.cluster.service.ClusterMarkFile) AtomicBuffer(org.agrona.concurrent.AtomicBuffer)

Example 20 with ClusterMarkFile

use of io.aeron.cluster.service.ClusterMarkFile in project aeron by real-logic.

the class SystemTestWatcher method countClusterMarkFileErrors.

private int countClusterMarkFileErrors(final List<Path> paths, final Predicate<String> filter) {
    final MutableInteger errorCount = new MutableInteger();
    for (final Path path : paths) {
        try (ClusterMarkFile clusterMarkFile = openClusterMarkFile(path)) {
            final AtomicBuffer buffer = clusterMarkFile.errorBuffer();
            ErrorLogReader.read(buffer, (observationCount, firstObservationTimestamp, lastObservationTimestamp, encodedException) -> {
                if (filter.test(encodedException)) {
                    errorCount.set(errorCount.get() + observationCount);
                }
            });
        }
    }
    return errorCount.get();
}
Also used : Path(java.nio.file.Path) ClusterMarkFile(io.aeron.cluster.service.ClusterMarkFile) MutableInteger(org.agrona.collections.MutableInteger) AtomicBuffer(org.agrona.concurrent.AtomicBuffer)

Aggregations

ClusterMarkFile (io.aeron.cluster.service.ClusterMarkFile)20 Path (java.nio.file.Path)4 AtomicBuffer (org.agrona.concurrent.AtomicBuffer)4 ClusterNodeControlProperties (io.aeron.cluster.service.ClusterNodeControlProperties)2 File (java.io.File)2 Date (java.util.Date)2 MutableInteger (org.agrona.collections.MutableInteger)2 EpochClock (org.agrona.concurrent.EpochClock)2 SystemEpochClock (org.agrona.concurrent.SystemEpochClock)2 AtomicCounter (org.agrona.concurrent.status.AtomicCounter)2 CountersReader (org.agrona.concurrent.status.CountersReader)2