List of usage examples for java.util.concurrent CompletableFuture hashCode
@HotSpotIntrinsicCandidate public native int hashCode();
From source file:ai.grakn.client.LoaderClient.java
private void unblock(CompletableFuture<Json> status) { blocker.release(); futures.remove(status.hashCode()); }
From source file:ai.grakn.client.LoaderClient.java
/** * Send a collection of insert queries to the TasksController, blocking until * there is availability to send.//from ww w . j a v a2s.c om * * Release the semaphore when a task completes. * If there was an error communicating with the host to get the status, throw an exception. * * @param queries Queries to be inserted */ private void sendQueriesToLoader(Collection<InsertQuery> queries) { try { blocker.acquire(); } catch (InterruptedException e) { throw new RuntimeException(e); } try { String taskId = executePost(getConfiguration(queries, batchNumber.incrementAndGet())); CompletableFuture<Json> status = makeTaskCompletionFuture(taskId); // Add this status to the set of completable futures futures.put(status.hashCode(), status); // Function to execute when the task completes status.whenComplete((result, error) -> { unblock(status); if (error != null) { LOG.error(getFullStackTrace(error)); } onCompletionOfTask.accept(result); }); } catch (Throwable throwable) { LOG.error(getFullStackTrace(throwable)); blocker.release(); } }