private T timedCall()

in flume-hive-sink/src/main/java/org/apache/flume/sink/hive/HiveWriter.java [423:458]


  private <T> T timedCall(final CallRunner1<T> callRunner)
      throws TimeoutException, InterruptedException, StreamingException {
    Future<T> future = callTimeoutPool.submit(new Callable<T>() {
      @Override
      public T call() throws StreamingException, InterruptedException, Failure {
        return callRunner.call();
      }
    });

    try {
      if (callTimeout > 0) {
        return future.get(callTimeout, TimeUnit.MILLISECONDS);
      } else {
        return future.get();
      }
    } catch (TimeoutException eT) {
      future.cancel(true);
      sinkCounter.incrementConnectionFailedCount();
      throw eT;
    } catch (ExecutionException e1) {
      sinkCounter.incrementConnectionFailedCount();
      Throwable cause = e1.getCause();
      if (cause instanceof IOException) {
        throw new StreamingException("I/O Failure", (IOException) cause);
      } else if (cause instanceof StreamingException) {
        throw (StreamingException) cause;
      } else if (cause instanceof TimeoutException) {
        throw new StreamingException("Operation Timed Out.", (TimeoutException) cause);
      } else if (cause instanceof RuntimeException) {
        throw (RuntimeException) cause;
      } else if (cause instanceof InterruptedException) {
        throw (InterruptedException) cause;
      }
      throw new StreamingException(e1.getMessage(), e1);
    }
  }