Package org.copperengine.core.persistent
Class PostgreSQLDialect
- java.lang.Object
-
- org.copperengine.core.persistent.AbstractSqlDialect
-
- org.copperengine.core.persistent.PostgreSQLDialect
-
- All Implemented Interfaces:
DatabaseDialect
,org.copperengine.management.DatabaseDialectMXBean
public class PostgreSQLDialect extends AbstractSqlDialect
PostgreSQL implementation of theScottyDBStorageInterface
.
-
-
Field Summary
-
Fields inherited from class org.copperengine.core.persistent.AbstractSqlDialect
ACQUIRE_BLOCKING_WAIT_SEC, dbBatchingLatencyMSec, defaultStaleResponseRemovalTimeout, multiEngineMode, queryUpdateQueueState, selectQueueSizeStmtStatistic, serializer, supportsClob, supportsMultipleEngines
-
-
Constructor Summary
Constructors Constructor Description PostgreSQLDialect()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addLimitation(java.lang.StringBuilder sql, int max)
protected void
addLimitationAndOffset(java.lang.StringBuilder sql, int max, int offset)
int
countAuditTrailInstances(org.copperengine.management.model.AuditTrailInstanceFilter filter, java.sql.Connection con)
int
countWorkflowInstances(org.copperengine.management.model.WorkflowInstanceFilter filter, java.sql.Connection con)
BatchCommand
createBatchCommand4error(Workflow<?> w, java.lang.Throwable t, DBProcessingState dbProcessingState, Acknowledge ack)
BatchCommand
createBatchCommand4NotifyNoEarlyResponseHandling(Response<?> response, Acknowledge ack)
protected java.sql.PreparedStatement
createDeleteStaleResponsesStmt(java.sql.Connection c, int MAX_ROWS)
protected java.sql.PreparedStatement
createDequeueStmt(java.sql.Connection c, java.lang.String ppoolId, int max)
protected java.sql.PreparedStatement
createQueryAllActiveStmt(java.sql.Connection c, java.lang.String className, int max)
protected java.sql.PreparedStatement
createUpdateStateStmt(java.sql.Connection c, int max)
protected void
doLock(java.sql.Connection con, java.lang.String lockContext)
ref: https://www.postgresql.org/docs/9.5/static/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS pg_advisory_lock locks an application-defined resource, which can be identified either by a single 64-bit key value or two 32-bit key values (note that these two key spaces do not overlap).protected void
doReleaseLock(java.sql.Connection con, java.lang.String lockContext)
Releases the lock on the lockContext, use together withAbstractSqlDialect.lock(Connection, String)
java.lang.String
getDialectDescription()
void
insert(java.util.List<Workflow<?>> wfs, java.sql.Connection con)
java.util.List<org.copperengine.management.model.AuditTrailInfo>
queryAuditTrailInstances(org.copperengine.management.model.AuditTrailInstanceFilter filter, java.sql.Connection con)
java.util.List<Workflow<?>>
queryWorkflowInstances(org.copperengine.management.model.WorkflowInstanceFilter filter, java.sql.Connection con)
void
restartFiltered(org.copperengine.management.model.WorkflowInstanceFilter filter, java.sql.Connection con)
-
Methods inherited from class org.copperengine.core.persistent.AbstractSqlDialect
checkDbConsistency, computeLockId, createBatchCommand4Finish, createBatchCommand4Notify, createBatchCommand4registerCallback, createReadStmt, decode, deleteBroken, deleteFiltered, deleteStaleResponse, deleteWaiting, dequeue, getDbBatchingLatencyMSec, getDefaultStaleResponseRemovalTimeout, getResourceAsString, getResourceAsString, getWorkflowPersistencePlugin, insert, isBlank, isRemoveWhenFinished, lock, notify, queryAllActive, queryAuditTrailMessage, queryObjectState, queryQueueSize, read, readDatabaseClock, releaseLock, restart, restartAll, resumeBrokenBusinessProcesses, setDbBatchingLatencyMSec, setDefaultStaleResponseRemovalTimeout, setEngineId, setEngineIdProvider, setMultiEngineMode, setRemoveWhenFinished, setRuntimeStatisticsCollector, setSerializer, setWfRepository, setWorkflowPersistencePlugin, shutdown, splitt, startup, updateQueueState
-
-
-
-
Method Detail
-
createUpdateStateStmt
protected java.sql.PreparedStatement createUpdateStateStmt(java.sql.Connection c, int max) throws java.sql.SQLException
- Specified by:
createUpdateStateStmt
in classAbstractSqlDialect
- Throws:
java.sql.SQLException
-
createDequeueStmt
protected java.sql.PreparedStatement createDequeueStmt(java.sql.Connection c, java.lang.String ppoolId, int max) throws java.sql.SQLException
- Specified by:
createDequeueStmt
in classAbstractSqlDialect
- Throws:
java.sql.SQLException
-
createDeleteStaleResponsesStmt
protected java.sql.PreparedStatement createDeleteStaleResponsesStmt(java.sql.Connection c, int MAX_ROWS) throws java.sql.SQLException
- Specified by:
createDeleteStaleResponsesStmt
in classAbstractSqlDialect
- Throws:
java.sql.SQLException
-
createBatchCommand4error
public BatchCommand createBatchCommand4error(Workflow<?> w, java.lang.Throwable t, DBProcessingState dbProcessingState, Acknowledge ack)
- Specified by:
createBatchCommand4error
in interfaceDatabaseDialect
- Specified by:
createBatchCommand4error
in classAbstractSqlDialect
-
createBatchCommand4NotifyNoEarlyResponseHandling
public BatchCommand createBatchCommand4NotifyNoEarlyResponseHandling(Response<?> response, Acknowledge ack) throws java.lang.Exception
- Specified by:
createBatchCommand4NotifyNoEarlyResponseHandling
in classAbstractSqlDialect
- Throws:
java.lang.Exception
-
getDialectDescription
public java.lang.String getDialectDescription()
-
insert
public void insert(java.util.List<Workflow<?>> wfs, java.sql.Connection con) throws DuplicateIdException, java.lang.Exception
- Specified by:
insert
in interfaceDatabaseDialect
- Overrides:
insert
in classAbstractSqlDialect
- Throws:
DuplicateIdException
java.lang.Exception
-
createQueryAllActiveStmt
protected java.sql.PreparedStatement createQueryAllActiveStmt(java.sql.Connection c, java.lang.String className, int max) throws java.sql.SQLException
- Specified by:
createQueryAllActiveStmt
in classAbstractSqlDialect
- Throws:
java.sql.SQLException
-
doLock
protected void doLock(java.sql.Connection con, java.lang.String lockContext) throws java.sql.SQLException
ref: https://www.postgresql.org/docs/9.5/static/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS pg_advisory_lock locks an application-defined resource, which can be identified either by a single 64-bit key value or two 32-bit key values (note that these two key spaces do not overlap). If another session already holds a lock on the same resource identifier, this function will wait until the resource becomes available. The lock is exclusive. Multiple lock requests stack, so that if the same resource is locked three times it must then be unlocked three times to be released for other sessions' use. DO NOT USE IT WITHOUT finally { release_lock(lockContext)} or it will be deadlocked!!- Overrides:
doLock
in classAbstractSqlDialect
- Parameters:
con
- connection object on which the lock will be acquired onlockContext
- String for the lock name (Will be transformed to an int byAbstractSqlDialect.computeLockId(String)
.- Throws:
java.sql.SQLException
- If anything goes wrong in acquiring the lock on the database
-
doReleaseLock
protected void doReleaseLock(java.sql.Connection con, java.lang.String lockContext)
Description copied from class:AbstractSqlDialect
Releases the lock on the lockContext, use together withAbstractSqlDialect.lock(Connection, String)
- Overrides:
doReleaseLock
in classAbstractSqlDialect
- Parameters:
con
- connection object on which the lock will be released onlockContext
- String for the lock name
-
addLimitation
protected void addLimitation(java.lang.StringBuilder sql, int max)
- Specified by:
addLimitation
in classAbstractSqlDialect
-
addLimitationAndOffset
protected void addLimitationAndOffset(java.lang.StringBuilder sql, int max, int offset)
- Specified by:
addLimitationAndOffset
in classAbstractSqlDialect
-
queryWorkflowInstances
public java.util.List<Workflow<?>> queryWorkflowInstances(org.copperengine.management.model.WorkflowInstanceFilter filter, java.sql.Connection con) throws java.sql.SQLException
- Specified by:
queryWorkflowInstances
in interfaceDatabaseDialect
- Overrides:
queryWorkflowInstances
in classAbstractSqlDialect
- Throws:
java.sql.SQLException
-
countWorkflowInstances
public int countWorkflowInstances(org.copperengine.management.model.WorkflowInstanceFilter filter, java.sql.Connection con) throws java.sql.SQLException
- Specified by:
countWorkflowInstances
in interfaceDatabaseDialect
- Overrides:
countWorkflowInstances
in classAbstractSqlDialect
- Throws:
java.sql.SQLException
-
restartFiltered
public void restartFiltered(org.copperengine.management.model.WorkflowInstanceFilter filter, java.sql.Connection con) throws java.lang.Exception
- Specified by:
restartFiltered
in interfaceDatabaseDialect
- Overrides:
restartFiltered
in classAbstractSqlDialect
- Throws:
java.lang.Exception
-
queryAuditTrailInstances
public java.util.List<org.copperengine.management.model.AuditTrailInfo> queryAuditTrailInstances(org.copperengine.management.model.AuditTrailInstanceFilter filter, java.sql.Connection con) throws java.sql.SQLException
- Specified by:
queryAuditTrailInstances
in interfaceDatabaseDialect
- Overrides:
queryAuditTrailInstances
in classAbstractSqlDialect
- Throws:
java.sql.SQLException
-
countAuditTrailInstances
public int countAuditTrailInstances(org.copperengine.management.model.AuditTrailInstanceFilter filter, java.sql.Connection con) throws java.sql.SQLException
- Specified by:
countAuditTrailInstances
in interfaceDatabaseDialect
- Overrides:
countAuditTrailInstances
in classAbstractSqlDialect
- Throws:
java.sql.SQLException
-
-