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)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
command(String language, String query, AsyncResultsetCallback callback, Object... parameters)
void
command(String language, String query, AsyncResultsetCallback callback, Map<String,Object> parameters)
void
compact(IndexInternal index)
void
createRecord(MutableDocument record, NewRecordCallback newRecordCallback)
void
createRecord(Record record, String bucketName, NewRecordCallback newRecordCallback)
int
getBackPressure()
long
getCheckForStalledQueuesMaxDelay()
int
getCommitEvery()
int
getParallelLevel()
int
getSlot(int value)
DatabaseAsyncExecutorImpl.DBAsyncStats
getStats()
boolean
isTransactionUseWAL()
void
kill()
Test only API.void
newEdge(Vertex sourceVertex, String edgeType, RID destinationVertexRID, boolean bidirectional, boolean light, NewEdgeCallback callback, Object... properties)
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)
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)
void
onError(ErrorCallback callback)
void
onError(Throwable e)
void
onOk()
void
onOk(OkCallback callback)
void
query(String language, String query, AsyncResultsetCallback callback, Object... parameters)
void
query(String language, String query, AsyncResultsetCallback callback, Map<String,Object> parameters)
void
scanType(String typeName, boolean polymorphic, DocumentCallback callback)
void
scanType(String typeName, boolean polymorphic, DocumentCallback callback, ErrorRecordCallback errorRecordCallback)
boolean
scheduleTask(int slot, DatabaseAsyncTask task, boolean waitIfQueueIsFull, int applyBackPressureOnPercentage)
Schedule a task to be executed by parallel executors.void
setBackPressure(int percentage)
void
setCheckForStalledQueuesMaxDelay(long checkForStalledQueuesMaxDelay)
void
setCommitEvery(int commitEvery)
void
setParallelLevel(int parallelLevel)
void
setTransactionSync(WALFile.FLUSH_TYPE transactionSync)
void
setTransactionUseWAL(boolean transactionUseWAL)
void
transaction(Database.TransactionScope txBlock)
void
transaction(Database.TransactionScope txBlock, int retries)
void
transaction(Database.TransactionScope txBlock, int retries, OkCallback ok, ErrorCallback error)
void
updateRecord(MutableDocument record, UpdatedRecordCallback updateRecordCallback)
void
waitCompletion()
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)
-
-
Method Detail
-
getStats
public DatabaseAsyncExecutorImpl.DBAsyncStats getStats()
-
setTransactionUseWAL
public void setTransactionUseWAL(boolean transactionUseWAL)
- Specified by:
setTransactionUseWAL
in interfaceDatabaseAsyncExecutor
-
isTransactionUseWAL
public boolean isTransactionUseWAL()
- Specified by:
isTransactionUseWAL
in interfaceDatabaseAsyncExecutor
-
setTransactionSync
public void setTransactionSync(WALFile.FLUSH_TYPE transactionSync)
- Specified by:
setTransactionSync
in interfaceDatabaseAsyncExecutor
-
getCheckForStalledQueuesMaxDelay
public long getCheckForStalledQueuesMaxDelay()
-
setCheckForStalledQueuesMaxDelay
public void setCheckForStalledQueuesMaxDelay(long checkForStalledQueuesMaxDelay)
-
onOk
public void onOk(OkCallback callback)
- Specified by:
onOk
in interfaceDatabaseAsyncExecutor
-
onError
public void onError(ErrorCallback callback)
- Specified by:
onError
in interfaceDatabaseAsyncExecutor
-
compact
public void compact(IndexInternal index)
-
waitCompletion
public void waitCompletion()
- 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... parameters)
- Specified by:
query
in interfaceDatabaseAsyncExecutor
-
query
public void query(String language, String query, AsyncResultsetCallback callback, Map<String,Object> parameters)
- Specified by:
query
in interfaceDatabaseAsyncExecutor
-
command
public void command(String language, String query, AsyncResultsetCallback callback, Object... parameters)
- Specified by:
command
in interfaceDatabaseAsyncExecutor
-
command
public void command(String language, String query, AsyncResultsetCallback callback, Map<String,Object> parameters)
- Specified by:
command
in interfaceDatabaseAsyncExecutor
-
scanType
public void scanType(String typeName, boolean polymorphic, DocumentCallback callback)
- Specified by:
scanType
in interfaceDatabaseAsyncExecutor
-
scanType
public void scanType(String typeName, boolean polymorphic, DocumentCallback callback, ErrorRecordCallback errorRecordCallback)
- Specified by:
scanType
in interfaceDatabaseAsyncExecutor
-
transaction
public void transaction(Database.TransactionScope txBlock)
- Specified by:
transaction
in interfaceDatabaseAsyncExecutor
-
transaction
public void transaction(Database.TransactionScope txBlock, int retries)
- Specified by:
transaction
in interfaceDatabaseAsyncExecutor
-
transaction
public void transaction(Database.TransactionScope txBlock, int retries, OkCallback ok, ErrorCallback error)
- Specified by:
transaction
in interfaceDatabaseAsyncExecutor
-
createRecord
public void createRecord(MutableDocument record, NewRecordCallback newRecordCallback)
- Specified by:
createRecord
in interfaceDatabaseAsyncExecutor
-
createRecord
public void createRecord(Record record, String bucketName, NewRecordCallback newRecordCallback)
- Specified by:
createRecord
in interfaceDatabaseAsyncExecutor
-
updateRecord
public void updateRecord(MutableDocument record, UpdatedRecordCallback updateRecordCallback)
- Specified by:
updateRecord
in interfaceDatabaseAsyncExecutor
-
newEdge
public void newEdge(Vertex sourceVertex, String edgeType, RID destinationVertexRID, boolean bidirectional, boolean light, NewEdgeCallback callback, Object... properties)
- Specified by:
newEdge
in interfaceDatabaseAsyncExecutor
-
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)
- Specified by:
newEdgeByKeys
in interfaceDatabaseAsyncExecutor
-
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)
- Specified by:
newEdgeByKeys
in interfaceDatabaseAsyncExecutor
-
kill
public void kill()
Test only API.- Specified by:
kill
in interfaceDatabaseAsyncExecutor
-
close
public void close()
-
getParallelLevel
public int getParallelLevel()
- Specified by:
getParallelLevel
in interfaceDatabaseAsyncExecutor
-
setParallelLevel
public void setParallelLevel(int parallelLevel)
- Specified by:
setParallelLevel
in interfaceDatabaseAsyncExecutor
-
getBackPressure
public int getBackPressure()
- Specified by:
getBackPressure
in interfaceDatabaseAsyncExecutor
-
setBackPressure
public void setBackPressure(int percentage)
- Specified by:
setBackPressure
in interfaceDatabaseAsyncExecutor
-
getCommitEvery
public int getCommitEvery()
- Specified by:
getCommitEvery
in interfaceDatabaseAsyncExecutor
-
setCommitEvery
public void setCommitEvery(int commitEvery)
- Specified by:
setCommitEvery
in interfaceDatabaseAsyncExecutor
-
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)
-
-