Search in sources :

Example 1 with ClusterMarkFile

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

the class ClusterTool method errors.

/**
 * Print out the errors in the error logs for the cluster components.
 *
 * @param out        to print the output to.
 * @param clusterDir where the cluster is running.
 */
public static void errors(final PrintStream out, final File clusterDir) {
    if (markFileExists(clusterDir) || TIMEOUT_MS > 0) {
        try (ClusterMarkFile markFile = openMarkFile(clusterDir, System.out::println)) {
            printTypeAndActivityTimestamp(out, markFile);
            printErrors(out, markFile);
            final String aeronDirectory = markFile.decoder().aeronDirectory();
            out.println();
            printDriverErrors(out, aeronDirectory);
        }
    } else {
        out.println(ClusterMarkFile.FILENAME + " does not exist.");
    }
    final ClusterMarkFile[] serviceMarkFiles = openServiceMarkFiles(clusterDir, out::println);
    errors(out, serviceMarkFiles);
}
Also used : ClusterMarkFile(io.aeron.cluster.service.ClusterMarkFile)

Example 2 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 3 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 4 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 5 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 clusterDir where the cluster is running.
 */
public static void describe(final PrintStream out, final File clusterDir) {
    if (markFileExists(clusterDir) || TIMEOUT_MS > 0) {
        try (ClusterMarkFile markFile = openMarkFile(clusterDir, out::println)) {
            printTypeAndActivityTimestamp(out, markFile);
            out.println(markFile.decoder());
        }
    } else {
        out.println(ClusterMarkFile.FILENAME + " does not exist.");
    }
    final ClusterMarkFile[] serviceMarkFiles = openServiceMarkFiles(clusterDir, out::println);
    describe(out, serviceMarkFiles);
}
Also used : ClusterMarkFile(io.aeron.cluster.service.ClusterMarkFile)

Aggregations

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