コード例 #1
0
 @Override
 public void beforeStop() {
   /* Marks the containers as being shut down and cancels all requests, but
    * doesn't wait for termination.
    */
   flushRequests.shutdown();
   stageRequests.shutdown();
   removeRequests.shutdown();
 }
コード例 #2
0
 /**
  * Removes a set of files from nearline storage.
  *
  * @param hsmInstance instance name of nearline storage
  * @param files files to remove
  * @param callback callback notified for every file removed
  */
 public void remove(
     String hsmInstance, Iterable<URI> files, CompletionHandler<Void, URI> callback) {
   try {
     NearlineStorage nearlineStorage = hsmSet.getNearlineStorageByName(hsmInstance);
     checkArgument(nearlineStorage != null, "No such nearline storage: " + hsmInstance);
     removeRequests.addAll(nearlineStorage, files, callback);
   } catch (RuntimeException e) {
     for (URI location : files) {
       callback.failed(e, location);
     }
   }
 }
コード例 #3
0
  @PreDestroy
  public void shutdown() throws InterruptedException {
    flushRequests.shutdown();
    stageRequests.shutdown();
    removeRequests.shutdown();

    if (timeoutFuture != null) {
      timeoutFuture.cancel(false);
    }
    repository.removeListener(this);

    /* Waits for all requests to have finished. This is blocking to avoid that the
     * repository gets closed nearline storage requests have had a chance to finish.
     */
    long deadline = System.currentTimeMillis() + 3000;
    if (flushRequests.awaitTermination(
        deadline - System.currentTimeMillis(), TimeUnit.MILLISECONDS)) {
      if (stageRequests.awaitTermination(
          deadline - System.currentTimeMillis(), TimeUnit.MILLISECONDS)) {
        removeRequests.awaitTermination(
            deadline - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
      }
    }
  }
コード例 #4
0
 public int getRemoveQueueSize() {
   return removeRequests.getCount(AbstractRequest.State.QUEUED);
 }
コード例 #5
0
 public int getActiveRemoveJobs() {
   return removeRequests.getCount(AbstractRequest.State.ACTIVE)
       + removeRequests.getCount(AbstractRequest.State.CANCELED);
 }