From: David ‘Bombe’ Roden Date: Fri, 10 Jul 2015 20:09:15 +0000 (+0200) Subject: Add flag to GetNode command to include volatile data X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=33619cae4ed0a765a2f81f67e5923f4f427b177f;p=jFCPlib.git Add flag to GetNode command to include volatile data --- diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/GetNodeCommand.java b/src/main/java/net/pterodactylus/fcp/quelaton/GetNodeCommand.java index ff94622..e55c890 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/GetNodeCommand.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/GetNodeCommand.java @@ -11,5 +11,6 @@ public interface GetNodeCommand extends Executable { GetNodeCommand opennetRef(); GetNodeCommand includePrivate(); + GetNodeCommand includeVolatile(); } diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/GetNodeCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/GetNodeCommandImpl.java index 23c5ad0..51ebd73 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/GetNodeCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/GetNodeCommandImpl.java @@ -23,6 +23,7 @@ public class GetNodeCommandImpl implements GetNodeCommand { private final ConnectionSupplier connectionSupplier; private final AtomicBoolean giveOpennetRef = new AtomicBoolean(false); private final AtomicBoolean includePrivate = new AtomicBoolean(false); + private final AtomicBoolean includeVolatile = new AtomicBoolean(false); public GetNodeCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier) { this.threadPool = MoreExecutors.listeningDecorator(threadPool); @@ -42,9 +43,15 @@ public class GetNodeCommandImpl implements GetNodeCommand { } @Override + public GetNodeCommand includeVolatile() { + includeVolatile.set(true); + return this; + } + + @Override public ListenableFuture execute() { GetNode getNode = new GetNode(new RandomIdentifierGenerator().generate(), giveOpennetRef.get(), - includePrivate.get(), false); + includePrivate.get(), includeVolatile.get()); return threadPool.submit(() -> new GetNodeReplySequence().send(getNode).get()); } diff --git a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java index 1e484dc..47b787d 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -835,4 +835,34 @@ public class DefaultFcpClientTest { assertThat(nodeData.get().getARK().getPrivateURI(), is("SSK@XdHMiRl")); } + @Test + public void defaultFcpClientCanGetNodeInformationWithVolatileData() + throws InterruptedException, ExecutionException, IOException { + Future nodeData = fcpClient.getNode().includeVolatile().execute(); + connectNode(); + List lines = fcpServer.collectUntil(is("EndMessage")); + String identifier = extractIdentifier(lines); + assertThat(lines, matchesFcpMessage( + "GetNode", + "Identifier=" + identifier, + "GiveOpennetRef=false", + "WithPrivate=false", + "WithVolatile=true", + "EndMessage" + )); + fcpServer.writeLine( + "NodeData", + "Identifier=" + identifier, + "opennet=false", + "ark.pubURI=SSK@3YEf.../ark", + "ark.number=78", + "auth.negTypes=2", + "version=Fred,0.7,1.0,1466", + "lastGoodVersion=Fred,0.7,1.0,1466", + "volatile.freeJavaMemory=205706528", + "EndMessage" + ); + assertThat(nodeData.get().getVolatile("freeJavaMemory").toString(), is("205706528")); + } + }