com.hazelcast.util
Class FutureUtil

java.lang.Object
  extended by com.hazelcast.util.FutureUtil

public final class FutureUtil
extends Object

This utility class contains convenience methods to work with multiple futures at the same time, e.g. waitWithDeadline(java.util.Collection, long, java.util.concurrent.TimeUnit, long, java.util.concurrent.TimeUnit)


Nested Class Summary
static interface FutureUtil.ExceptionHandler
          Internally used interface to define behavior of the FutureUtil methods when exceptions arise
 
Field Summary
static FutureUtil.ExceptionHandler IGNORE_ALL_EXCEPT_LOG_MEMBER_LEFT
          Ignores all exceptions but still logs MemberLeftException per future and just tries to finish all of the given ones.
static FutureUtil.ExceptionHandler IGNORE_ALL_EXCEPTIONS
          Ignores all exceptions
static FutureUtil.ExceptionHandler RETHROW_EVERYTHING
          Just rethrows all exceptions
static FutureUtil.ExceptionHandler RETHROW_EXECUTION_EXCEPTION
          This ExceptionHandler rethrows ExecutionExceptions and logs MemberLeftExceptions to the log.
static FutureUtil.ExceptionHandler RETHROW_TRANSACTION_EXCEPTION
          Handler for transaction specific rethrown of exceptions.
 
Method Summary
static FutureUtil.ExceptionHandler logAllExceptions(ILogger logger, Level level)
          This ExceptionHandler rethrows ExecutionExceptions and logs MemberLeftExceptions to the log.
static FutureUtil.ExceptionHandler logAllExceptions(ILogger logger, String message, Level level)
          This ExceptionHandler rethrows ExecutionExceptions and logs MemberLeftExceptions to the log.
static FutureUtil.ExceptionHandler logAllExceptions(Level level)
          This ExceptionHandler rethrows ExecutionExceptions and logs MemberLeftExceptions to the log.
static FutureUtil.ExceptionHandler logAllExceptions(String message, Level level)
          This ExceptionHandler rethrows ExecutionExceptions and logs MemberLeftExceptions to the log.
static
<V> Collection<V>
returnWithDeadline(Collection<Future<V>> futures, long timeout, TimeUnit timeUnit)
           
static
<V> Collection<V>
returnWithDeadline(Collection<Future<V>> futures, long timeout, TimeUnit timeUnit, FutureUtil.ExceptionHandler exceptionHandler)
           
static
<V> Collection<V>
returnWithDeadline(Collection<Future<V>> futures, long overallTimeout, TimeUnit overallTimeUnit, long perFutureTimeout, TimeUnit perFutureTimeUnit)
           
static
<V> Collection<V>
returnWithDeadline(Collection<Future<V>> futures, long overallTimeout, TimeUnit overallTimeUnit, long perFutureTimeout, TimeUnit perFutureTimeUnit, FutureUtil.ExceptionHandler exceptionHandler)
           
static void waitWithDeadline(Collection<Future> futures, long timeout, TimeUnit timeUnit)
           
static void waitWithDeadline(Collection<Future> futures, long timeout, TimeUnit timeUnit, FutureUtil.ExceptionHandler exceptionHandler)
           
static void waitWithDeadline(Collection<Future> futures, long overallTimeout, TimeUnit overallTimeUnit, long perFutureTimeout, TimeUnit perFutureTimeUnit)
           
static void waitWithDeadline(Collection<Future> futures, long overallTimeout, TimeUnit overallTimeUnit, long perFutureTimeout, TimeUnit perFutureTimeUnit, FutureUtil.ExceptionHandler exceptionHandler)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RETHROW_EVERYTHING

public static final FutureUtil.ExceptionHandler RETHROW_EVERYTHING
Just rethrows all exceptions


IGNORE_ALL_EXCEPTIONS

public static final FutureUtil.ExceptionHandler IGNORE_ALL_EXCEPTIONS
Ignores all exceptions


IGNORE_ALL_EXCEPT_LOG_MEMBER_LEFT

public static final FutureUtil.ExceptionHandler IGNORE_ALL_EXCEPT_LOG_MEMBER_LEFT
Ignores all exceptions but still logs MemberLeftException per future and just tries to finish all of the given ones. This is the default behavior if nothing else is given.


RETHROW_EXECUTION_EXCEPTION

public static final FutureUtil.ExceptionHandler RETHROW_EXECUTION_EXCEPTION
This ExceptionHandler rethrows ExecutionExceptions and logs MemberLeftExceptions to the log.


RETHROW_TRANSACTION_EXCEPTION

public static final FutureUtil.ExceptionHandler RETHROW_TRANSACTION_EXCEPTION
Handler for transaction specific rethrown of exceptions.

Method Detail

logAllExceptions

@PrivateApi
public static FutureUtil.ExceptionHandler logAllExceptions(ILogger logger,
                                                                      String message,
                                                                      Level level)
This ExceptionHandler rethrows ExecutionExceptions and logs MemberLeftExceptions to the log.

Parameters:
logger - the ILogger instance to be used for logging
message - the log message to appear in the logs before the stacktrace
level - the log level to be used for logging

logAllExceptions

@PrivateApi
public static FutureUtil.ExceptionHandler logAllExceptions(String message,
                                                                      Level level)
This ExceptionHandler rethrows ExecutionExceptions and logs MemberLeftExceptions to the log.

Parameters:
message - the log message to appear in the logs before the stacktrace
level - the log level to be used for logging

logAllExceptions

@PrivateApi
public static FutureUtil.ExceptionHandler logAllExceptions(ILogger logger,
                                                                      Level level)
This ExceptionHandler rethrows ExecutionExceptions and logs MemberLeftExceptions to the log.

Parameters:
logger - the ILogger instance to be used for logging
level - the log level to be used for logging

logAllExceptions

@PrivateApi
public static FutureUtil.ExceptionHandler logAllExceptions(Level level)
This ExceptionHandler rethrows ExecutionExceptions and logs MemberLeftExceptions to the log.

Parameters:
level - the log level to be used for logging

returnWithDeadline

@PrivateApi
public static <V> Collection<V> returnWithDeadline(Collection<Future<V>> futures,
                                                              long timeout,
                                                              TimeUnit timeUnit)

returnWithDeadline

@PrivateApi
public static <V> Collection<V> returnWithDeadline(Collection<Future<V>> futures,
                                                              long timeout,
                                                              TimeUnit timeUnit,
                                                              FutureUtil.ExceptionHandler exceptionHandler)

returnWithDeadline

@PrivateApi
public static <V> Collection<V> returnWithDeadline(Collection<Future<V>> futures,
                                                              long overallTimeout,
                                                              TimeUnit overallTimeUnit,
                                                              long perFutureTimeout,
                                                              TimeUnit perFutureTimeUnit)

returnWithDeadline

@PrivateApi
public static <V> Collection<V> returnWithDeadline(Collection<Future<V>> futures,
                                                              long overallTimeout,
                                                              TimeUnit overallTimeUnit,
                                                              long perFutureTimeout,
                                                              TimeUnit perFutureTimeUnit,
                                                              FutureUtil.ExceptionHandler exceptionHandler)

waitWithDeadline

@PrivateApi
public static void waitWithDeadline(Collection<Future> futures,
                                               long timeout,
                                               TimeUnit timeUnit)

waitWithDeadline

@PrivateApi
public static void waitWithDeadline(Collection<Future> futures,
                                               long timeout,
                                               TimeUnit timeUnit,
                                               FutureUtil.ExceptionHandler exceptionHandler)

waitWithDeadline

@PrivateApi
public static void waitWithDeadline(Collection<Future> futures,
                                               long overallTimeout,
                                               TimeUnit overallTimeUnit,
                                               long perFutureTimeout,
                                               TimeUnit perFutureTimeUnit)

waitWithDeadline

@PrivateApi
public static void waitWithDeadline(Collection<Future> futures,
                                               long overallTimeout,
                                               TimeUnit overallTimeUnit,
                                               long perFutureTimeout,
                                               TimeUnit perFutureTimeUnit,
                                               FutureUtil.ExceptionHandler exceptionHandler)


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.