@Test public void shouldReturnServiceUnavailableWithNoLocationIfDeleteFailsBecauseNotLeaderExceptionIsThrownWithTheLeaderSetToNull() { when(distributedStore.delete(KEY)).thenReturn(Futures.<Void>immediateFailedFuture(new NotLeaderException(self, null))); assertThatValidDeleteRequestReturnsErrorStatus(ClientResponse.Status.SERVICE_UNAVAILABLE); }
@DELETE public void delete() throws Exception { LOGGER.info("delete: {}", key); try { ListenableFuture<Void> deleteFuture = distributedStore.delete(key); deleteFuture.get(ResourceConstants.COMMAND_TIMEOUT, ResourceConstants.COMMAND_TIMEOUT_TIME_UNIT); } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof NotLeaderException) { throw createCannotSubmitCommandException((NotLeaderException) cause); } else { throw e; } } }
KeyResource { @DELETE public void delete() throws Exception { LOGGER.info("delete: {}", key); try { ListenableFuture<Void> deleteFuture = distributedStore.delete(key); deleteFuture.get(ResourceConstants.COMMAND_TIMEOUT, ResourceConstants.COMMAND_TIMEOUT_TIME_UNIT); } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof NotLeaderException) { throw createCannotSubmitCommandException((NotLeaderException) cause); } else { throw e; } } } }
KeyResource { @DELETE public void delete() throws Exception { LOGGER.info("delete: {}", key); try { ListenableFuture<Void> deleteFuture = distributedStore.delete(key); deleteFuture.get(ResourceConstants.COMMAND_TIMEOUT, ResourceConstants.COMMAND_TIMEOUT_TIME_UNIT); } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof NotLeaderException) { throw createCannotSubmitCommandException((NotLeaderException) cause); } else { throw e; } } } KeyResource(String key, Set<ClusterMember> members, DistributedStore distributedStore); }
KeyResource { @DELETE public void delete() throws Exception { LOGGER.info("delete: {}", key); try { ListenableFuture<Void> deleteFuture = distributedStore.delete(key); deleteFuture.get(ResourceConstants.COMMAND_TIMEOUT, ResourceConstants.COMMAND_TIMEOUT_TIME_UNIT); } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof NotLeaderException) { throw createCannotSubmitCommandException((NotLeaderException) cause); } else { throw e; } } } KeyResource(String key, Set<ClusterMember> members, DistributedStore distributedStore); @GET @Produces(MediaType.APPLICATION_JSON) KeyValue get(); @PUT @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Nullable KeyValue update(SetValue setValue); @DELETE void delete(); }
KeyResource { @DELETE public void delete() throws Exception { LOGGER.info("delete: {}", key); try { ListenableFuture<Void> deleteFuture = distributedStore.delete(key); deleteFuture.get(ResourceConstants.COMMAND_TIMEOUT, ResourceConstants.COMMAND_TIMEOUT_TIME_UNIT); } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof NotLeaderException) { throw createCannotSubmitCommandException((NotLeaderException) cause); } else { throw e; } } } KeyResource(String key, Set<ClusterMember> members, DistributedStore distributedStore); @GET @Produces(MediaType.APPLICATION_JSON) KeyValue get(); @PUT @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Nullable KeyValue update(SetValue setValue); @DELETE void delete();  }