Search in sources :

Example 1 with GetBucketListReply

use of com.yahoo.documentapi.messagebus.protocol.GetBucketListReply in project vespa by vespa-engine.

the class BucketStatsRetriever method retrieveBucketList.

public List<GetBucketListReply.BucketInfo> retrieveBucketList(BucketId bucketId, String bucketSpace) throws BucketStatsException {
    GetBucketListMessage msg = new GetBucketListMessage(bucketId, bucketSpace);
    GetBucketListReply bucketListReply = sendMessage(msg, GetBucketListReply.class);
    return bucketListReply.getBuckets();
}
Also used : GetBucketListReply(com.yahoo.documentapi.messagebus.protocol.GetBucketListReply) GetBucketListMessage(com.yahoo.documentapi.messagebus.protocol.GetBucketListMessage)

Example 2 with GetBucketListReply

use of com.yahoo.documentapi.messagebus.protocol.GetBucketListReply in project vespa by vespa-engine.

the class BucketStatsRetrieverTest method testRetrieveBucketList.

@Test
public void testRetrieveBucketList() throws BucketStatsException {
    String bucketInfo = "I like turtles!";
    BucketId bucketId = bucketIdFactory.getBucketId(new DocumentId("id:ns:type::another"));
    GetBucketListReply reply = new GetBucketListReply();
    reply.getBuckets().add(new GetBucketListReply.BucketInfo(bucketId, bucketInfo));
    when(mockedSession.syncSend(any())).thenReturn(reply);
    List<GetBucketListReply.BucketInfo> bucketList = createRetriever().retrieveBucketList(bucketId, bucketSpace);
    verify(mockedSession, times(1)).syncSend(any());
    assertEquals(1, bucketList.size());
    assertEquals(bucketInfo, bucketList.get(0).getBucketInformation());
}
Also used : GetBucketListReply(com.yahoo.documentapi.messagebus.protocol.GetBucketListReply) DocumentId(com.yahoo.document.DocumentId) BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Example 3 with GetBucketListReply

use of com.yahoo.documentapi.messagebus.protocol.GetBucketListReply in project vespa by vespa-engine.

the class BucketStatsRetrieverTest method testRoute.

@Test
public void testRoute() throws BucketStatsException {
    String route = "default";
    BucketId bucketId = bucketIdFactory.getBucketId(new DocumentId("id:ns:type::another"));
    GetBucketListReply reply = new GetBucketListReply();
    reply.getBuckets().add(new GetBucketListReply.BucketInfo(bucketId, "I like turtles!"));
    when(mockedSession.syncSend(any())).thenReturn(reply);
    BucketStatsRetriever retriever = new BucketStatsRetriever(mockedFactory, route, t -> {
    });
    retriever.retrieveBucketList(new BucketId(0), bucketSpace);
    verify(mockedSession).syncSend(argThat(new ArgumentMatcher<Message>() {

        @Override
        public boolean matches(Object o) {
            return ((Message) o).getRoute().equals(Route.parse(route));
        }
    }));
}
Also used : GetBucketListReply(com.yahoo.documentapi.messagebus.protocol.GetBucketListReply) ArgumentMatcher(org.mockito.ArgumentMatcher) DocumentId(com.yahoo.document.DocumentId) BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Example 4 with GetBucketListReply

use of com.yahoo.documentapi.messagebus.protocol.GetBucketListReply in project vespa by vespa-engine.

the class BucketStatsRetrieverTest method testShouldFailOnReplyError.

@Test(expected = BucketStatsException.class)
public void testShouldFailOnReplyError() throws BucketStatsException {
    GetBucketListReply reply = new GetBucketListReply();
    reply.addError(new Error(0, "errormsg"));
    when(mockedSession.syncSend(any())).thenReturn(reply);
    createRetriever().retrieveBucketList(new BucketId(1), bucketSpace);
}
Also used : GetBucketListReply(com.yahoo.documentapi.messagebus.protocol.GetBucketListReply) Error(com.yahoo.messagebus.Error) BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Aggregations

GetBucketListReply (com.yahoo.documentapi.messagebus.protocol.GetBucketListReply)4 BucketId (com.yahoo.document.BucketId)3 Test (org.junit.Test)3 DocumentId (com.yahoo.document.DocumentId)2 GetBucketListMessage (com.yahoo.documentapi.messagebus.protocol.GetBucketListMessage)1 Error (com.yahoo.messagebus.Error)1 ArgumentMatcher (org.mockito.ArgumentMatcher)1