Search in sources :

Example 31 with ClusterState

use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.

the class ClusterStateRequestHandler method handle.

@Override
public StatusPageResponse handle(StatusPageServer.HttpRequest request) {
    ClusterState cs = stateVersionTracker.getVersionedClusterState();
    StatusPageResponse response = new StatusPageResponse();
    response.setContentType("text/plain");
    response.writeContent(cs.toString());
    return response;
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState) StatusPageResponse(com.yahoo.vespa.clustercontroller.core.status.statuspage.StatusPageResponse)

Example 32 with ClusterState

use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.

the class ClusterStateGenerator method generatedStateFrom.

static AnnotatedClusterState generatedStateFrom(final Params params) {
    final ContentCluster cluster = params.cluster;
    final ClusterState workingState = ClusterState.emptyState();
    final Map<Node, NodeStateReason> nodeStateReasons = new HashMap<>();
    for (final NodeInfo nodeInfo : cluster.getNodeInfo()) {
        final NodeState nodeState = computeEffectiveNodeState(nodeInfo, params);
        workingState.setNodeState(nodeInfo.getNode(), nodeState);
    }
    takeDownGroupsWithTooLowAvailability(workingState, nodeStateReasons, params);
    final Optional<ClusterStateReason> reasonToBeDown = clusterDownReason(workingState, params);
    if (reasonToBeDown.isPresent()) {
        workingState.setClusterState(State.DOWN);
    }
    workingState.setDistributionBits(inferDistributionBitCount(cluster, workingState, params));
    return new AnnotatedClusterState(workingState, reasonToBeDown, nodeStateReasons);
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState) NodeState(com.yahoo.vdslib.state.NodeState) HashMap(java.util.HashMap) Node(com.yahoo.vdslib.state.Node)

Example 33 with ClusterState

use of com.yahoo.vdslib.state.ClusterState 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 34 with ClusterState

use of com.yahoo.vdslib.state.ClusterState 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 35 with ClusterState

use of com.yahoo.vdslib.state.ClusterState 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

ClusterState (com.yahoo.vdslib.state.ClusterState)38 Test (org.junit.Test)11 NodeState (com.yahoo.vdslib.state.NodeState)10 Node (com.yahoo.vdslib.state.Node)8 BucketId (com.yahoo.document.BucketId)6 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)6 State (com.yahoo.vdslib.state.State)4 Request (com.yahoo.jrt.Request)2 Spec (com.yahoo.jrt.Spec)2 Supervisor (com.yahoo.jrt.Supervisor)2 Target (com.yahoo.jrt.Target)2 Transport (com.yahoo.jrt.Transport)2 StringWriter (java.io.StringWriter)2 HashMap (java.util.HashMap)2 ParseException (com.yahoo.document.select.parser.ParseException)1 StringValue (com.yahoo.jrt.StringValue)1 Distribution (com.yahoo.vdslib.distribution.Distribution)1 NodeType (com.yahoo.vdslib.state.NodeType)1 AnnotatedClusterState (com.yahoo.vespa.clustercontroller.core.AnnotatedClusterState)1 HostInfo (com.yahoo.vespa.clustercontroller.core.hostinfo.HostInfo)1