public class Persistor
extends java.lang.Object
implements org.resoa.grid.ResoaPersistence
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DIR_DEFAULT_DATABASE
Default root path for storage
|
static java.lang.String |
DIR_DEFAULT_JOURNAL
Default root path for journal
|
static org.resoa.util.Priority |
GRIDPRIORITY
Priority of persistence grid messages
|
static java.lang.String |
KEY_DIR_DATABASE |
static java.lang.String |
KEY_DIR_JOURNAL |
static int |
MAXSYNCTIME_Seconds
Default timeout for Persistence Slave synchronization during startup in seconds
|
static int |
TIMEOUT_MASTERCOMMIT
Default timeout for MASTERCOMMIT transactions in seconds
|
static int |
TIMEOUT_SLAVECOMMIT
Default timeout for SLAVECOMMIT transactions in seconds
|
static int |
TIMEOUT_TASKCANCELS
Timeout for transaction cancellation cache, default is 3 minutes.
|
Constructor and Description |
---|
Persistor(org.resoa.topology.GridInfo gridInfo)
Constructor for local default configuration
|
Persistor(org.resoa.service.ResoaServiceDomainExplorer domainExplorer,
org.resoa.node.ResoaGateway gateway,
CacheManager cacheManager)
Constructor
|
Modifier and Type | Method and Description |
---|---|
PersistentDomain |
addPersistenceDomain(org.resoa.service.DomainDescriptor persistentDomainDesc,
PersistenceConfig persistConfig)
Enable persistence for a domain
|
<T> void |
createNew(T instance) |
<T> void |
createNew(T instance,
org.resoa.util.Priority prio) |
<T> void |
createNew(T instance,
org.resoa.grid.ResoaPersistence.Policy policy) |
<T> void |
createNew(T instance,
org.resoa.grid.ResoaPersistence.Policy policy,
org.resoa.util.Priority prio) |
void |
delete(java.lang.Class<?> type,
java.lang.Object key) |
void |
delete(java.lang.Class<?> type,
java.lang.Object key,
org.resoa.util.Priority prio) |
void |
delete(java.lang.Class<?> type,
java.lang.Object key,
org.resoa.grid.ResoaPersistence.Policy policy) |
void |
delete(java.lang.Class<?> type,
java.lang.Object key,
org.resoa.grid.ResoaPersistence.Policy policy,
org.resoa.util.Priority prio) |
<T> void |
delete(T instance) |
<T> void |
delete(T instance,
org.resoa.util.Priority prio) |
<T> void |
delete(T instance,
org.resoa.grid.ResoaPersistence.Policy policy) |
<T> void |
delete(T instance,
org.resoa.grid.ResoaPersistence.Policy policy,
org.resoa.util.Priority prio) |
void |
executeTask(Task task,
PersistentDomain domain)
Execute a task (called by PersistentDomain for Slave Commit processing)
|
boolean |
exists(java.lang.Class<?> type,
java.lang.Object key)
checks, if an instance exists in storage
|
<T> boolean |
exists(T instance) |
CacheManager |
getCacheManager() |
DatabaseManager |
getDatabaseManager(java.lang.String dbType)
Get a database manager instance for a sql database
|
java.lang.String |
getDatabaseRootDir() |
org.resoa.node.DataSourceProvider |
getDataSourceProvider() |
DatabaseTransition |
getDbTransition(java.lang.String serviceDomain) |
DatabaseTransition |
getDbTransitionForType(java.lang.String typeName) |
org.resoa.service.ResoaServiceDomainExplorer |
getDomainExplorer() |
ExecutionLogManager |
getExecutionLogManager(java.lang.String domain)
Return the ExecutionLogManager for a domain
|
org.resoa.topology.GridInfo |
getGridInfo() |
java.lang.String |
getJournalRootDir() |
java.lang.String |
getNodeName() |
PersistenceMode |
getPersistenceMode(java.lang.String domain) |
PersistencePolicy |
getPersistencePolicy(org.resoa.grid.ResoaPersistence.Policy policy)
Returns the policy implementation
|
PersistencePolicy |
getPersistencePolicy(java.lang.String policyName)
Returns the policy implementation
|
PersistentDomain |
getPersistentDomainDescriptor(java.lang.String domain)
Return the persistence domain descriptor
|
java.util.List<PersistentDomain> |
getPersistentDomains()
Get all active peristent domains
|
<T> PersistentType<T> |
getPersistentType(java.lang.Class<T> persistentType)
Get a peristent type descriptor
|
PersistentType<?> |
getPersistentType(java.lang.String typeName)
Get a peristentType descriptor
|
org.resoa.node.ResoaGateway |
getResoaGateway() |
TaskThreadPool |
getThreadPool() |
TransactionLogger |
getTransactionLogger() |
void |
indicatePersistenceError(Task task,
PersistentDomain domain,
org.resoa.exception.PersistenceException pex)
Handles Persistence exceptions during final storage processing
|
boolean |
isDomainMaster(java.lang.String domain) |
void |
onDomainDeployment(org.resoa.service.DomainDescriptor persistentDomainDesc) |
void |
onDomainUnDeployment(java.lang.String domain) |
void |
onGatewayStop() |
void |
onNodeDisconnect(org.resoa.stack.config.StackProfile profile) |
void |
processExecutionLog(ExecLog log,
boolean isIntialLog)
Process an ExecutionLog.
|
<T> T |
read(java.lang.Class<T> type,
java.lang.Object key) |
<T> java.util.List<T> |
read(java.lang.Class<T> type,
org.resoa.grid.RecordSet processingRules) |
org.resoa.grid.RecordSet |
readJSON(java.lang.Class<?> type,
org.resoa.grid.RecordSet processingRules,
boolean requestKeysOnly) |
java.lang.String |
readJSON(java.lang.Class<?> type,
java.lang.String key) |
int |
requestExecutionLog(PersistentDomain persistentDomain)
Request the executionLog from Master
|
void |
setCacheManager(CacheManager cacheManager)
Set the cache manager instance.
|
void |
setDatabaseRootDir(java.lang.String dbRootDir,
boolean mergeWithGatwayPath) |
void |
setDataSourceProvider(org.resoa.node.DataSourceProvider dataSourceProvider) |
void |
setGridInfo(org.resoa.topology.GridInfo gridInfo) |
void |
setJournalRootDir(java.lang.String dbJournalDir,
boolean mergeWithGatwayPath) |
void |
setPersistenceMode(java.lang.String domain,
PersistenceMode newMode)
Set the peristence mode
|
void |
setStateListener(StateListener stateListener)
Register a listener for task status changes
|
protected void |
startSynchronization(PersistentDomain pdom)
Wait for the end of the synchronization of persistent mode MASTER/SLAVE.
|
void |
stop(boolean waitForPoolThreadsEnd)
Stop all persistent services
|
<T> void |
store(java.util.List<T> instances,
org.resoa.grid.ResoaPersistence.Policy policy,
org.resoa.util.Priority prio) |
<T> void |
store(T instance) |
<T> void |
store(T instance,
org.resoa.util.Priority prio) |
<T> void |
store(T instance,
org.resoa.grid.ResoaPersistence.Policy policy) |
<T> void |
store(T instance,
org.resoa.grid.ResoaPersistence.Policy policy,
org.resoa.util.Priority prio) |
void |
updateTaskStatus(TaskStatus newStatus,
Task task)
Updates the task status with broadcast to status change listeners
|
PersistencePolicy |
validatePersistencePolicy(Task task,
PersistencePolicy currentPolicy,
boolean isCreateNew)
Validate the policy.
|
public static int MAXSYNCTIME_Seconds
public static org.resoa.util.Priority GRIDPRIORITY
public static int TIMEOUT_MASTERCOMMIT
public static int TIMEOUT_SLAVECOMMIT
public static int TIMEOUT_TASKCANCELS
public static java.lang.String DIR_DEFAULT_DATABASE
public static java.lang.String DIR_DEFAULT_JOURNAL
public static java.lang.String KEY_DIR_JOURNAL
public static java.lang.String KEY_DIR_DATABASE
public Persistor(org.resoa.topology.GridInfo gridInfo)
gridInfo
- public Persistor(org.resoa.service.ResoaServiceDomainExplorer domainExplorer, org.resoa.node.ResoaGateway gateway, CacheManager cacheManager)
gateway
- the gateway to use for grid persistencedomainExplorer
- cacheManager
- public org.resoa.node.DataSourceProvider getDataSourceProvider()
public void setDataSourceProvider(org.resoa.node.DataSourceProvider dataSourceProvider)
dataSourceProvider
- the dataSourceProvider to setpublic void setStateListener(StateListener stateListener)
stateListener
- the stateListener to setpublic CacheManager getCacheManager()
public DatabaseManager getDatabaseManager(java.lang.String dbType) throws org.resoa.exception.PersistenceException
dbType
- the database type (currently supported: mysql, postgresql)org.resoa.exception.ResoaException
org.resoa.exception.PersistenceException
public void setCacheManager(CacheManager cacheManager)
cacheManager
- public org.resoa.topology.GridInfo getGridInfo()
public void setGridInfo(org.resoa.topology.GridInfo gridInfo)
gridInfo
- the gridInfo to setpublic org.resoa.node.ResoaGateway getResoaGateway()
public java.lang.String getNodeName()
public java.lang.String getDatabaseRootDir()
public void setDatabaseRootDir(java.lang.String dbRootDir, boolean mergeWithGatwayPath)
dbRootDir
- the dbRootPath to setmergeWithGatwayPath
- if true, the path will be combined with the gateway config root pathpublic java.lang.String getJournalRootDir()
public void setJournalRootDir(java.lang.String dbJournalDir, boolean mergeWithGatwayPath)
dbJournalDir
- the dbRootPath to setmergeWithGatwayPath
- if true, the path will be combined with the gateway config root pathpublic TaskThreadPool getThreadPool()
public DatabaseTransition getDbTransition(java.lang.String serviceDomain)
serviceDomain
- the service domain namepublic DatabaseTransition getDbTransitionForType(java.lang.String typeName)
typeName
- the entity namepublic org.resoa.service.ResoaServiceDomainExplorer getDomainExplorer()
public void updateTaskStatus(TaskStatus newStatus, Task task)
newStatus
- the new statustask
- the taskpublic PersistenceMode getPersistenceMode(java.lang.String domain)
domain
- the Service domain namepublic void setPersistenceMode(java.lang.String domain, PersistenceMode newMode)
domain
- newMode
- public PersistentDomain getPersistentDomainDescriptor(java.lang.String domain)
domain
- the service domain namepublic java.util.List<PersistentDomain> getPersistentDomains()
public boolean isDomainMaster(java.lang.String domain)
domain
- the service domain namepublic PersistentType<?> getPersistentType(java.lang.String typeName)
typeName
- the class namepublic <T> PersistentType<T> getPersistentType(java.lang.Class<T> persistentType)
T
- persistentType
- the persistent class namepublic void onDomainDeployment(org.resoa.service.DomainDescriptor persistentDomainDesc) throws org.resoa.exception.ResoaException
onDomainDeployment
in interface org.resoa.grid.GatewayEventListener
org.resoa.exception.ResoaException
public PersistentDomain addPersistenceDomain(org.resoa.service.DomainDescriptor persistentDomainDesc, PersistenceConfig persistConfig) throws org.resoa.exception.PersistenceException
persistentDomainDesc
- persistConfig
- org.resoa.exception.PersistenceException
public TransactionLogger getTransactionLogger() throws org.resoa.exception.PersistenceException
org.resoa.exception.PersistenceException
public void onDomainUnDeployment(java.lang.String domain)
onDomainUnDeployment
in interface org.resoa.grid.GatewayEventListener
protected void startSynchronization(PersistentDomain pdom)
public void stop(boolean waitForPoolThreadsEnd)
waitForPoolThreadsEnd
- public PersistencePolicy getPersistencePolicy(org.resoa.grid.ResoaPersistence.Policy policy)
policy
- public PersistencePolicy getPersistencePolicy(java.lang.String policyName)
policyName
- the policy as Stringpublic PersistencePolicy validatePersistencePolicy(Task task, PersistencePolicy currentPolicy, boolean isCreateNew)
task
- currentPolicy
- isCreateNew
- public ExecutionLogManager getExecutionLogManager(java.lang.String domain)
domain
- public int requestExecutionLog(PersistentDomain persistentDomain)
persistentDomain
- the persistent domain descriptorpublic void processExecutionLog(ExecLog log, boolean isIntialLog) throws org.resoa.exception.PersistenceException
log
- the ExecutionLogorg.resoa.exception.PersistenceException
public void executeTask(Task task, PersistentDomain domain)
public void indicatePersistenceError(Task task, PersistentDomain domain, org.resoa.exception.PersistenceException pex)
task
- the Task causing the errordomain
- the domainpex
- the causing exceptionpublic void onGatewayStop()
onGatewayStop
in interface org.resoa.grid.GatewayEventListener
public void onNodeDisconnect(org.resoa.stack.config.StackProfile profile)
onNodeDisconnect
in interface org.resoa.grid.GatewayEventListener
public <T> void store(T instance, org.resoa.grid.ResoaPersistence.Policy policy, org.resoa.util.Priority prio) throws org.resoa.exception.PersistenceException
org.resoa.exception.PersistenceException
public <T> void store(T instance, org.resoa.grid.ResoaPersistence.Policy policy) throws org.resoa.exception.PersistenceException
store
in interface org.resoa.grid.ResoaPersistence
org.resoa.exception.PersistenceException
public <T> void store(T instance, org.resoa.util.Priority prio) throws org.resoa.exception.PersistenceException
org.resoa.exception.PersistenceException
public <T> void store(T instance) throws org.resoa.exception.PersistenceException
store
in interface org.resoa.grid.ResoaPersistence
org.resoa.exception.PersistenceException
public <T> void store(java.util.List<T> instances, org.resoa.grid.ResoaPersistence.Policy policy, org.resoa.util.Priority prio) throws org.resoa.exception.PersistenceException
org.resoa.exception.PersistenceException
public <T> void createNew(T instance, org.resoa.grid.ResoaPersistence.Policy policy, org.resoa.util.Priority prio) throws org.resoa.exception.PersistenceException
org.resoa.exception.PersistenceException
public <T> void createNew(T instance, org.resoa.util.Priority prio) throws org.resoa.exception.PersistenceException
org.resoa.exception.PersistenceException
public <T> void createNew(T instance, org.resoa.grid.ResoaPersistence.Policy policy) throws org.resoa.exception.PersistenceException
org.resoa.exception.PersistenceException
public <T> void createNew(T instance) throws org.resoa.exception.PersistenceException
createNew
in interface org.resoa.grid.ResoaPersistence
org.resoa.exception.PersistenceException
public <T> void delete(T instance) throws org.resoa.exception.PersistenceException
delete
in interface org.resoa.grid.ResoaPersistence
org.resoa.exception.PersistenceException
public <T> void delete(T instance, org.resoa.grid.ResoaPersistence.Policy policy) throws org.resoa.exception.PersistenceException
delete
in interface org.resoa.grid.ResoaPersistence
org.resoa.exception.PersistenceException
public <T> void delete(T instance, org.resoa.util.Priority prio) throws org.resoa.exception.PersistenceException
org.resoa.exception.PersistenceException
public <T> void delete(T instance, org.resoa.grid.ResoaPersistence.Policy policy, org.resoa.util.Priority prio) throws org.resoa.exception.PersistenceException
org.resoa.exception.PersistenceException
public void delete(java.lang.Class<?> type, java.lang.Object key, org.resoa.util.Priority prio) throws org.resoa.exception.PersistenceException
org.resoa.exception.PersistenceException
public void delete(java.lang.Class<?> type, java.lang.Object key, org.resoa.grid.ResoaPersistence.Policy policy) throws org.resoa.exception.PersistenceException
delete
in interface org.resoa.grid.ResoaPersistence
org.resoa.exception.PersistenceException
public void delete(java.lang.Class<?> type, java.lang.Object key) throws org.resoa.exception.PersistenceException
delete
in interface org.resoa.grid.ResoaPersistence
org.resoa.exception.PersistenceException
public void delete(java.lang.Class<?> type, java.lang.Object key, org.resoa.grid.ResoaPersistence.Policy policy, org.resoa.util.Priority prio) throws org.resoa.exception.PersistenceException
org.resoa.exception.PersistenceException
public <T> boolean exists(T instance)
exists
in interface org.resoa.grid.ResoaPersistence
public boolean exists(java.lang.Class<?> type, java.lang.Object key)
exists
in interface org.resoa.grid.ResoaPersistence
type
- the typekey
- the keypublic <T> T read(java.lang.Class<T> type, java.lang.Object key)
read
in interface org.resoa.grid.ResoaPersistence
public java.lang.String readJSON(java.lang.Class<?> type, java.lang.String key)
public <T> java.util.List<T> read(java.lang.Class<T> type, org.resoa.grid.RecordSet processingRules)
read
in interface org.resoa.grid.ResoaPersistence
public org.resoa.grid.RecordSet readJSON(java.lang.Class<?> type, org.resoa.grid.RecordSet processingRules, boolean requestKeysOnly) throws java.util.regex.PatternSyntaxException
java.util.regex.PatternSyntaxException
Copyright © 2005-2014 The Resoa Project, resoa.org.