summaryrefslogtreecommitdiffstats
path: root/jrt
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2019-05-23 21:27:02 +0200
committerBjørn Christian Seime <bjorncs@verizonmedia.com>2019-05-23 22:01:21 +0200
commit3cf7a16ab281cc5a2bde4dd608f25e8b074efd7e (patch)
tree6368e1303ec54610c2bcefd0e4956a8013b9f639 /jrt
parentf2aaa615ebab15c614d52617268920c8fdfd1a84 (diff)
Remove usage of deprecated Method constructor
Diffstat (limited to 'jrt')
-rw-r--r--jrt/src/com/yahoo/jrt/MandatoryMethods.java15
-rw-r--r--jrt/tests/com/yahoo/jrt/AbortTest.java2
-rw-r--r--jrt/tests/com/yahoo/jrt/BackTargetTest.java24
-rw-r--r--jrt/tests/com/yahoo/jrt/DetachTest.java15
-rw-r--r--jrt/tests/com/yahoo/jrt/EchoTest.java4
-rw-r--r--jrt/tests/com/yahoo/jrt/InvokeAsyncTest.java4
-rw-r--r--jrt/tests/com/yahoo/jrt/InvokeErrorTest.java9
-rw-r--r--jrt/tests/com/yahoo/jrt/InvokeSyncTest.java16
-rw-r--r--jrt/tests/com/yahoo/jrt/InvokeVoidTest.java12
-rw-r--r--jrt/tests/com/yahoo/jrt/LatencyTest.java7
-rw-r--r--jrt/tests/com/yahoo/jrt/SessionTest.java20
-rw-r--r--jrt/tests/com/yahoo/jrt/TimeoutTest.java4
12 files changed, 58 insertions, 74 deletions
diff --git a/jrt/src/com/yahoo/jrt/MandatoryMethods.java b/jrt/src/com/yahoo/jrt/MandatoryMethods.java
index 1176884eed5..57dd40c324b 100644
--- a/jrt/src/com/yahoo/jrt/MandatoryMethods.java
+++ b/jrt/src/com/yahoo/jrt/MandatoryMethods.java
@@ -3,7 +3,6 @@ package com.yahoo.jrt;
import java.util.Collection;
-import java.util.Iterator;
class MandatoryMethods {
@@ -15,21 +14,19 @@ class MandatoryMethods {
//---------------------------------------------------------------------
Method m;
//---------------------------------------------------------------------
- m = new Method("frt.rpc.ping", "", "", this, "ping");
+ m = new Method("frt.rpc.ping", "", "", this::ping);
m.methodDesc("Method that may be used to "
+ "check if the server is online");
parent.addMethod(m);
//---------------------------------------------------------------------
- m = new Method("frt.rpc.getMethodList", "", "SSS", this,
- "getMethodList");
+ m = new Method("frt.rpc.getMethodList", "", "SSS", this::getMethodList);
m.methodDesc("Obtain a list of all available methods");
m.returnDesc(0, "names", "Method names");
m.returnDesc(1, "params", "Method parameter types");
m.returnDesc(2, "return", "Method return types");
parent.addMethod(m);
//---------------------------------------------------------------------
- m = new Method("frt.rpc.getMethodInfo", "s", "sssSSSS", this,
- "getMethodInfo");
+ m = new Method("frt.rpc.getMethodInfo", "s", "sssSSSS", this::getMethodInfo);
m.methodDesc("Obtain detailed information about a single method");
m.paramDesc (0, "methodName", "The method we want information about");
m.returnDesc(0, "desc", "Description of what the method does");
@@ -43,11 +40,11 @@ class MandatoryMethods {
//---------------------------------------------------------------------
}
- public void ping(Request req) {
+ private void ping(Request req) {
// no code needed :)
}
- public void getMethodList(Request req) {
+ private void getMethodList(Request req) {
Collection<Method> methods = parent.methodMap().values();
int cnt = methods.size();
String[] ret0_names = new String[cnt];
@@ -66,7 +63,7 @@ class MandatoryMethods {
req.returnValues().add(new StringArray(ret2_return));
}
- public void getMethodInfo(Request req) {
+ private void getMethodInfo(Request req) {
Method method = parent.methodMap().get(req.parameters().get(0).asString());
if (method == null) {
req.setError(ErrorCode.METHOD_FAILED, "No Such Method");
diff --git a/jrt/tests/com/yahoo/jrt/AbortTest.java b/jrt/tests/com/yahoo/jrt/AbortTest.java
index 9093158162d..edd74152a1c 100644
--- a/jrt/tests/com/yahoo/jrt/AbortTest.java
+++ b/jrt/tests/com/yahoo/jrt/AbortTest.java
@@ -21,7 +21,7 @@ public class AbortTest {
client = new Supervisor(new Transport());
acceptor = server.listen(new Spec(0));
target = client.connect(new Spec("localhost", acceptor.port()));
- server.addMethod(new Method("test", "i", "i", this, "rpc_test"));
+ server.addMethod(new Method("test", "i", "i", this::rpc_test));
barrier = new Test.Barrier();
}
diff --git a/jrt/tests/com/yahoo/jrt/BackTargetTest.java b/jrt/tests/com/yahoo/jrt/BackTargetTest.java
index ade24f40c55..2a0066d68a0 100644
--- a/jrt/tests/com/yahoo/jrt/BackTargetTest.java
+++ b/jrt/tests/com/yahoo/jrt/BackTargetTest.java
@@ -25,15 +25,13 @@ public class BackTargetTest {
acceptor = server.listen(new Spec(0));
target = client.connect(new Spec("localhost", acceptor.port()));
- server.addMethod(new Method("inc", "", "", this, "server_inc"));
- server.addMethod(new Method("sample_target", "", "", this,
- "server_sample_target"));
- server.addMethod(new Method("back_inc", "", "", this, "back_inc"));
+ server.addMethod(new Method("inc", "", "", this::server_inc));
+ server.addMethod(new Method("sample_target", "", "", this::server_sample_target));
+ server.addMethod(new Method("back_inc", "", "", this::back_inc));
- client.addMethod(new Method("inc", "", "", this, "client_inc"));
- client.addMethod(new Method("sample_target", "", "", this,
- "client_sample_target"));
- client.addMethod(new Method("back_inc", "", "", this, "back_inc"));
+ client.addMethod(new Method("inc", "", "", this::client_inc));
+ client.addMethod(new Method("sample_target", "", "", this::client_sample_target));
+ client.addMethod(new Method("back_inc", "", "", this::back_inc));
serverValue = 0;
clientValue = 0;
@@ -49,23 +47,23 @@ public class BackTargetTest {
server.transport().shutdown().join();
}
- public void server_inc(Request req) {
+ private void server_inc(Request req) {
serverValue++;
}
- public void server_sample_target(Request req) {
+ private void server_sample_target(Request req) {
serverBackTarget = req.target();
}
- public void client_inc(Request req) {
+ private void client_inc(Request req) {
clientValue++;
}
- public void client_sample_target(Request req) {
+ private void client_sample_target(Request req) {
clientBackTarget = req.target();
}
- public void back_inc(Request req) {
+ private void back_inc(Request req) {
Target t = req.target();
t.invokeVoid(new Request("inc"));
}
diff --git a/jrt/tests/com/yahoo/jrt/DetachTest.java b/jrt/tests/com/yahoo/jrt/DetachTest.java
index 808d029b5a5..8b107c8b61b 100644
--- a/jrt/tests/com/yahoo/jrt/DetachTest.java
+++ b/jrt/tests/com/yahoo/jrt/DetachTest.java
@@ -23,12 +23,9 @@ public class DetachTest {
acceptor = server.listen(new Spec(0));
target = client.connect(new Spec("localhost", acceptor.port()));
- server.addMethod(new Method("d_inc", "i", "i", this,
- "rpc_detach_inc"));
- server.addMethod(new Method("d_inc_r", "i", "i", this,
- "rpc_detach_inc_return"));
- server.addMethod(new Method("inc_b", "i", "i", this,
- "rpc_inc_barrier"));
+ server.addMethod(new Method("d_inc", "i", "i", this::rpc_detach_inc));
+ server.addMethod(new Method("d_inc_r", "i", "i", this::rpc_detach_inc_return));
+ server.addMethod(new Method("inc_b", "i", "i", this::rpc_inc_barrier));
receptor = new Test.Receptor();
barrier = new Test.Barrier();
}
@@ -43,21 +40,21 @@ public class DetachTest {
Request detached = null;
- public void rpc_detach_inc(Request req) {
+ private void rpc_detach_inc(Request req) {
req.detach();
int value = req.parameters().get(0).asInt32();
req.returnValues().add(new Int32Value(value + 1));
detached = req;
}
- public void rpc_detach_inc_return(Request req) {
+ private void rpc_detach_inc_return(Request req) {
req.detach();
int value = req.parameters().get(0).asInt32();
req.returnValues().add(new Int32Value(value + 1));
req.returnRequest();
}
- public void rpc_inc_barrier(Request req) {
+ private void rpc_inc_barrier(Request req) {
int value = req.parameters().get(0).asInt32();
req.returnValues().add(new Int32Value(value + 1));
receptor.put(req);
diff --git a/jrt/tests/com/yahoo/jrt/EchoTest.java b/jrt/tests/com/yahoo/jrt/EchoTest.java
index 67544d3f1d4..97139fd60ab 100644
--- a/jrt/tests/com/yahoo/jrt/EchoTest.java
+++ b/jrt/tests/com/yahoo/jrt/EchoTest.java
@@ -95,7 +95,7 @@ public class EchoTest {
client = new Supervisor(new Transport(crypto, 1));
acceptor = server.listen(new Spec(0));
target = client.connect(new Spec("localhost", acceptor.port()));
- server.addMethod(new Method("echo", "*", "*", this, "rpc_echo"));
+ server.addMethod(new Method("echo", "*", "*", this::rpc_echo));
refValues = new Values();
byte[] dataValue = { 1, 2, 3, 4 };
byte[] int8Array = { 1, 2, 3, 4 };
@@ -135,7 +135,7 @@ public class EchoTest {
server.transport().shutdown().join();
}
- public void rpc_echo(Request req) {
+ private void rpc_echo(Request req) {
if (!Test.equals(req.parameters(), refValues)) {
System.err.println("Parameters does not match reference values");
req.setError(ErrorCode.METHOD_FAILED, "parameter mismatch");
diff --git a/jrt/tests/com/yahoo/jrt/InvokeAsyncTest.java b/jrt/tests/com/yahoo/jrt/InvokeAsyncTest.java
index cdc52e9441a..92925fc1a12 100644
--- a/jrt/tests/com/yahoo/jrt/InvokeAsyncTest.java
+++ b/jrt/tests/com/yahoo/jrt/InvokeAsyncTest.java
@@ -23,7 +23,7 @@ public class InvokeAsyncTest {
client = new Supervisor(new Transport());
acceptor = server.listen(new Spec(0));
target = client.connect(new Spec("localhost", acceptor.port()));
- server.addMethod(new Method("concat", "ss", "s", this, "rpc_concat")
+ server.addMethod(new Method("concat", "ss", "s", this::rpc_concat)
.methodDesc("Concatenate 2 strings")
.paramDesc(0, "str1", "a string")
.paramDesc(1, "str2", "another string")
@@ -39,7 +39,7 @@ public class InvokeAsyncTest {
server.transport().shutdown().join();
}
- public void rpc_concat(Request req) {
+ private void rpc_concat(Request req) {
barrier.waitFor();
req.returnValues().add(new StringValue(req.parameters()
.get(0).asString() +
diff --git a/jrt/tests/com/yahoo/jrt/InvokeErrorTest.java b/jrt/tests/com/yahoo/jrt/InvokeErrorTest.java
index 4e810b71fb6..becc87a78c1 100644
--- a/jrt/tests/com/yahoo/jrt/InvokeErrorTest.java
+++ b/jrt/tests/com/yahoo/jrt/InvokeErrorTest.java
@@ -23,9 +23,8 @@ public class InvokeErrorTest {
client = new Supervisor(new Transport());
acceptor = server.listen(new Spec(0));
target = client.connect(new Spec("localhost", acceptor.port()));
- server.addMethod(new Method("test", "iib", "i", this, "rpc_test"));
- server.addMethod(new Method("test_barrier", "iib", "i", this,
- "rpc_test_barrier"));
+ server.addMethod(new Method("test", "iib", "i", this::rpc_test));
+ server.addMethod(new Method("test_barrier", "iib", "i", this::rpc_test_barrier));
barrier = new Test.Barrier();
}
@@ -37,7 +36,7 @@ public class InvokeErrorTest {
server.transport().shutdown().join();
}
- public void rpc_test(Request req) {
+ private void rpc_test(Request req) {
int value = req.parameters().get(0).asInt32();
int error = req.parameters().get(1).asInt32();
int extra = req.parameters().get(2).asInt8();
@@ -51,7 +50,7 @@ public class InvokeErrorTest {
}
}
- public void rpc_test_barrier(Request req) {
+ private void rpc_test_barrier(Request req) {
rpc_test(req);
barrier.waitFor();
}
diff --git a/jrt/tests/com/yahoo/jrt/InvokeSyncTest.java b/jrt/tests/com/yahoo/jrt/InvokeSyncTest.java
index 931001804aa..6a227575ed9 100644
--- a/jrt/tests/com/yahoo/jrt/InvokeSyncTest.java
+++ b/jrt/tests/com/yahoo/jrt/InvokeSyncTest.java
@@ -1,16 +1,16 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jrt;
+import com.yahoo.jrt.tool.RpcInvoker;
+import org.junit.After;
+import org.junit.Before;
+
import java.io.ByteArrayOutputStream;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
-import com.yahoo.jrt.tool.RpcInvoker;
-import org.junit.After;
-import org.junit.Before;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -28,12 +28,12 @@ public class InvokeSyncTest {
client = new Supervisor(new Transport());
acceptor = server.listen(new Spec(0));
target = client.connect(new Spec("localhost", acceptor.port()));
- server.addMethod(new Method("concat", "ss", "s", this, "rpc_concat")
+ server.addMethod(new Method("concat", "ss", "s", this::rpc_concat)
.methodDesc("Concatenate 2 strings")
.paramDesc(0, "str1", "a string")
.paramDesc(1, "str2", "another string")
.returnDesc(0, "ret", "str1 followed by str2"));
- server.addMethod(new Method("alltypes", "bhilfds", "s", this, "rpc_alltypes")
+ server.addMethod(new Method("alltypes", "bhilfds", "s", this::rpc_alltypes)
.methodDesc("Method taking all types of params"));
}
@@ -46,14 +46,14 @@ public class InvokeSyncTest {
server.transport().shutdown().join();
}
- public void rpc_concat(Request req) {
+ private void rpc_concat(Request req) {
req.returnValues().add(new StringValue(req.parameters()
.get(0).asString() +
req.parameters()
.get(1).asString()));
}
- public void rpc_alltypes(Request req) {
+ private void rpc_alltypes(Request req) {
req.returnValues().add(new StringValue("This was alltypes. The string param was: "+req.parameters().get(6).asString()));
}
diff --git a/jrt/tests/com/yahoo/jrt/InvokeVoidTest.java b/jrt/tests/com/yahoo/jrt/InvokeVoidTest.java
index 25e86a16445..09a8de53066 100644
--- a/jrt/tests/com/yahoo/jrt/InvokeVoidTest.java
+++ b/jrt/tests/com/yahoo/jrt/InvokeVoidTest.java
@@ -22,12 +22,12 @@ public class InvokeVoidTest {
acceptor = server.listen(new Spec(0));
target = client.connect(new Spec("localhost", acceptor.port()));
- server.addMethod(new Method("set", "i", "", this, "rpc_set")
+ server.addMethod(new Method("set", "i", "", this::rpc_set)
.methodDesc("Set the stored value")
.paramDesc(0, "value", "the new value"));
- server.addMethod(new Method("inc", "", "", this, "rpc_inc")
+ server.addMethod(new Method("inc", "", "", this::rpc_inc)
.methodDesc("Increase the stored value"));
- server.addMethod(new Method("get", "", "i", this, "rpc_get")
+ server.addMethod(new Method("get", "", "i", this::rpc_get)
.methodDesc("Get the stored value")
.returnDesc(0, "value", "the stored value"));
}
@@ -42,13 +42,13 @@ public class InvokeVoidTest {
private int value = 0;
- public void rpc_set(Request req) {
+ private void rpc_set(Request req) {
value = req.parameters().get(0).asInt32();
}
- public void rpc_inc(Request req) {
+ private void rpc_inc(Request req) {
value++;
}
- public void rpc_get(Request req) {
+ private void rpc_get(Request req) {
req.returnValues().add(new Int32Value(value));
}
diff --git a/jrt/tests/com/yahoo/jrt/LatencyTest.java b/jrt/tests/com/yahoo/jrt/LatencyTest.java
index 578ed6b14bc..97d7affd6ea 100644
--- a/jrt/tests/com/yahoo/jrt/LatencyTest.java
+++ b/jrt/tests/com/yahoo/jrt/LatencyTest.java
@@ -2,9 +2,6 @@
package com.yahoo.jrt;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;
import java.util.logging.Logger;
@@ -23,13 +20,13 @@ public class LatencyTest {
public Network(CryptoEngine crypto, int threads) throws ListenFailedException {
server = new Supervisor(new Transport(crypto, threads));
client = new Supervisor(new Transport(crypto, threads));
- server.addMethod(new Method("inc", "i", "i", this, "rpc_inc"));
+ server.addMethod(new Method("inc", "i", "i", this::rpc_inc));
acceptor = server.listen(new Spec(0));
}
public Target connect() {
return client.connect(new Spec("localhost", acceptor.port()));
}
- public void rpc_inc(Request req) {
+ private void rpc_inc(Request req) {
req.returnValues().add(new Int32Value(req.parameters().get(0).asInt32() + 1));
}
public void close() {
diff --git a/jrt/tests/com/yahoo/jrt/SessionTest.java b/jrt/tests/com/yahoo/jrt/SessionTest.java
index dc33af96e44..29d6bb21d5f 100644
--- a/jrt/tests/com/yahoo/jrt/SessionTest.java
+++ b/jrt/tests/com/yahoo/jrt/SessionTest.java
@@ -130,14 +130,10 @@ public class SessionTest implements SessionHandler {
target = client.connect(new Spec("localhost", acceptor.port()),
new Session());
- server.addMethod(new Method("set", "i", "", this,
- "rpc_set"));
- server.addMethod(new Method("get", "", "i", this,
- "rpc_get"));
- server.addMethod(new Method("call_detach", "", "", this,
- "rpc_call_detach"));
- client.addMethod(new Method("detach", "", "", this,
- "rpc_detach"));
+ server.addMethod(new Method("set", "i", "", this::rpc_set));
+ server.addMethod(new Method("get", "", "i", this::rpc_get));
+ server.addMethod(new Method("call_detach", "", "", this::rpc_call_detach));
+ client.addMethod(new Method("detach", "", "", this::rpc_detach));
receptor = new Test.Receptor();
}
@@ -197,23 +193,23 @@ public class SessionTest implements SessionHandler {
}
}
- public void rpc_set(Request req) {
+ private void rpc_set(Request req) {
Session s = (Session) req.target().getContext();
s.value(req.parameters().get(0).asInt32());
}
- public void rpc_get(Request req) {
+ private void rpc_get(Request req) {
Session s = (Session) req.target().getContext();
req.returnValues().add(new Int32Value(s.value()));
}
- public void rpc_call_detach(Request req) {
+ private void rpc_call_detach(Request req) {
Session s = (Session) req.target().getContext();
s.touch();
req.target().invokeVoid(new Request("detach"));
}
- public void rpc_detach(Request req) {
+ private void rpc_detach(Request req) {
Session s = (Session) req.target().getContext();
if (s == null) {
Session.setError();
diff --git a/jrt/tests/com/yahoo/jrt/TimeoutTest.java b/jrt/tests/com/yahoo/jrt/TimeoutTest.java
index 61822554a65..4bcc99c8519 100644
--- a/jrt/tests/com/yahoo/jrt/TimeoutTest.java
+++ b/jrt/tests/com/yahoo/jrt/TimeoutTest.java
@@ -22,7 +22,7 @@ public class TimeoutTest {
client = new Supervisor(new Transport());
acceptor = server.listen(new Spec(0));
target = client.connect(new Spec("localhost", acceptor.port()));
- server.addMethod(new Method("concat", "ss", "s", this, "rpc_concat")
+ server.addMethod(new Method("concat", "ss", "s", this::rpc_concat)
.methodDesc("Concatenate 2 strings")
.paramDesc(0, "str1", "a string")
.paramDesc(1, "str2", "another string")
@@ -38,7 +38,7 @@ public class TimeoutTest {
server.transport().shutdown().join();
}
- public void rpc_concat(Request req) {
+ private void rpc_concat(Request req) {
barrier.waitFor();
req.returnValues().add(new StringValue(req.parameters()
.get(0).asString() +