use of com.apple.foundationdb.FDB in project fdb-record-layer by FoundationDB.
the class ClientLogEventCounterTest method main.
@SuppressWarnings("PMD.SystemPrintln")
public static void main(String[] args) {
String cluster = null;
Instant start = null;
Instant end = null;
boolean countReads = true;
boolean countWrites = false;
final boolean countSingleKeys = true;
final boolean countRanges = true;
if (args.length > 0) {
cluster = args[0];
}
if (args.length > 1) {
start = ZonedDateTime.parse(args[1]).toInstant();
}
if (args.length > 2) {
end = ZonedDateTime.parse(args[2]).toInstant();
}
if (args.length > 3) {
String arg = args[3];
countReads = "READ".equals(arg) || "BOTH".equals(arg);
countWrites = "WRITE".equals(arg) || "BOTH".equals(arg);
}
FDB fdb = FDB.selectAPIVersion(630);
Database database = fdb.open(cluster);
Executor executor = database.getExecutor();
TupleKeyCountTree root = new TupleKeyCountTree();
DatabaseClientLogEventCounter counter = new DatabaseClientLogEventCounter(root, countReads, countWrites, countSingleKeys, countRanges, true);
TupleKeyCountTree.Printer printer = (depth, path) -> {
for (int i = 0; i < depth; i++) {
System.out.print(" ");
}
System.out.print(path.stream().map(Object::toString).collect(Collectors.joining("/")));
int percent = (path.get(0).getCount() * 100) / path.get(0).getParent().getCount();
System.out.println(" " + percent + "%");
};
int eventLimit = 10_000;
long timeLimit = 15_000;
DatabaseClientLogEvents events = DatabaseClientLogEvents.forEachEventBetweenTimestamps(database, executor, counter, start, end, eventLimit, timeLimit).join();
while (true) {
System.out.println(events.getEarliestTimestamp() + " - " + events.getLatestTimestamp());
root.hideLessThanFraction(0.10);
root.printTree(printer, "/");
if (!events.hasMore()) {
break;
}
events.forEachEventContinued(database, executor, counter, eventLimit, timeLimit).join();
}
}
use of com.apple.foundationdb.FDB in project fdb-record-layer by FoundationDB.
the class DatabaseClientLogEventsTest method main.
@SuppressWarnings("PMD.SystemPrintln")
public static void main(String[] args) {
String cluster = null;
Instant start = null;
Instant end = null;
if (args.length > 0) {
cluster = args[0];
}
if (args.length > 1) {
start = ZonedDateTime.parse(args[1]).toInstant();
}
if (args.length > 2) {
end = ZonedDateTime.parse(args[2]).toInstant();
}
FDB fdb = FDB.selectAPIVersion(630);
Database database = fdb.open(cluster);
Executor executor = database.getExecutor();
DatabaseClientLogEvents.EventConsumer consumer = (tr, event) -> {
System.out.println(event);
return AsyncUtil.DONE;
};
DatabaseClientLogEvents.forEachEventBetweenTimestamps(database, executor, consumer, start, end, Integer.MAX_VALUE, Long.MAX_VALUE).join();
}
use of com.apple.foundationdb.FDB in project fdb-record-layer by FoundationDB.
the class RankedSetTest method setUp.
@BeforeEach
public void setUp() throws Exception {
FDB fdb = FDB.instance();
if (TRACE) {
NetworkOptions options = fdb.options();
options.setTraceEnable("/tmp");
options.setTraceLogGroup("RankedSetTest");
}
this.db = fdb.open();
this.rsSubspace = DirectoryLayer.getDefault().createOrOpen(db, PathUtil.from(getClass().getSimpleName())).get();
db.run(tr -> {
tr.clear(rsSubspace.range());
return null;
});
}
Aggregations