Search in sources :

Example 16 with BucketId

use of com.yahoo.document.BucketId in project vespa by vespa-engine.

the class DistributionTestCase method testHierarchicalDistributionCapacity.

@Test
public void testHierarchicalDistributionCapacity() throws Exception {
    StorDistributionConfig.Builder config = buildHierarchicalConfig(6, 3, 1, "1|*", 3);
    config.group.get(1).capacity(3);
    test = new DistributionTestFactory("group-capacity").setNodeCount(getNodeCount(1, 3, 3)).setDistribution(config);
    int[] counts = new int[9];
    for (int i = 0; i < 900; ++i) {
        BucketId bucket = new BucketId(16, i);
        ++counts[test.recordResult(bucket).assertNodeCount(1).getNodes().get(0)];
    }
    int groupCount = 0;
    for (StorDistributionConfig.Group.Nodes.Builder n : config.group.get(1).nodes) {
        StorDistributionConfig.Group.Nodes node = new StorDistributionConfig.Group.Nodes(n);
        groupCount += counts[node.index()];
    }
    int avg3 = groupCount / 3;
    int avg1 = (900 - groupCount) / 6;
    double diff = 1.0 * avg3 / avg1;
    assertTrue(Arrays.toString(counts) + ": Too large diff" + diff, diff < 3.1);
    assertTrue(Arrays.toString(counts) + ": Too small diff" + diff, diff > 2.9);
}
Also used : StorDistributionConfig(com.yahoo.vespa.config.content.StorDistributionConfig) BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Example 17 with BucketId

use of com.yahoo.document.BucketId in project vespa by vespa-engine.

the class DistributionTestCase method testMinimalMovement.

@Test
public void testMinimalMovement() throws Exception {
    test = new DistributionTestFactory("minimal-movement").setClusterState(new ClusterState("distributor:4 .2.s:d"));
    DistributionTestFactory control = new DistributionTestFactory("minimal-movement-reference").setClusterState(new ClusterState("distributor:4"));
    int moved = 0;
    int staying = 0;
    for (BucketId bucket : getTestBuckets()) {
        DistributionTestFactory.Test org = control.recordResult(bucket).assertNodeCount(1);
        DistributionTestFactory.Test res = test.recordResult(bucket).assertNodeCount(1);
        if (org.getNodes().get(0) == 2) {
            assertTrue(res.getNodes().get(0) != 2);
            ++moved;
        } else {
            assertEquals(org, res);
            ++staying;
        }
    }
    assertEquals(63, moved);
    assertEquals(81, staying);
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState) BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Example 18 with BucketId

use of com.yahoo.document.BucketId in project vespa by vespa-engine.

the class BucketStatsPrinterTest method mockBucketStatsRetriever.

@Before
public void mockBucketStatsRetriever() throws BucketStatsException {
    retriever = mock(BucketStatsRetriever.class);
    when(retriever.getBucketIdForType(any(), any())).thenReturn(new BucketId(0x42));
    when(retriever.retrieveBucketList(any(), any())).thenReturn(Collections.emptyList());
    when(retriever.retrieveBucketStats(any(), any(), any(), any())).thenReturn("");
}
Also used : BucketId(com.yahoo.document.BucketId) Before(org.junit.Before)

Example 19 with BucketId

use of com.yahoo.document.BucketId in project vespa by vespa-engine.

the class BucketStatsRetrieverTest method testRetrieveBucketStats.

@Test
public void testRetrieveBucketStats() throws BucketStatsException {
    String docId = "id:ns:type::another";
    String bucketInfo = "I like turtles!";
    BucketId bucketId = bucketIdFactory.getBucketId(new DocumentId(docId));
    StatBucketReply reply = new StatBucketReply();
    reply.setResults(bucketInfo);
    when(mockedSession.syncSend(any())).thenReturn(reply);
    String result = createRetriever().retrieveBucketStats(ClientParameters.SelectionType.DOCUMENT, docId, bucketId, bucketSpace);
    verify(mockedSession, times(1)).syncSend(any());
    assertEquals(bucketInfo, result);
}
Also used : StatBucketReply(com.yahoo.documentapi.messagebus.protocol.StatBucketReply) DocumentId(com.yahoo.document.DocumentId) BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Example 20 with BucketId

use of com.yahoo.document.BucketId 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)

Aggregations

BucketId (com.yahoo.document.BucketId)67 BucketIdFactory (com.yahoo.document.BucketIdFactory)25 Test (org.junit.Test)24 ProgressToken (com.yahoo.documentapi.ProgressToken)22 VisitorIterator (com.yahoo.documentapi.VisitorIterator)19 DocumentId (com.yahoo.document.DocumentId)10 ClusterState (com.yahoo.vdslib.state.ClusterState)6 GetBucketListReply (com.yahoo.documentapi.messagebus.protocol.GetBucketListReply)5 Error (com.yahoo.messagebus.Error)5 TreeSet (java.util.TreeSet)5 MessageBusVisitorSession (com.yahoo.documentapi.messagebus.MessageBusVisitorSession)4 ParseException (com.yahoo.document.select.parser.ParseException)3 com.yahoo.documentapi (com.yahoo.documentapi)3 LoadType (com.yahoo.documentapi.messagebus.loadtypes.LoadType)3 com.yahoo.documentapi.messagebus.protocol (com.yahoo.documentapi.messagebus.protocol)3 com.yahoo.messagebus (com.yahoo.messagebus)3 Result (com.yahoo.messagebus.Result)3 Route (com.yahoo.messagebus.routing.Route)3 RouteSpec (com.yahoo.messagebus.routing.RouteSpec)3 RoutingTable (com.yahoo.messagebus.routing.RoutingTable)3