diff options
Diffstat (limited to 'container-search')
5 files changed, 36 insertions, 22 deletions
diff --git a/container-search/src/main/java/com/yahoo/fs4/mplex/FS4Channel.java b/container-search/src/main/java/com/yahoo/fs4/mplex/FS4Channel.java index a4b61803285..adfc63d02f7 100644 --- a/container-search/src/main/java/com/yahoo/fs4/mplex/FS4Channel.java +++ b/container-search/src/main/java/com/yahoo/fs4/mplex/FS4Channel.java @@ -105,8 +105,7 @@ public class FS4Channel { * @param packetCount the number of packets to receive, or -1 to receive any number up to eol/error */ public BasicPacket[] receivePackets(long timeout, int packetCount) - throws InvalidChannelException, ChannelTimeoutException - { + throws InvalidChannelException, ChannelTimeoutException { ensureValid(); List<BasicPacket> packets = new ArrayList<>(12); diff --git a/container-search/src/main/java/com/yahoo/prelude/query/CompositeItem.java b/container-search/src/main/java/com/yahoo/prelude/query/CompositeItem.java index eee9949d831..ff74a8779c1 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/CompositeItem.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/CompositeItem.java @@ -219,7 +219,7 @@ public abstract class CompositeItem extends Item { copy.subitems = new java.util.ArrayList<>(); for (Item subItem : subitems) { Item subItemCopy = subItem.clone(); - copy.adding(subItemCopy); + subItemCopy.setParent(copy); copy.subitems.add(subItemCopy); } fixConnexity(copy); diff --git a/container-search/src/main/java/com/yahoo/search/cluster/ClusterSearcher.java b/container-search/src/main/java/com/yahoo/search/cluster/ClusterSearcher.java index ff099d4d490..e99199d85f7 100644 --- a/container-search/src/main/java/com/yahoo/search/cluster/ClusterSearcher.java +++ b/container-search/src/main/java/com/yahoo/search/cluster/ClusterSearcher.java @@ -160,7 +160,7 @@ public abstract class ClusterSearcher<T> extends PingableSearcher implements Nod result = robustSearch(query, execution, connection); - if (!shouldRetry(query, result)) + if ( ! shouldRetry(query, result)) return result; if (query.getTraceLevel() >= 6) diff --git a/container-search/src/test/java/com/yahoo/fs4/mplex/BackendTestCase.java b/container-search/src/test/java/com/yahoo/fs4/mplex/BackendTestCase.java index 9db956d4b8b..ed6dbf84bd2 100644 --- a/container-search/src/test/java/com/yahoo/fs4/mplex/BackendTestCase.java +++ b/container-search/src/test/java/com/yahoo/fs4/mplex/BackendTestCase.java @@ -139,7 +139,6 @@ public class BackendTestCase { 0,0,0,1, 0, 0, 0, 42, 0, 0, 0, 127, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 1 }; - @Before public void setUp() throws Exception { logger = Logger.getLogger(Backend.class.getName()); initUseParent = logger.getUseParentHandlers(); @@ -150,7 +149,6 @@ public class BackendTestCase { backend = listeners.getBackend(server.host.getHostString(), server.host.getPort()); } - @After public void tearDown() throws Exception { listeners.deconstruct(); server.dispatch.socket.close(); @@ -160,7 +158,21 @@ public class BackendTestCase { } @Test - public void testBackend() throws IOException, InvalidChannelException { + public void testAll() throws Exception { + setUp(); + doTestBackend(); + tearDown(); + + setUp(); + doTestPinging(); + tearDown(); + + setUp(); + doRequireStatistics(); + tearDown(); + } + + public void doTestBackend() throws IOException, InvalidChannelException { FS4Channel channel = backend.openChannel(); Query q = new Query("/?query=a"); BasicPacket[] b = null; @@ -178,8 +190,7 @@ public class BackendTestCase { channel.close(); } - @Test - public void testPinging() throws IOException, InvalidChannelException { + public void doTestPinging() throws IOException, InvalidChannelException { FS4Channel channel = backend.openPingChannel(); BasicPacket[] b = null; server.dispatch.setNoChannel(); @@ -196,8 +207,7 @@ public class BackendTestCase { channel.close(); } - @Test - public void requireStatistics() throws IOException, InvalidChannelException { + public void doRequireStatistics() throws IOException, InvalidChannelException { FS4Channel channel = backend.openPingChannel(); server.dispatch.channelId = -1; server.dispatch.packetData = PONG; diff --git a/container-search/src/test/java/com/yahoo/search/cluster/test/ClusteredConnectionTestCase.java b/container-search/src/test/java/com/yahoo/search/cluster/test/ClusteredConnectionTestCase.java index a565c171b98..a35cbdf289e 100644 --- a/container-search/src/test/java/com/yahoo/search/cluster/test/ClusteredConnectionTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/cluster/test/ClusteredConnectionTestCase.java @@ -34,7 +34,7 @@ public class ClusteredConnectionTestCase { connections.add(connection0); connections.add(connection1); connections.add(connection2); - MyBackend myBackend=new MyBackend(new ComponentId("test"),connections); + MyBackend myBackend = new MyBackend(new ComponentId("test"), connections); Result r; r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0)); @@ -67,7 +67,7 @@ public class ClusteredConnectionTestCase { assertEquals("from:0",r.hits().get(0).getId().stringValue()); connection0.setInService(false); - r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0)); + r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0)); assertEquals("Failed calling connection '2' in searcher 'test' for query 'NULL': Connection failed", r.hits().getError().getDetailedMessage()); @@ -134,7 +134,7 @@ public class ClusteredConnectionTestCase { private String id; - private boolean inService=true; + private boolean inService = true; public Connection(String id) { this.id=id; @@ -142,12 +142,12 @@ public class ClusteredConnectionTestCase { /** This is used for both fill, pings and queries */ public String getResponse() { - if (!inService) throw new RuntimeException("Connection failed"); + if ( ! inService) throw new RuntimeException("Connection failed"); return id; } public void setInService(boolean inservice) { - this.inService=inservice; + this.inService = inservice; } public String toString() { @@ -164,25 +164,25 @@ public class ClusteredConnectionTestCase { private static class MyBackend extends ClusterSearcher<Connection> { public MyBackend(ComponentId componentId, List<Connection> connections) { - super(componentId,connections,false); + super(componentId,connections, false); } @Override - public Result search(Query query,Execution execution,Connection connection) { - Result result=new Result(query); + public Result search(Query query,Execution execution, Connection connection) { + Result result = new Result(query); result.hits().add(new Hit("from:" + connection.getResponse())); return result; } @Override - public void fill(Result result,String summary,Execution execution,Connection connection) { + public void fill(Result result,String summary, Execution execution, Connection connection) { result.hits().get(0).fields().put("filled",connection.getResponse()); } @Override public Pong ping(Ping ping,Connection connection) { - Pong pong=new Pong(); - if (connection.getResponse()==null) + Pong pong = new Pong(); + if (connection.getResponse() == null) pong.addError(ErrorMessage.createBackendCommunicationError("No ping response from '" + connection + "'")); return pong; } @@ -203,6 +203,11 @@ public class ClusteredConnectionTestCase { return hashValue; } + @Override + public long getTimeout() { + return 5000; + } + } } |