Search in sources :

Example 11 with ClusterDef

use of com.yahoo.vespaclient.ClusterDef in project vespa by vespa-engine.

the class OperationHandlerImpl method resolveBucketSpaceRoute.

protected BucketSpaceRoute resolveBucketSpaceRoute(Optional<String> wantedCluster, String docType) throws RestApiException {
    final List<ClusterDef> clusters = clusterEnumerator.enumerateClusters();
    ClusterDef clusterDef = resolveClusterDef(wantedCluster, clusters);
    Optional<String> targetBucketSpace = bucketSpaceResolver.clusterBucketSpaceFromDocumentType(clusterDef.getConfigId(), docType);
    if (!targetBucketSpace.isPresent()) {
        throw new RestApiException(Response.createErrorResponse(400, String.format("Document type '%s' in cluster '%s' is not mapped to a known bucket space", docType, clusterDef.getName()), RestUri.apiErrorCodes.UNKNOWN_BUCKET_SPACE));
    }
    return new BucketSpaceRoute(clusterDefToRoute(clusterDef), targetBucketSpace.get());
}
Also used : ClusterDef(com.yahoo.vespaclient.ClusterDef)

Example 12 with ClusterDef

use of com.yahoo.vespaclient.ClusterDef in project vespa by vespa-engine.

the class OperationHandlerImplTest method oneClusterMatching.

@Test()
public void oneClusterMatching() throws RestApiException {
    List<ClusterDef> clusterDef = new ArrayList<>();
    clusterDef.add(new ClusterDef("foo", "configId"));
    assertThat(toRoute(OperationHandlerImpl.resolveClusterDef(Optional.of("foo"), clusterDef)), is("[Storage:cluster=foo;clusterconfigid=configId]"));
}
Also used : ClusterDef(com.yahoo.vespaclient.ClusterDef) Test(org.junit.Test)

Example 13 with ClusterDef

use of com.yahoo.vespaclient.ClusterDef in project vespa by vespa-engine.

the class OperationHandlerImplTest method oneClusterMatchingManyAvailable.

@Test()
public void oneClusterMatchingManyAvailable() throws RestApiException {
    List<ClusterDef> clusterDef = new ArrayList<>();
    clusterDef.add(new ClusterDef("foo2", "configId2"));
    clusterDef.add(new ClusterDef("foo", "configId"));
    clusterDef.add(new ClusterDef("foo3", "configId2"));
    assertThat(toRoute(OperationHandlerImpl.resolveClusterDef(Optional.of("foo"), clusterDef)), is("[Storage:cluster=foo;clusterconfigid=configId]"));
}
Also used : ClusterDef(com.yahoo.vespaclient.ClusterDef) Test(org.junit.Test)

Example 14 with ClusterDef

use of com.yahoo.vespaclient.ClusterDef in project vespa by vespa-engine.

the class VespaFeedHandlerTestCase method testRemoveGroup.

@Test
public void testRemoveGroup() throws Exception {
    setup(null);
    context.getClusterList().getStorageClusters().add(new ClusterDef("storage", "storage/cluster.storage"));
    Result res = testRequest(HttpRequest.createTestRequest("removelocation?group=foo", com.yahoo.jdisc.http.HttpRequest.Method.PUT));
    assertEquals(1, res.messages.size());
    {
        Message m = res.messages.get(0);
        assertEquals(DocumentProtocol.MESSAGE_REMOVELOCATION, m.getType());
        String selection = ((RemoveLocationMessage) m).getDocumentSelection();
        assertEquals("storage", m.getRoute().toString());
        assertEquals("id.group=\"foo\"", selection);
    }
}
Also used : ClusterDef(com.yahoo.vespaclient.ClusterDef) Test(org.junit.Test)

Example 15 with ClusterDef

use of com.yahoo.vespaclient.ClusterDef in project vespa by vespa-engine.

the class VdsVisitTestCase method testAutoSelectClusterRoute.

@Test
public void testAutoSelectClusterRoute() throws Exception {
    List<ClusterDef> clusterDefs = new ArrayList<>();
    clusterDefs.add(new ClusterDef("storage", "content/cluster.foo/storage"));
    ClusterList clusterList = new ClusterList(clusterDefs);
    String route = VdsVisit.resolveClusterRoute(clusterList, null);
    assertEquals("[Storage:cluster=storage;clusterconfigid=content/cluster.foo/storage]", route);
}
Also used : ClusterList(com.yahoo.vespaclient.ClusterList) ClusterDef(com.yahoo.vespaclient.ClusterDef) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

ClusterDef (com.yahoo.vespaclient.ClusterDef)19 Test (org.junit.Test)16 ClusterList (com.yahoo.vespaclient.ClusterList)7 ArrayList (java.util.ArrayList)5 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)1 StaticThrottlePolicy (com.yahoo.messagebus.StaticThrottlePolicy)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 ArgumentMatcher (org.mockito.ArgumentMatcher)1