Search in sources :

Example 1 with ClusterInfoConfig

use of com.yahoo.cloud.config.ClusterInfoConfig in project vespa by vespa-engine.

the class StateRestApiV2HandlerTest method testNoMatchingSockets.

@Test
public void testNoMatchingSockets() {
    ClusterController controller = new ClusterController();
    ClusterInfoConfig config = new ClusterInfoConfig(new ClusterInfoConfig.Builder().clusterId("cluster-id").nodeCount(1));
    ClusterInfoConfig.Builder clusterConfig = new ClusterInfoConfig.Builder();
    new StateRestApiV2Handler(controller, config, StateRestApiV2Handler.testOnlyContext());
}
Also used : ClusterInfoConfig(com.yahoo.cloud.config.ClusterInfoConfig) Test(org.junit.Test)

Example 2 with ClusterInfoConfig

use of com.yahoo.cloud.config.ClusterInfoConfig in project vespa by vespa-engine.

the class StateRestApiV2HandlerTest method testMappingOfIndexToClusterControllers.

@Test
public void testMappingOfIndexToClusterControllers() {
    ClusterInfoConfig.Builder builder = new ClusterInfoConfig.Builder().clusterId("cluster-id").nodeCount(1).services(new ClusterInfoConfig.Services.Builder().index(1).hostname("host-1").ports(new ClusterInfoConfig.Services.Ports.Builder().number(80).tags("state http")).ports(new ClusterInfoConfig.Services.Ports.Builder().number(81).tags("ignored port http"))).services(new ClusterInfoConfig.Services.Builder().index(3).hostname("host-3").ports(new ClusterInfoConfig.Services.Ports.Builder().number(85).tags("state http")).ports(new ClusterInfoConfig.Services.Ports.Builder().number(86).tags("foo http bar state")));
    ClusterInfoConfig config = new ClusterInfoConfig(builder);
    Map<Integer, ClusterControllerStateRestAPI.Socket> mapping = StateRestApiV2Handler.getClusterControllerSockets(config);
    Map<Integer, ClusterControllerStateRestAPI.Socket> expected = new TreeMap<>();
    expected.put(1, new ClusterControllerStateRestAPI.Socket("host-1", 80));
    expected.put(3, new ClusterControllerStateRestAPI.Socket("host-3", 85));
    assertEquals(expected, mapping);
}
Also used : TreeMap(java.util.TreeMap) ClusterControllerStateRestAPI(com.yahoo.vespa.clustercontroller.core.restapiv2.ClusterControllerStateRestAPI) ClusterInfoConfig(com.yahoo.cloud.config.ClusterInfoConfig) Test(org.junit.Test)

Example 3 with ClusterInfoConfig

use of com.yahoo.cloud.config.ClusterInfoConfig in project vespa by vespa-engine.

the class ContainerClusterTest method requireThatClusterInfoIsPopulated.

@Test
public void requireThatClusterInfoIsPopulated() {
    ContainerCluster cluster = newContainerCluster();
    ClusterInfoConfig config = getClusterInfoConfig(cluster);
    assertEquals("name", config.clusterId());
    assertEquals(2, config.nodeCount());
    assertEquals(2, config.services().size());
    Iterator<ClusterInfoConfig.Services> iterator = config.services().iterator();
    ClusterInfoConfig.Services service = iterator.next();
    assertEquals("host-c1", service.hostname());
    assertEquals(0, service.index());
    assertEquals(4, service.ports().size());
    service = iterator.next();
    assertEquals("host-c2", service.hostname());
    assertEquals(1, service.index());
    assertEquals(4, service.ports().size());
}
Also used : ClusterInfoConfig(com.yahoo.cloud.config.ClusterInfoConfig) Test(org.junit.Test)

Example 4 with ClusterInfoConfig

use of com.yahoo.cloud.config.ClusterInfoConfig in project vespa by vespa-engine.

the class RateLimitingSearcherTestCase method testRateLimiting.

@Test
public void testRateLimiting() {
    RateLimitingConfig.Builder rateLimitingConfig = new RateLimitingConfig.Builder();
    rateLimitingConfig.maxAvailableCapacity(4);
    rateLimitingConfig.capacityIncrement(2);
    rateLimitingConfig.recheckForCapacityProbability(1.0);
    ClusterInfoConfig.Builder clusterInfoConfig = new ClusterInfoConfig.Builder();
    clusterInfoConfig.clusterId("testCluster");
    clusterInfoConfig.nodeCount(4);
    ManualClock clock = new ManualClock();
    MetricReceiver.MockReceiver metric = new MetricReceiver.MockReceiver();
    Chain<Searcher> chain = new Chain<Searcher>("test", new RateLimitingSearcher(new RateLimitingConfig(rateLimitingConfig), new ClusterInfoConfig(clusterInfoConfig), metric, clock), new CostSettingSearcher());
    assertEquals("'rate' request are available initially", 2, tryRequests(chain, "id1"));
    assertTrue("However, don't reject if we dryRun", executeWasAllowed(chain, "id1", true));
    // causes 2 new requests to become available
    clock.advance(Duration.ofMillis(1500));
    assertEquals("'rate' new requests became available", 2, tryRequests(chain, "id1"));
    assertEquals("Another id", 2, tryRequests(chain, "id2"));
    clock.advance(Duration.ofMillis(1000000));
    assertEquals("'maxAvailableCapacity' request became available", 4, tryRequests(chain, "id2"));
    assertFalse("If quota is set to 0, all requests are rejected, even initially", executeWasAllowed(chain, "id3", 0));
    clock.advance(Duration.ofMillis(1000000));
    assertTrue("A single query which costs more than capacity is allowed as cost is calculated after allowing it", executeWasAllowed(chain, "id1", 8, 8, false));
    assertFalse("capacity is -4: disallowing", executeWasAllowed(chain, "id1"));
    clock.advance(Duration.ofMillis(1000));
    assertFalse("capacity is -2: disallowing", executeWasAllowed(chain, "id1"));
    clock.advance(Duration.ofMillis(1000));
    assertFalse("capacity is 0: disallowing", executeWasAllowed(chain, "id1"));
    clock.advance(Duration.ofMillis(1000));
    assertTrue(executeWasAllowed(chain, "id1"));
    // check metrics
    Map<Point, UntypedMetric> map = metric.getSnapshot().getMapForMetric("requestsOverQuota");
    assertEquals(requestsToTry - 2 + 1 + requestsToTry - 2 + 3, map.get(metric.point("id", "id1")).getCount());
    assertEquals(requestsToTry - 2 + requestsToTry - 4, map.get(metric.point("id", "id2")).getCount());
}
Also used : Chain(com.yahoo.component.chain.Chain) MetricReceiver(com.yahoo.metrics.simple.MetricReceiver) RateLimitingSearcher(com.yahoo.search.searchers.RateLimitingSearcher) Searcher(com.yahoo.search.Searcher) Point(com.yahoo.metrics.simple.Point) RateLimitingConfig(com.yahoo.search.config.RateLimitingConfig) RateLimitingSearcher(com.yahoo.search.searchers.RateLimitingSearcher) UntypedMetric(com.yahoo.metrics.simple.UntypedMetric) ManualClock(com.yahoo.test.ManualClock) ClusterInfoConfig(com.yahoo.cloud.config.ClusterInfoConfig) Test(org.junit.Test)

Aggregations

ClusterInfoConfig (com.yahoo.cloud.config.ClusterInfoConfig)4 Test (org.junit.Test)4 Chain (com.yahoo.component.chain.Chain)1 MetricReceiver (com.yahoo.metrics.simple.MetricReceiver)1 Point (com.yahoo.metrics.simple.Point)1 UntypedMetric (com.yahoo.metrics.simple.UntypedMetric)1 Searcher (com.yahoo.search.Searcher)1 RateLimitingConfig (com.yahoo.search.config.RateLimitingConfig)1 RateLimitingSearcher (com.yahoo.search.searchers.RateLimitingSearcher)1 ManualClock (com.yahoo.test.ManualClock)1 ClusterControllerStateRestAPI (com.yahoo.vespa.clustercontroller.core.restapiv2.ClusterControllerStateRestAPI)1 TreeMap (java.util.TreeMap)1