Final commit

This commit is contained in:
Armin Friedl 2019-05-12 13:06:49 +02:00
parent 71fe2b4dc6
commit fd0f5b0a9b
5 changed files with 41 additions and 5 deletions

View file

@ -20,7 +20,7 @@ using namespace std;
#define BATCH_MAX 4096
int main(int argc, char** argv) {
util::bytestr key("db53d9bbd1f3a83b094eeca7dd970bd85b492fa2");
util::bytestr key("9e42601eeaedc244e15f17375adb0e2cd08efdc9");
if (argc < 4) {
cout << "Invalid argument count" << endl;

View file

@ -2,7 +2,7 @@
case $1 in
cnc)
setsid scp /home/armin/dev/btcollider/cnc/CnC/cnc.jar btcollider:~
scp /home/armin/dev/btcollider/cnc/CnC/cnc.jar btcollider:~
;;
doc)
cd docker && make

View file

@ -24,6 +24,8 @@ public class CnC {
public static final int MAX_BITS = 62;
public static void main(String[] args) {
log.info("Version 2.1");
if (args.length < 2 || args.length > 3) {
System.out
.println("USAGE: java -jar cnc.jar <succFile Path> <dumpFile Path> [loadDump Path]");
@ -33,7 +35,7 @@ public class CnC {
String succFile = args[0];
String dumpFile = args[1];
KeyServer kts = KSFactory.build(54, 30, 90, TimeUnit.MINUTES, 0.65f);
KeyServer kts = KSFactory.build(31, 26, 90, TimeUnit.MINUTES, 0.65f);
if (args.length == 3) {
log.info("Undumping from {}", args[2]);
try (InputStream is = new FileInputStream(args[2])) {

View file

@ -22,6 +22,7 @@ public class KeyTreeServer implements KeyServer {
private KeyTree root;
private int index;
private int depth;
private ScheduledExecutorService es;
public KeyTreeServer(int index, int depth, long maxWorkSpan, long pruneKey) {
assert Math.pow(2, CnC.MAX_BITS) <= Long.MAX_VALUE;
@ -37,7 +38,7 @@ public class KeyTreeServer implements KeyServer {
if (maxWorkSpan > 0) {
log.info("Starting KeyTree concierge with timeout {}s",
TimeUnit.MILLISECONDS.toSeconds(maxWorkSpan));
ScheduledExecutorService es = Executors.newSingleThreadScheduledExecutor();
es = Executors.newSingleThreadScheduledExecutor();
es.scheduleWithFixedDelay(new KTConcierge(root, maxWorkSpan), 0, 30, TimeUnit.SECONDS);
} else {
log.info("KeyTree concierge disabled");
@ -355,4 +356,34 @@ public class KeyTreeServer implements KeyServer {
recUndump(node.getLeft(), in);
recUndump(node.getRight(), in);
}
public void shutDown() {
es.shutdown();
try {
if (!es.awaitTermination(1, TimeUnit.MINUTES)) {
log.warn("KeyTree concierge didn't shutdown properly");
}
} catch (InterruptedException e) {
log.warn("Interrupted while trying to shutdown KeyTree concierge", e);
} finally {
if (!es.isTerminated()) {
log.warn("KeyTree concierge tasks haven't terminated properly. Trying to force shutdown.");
es.shutdownNow();
try {
if (!es.awaitTermination(1, TimeUnit.MINUTES)) {
log.warn("Forced concierge shutdown failed");
}
} catch (InterruptedException e) {
log.warn("Forced concierge shutdown interrupted", e);
} finally {
log.warn("KeyTree concierge couldn't be shut down");
}
} else {
log.debug("KeyTree concierge shut down");
}
}
}
}

View file

@ -49,7 +49,10 @@ public class MultiStagedServer implements KeyServer {
// This represents the actual work-horse KeyTreeServer for the current partition with
// enabled KTConcierge service.
// Needs subindex+1 because starting bit always set to 1
long subPrune = ((long) 1 << subIndex + 1) | ((((long) 1 << subIndex + 1) - 1) & pruneKey);
// Can't use subPrune because it's only valid in the first partition, but partitions are random
long subPrune = 0;
// long subPrune = ((long) 1 << subIndex + 1) | ((((long) 1 << subIndex + 1) - 1) & pruneKey);
this.secKTS = new KeyTreeServer(subIndex + 1, remainingDepth, maxWorkSpan, subPrune);
this.keyRangeBuffer = new KeyRangeBuffer(maxWorkSpan);