Package com.arcadedb.database.async
Class DatabaseAsyncExecutorImpl
- java.lang.Object
-
- com.arcadedb.database.async.DatabaseAsyncExecutorImpl
-
- All Implemented Interfaces:
DatabaseAsyncExecutor
public class DatabaseAsyncExecutorImpl extends Object implements DatabaseAsyncExecutor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
DatabaseAsyncExecutorImpl.AsyncThread
static class
DatabaseAsyncExecutorImpl.DBAsyncStats
-
Field Summary
Fields Modifier and Type Field Description static DatabaseAsyncTask
FORCE_EXIT
-
Constructor Summary
Constructors Constructor Description DatabaseAsyncExecutorImpl(DatabaseInternal database, ContextConfiguration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
command(String language, String query, AsyncResultsetCallback callback, Object... args)
Schedules the execution of a command by specifying the language and an optional variable array of arguments.void
command(String language, String query, AsyncResultsetCallback callback, Map<String,Object> args)
Schedules the execution of a command by specifying the language and arguments in a map.void
compact(IndexInternal index)
void
createRecord(MutableDocument record, NewRecordCallback newRecordCallback)
Schedules the request to create a record.void
createRecord(MutableDocument record, NewRecordCallback newRecordCallback, ErrorCallback errorCallback)
Schedules the request to create a record.void
createRecord(Record record, String bucketName, NewRecordCallback newRecordCallback)
Schedules the request to create a record in a specific bucket.void
createRecord(Record record, String bucketName, NewRecordCallback newRecordCallback, ErrorCallback errorCallback)
Schedules the request to create a record in a specific bucket.void
deleteRecord(Record record, DeletedRecordCallback deleteRecordCallback)
Schedules the request to delete a record.void
deleteRecord(Record record, DeletedRecordCallback deleteRecordCallback, ErrorCallback errorCallback)
Schedules the request to delete a record.int
getBackPressure()
Returns the current settings for backpressure in terms of percentage from 0 (disabled) to 100 of how much the queue is full to activate backpressure.long
getCheckForStalledQueuesMaxDelay()
int
getCommitEvery()
Gets the current batch size in terms of number of operations.int
getParallelLevel()
Returns the number of executor threads for asynchronous operations.int
getSlot(int value)
DatabaseAsyncExecutorImpl.DBAsyncStats
getStats()
WALFile.FLUSH_TYPE
getTransactionSync()
Returns the current settings for asynchronous transaction syncboolean
isProcessing()
Returns true if there is any asynchronous tasks executing or scheduled.boolean
isTransactionUseWAL()
Returns the current settings if the WAL (Write Ahead Log - Transaction Journal) is active for asynchronous operations.void
kill()
Test only API.void
newEdge(Vertex sourceVertex, String edgeType, RID destinationVertexRID, boolean bidirectional, boolean light, NewEdgeCallback callback, Object... properties)
Schedules the creation of an edge between two vertices.void
newEdgeByKeys(String sourceVertexType, String[] sourceVertexKeyNames, Object[] sourceVertexKeyValues, String destinationVertexType, String[] destinationVertexKeyNames, Object[] destinationVertexKeyValues, boolean createVertexIfNotExist, String edgeType, boolean bidirectional, boolean lightWeight, NewEdgeCallback callback, Object... properties)
Schedules the request to creates a new edge between two vertices specifying the key/value pairs to lookup for both source and destination vertices.void
newEdgeByKeys(String sourceVertexType, String sourceVertexKeyName, Object sourceVertexKeyValue, String destinationVertexType, String destinationVertexKeyName, Object destinationVertexKeyValue, boolean createVertexIfNotExist, String edgeType, boolean bidirectional, boolean lightWeight, NewEdgeCallback callback, Object... properties)
Schedules the request to creates a new edge between two vertices specifying the key/value pairs to lookup for both source and destination vertices.void
onError(ErrorCallback callback)
Defines a global callback to handle all the errors from asynchronous operations.void
onError(Throwable e)
void
onOk()
void
onOk(OkCallback callback)
Defines a global callback to handle all the returns from asynchronous operations completed without errors.void
query(String language, String query, AsyncResultsetCallback callback, Object... args)
Schedules the execution of a query as an idempotent (read only) command by specifying the language and an optional variable array of arguments.void
query(String language, String query, AsyncResultsetCallback callback, Map<String,Object> args)
Schedules the execution of a query as an idempotent (read only) command by specifying the language and arguments in a map.void
scanType(String typeName, boolean polymorphic, DocumentCallback callback)
Schedules the scan of the records contained in all the buckets defined by a type.void
scanType(String typeName, boolean polymorphic, DocumentCallback callback, ErrorRecordCallback errorRecordCallback)
Schedules the scan of the records contained in all the buckets defined by a type.boolean
scheduleTask(int slot, DatabaseAsyncTask task, boolean waitIfQueueIsFull, int applyBackPressureOnPercentage)
Schedule a task to be executed by parallel executors.void
setBackPressure(int percentage)
Sets when the threshold when the backpressure is used.void
setCheckForStalledQueuesMaxDelay(long checkForStalledQueuesMaxDelay)
void
setCommitEvery(int commitEvery)
Sets the amount of operations contained in a batch to be automatically committed when the batch is full.void
setParallelLevel(int parallelLevel)
Changes the number of executor threads for asynchronous operations.void
setTransactionSync(WALFile.FLUSH_TYPE transactionSync)
Sets the WAL (Write Ahead Log - Transaction Journal) flush strategy for asynchronous operations.void
setTransactionUseWAL(boolean transactionUseWAL)
Changes the setting on using the WAL (Write Ahead Log - Transaction Journal) for asynchronous operations.void
transaction(BasicDatabase.TransactionScope txBlock)
Schedules the request to execute a lambda in the transaction scope.void
transaction(BasicDatabase.TransactionScope txBlock, int retries)
Schedules the request to execute a lambda in the transaction scope.void
transaction(BasicDatabase.TransactionScope txBlock, int retries, OkCallback ok, ErrorCallback error)
Schedules the request to execute a lambda in the transaction scope.void
transaction(BasicDatabase.TransactionScope txBlock, int retries, OkCallback ok, ErrorCallback error, int slot)
Schedules the request to execute a lambda in the transaction scope.void
updateRecord(MutableDocument record, UpdatedRecordCallback updateRecordCallback)
Schedules the request to update a record.void
updateRecord(MutableDocument record, UpdatedRecordCallback updateRecordCallback, ErrorCallback errorCallback)
Schedules the request to update a record.void
waitCompletion()
Waits for the completion of all the pending tasks.boolean
waitCompletion(long timeout)
Waits for the completion of all the pending tasks.
-
-
-
Field Detail
-
FORCE_EXIT
public static final DatabaseAsyncTask FORCE_EXIT
-
-
Constructor Detail
-
DatabaseAsyncExecutorImpl
public DatabaseAsyncExecutorImpl(DatabaseInternal database, ContextConfiguration configuration)
-
-
Method Detail
-
getStats
public DatabaseAsyncExecutorImpl.DBAsyncStats getStats()
-
setTransactionUseWAL
public void setTransactionUseWAL(boolean transactionUseWAL)
Description copied from interface:DatabaseAsyncExecutor
Changes the setting on using the WAL (Write Ahead Log - Transaction Journal) for asynchronous operations. The default setting is true = WAL enabled. Disabling the WAL is not recommended for online operations, but it can be used for the initial load/import of the database.- Specified by:
setTransactionUseWAL
in interfaceDatabaseAsyncExecutor
- Parameters:
transactionUseWAL
- true to enable WAL for asynchronous operations, otherwise false
-
isTransactionUseWAL
public boolean isTransactionUseWAL()
Description copied from interface:DatabaseAsyncExecutor
Returns the current settings if the WAL (Write Ahead Log - Transaction Journal) is active for asynchronous operations.- Specified by:
isTransactionUseWAL
in interfaceDatabaseAsyncExecutor
- Returns:
- true if active, otherwise false
-
getTransactionSync
public WALFile.FLUSH_TYPE getTransactionSync()
Description copied from interface:DatabaseAsyncExecutor
Returns the current settings for asynchronous transaction sync- Specified by:
getTransactionSync
in interfaceDatabaseAsyncExecutor
- Returns:
- NO (no flush), YES_NOMETADATA (flush only data, no metadata), YES_FULL (full flush)
-
setTransactionSync
public void setTransactionSync(WALFile.FLUSH_TYPE transactionSync)
Description copied from interface:DatabaseAsyncExecutor
Sets the WAL (Write Ahead Log - Transaction Journal) flush strategy for asynchronous operations.- Specified by:
setTransactionSync
in interfaceDatabaseAsyncExecutor
- Parameters:
transactionSync
- The new value contained in the enum: `NO` (no flush), `YES_NOMETADATA` (flush only data, no metadata), `YES_FULL` (full flush)- See Also:
Database.setWALFlush(WALFile.FLUSH_TYPE)
-
getCheckForStalledQueuesMaxDelay
public long getCheckForStalledQueuesMaxDelay()
-
setCheckForStalledQueuesMaxDelay
public void setCheckForStalledQueuesMaxDelay(long checkForStalledQueuesMaxDelay)
-
onOk
public void onOk(OkCallback callback)
Description copied from interface:DatabaseAsyncExecutor
Defines a global callback to handle all the returns from asynchronous operations completed without errors.- Specified by:
onOk
in interfaceDatabaseAsyncExecutor
- Parameters:
callback
- Callback invoked when an asynchronous operation succeeds
-
onError
public void onError(ErrorCallback callback)
Description copied from interface:DatabaseAsyncExecutor
Defines a global callback to handle all the errors from asynchronous operations.- Specified by:
onError
in interfaceDatabaseAsyncExecutor
- Parameters:
callback
- Callback invoked when an asynchronous operation fails
-
compact
public void compact(IndexInternal index)
-
waitCompletion
public void waitCompletion()
Description copied from interface:DatabaseAsyncExecutor
Waits for the completion of all the pending tasks.- Specified by:
waitCompletion
in interfaceDatabaseAsyncExecutor
-
waitCompletion
public boolean waitCompletion(long timeout)
Description copied from interface:DatabaseAsyncExecutor
Waits for the completion of all the pending tasks.- Specified by:
waitCompletion
in interfaceDatabaseAsyncExecutor
- Parameters:
timeout
- timeout in milliseconds- Returns:
- true if returns before the timeout expires or any interruptions, otherwise false
-
query
public void query(String language, String query, AsyncResultsetCallback callback, Object... args)
Description copied from interface:DatabaseAsyncExecutor
Schedules the execution of a query as an idempotent (read only) command by specifying the language and an optional variable array of arguments.- Specified by:
query
in interfaceDatabaseAsyncExecutor
- Parameters:
language
- The language to use between the supported ones ("sql", "gremlin", "cypher", "graphql", "mongo", etc.)query
- The command to be interpreted in the specified language as a stringcallback
- Callback to manage the query resultargs
- (optional) Arguments to pass to the command as a variable length array
-
query
public void query(String language, String query, AsyncResultsetCallback callback, Map<String,Object> args)
Description copied from interface:DatabaseAsyncExecutor
Schedules the execution of a query as an idempotent (read only) command by specifying the language and arguments in a map.- Specified by:
query
in interfaceDatabaseAsyncExecutor
- Parameters:
language
- The language to use between the supported ones ("sql", "gremlin", "cypher", "graphql", "mongo", etc.)query
- The command to be interpreted in the specified language as a stringcallback
- Callback to manage the query resultargs
- Arguments to pass to the command as a map of name/values
-
command
public void command(String language, String query, AsyncResultsetCallback callback, Object... args)
Description copied from interface:DatabaseAsyncExecutor
Schedules the execution of a command by specifying the language and an optional variable array of arguments.- Specified by:
command
in interfaceDatabaseAsyncExecutor
- Parameters:
language
- The language to use between the supported ones ("sql", "gremlin", "cypher", "graphql", "mongo", etc.)query
- The command to be interpreted in the specified language as a stringcallback
- Callback to manage the command resultargs
- (optional) Arguments to pass to the command as a variable length array
-
command
public void command(String language, String query, AsyncResultsetCallback callback, Map<String,Object> args)
Description copied from interface:DatabaseAsyncExecutor
Schedules the execution of a command by specifying the language and arguments in a map.- Specified by:
command
in interfaceDatabaseAsyncExecutor
- Parameters:
language
- The language to use between the supported ones ("sql", "gremlin", "cypher", "graphql", "mongo", etc.)query
- The command to be interpreted in the specified language as a stringcallback
- Callback to manage the command resultargs
- Arguments to pass to the command as a map of name/values
-
scanType
public void scanType(String typeName, boolean polymorphic, DocumentCallback callback)
Description copied from interface:DatabaseAsyncExecutor
Schedules the scan of the records contained in all the buckets defined by a type. This operation scans in sequence each bucket looking for documents, vertices and edges. For each record found a call to #DocumentCallback.onRecord is invoked. If the callback returns false, the scan is terminated, otherwise it continues to the next record.- Specified by:
scanType
in interfaceDatabaseAsyncExecutor
- Parameters:
typeName
- The name of the typepolymorphic
- true if the records of all the subtypes must be included, otherwise only the records strictly contained in the #typeName will be scannedcallback
- Callback to handle the loaded record document. Returns false to interrupt the scan operation, otherwise true to continue till the end
-
scanType
public void scanType(String typeName, boolean polymorphic, DocumentCallback callback, ErrorRecordCallback errorRecordCallback)
Description copied from interface:DatabaseAsyncExecutor
Schedules the scan of the records contained in all the buckets defined by a type. This operation scans in sequence each bucket looking for documents, vertices and edges. For each record found a call to #DocumentCallback.onRecord is invoked. If the callback returns false, the scan is terminated, otherwise it continues to the next record.- Specified by:
scanType
in interfaceDatabaseAsyncExecutor
- Parameters:
typeName
- The name of the typepolymorphic
- true if the records of all the subtypes must be included, otherwise only the records strictly contained in the #typeName will be scannedcallback
- Callback to handle the loaded record document. Returns false to interrupt the scan operation, otherwise true to continue till the enderrorRecordCallback
- Callback used in case of error during the scan
-
transaction
public void transaction(BasicDatabase.TransactionScope txBlock)
Description copied from interface:DatabaseAsyncExecutor
Schedules the request to execute a lambda in the transaction scope. In case an exception is thrown inside the lambda method, the transaction is rolled back.- Specified by:
transaction
in interfaceDatabaseAsyncExecutor
- Parameters:
txBlock
- Transaction lambda to execute
-
transaction
public void transaction(BasicDatabase.TransactionScope txBlock, int retries)
Description copied from interface:DatabaseAsyncExecutor
Schedules the request to execute a lambda in the transaction scope. In case an exception is thrown inside the lambda method, the transaction is rolled back. The difference with the methodDatabaseAsyncExecutor.transaction(Database.TransactionScope)
is that in case the NeedRetryException exception is thrown, the * transaction is re-executed for a number of retries.- Specified by:
transaction
in interfaceDatabaseAsyncExecutor
- Parameters:
txBlock
- Transaction lambda to executeretries
- Number of retries in case the NeedRetryException exception is thrown
-
transaction
public void transaction(BasicDatabase.TransactionScope txBlock, int retries, OkCallback ok, ErrorCallback error)
Description copied from interface:DatabaseAsyncExecutor
Schedules the request to execute a lambda in the transaction scope. In case an exception is thrown inside the lambda method, the transaction is rolled back. The difference with the methodDatabaseAsyncExecutor.transaction(Database.TransactionScope)
is that in case the NeedRetryException exception is thrown, the transaction is re-executed for a number of retries.- Specified by:
transaction
in interfaceDatabaseAsyncExecutor
- Parameters:
txBlock
- Transaction lambda to executeretries
- Number of retries in case the NeedRetryException exception is thrownok
- Callback executed in case the transaction is committederror
- Callback executed in case of error after the transaction is rolled back
-
transaction
public void transaction(BasicDatabase.TransactionScope txBlock, int retries, OkCallback ok, ErrorCallback error, int slot)
Description copied from interface:DatabaseAsyncExecutor
Schedules the request to execute a lambda in the transaction scope. In case an exception is thrown inside the lambda method, the transaction is rolled back. The difference with the methodDatabaseAsyncExecutor.transaction(Database.TransactionScope)
is that in case the NeedRetryException exception is thrown, the transaction is re-executed for a number of retries. The slot parameter is useful to avoid concurrency in particular use cases.- Specified by:
transaction
in interfaceDatabaseAsyncExecutor
- Parameters:
txBlock
- Transaction lambda to executeretries
- Number of retries in case the NeedRetryException exception is thrownok
- Callback executed in case the transaction is committederror
- Callback executed in case of error after the transaction is rolled backslot
- slot number to execute the transaction
-
createRecord
public void createRecord(MutableDocument record, NewRecordCallback newRecordCallback)
Description copied from interface:DatabaseAsyncExecutor
Schedules the request to create a record. If the record is created successfully, the callback @NewRecordCallback
is executed.- Specified by:
createRecord
in interfaceDatabaseAsyncExecutor
- Parameters:
record
- Record to createnewRecordCallback
- Callback invoked after the record has been created
-
createRecord
public void createRecord(MutableDocument record, NewRecordCallback newRecordCallback, ErrorCallback errorCallback)
Description copied from interface:DatabaseAsyncExecutor
Schedules the request to create a record. If the record is created successfully, the callback @NewRecordCallback
is executed.- Specified by:
createRecord
in interfaceDatabaseAsyncExecutor
- Parameters:
record
- Record to createnewRecordCallback
- Callback invoked after the record has been createderrorCallback
- Callback invoked in case of error
-
createRecord
public void createRecord(Record record, String bucketName, NewRecordCallback newRecordCallback)
Description copied from interface:DatabaseAsyncExecutor
Schedules the request to create a record in a specific bucket. The bucket must be one defined in the schema to store the records of the current type. If the record is created successfully, the callback @NewRecordCallback
is executed.- Specified by:
createRecord
in interfaceDatabaseAsyncExecutor
- Parameters:
record
- Record to createnewRecordCallback
- Callback invoked after the record has been created
-
createRecord
public void createRecord(Record record, String bucketName, NewRecordCallback newRecordCallback, ErrorCallback errorCallback)
Description copied from interface:DatabaseAsyncExecutor
Schedules the request to create a record in a specific bucket. The bucket must be one defined in the schema to store the records of the current type. If the record is created successfully, the callback @NewRecordCallback
is executed.- Specified by:
createRecord
in interfaceDatabaseAsyncExecutor
- Parameters:
record
- Record to createnewRecordCallback
- Callback invoked after the record has been createderrorCallback
- Callback invoked in case of error
-
updateRecord
public void updateRecord(MutableDocument record, UpdatedRecordCallback updateRecordCallback)
Description copied from interface:DatabaseAsyncExecutor
Schedules the request to update a record. If the record is updated successfully, the callback @UpdatedRecordCallback
is executed.- Specified by:
updateRecord
in interfaceDatabaseAsyncExecutor
- Parameters:
record
- Record to updateupdateRecordCallback
- Callback invoked after the record has been updated
-
updateRecord
public void updateRecord(MutableDocument record, UpdatedRecordCallback updateRecordCallback, ErrorCallback errorCallback)
Description copied from interface:DatabaseAsyncExecutor
Schedules the request to update a record. If the record is updated successfully, the callback @UpdatedRecordCallback
is executed.- Specified by:
updateRecord
in interfaceDatabaseAsyncExecutor
- Parameters:
record
- Record to updateupdateRecordCallback
- Callback invoked after the record has been updatederrorCallback
- Callback invoked in case of error
-
deleteRecord
public void deleteRecord(Record record, DeletedRecordCallback deleteRecordCallback)
Description copied from interface:DatabaseAsyncExecutor
Schedules the request to delete a record. If the record is deleted successfully, the callback @DeletedRecordCallback
is executed.- Specified by:
deleteRecord
in interfaceDatabaseAsyncExecutor
- Parameters:
record
- Record to deletedeleteRecordCallback
- Callback invoked after the record has been deleted
-
deleteRecord
public void deleteRecord(Record record, DeletedRecordCallback deleteRecordCallback, ErrorCallback errorCallback)
Description copied from interface:DatabaseAsyncExecutor
Schedules the request to delete a record. If the record is deleted successfully, the callback @DeletedRecordCallback
is executed.- Specified by:
deleteRecord
in interfaceDatabaseAsyncExecutor
- Parameters:
record
- Record to deletedeleteRecordCallback
- Callback invoked after the record has been deletederrorCallback
- Callback invoked in case of error
-
newEdge
public void newEdge(Vertex sourceVertex, String edgeType, RID destinationVertexRID, boolean bidirectional, boolean light, NewEdgeCallback callback, Object... properties)
Description copied from interface:DatabaseAsyncExecutor
Schedules the creation of an edge between two vertices. If the edge is created successfully, the callback @NewEdgeCallback
is executed.- Specified by:
newEdge
in interfaceDatabaseAsyncExecutor
- Parameters:
sourceVertex
- Source vertex instanceedgeType
- Type of the edge to create. The type must be defined in the schema beforehanddestinationVertexRID
- Destination vertex id as @RID
bidirectional
- True to create a bidirectional edge. Using bidirectional edges is always the recommended setting, unless advanced fine-tuning on performanceslight
- True to create a light-weight edge. Using bidirectional edges is always the recommended setting, unless advanced fine-tuning on performancescallback
- Callback invoked when the edge is createdproperties
- Initial properties to set to the new edge as a variable argument array with key/value pairs
-
newEdgeByKeys
public void newEdgeByKeys(String sourceVertexType, String sourceVertexKeyName, Object sourceVertexKeyValue, String destinationVertexType, String destinationVertexKeyName, Object destinationVertexKeyValue, boolean createVertexIfNotExist, String edgeType, boolean bidirectional, boolean lightWeight, NewEdgeCallback callback, Object... properties)
Description copied from interface:DatabaseAsyncExecutor
Schedules the request to creates a new edge between two vertices specifying the key/value pairs to lookup for both source and destination vertices. The direction of the edge is from source to destination. This API is useful for bulk import of edges.- Specified by:
newEdgeByKeys
in interfaceDatabaseAsyncExecutor
- Parameters:
sourceVertexType
- Source vertex type namesourceVertexKeyName
- Source vertex keysourceVertexKeyValue
- Source vertex valuedestinationVertexType
- Destination vertex type namedestinationVertexKeyName
- Destination vertex keydestinationVertexKeyValue
- Source vertex valuecreateVertexIfNotExist
- True to create vertices if the lookup did not find the vertices. This is valid for both source and destination vertices. In case the vertices are implicitly created, only the properties specified in keys and values will be setedgeType
- Type of the edge to create. The type must be defined in the schema beforehandbidirectional
- True to create a bidirectional edge. Using bidirectional edges is always the recommended setting, unless advanced fine-tuning on performanceslightWeight
- True to create a light-weight edge. Using bidirectional edges is always the recommended setting, unless advanced fine-tuning on performancescallback
- Callback invoked when the edge is createdproperties
- Initial properties to set to the new edge as a variable argument array with key/value pairs- See Also:
DatabaseAsyncExecutor.newEdgeByKeys(String, String, Object, String, String, Object, boolean, String, boolean, boolean, NewEdgeCallback, Object...)
,DatabaseAsyncExecutor.newEdgeByKeys(String, String[], Object[], String, String[], Object[], boolean, String, boolean, boolean, NewEdgeCallback, Object...)
-
newEdgeByKeys
public void newEdgeByKeys(String sourceVertexType, String[] sourceVertexKeyNames, Object[] sourceVertexKeyValues, String destinationVertexType, String[] destinationVertexKeyNames, Object[] destinationVertexKeyValues, boolean createVertexIfNotExist, String edgeType, boolean bidirectional, boolean lightWeight, NewEdgeCallback callback, Object... properties)
Description copied from interface:DatabaseAsyncExecutor
Schedules the request to creates a new edge between two vertices specifying the key/value pairs to lookup for both source and destination vertices. The direction of the edge is from source to destination. This API is useful for bulk import of edges.- Specified by:
newEdgeByKeys
in interfaceDatabaseAsyncExecutor
- Parameters:
sourceVertexType
- Source vertex type namesourceVertexKeyNames
- Source vertex keyssourceVertexKeyValues
- Source vertex valuesdestinationVertexType
- Destination vertex type namedestinationVertexKeyNames
- Destination vertex keysdestinationVertexKeyValues
- Source vertex valuescreateVertexIfNotExist
- True to create vertices if the lookup did not find the vertices. This is valid for both source and destination vertices. In case the vertices are implicitly created, only the properties specified in keys and values will be setedgeType
- Type of the edge to create. The type must be defined in the schema beforehandbidirectional
- True to create a bidirectional edge. Using bidirectional edges is always the recommended setting, unless advanced fine-tuning on performanceslightWeight
- True to create a light-weight edge. Using bidirectional edges is always the recommended setting, unless advanced fine-tuning on performancescallback
- Callback invoked when the edge is createdproperties
- Initial properties to set to the new edge as a variable argument array with key/value pairs- See Also:
DatabaseAsyncExecutor.newEdgeByKeys(String, String, Object, String, String, Object, boolean, String, boolean, boolean, NewEdgeCallback, Object...)
,DatabaseAsyncExecutor.newEdgeByKeys(String, String[], Object[], String, String[], Object[], boolean, String, boolean, boolean, NewEdgeCallback, Object...)
-
kill
public void kill()
Test only API.- Specified by:
kill
in interfaceDatabaseAsyncExecutor
-
close
public void close()
-
getParallelLevel
public int getParallelLevel()
Description copied from interface:DatabaseAsyncExecutor
Returns the number of executor threads for asynchronous operations.- Specified by:
getParallelLevel
in interfaceDatabaseAsyncExecutor
- Returns:
- the number of executor threads for asynchronous operations
-
setParallelLevel
public void setParallelLevel(int parallelLevel)
Description copied from interface:DatabaseAsyncExecutor
Changes the number of executor threads for asynchronous operations. It is recommended to keep this number equals or lower than the actual cores available on the server.- Specified by:
setParallelLevel
in interfaceDatabaseAsyncExecutor
- Parameters:
parallelLevel
- Number of executor threads
-
getBackPressure
public int getBackPressure()
Description copied from interface:DatabaseAsyncExecutor
Returns the current settings for backpressure in terms of percentage from 0 (disabled) to 100 of how much the queue is full to activate backpressure. The default setting is 0 (disabled).- Specified by:
getBackPressure
in interfaceDatabaseAsyncExecutor
- Returns:
- A value from 0 to 100. 0 means backpressure disabled
-
setBackPressure
public void setBackPressure(int percentage)
Description copied from interface:DatabaseAsyncExecutor
Sets when the threshold when the backpressure is used. The percentage is how much the asynchronous queue is full before the backpressure kicks in. When the backpressure is active, the request to enqueue asynchronous operations is delayed exponentially with the amount of free slots in the queue. The default setting is 0 (disabled).- Specified by:
setBackPressure
in interfaceDatabaseAsyncExecutor
- Parameters:
percentage
- Value from 0 (disabled) to 100 of how much the queue is full to activate backpressure
-
getCommitEvery
public int getCommitEvery()
Description copied from interface:DatabaseAsyncExecutor
Gets the current batch size in terms of number of operations.- Specified by:
getCommitEvery
in interfaceDatabaseAsyncExecutor
- Returns:
- The batch size in terms of number of operations
- See Also:
DatabaseAsyncExecutor.setCommitEvery(int)
-
setCommitEvery
public void setCommitEvery(int commitEvery)
Description copied from interface:DatabaseAsyncExecutor
Sets the amount of operations contained in a batch to be automatically committed when the batch is full. The default value is defined inGlobalConfiguration.ASYNC_TX_BATCH_SIZE
. If the size of the batch of operations is 0, then no automatic commit is performed.- Specified by:
setCommitEvery
in interfaceDatabaseAsyncExecutor
- Parameters:
commitEvery
- Number of operations in a batch- See Also:
DatabaseAsyncExecutor.getCommitEvery()
-
onOk
public void onOk()
- Specified by:
onOk
in interfaceDatabaseAsyncExecutor
-
onError
public void onError(Throwable e)
- Specified by:
onError
in interfaceDatabaseAsyncExecutor
-
scheduleTask
public boolean scheduleTask(int slot, DatabaseAsyncTask task, boolean waitIfQueueIsFull, int applyBackPressureOnPercentage)
Schedule a task to be executed by parallel executors.- Parameters:
slot
- slot idtask
- task to schedulewaitIfQueueIsFull
- true to wait in case the queue is full, otherwise false- Returns:
- true if the task has been scheduled, otherwise false
-
getSlot
public int getSlot(int value)
-
isProcessing
public boolean isProcessing()
Description copied from interface:DatabaseAsyncExecutor
Returns true if there is any asynchronous tasks executing or scheduled.- Specified by:
isProcessing
in interfaceDatabaseAsyncExecutor
-
-