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);
}
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);
}
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("");
}
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);
}
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());
}
Aggregations