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