addMessageFileSystemPaths();
initialized = true;
}
private void addMessageFileSystemPaths() {
messageFileSystem.addPath("/meshy/" + getUUID() + "/stats", new InternalHandler() {
@Override
public byte[] handleMessageRequest(String fileName, Map<String, String> options) {
StringBuilder sb = new StringBuilder();
for (String line : group.getLastStats()) {
sb.append(line);
sb.append("\n");
}
return Bytes.toBytes(sb.toString());
}
});
messageFileSystem.addPath("/meshy/statsMap", new InternalHandler() {
@Override
public byte[] handleMessageRequest(String fileName, Map<String, String> options) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
Map<String, Integer> stats = group.getLastStatsMap();
try {
Bytes.writeInt(stats.size(), out);
for (Map.Entry<String, Integer> e : stats.entrySet()) {
Bytes.writeString(e.getKey(), out);
Bytes.writeInt(e.getValue(), out);
}
} catch (IOException e) {
//ByteArrayOutputStreams do not throw IOExceptions
}
return out.toByteArray();
}
});
messageFileSystem.addPath("/meshy/host/ban", new InternalHandler() {
/**
* If host option exists, then ban that host. Otherwise, list currently
* banned hosts.
*/
@Override