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