Search in sources :

Example 6 with InvalidChannelException

use of com.yahoo.fs4.mplex.InvalidChannelException in project vespa by vespa-engine.

the class BackendTestCase method testBackend.

@Test
public void testBackend() throws IOException, InvalidChannelException {
    FS4Channel channel = backend.openChannel();
    Query q = new Query("/?query=a");
    BasicPacket[] b = null;
    int channelId = channel.getChannelId();
    server.dispatch.channelId = channelId;
    assertTrue(backend.sendPacket(QueryPacket.create(q), channelId));
    try {
        b = channel.receivePackets(1000, 1);
    } catch (ChannelTimeoutException e) {
        fail("Could not get packets from simulated backend.");
    }
    assertEquals(1, b.length);
    assertEquals(217, b[0].getCode());
    channel.close();
}
Also used : BasicPacket(com.yahoo.fs4.BasicPacket) Query(com.yahoo.search.Query) ChannelTimeoutException(com.yahoo.fs4.ChannelTimeoutException) Test(org.junit.Test)

Example 7 with InvalidChannelException

use of com.yahoo.fs4.mplex.InvalidChannelException in project vespa by vespa-engine.

the class BackendTestCase method requireStatistics.

@Test
public void requireStatistics() throws IOException, InvalidChannelException {
    FS4Channel channel = backend.openPingChannel();
    server.dispatch.channelId = -1;
    server.dispatch.packetData = PONG;
    assertTrue(channel.sendPacket(new PingPacket()));
    try {
        channel.receivePackets(1000, 1);
    } catch (ChannelTimeoutException e) {
        fail("Could not get packets from simulated backend.");
    }
    BackendStatistics stats = backend.getStatistics();
    assertEquals(1, stats.totalConnections());
}
Also used : PingPacket(com.yahoo.fs4.PingPacket) ChannelTimeoutException(com.yahoo.fs4.ChannelTimeoutException) BackendStatistics(com.yahoo.fs4.mplex.Backend.BackendStatistics) Test(org.junit.Test)

Aggregations

BasicPacket (com.yahoo.fs4.BasicPacket)6 ChannelTimeoutException (com.yahoo.fs4.ChannelTimeoutException)6 PingPacket (com.yahoo.fs4.PingPacket)4 GetDocSumsPacket (com.yahoo.fs4.GetDocSumsPacket)3 Packet (com.yahoo.fs4.Packet)3 InvalidChannelException (com.yahoo.fs4.mplex.InvalidChannelException)3 IOException (java.io.IOException)3 PongPacket (com.yahoo.fs4.PongPacket)2 QueryPacket (com.yahoo.fs4.QueryPacket)2 QueryResultPacket (com.yahoo.fs4.QueryResultPacket)2 FS4Channel (com.yahoo.fs4.mplex.FS4Channel)2 Query (com.yahoo.search.Query)2 Test (org.junit.Test)2 CompressionType (com.yahoo.compress.CompressionType)1 BackendStatistics (com.yahoo.fs4.mplex.Backend.BackendStatistics)1 Pong (com.yahoo.prelude.Pong)1 Result (com.yahoo.search.Result)1 Hit (com.yahoo.search.result.Hit)1 ArrayList (java.util.ArrayList)1