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;
}
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();
}
}
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.");
}
}
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);
}
}
}
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();
}
Aggregations