use of com.yahoo.document.BucketId in project vespa by vespa-engine.
the class DistributionTestCase method testAllDistributionBits.
@Test
public void testAllDistributionBits() throws Exception {
for (int distbits = 0; distbits <= 32; ++distbits) {
test = new DistributionTestFactory("distbit" + distbits).setClusterState(new ClusterState("bits:" + distbits + " distributor:10"));
List<BucketId> buckets = new ArrayList<>();
for (int i = 0; i < 100; ++i) {
buckets.add(new BucketId(distbits, i));
}
for (BucketId bucket : buckets) {
DistributionTestFactory.Test t = test.recordResult(bucket).assertNodeCount(1);
}
test.recordTestResults();
test = null;
}
}
use of com.yahoo.document.BucketId in project vespa by vespa-engine.
the class DistributionTestCase method testSimple.
@Test
public void testSimple() {
test = new DistributionTestFactory("simple");
List<BucketId> buckets = getTestBuckets();
Integer[] nodes = { 6, 3, 4, 8, 8, 8, 8, 8, 8, 3 };
for (int i = 0; i < buckets.size(); ++i) {
BucketId bucket = buckets.get(i);
DistributionTestFactory.Test t = test.recordResult(bucket).assertNodeCount(1);
if (i < nodes.length)
t.assertNodeUsed(nodes[i]);
}
}
use of com.yahoo.document.BucketId in project vespa by vespa-engine.
the class DistributionTestCase method clusterDownInHierarchicSetupThrowsNoDistributorsAvailableException.
@Test(expected = Distribution.NoDistributorsAvailableException.class)
public void clusterDownInHierarchicSetupThrowsNoDistributorsAvailableException() throws Exception {
ClusterState clusterState = new ClusterState("cluster:d");
StorDistributionConfig.Builder config = buildHierarchicalConfig(4, 4, 1, "1|1|1|*", 1);
Distribution distr = new Distribution(new StorDistributionConfig(config));
distr.getIdealDistributorNode(clusterState, new BucketId(16, 0), "uim");
}
use of com.yahoo.document.BucketId in project vespa by vespa-engine.
the class DistributionTestCase method getTestBuckets.
private static List<BucketId> getTestBuckets(int minUsedBits) {
List<BucketId> buckets = new ArrayList<>();
assertTrue(minUsedBits <= 16);
// Get a set of buckets from the same split level
for (int i = 16; i <= 18; ++i) {
for (int j = 0; j < 20; ++j) {
buckets.add(new BucketId(i, j));
}
}
// Get a few random buckets at every split level.
Random randomized = new Random(413);
long randValue = randomized.nextLong();
for (int i = minUsedBits; i < 58; ++i) {
buckets.add(new BucketId(i, randValue));
}
randValue = randomized.nextLong();
for (int i = minUsedBits; i < 58; ++i) {
buckets.add(new BucketId(i, randValue));
}
return Collections.unmodifiableList(buckets);
}
use of com.yahoo.document.BucketId in project vespa by vespa-engine.
the class DistributionTestCase method writeDistributionTest.
/**
* The java side runs unit tests first. Thus java side will generate the distribution tests that the C++ side will verify equality with.
* The tests serialized by the java side will be checked into version control, such that C++ side can test without java side. When one of the sides
* change, the failing side can be identified by checking if the serialized files are modified from what is checked into version control.
*/
private void writeDistributionTest(String name, String clusterState, String distributionConfig) throws IOException, ParseException, Distribution.TooFewBucketBitsInUseException, Distribution.NoDistributorsAvailableException {
writeFileAtomically("src/tests/distribution/testdata/java_" + name + ".cfg", distributionConfig);
writeFileAtomically("src/tests/distribution/testdata/java_" + name + ".state", clusterState);
StringWriter sw = new StringWriter();
Distribution distribution = new Distribution("raw:" + distributionConfig);
ClusterState state = new ClusterState(clusterState);
long maxBucket = 1;
for (int distributionBits = 0; distributionBits <= 32; ++distributionBits) {
state.setDistributionBits(distributionBits);
RandomGen randomizer = new RandomGen(distributionBits);
for (int bucketIndex = 0; bucketIndex < 64; ++bucketIndex) {
if (bucketIndex >= maxBucket)
break;
long bucketId = bucketIndex;
// Use random bucket if we dont test all
if (maxBucket > 64) {
bucketId = randomizer.nextLong();
}
BucketId bucket = new BucketId(distributionBits, bucketId);
for (int redundancy = 1; redundancy <= distribution.getRedundancy(); ++redundancy) {
int distributorIndex = distribution.getIdealDistributorNode(state, bucket, "uim");
sw.write(distributionBits + " " + bucket.withoutCountBits() + " " + redundancy + " " + distributorIndex + "\n");
}
}
maxBucket = maxBucket << 1;
}
writeFileAtomically("src/tests/distribution/testdata/java_" + name + ".distribution", sw.toString());
}
Aggregations