@Override public Future<String> getHealth() { return new CompletedFuture<>("Healthy", null); }
public T get(long timeout, TimeUnit unit) throws ExecutionException { return this.get(); } }
@Override public Future<? extends Map<String, String>> getCapabilities() { return new CompletedFuture(this.capabilities, null); }
@Override public Future<String> getDescription() { return new CompletedFuture<>("SimpleSpecExecutorInstance with URI: " + _specExecutorInstanceUri, null); }
@Override public Future<Config> getConfig() { return new CompletedFuture<>(_config, null); }
@Override public Future<? extends Map<String, String>> getCapabilities() { return new CompletedFuture<>(_capabilities, null); }
@Override public Future<Config> getConfig() { return new CompletedFuture(this.config, null); }
@Override public Future<String> getHealth() { return new CompletedFuture("Healthy", null); }
@Override public Future<String> getDescription() { return new CompletedFuture("InMemory SpecExecutorInstanceProducer", null); }
@Override public Future<? extends List<Spec>> listSpecs() { return new CompletedFuture<>(Lists.newArrayList(provisionedSpecs.values()), null); } }
@Override public Future<?> deleteSpec(URI deletedSpecURI) { if (!provisionedSpecs.containsKey(deletedSpecURI)) { throw new RuntimeException("Spec not found: " + deletedSpecURI); } provisionedSpecs.remove(deletedSpecURI); log.info(String.format("Deleted Spec with Uri: %s from this executor.", deletedSpecURI)); return new CompletedFuture(Boolean.TRUE, null); }
/** * This method returns job specs receive from Kafka. It will block if there are no job specs. * @return list of (verb, jobspecs) pairs. */ @Override public Future<? extends List<Pair<Verb, Spec>>> changedSpecs() { List<Pair<Verb, Spec>> changesSpecs = new ArrayList<>(); try { Pair<Verb, Spec> specPair = _jobSpecQueue.take(); do { changesSpecs.add(specPair); // if there are more elements then pass them along in this call specPair = _jobSpecQueue.poll(); } while (specPair != null); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } return new CompletedFuture(changesSpecs, null); }
@Override public Future<?> addSpec(Spec addedSpec) { provisionedSpecs.put(addedSpec.getUri(), addedSpec); log.info(String.format("Added Spec: %s with Uri: %s for execution on this executor.", addedSpec, addedSpec.getUri())); return new CompletedFuture(Boolean.TRUE, null); }
@Override public Future<?> updateSpec(Spec updatedSpec) { if (!provisionedSpecs.containsKey(updatedSpec.getUri())) { throw new RuntimeException("Spec not found: " + updatedSpec.getUri()); } provisionedSpecs.put(updatedSpec.getUri(), updatedSpec); log.info(String.format("Updated Spec: %s with Uri: %s for execution on this executor.", updatedSpec, updatedSpec.getUri())); return new CompletedFuture(Boolean.TRUE, null); }
return new CompletedFuture(changesSpecs, null);