Search in sources :

Example 31 with BucketId

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;
    }
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState) ArrayList(java.util.ArrayList) BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Example 32 with BucketId

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]);
    }
}
Also used : BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Example 33 with BucketId

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");
}
Also used : StorDistributionConfig(com.yahoo.vespa.config.content.StorDistributionConfig) ClusterState(com.yahoo.vdslib.state.ClusterState) BucketId(com.yahoo.document.BucketId) Test(org.junit.Test)

Example 34 with BucketId

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);
}
Also used : Random(java.util.Random) ArrayList(java.util.ArrayList) BucketId(com.yahoo.document.BucketId)

Example 35 with BucketId

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());
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState) StringWriter(java.io.StringWriter) BucketId(com.yahoo.document.BucketId)

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