Enum BlockingInAsyncDetection
- java.lang.Object
-
- java.lang.Enum<BlockingInAsyncDetection>
-
- com.apple.foundationdb.record.provider.foundationdb.BlockingInAsyncDetection
-
- All Implemented Interfaces:
Serializable
,Comparable<BlockingInAsyncDetection>
@API(EXPERIMENTAL) public enum BlockingInAsyncDetection extends Enum<BlockingInAsyncDetection>
Indicates whetherFDBDatabase.asyncToSync(FDBStoreTimer, FDBStoreTimer.Wait, java.util.concurrent.CompletableFuture)
orFDBRecordContext.asyncToSync(FDBStoreTimer.Wait, java.util.concurrent.CompletableFuture)
should attempt to detect when it is being called from an asynchronous context and, if so, how it should react to this fact. When this situation is detected, there are two scenarios that need to be dealt with:- Completed future - the future that was to be waited on is completed. In some code, this is
normal expected behavior; some prior logic ensured that the future was completed and subsequent calls
just "know" they won't block. Of course, it is possible that there is no such logic and the
future was simply accidentally completed. As a result there are two options for dealing with
the presence of such completed futures:
IGNORE_COMPLETE
(silently ignore) orWARN_COMPLETE
(log a warning). - Non-complete future - the future that was to be waited on is not complete. There is (typically) no
circumstance in which this is acceptable, so the options to react to this scenario are
EXCEPTION_BLOCKING
(throw an exception) orWARN_BLOCKING
(log a warning).
-
-
Enum Constant Summary
Enum Constants Enum Constant Description DISABLED
The detection of blocking in an asynchronous context is disabled.IGNORE_COMPLETE_EXCEPTION_BLOCKING
WhenasyncToSync()
is called in an asynchronous context and the future it is passed would block, an exception will be thrown.IGNORE_COMPLETE_WARN_BLOCKING
WhenasyncToSync()
is called in an asynchronous context and the future it is passed would block, a warning is logged.WARN_COMPLETE_EXCEPTION_BLOCKING
WhenasyncToSync()
is called in an asynchronous context and the future it is passed would block, an exception will be thrown; however, if the future is complete, then a warning will be logged.WARN_COMPLETE_WARN_BLOCKING
WhenasyncToSync()
is called in an asynchronous context, a warning is logged.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
ignoreComplete()
Indicates how to react if the future passed intoasyncToSync()
was completed.boolean
throwExceptionOnBlocking()
Indicates how to react if the future passed intoasyncToSync()
has not yet been completed.static BlockingInAsyncDetection
valueOf(String name)
Returns the enum constant of this type with the specified name.static BlockingInAsyncDetection[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
DISABLED
public static final BlockingInAsyncDetection DISABLED
The detection of blocking in an asynchronous context is disabled.
-
IGNORE_COMPLETE_EXCEPTION_BLOCKING
public static final BlockingInAsyncDetection IGNORE_COMPLETE_EXCEPTION_BLOCKING
WhenasyncToSync()
is called in an asynchronous context and the future it is passed would block, an exception will be thrown.
-
WARN_COMPLETE_EXCEPTION_BLOCKING
public static final BlockingInAsyncDetection WARN_COMPLETE_EXCEPTION_BLOCKING
WhenasyncToSync()
is called in an asynchronous context and the future it is passed would block, an exception will be thrown; however, if the future is complete, then a warning will be logged.
-
IGNORE_COMPLETE_WARN_BLOCKING
public static final BlockingInAsyncDetection IGNORE_COMPLETE_WARN_BLOCKING
WhenasyncToSync()
is called in an asynchronous context and the future it is passed would block, a warning is logged.
-
WARN_COMPLETE_WARN_BLOCKING
public static final BlockingInAsyncDetection WARN_COMPLETE_WARN_BLOCKING
WhenasyncToSync()
is called in an asynchronous context, a warning is logged.
-
-
Method Detail
-
values
public static BlockingInAsyncDetection[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (BlockingInAsyncDetection c : BlockingInAsyncDetection.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static BlockingInAsyncDetection valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
ignoreComplete
public boolean ignoreComplete()
Indicates how to react if the future passed intoasyncToSync()
was completed. A return value oftrue
indicates that this situation should be ignored, and a value offalse
indicates that a warning should be logged.- Returns:
- whether completed future should be ignored
-
throwExceptionOnBlocking
public boolean throwExceptionOnBlocking()
Indicates how to react if the future passed intoasyncToSync()
has not yet been completed. A return value oftrue
indicates that this situation should result in aBlockingInAsyncException
, and a value offalse
indicates that a warning should be logged.- Returns:
- whether non-completed future should throw an exception
-
-