@DELETE @Path("/routeconfig") public void deleteRouteConfig(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("service-id") String serviceId) throws Exception { ProgramId programId = new ProgramId(namespaceId, appId, ProgramType.SERVICE, serviceId); routeStore.delete(programId); responder.sendStatus(HttpResponseStatus.OK); } }
@DELETE @Path("/routeconfig") public void deleteRouteConfig(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("service-id") String serviceId) throws Exception { ProgramId programId = new ProgramId(namespaceId, appId, ProgramType.SERVICE, serviceId); routeStore.delete(programId); responder.sendStatus(HttpResponseStatus.OK); } }
private void deleteRouteConfig(ApplicationId appId, ApplicationSpecification appSpec) { for (ServiceSpecification serviceSpec : appSpec.getServices().values()) { ProgramId serviceId = appId.service(serviceSpec.getName()); try { routeStore.delete(serviceId); } catch (NotFoundException ex) { // expected if a config has not been stored for that service. } } }
private void deleteRouteConfig(ApplicationId appId, ApplicationSpecification appSpec) { for (ServiceSpecification serviceSpec : appSpec.getServices().values()) { ProgramId serviceId = appId.service(serviceSpec.getName()); try { routeStore.delete(serviceId); } catch (NotFoundException ex) { // expected if a config has not been stored for that service. } } }
@Test public void testRouteStorage() throws Exception { RouteStore routeStore = new LocalRouteStore(datasetFramework, new InMemoryTxSystemClient(txManager)); ApplicationId appId = new ApplicationId("n1", "a1"); ProgramId service1 = appId.service("s1"); RouteConfig routeConfig = new RouteConfig(ImmutableMap.of("v1", 100)); routeStore.store(service1, routeConfig); Assert.assertEquals(routeConfig.getRoutes(), routeStore.fetch(service1).getRoutes()); routeStore.delete(service1); Assert.assertNotNull(routeStore.fetch(service1)); try { routeStore.delete(service1); Assert.fail("Config should have been deleted and thus a NotFoundException must have been thrown."); } catch (NotFoundException e) { // expected } } }
@Test public void testStore() throws Exception { ApplicationId appId = new ApplicationId("n1", "a1"); final ProgramId s1 = appId.service("testStore"); try (final RouteStore routeStore = new ZKRouteStore(zkClientService)) { routeStore.store(s1, new RouteConfig(TEST_ROUTE_CONFIG)); Assert.assertEquals(TEST_ROUTE_CONFIG, routeStore.fetch(s1).getRoutes()); routeStore.delete(s1); Tasks.waitFor(true, new Callable<Boolean>() { @Override public Boolean call() throws Exception { return routeStore.fetch(s1).getRoutes().isEmpty(); } }, 5L, TimeUnit.SECONDS, 100, TimeUnit.MILLISECONDS); } }