|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase
A VirtualDatabase
represents a database from client point of
view and hide the complexity of the cluster distribution to the client. The
client always uses the virtual database name and the C-JDBC Controller will
use the real connections when an SQL request comes in.
Field Summary | |
private java.util.ArrayList |
activeThreads
|
protected AuthenticationManager |
authenticationManager
Authentification manager matching virtual database login/password to backends login/password |
protected java.util.ArrayList |
backends
ArrayList of DatabaseBackend objects |
protected int |
currentNbOfThreads
Current number of worker threads |
protected java.lang.String |
groupName
Group name if this virtual database is hosted by multiple controllers |
private int |
idleThreads
|
protected Trace |
logger
|
protected int |
maxNbOfConnections
Maximum number of concurrent accepted for this virtual database |
protected int |
maxNbOfThreads
Maximum number of worker threads to fork |
protected long |
maxThreadIdleTime
Maximum time a worker thread can remain idle before dying |
protected VirtualDatabaseMetaData |
metadata
Virtual Database MetaData |
protected int |
minNbOfThreads
Minimum number of worker threads to keep in the pool if poolConnectionThreads is true |
protected java.lang.String |
name
Virtual database name |
private java.util.ArrayList |
pendingConnections
|
protected boolean |
poolConnectionThreads
If false one worker thread is forked per connection else |
protected Trace |
requestLogger
|
protected RequestManager |
requestManager
The request manager to use for this database |
protected ReadPrioritaryFIFOWriteLock |
rwLock
Read/Write lock for backend list |
Constructor Summary | |
VirtualDatabase(java.lang.String name,
int maxConnections,
boolean pool,
int minThreads,
int maxThreads,
long maxThreadIdleTime)
Creates a new VirtualDatabase instance. |
Method Summary | |
void |
acquireReadLockBackendLists()
Acquires a read lock on the backend lists (both enabled and disabled backends). |
void |
addBackend(DatabaseBackend db)
Add a backend to this virtual database. |
void |
addCurrentNbOfThread()
Adds one to currentNbOfThreads. |
void |
addIdleThread()
Method add an idle thread. |
int |
begin(java.lang.String login)
Begins a new transaction and returns the corresponding transaction identifier. |
boolean |
checkAdminAuthentication(java.lang.String adminLogin,
java.lang.String adminPassword)
Checks if a given admin login/password is ok. |
boolean |
checkUserAuthentication(java.lang.String virtualLogin,
java.lang.String virtualPassword)
Checks if a given virtual login/password is ok. |
void |
commit(int transactionId)
Commits a transaction given its id. |
void |
disableAllBackend()
Prepare this virtual database for shutdown. |
void |
disableAllBackendForCheckpoint(java.lang.String checkpoint)
Disable all backends and store a checkpoint |
void |
disableBackend(java.lang.String backendName)
Disables a backend that is currently enabled on this virtual database (without further check). |
void |
disableBackendForCheckpoint(java.lang.String backendName,
java.lang.String checkpointName)
Disables a backend once all the pending write queries are executed. |
void |
enableAllBackend()
Prepare this virtual database for startup. |
void |
enableAllBackend(java.lang.String checkpoint)
Prepare this virtual database for startup. |
void |
enableBackend(java.lang.String backendName)
Enables a backend that has been previously added to this virtual database and that is in the disabled state. |
void |
enableBackendFromCheckpoint(java.lang.String backendName,
java.lang.String checkpointName)
Plays all the queries since the given checkpoint and enables the backend when it is completely synchronized. |
boolean |
equals(java.lang.Object other)
Two virtual databases are equal if they have the same name and group. |
java.sql.ResultSet |
execReadRequest(SelectRequest request)
Performs a read request and returns the reply. |
java.sql.ResultSet |
execReadStoredProcedure(StoredProcedure proc)
Call a stored procedure that returns a ResultSet. |
int |
execWriteRequest(AbstractWriteRequest request)
Performs a write request and returns the number of rows affected. |
java.sql.ResultSet |
execWriteRequestWithKeys(AbstractWriteRequest request)
Performs a write request and returns the auto generated keys. |
protected int |
execWriteStoredProcedure(StoredProcedure proc)
Call a stored procedure that performs an update. |
java.util.ArrayList |
getActiveThreads()
Returns the activeThreads. |
java.util.ArrayList |
getAllBackendNames()
|
private DatabaseBackend |
getAndCheckBackendForDisable(java.lang.String backendName)
Find the DatabaseBackend corresponding to the given backend name and check if it is possible to disable this backend. |
private DatabaseBackend |
getAndCheckBackendForEnable(java.lang.String backendName)
Find the DatabaseBackend corresponding to the given backend name and check if it is possible to enable this backend. |
AuthenticationManager |
getAuthenticationManager()
Returns the authentication manager of this virtual database. |
java.lang.String |
getBackendInformation(java.lang.String backendName)
Return information about the specified backend. |
java.util.ArrayList |
getBackends()
Return the list of all backends |
int |
getCurrentNbOfThreads()
Returns the currentNbOfThreads. |
java.lang.String |
getDatabaseName()
Gets the virtual database name to be used by the client (C-JDBC driver) This method should be used for local references only (it is faster). |
DatabaseSchema |
getDatabaseSchemaFromActiveBackends()
Get the current database schema from merging the schemas of all active backends. |
java.lang.String |
getGroupName()
Returns the group name this virtual database belongs to. |
int |
getIdleThreads()
Returns the number of idle zorker threads. |
java.lang.String |
getInformation()
Gets information about this virtual database. |
int |
getMaxNbOfConnections()
Returns the maxNbOfConnections. |
int |
getMaxNbOfThreads()
Returns the maxNbOfThreads. |
long |
getMaxThreadIdleTime()
Returns the maxThreadIdleTime. |
VirtualDatabaseMetaData |
getMetaData()
|
int |
getMinNbOfThreads()
Returns the minNbOfThreads. |
java.lang.String |
getName()
Gets the virtual database name to be used by the client (C-JDBC driver) |
java.util.ArrayList |
getPendingConnections()
Returns the pendingConnections. |
RequestManager |
getRequestManager()
Gets the request manager associated to this database. |
java.lang.String |
getVirtualDatabaseName()
Gets the virtual database name to be used by the client (C-JDBC driver) |
java.lang.String |
getXmlInformation()
Retrieves this VirtualDatabase object in xml format |
boolean |
isDistributed()
Is this virtual database distributed ? |
boolean |
isPoolConnectionThreads()
Returns the poolConnectionThreads. |
void |
releaseReadLockBackendLists()
Releases the read lock on the backend lists (both enabled and disabled backends). |
void |
removeBackend(DatabaseBackend db)
Remove a backend from this virtual database. |
void |
removeCurrentNbOfThread()
Substract one to currentNbOfThreads. |
void |
removeIdleThread()
Remove an idle thread. |
void |
rollback(int transactionId)
Rollbacks a transaction given its id. |
void |
setAuthenticationManager(AuthenticationManager authenticationManager)
Sets the authentication manager for this virtual database. |
void |
setDatabaseSchema(DatabaseSchema schema,
boolean isStatic)
Sets a new database schema for this database if no one exist or merge the given schema to the existing one. |
void |
setGroupName(java.lang.String groupName)
Sets the group name used by the controllers hosting this virtual database. |
void |
setMaxNbOfConnections(int maxNbOfConnections)
Sets the maxNbOfConnections. |
void |
setMaxNbOfThreads(int maxNbOfThreads)
Sets the maxNbOfThreads. |
void |
setMaxThreadIdleTime(long maxThreadIdleTime)
Sets the maxThreadIdleTime. |
void |
setMinNbOfThreads(int minNbOfThreads)
Sets the minNbOfThreads. |
void |
setPoolConnectionThreads(boolean poolConnectionThreads)
Sets the poolConnectionThreads. |
void |
setRequestManager(RequestManager requestManager)
Sets a new request manager for this database. |
void |
shutdown(int level)
Shutdown this virtual database. |
java.util.ArrayList |
viewAllBackendNames()
Get the name of all DatabaseBackend names. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.lang.String name
protected java.lang.String groupName
protected AuthenticationManager authenticationManager
protected java.util.ArrayList backends
ArrayList
of DatabaseBackend
objects
protected ReadPrioritaryFIFOWriteLock rwLock
protected RequestManager requestManager
protected Trace logger
protected Trace requestLogger
private java.util.ArrayList activeThreads
private int idleThreads
private java.util.ArrayList pendingConnections
protected int maxNbOfConnections
protected boolean poolConnectionThreads
protected long maxThreadIdleTime
protected int minNbOfThreads
protected int maxNbOfThreads
protected int currentNbOfThreads
protected VirtualDatabaseMetaData metadata
Constructor Detail |
public VirtualDatabase(java.lang.String name, int maxConnections, boolean pool, int minThreads, int maxThreads, long maxThreadIdleTime)
VirtualDatabase
instance.
name
- the virtual database name.maxConnections
- maximum number of concurrent connections.pool
- should we use a pool of threads for handling connections?minThreads
- minimum number of threads in the poolmaxThreads
- maximum number of threads in the poolmaxThreadIdleTime
- maximum time a thread can remain idle before being
removed from the pool.Method Detail |
public boolean isDistributed()
public boolean checkUserAuthentication(java.lang.String virtualLogin, java.lang.String virtualPassword)
virtualLogin
- the virtual user loginvirtualPassword
- the virtual user password
true
if the login/password is known from the AuthenticationManager
.
Returns false
if no AuthenticationManager
is
defined.public boolean checkAdminAuthentication(java.lang.String adminLogin, java.lang.String adminPassword)
checkAdminAuthentication
in interface VirtualDatabaseMBean
adminLogin
- admin user loginadminPassword
- admin user password
true
if the login/password is known from the AuthenticationManager
.
Returns false
if no AuthenticationManager
is
defined.public java.sql.ResultSet execReadRequest(SelectRequest request) throws java.sql.SQLException
request
- the request to execute
java.sql.ResultSet
value
java.sql.SQLException
- if the request failspublic int execWriteRequest(AbstractWriteRequest request) throws java.sql.SQLException
request
- the request to execute
java.sql.SQLException
- if the request failspublic java.sql.ResultSet execWriteRequestWithKeys(AbstractWriteRequest request) throws java.sql.SQLException
request
- the request to execute
java.sql.SQLException
- if the request failspublic java.sql.ResultSet execReadStoredProcedure(StoredProcedure proc) throws java.sql.SQLException
proc
- the stored procedure call
java.sql.ResultSet
value
java.sql.SQLException
- if an error occursprotected int execWriteStoredProcedure(StoredProcedure proc) throws java.sql.SQLException
proc
- the stored procedure call
java.sql.SQLException
- if an error occurspublic int begin(java.lang.String login) throws java.sql.SQLException
Connection.setAutoCommit(boolean)
is
called with false
argument.
login
- the login used by the connection
java.sql.SQLException
- if an error occurspublic void commit(int transactionId) throws java.sql.SQLException
transactionId
- the transaction id
java.sql.SQLException
- if an error occurspublic void rollback(int transactionId) throws java.sql.SQLException
transactionId
- the transaction id
java.sql.SQLException
- if an error occurspublic void addBackend(DatabaseBackend db) throws VirtualDatabaseException
db
- the database backend to add
VirtualDatabaseException
- if an error occurspublic void removeBackend(DatabaseBackend db) throws VirtualDatabaseException
db
- the database backend to remove
VirtualDatabaseException
- if an error occursprivate DatabaseBackend getAndCheckBackendForEnable(java.lang.String backendName) throws VirtualDatabaseException
backendName
- backend to look for
VirtualDatabaseException
- if an error occurspublic void enableBackend(java.lang.String backendName) throws VirtualDatabaseException
VirtualDatabaseMBean
enableBackend
in interface VirtualDatabaseMBean
backendName
- The database backend logical name to enable
VirtualDatabaseException
- in case of communication-related errorVirtualDatabaseManagementInterface#enableBackend(String)
public void enableBackendFromCheckpoint(java.lang.String backendName, java.lang.String checkpointName) throws VirtualDatabaseException
VirtualDatabaseMBean
enableBackendFromCheckpoint
in interface VirtualDatabaseMBean
backendName
- The database backend logical name to enablecheckpointName
- the checkpoint name to restart from
VirtualDatabaseException
- in case of communication-related errorVirtualDatabaseManagementInterface#enableBackendFromCheckpoint(String,
String)
private DatabaseBackend getAndCheckBackendForDisable(java.lang.String backendName) throws VirtualDatabaseException
backendName
- backend to look for
VirtualDatabaseException
- if an error occurspublic void disableBackend(java.lang.String backendName) throws VirtualDatabaseException
VirtualDatabaseMBean
disableBackend
in interface VirtualDatabaseMBean
backendName
- The database backend logical name to enable
VirtualDatabaseException
- in case of communication-related errorVirtualDatabaseManagementInterface#disableBackend(String)
public void disableAllBackend() throws VirtualDatabaseException
disableAllBackend
in interface VirtualDatabaseMBean
VirtualDatabaseException
- if failsgetAndCheckBackendForDisable(java.lang.String)
public void enableAllBackend() throws VirtualDatabaseException
enableAllBackend
in interface VirtualDatabaseMBean
VirtualDatabaseException
- if failspublic void enableAllBackend(java.lang.String checkpoint) throws VirtualDatabaseException
enableAllBackend
in interface VirtualDatabaseMBean
checkpoint
- checkpoint for recovery log
VirtualDatabaseException
- if failspublic void disableBackendForCheckpoint(java.lang.String backendName, java.lang.String checkpointName) throws VirtualDatabaseException
VirtualDatabaseMBean
disableBackendForCheckpoint
in interface VirtualDatabaseMBean
backendName
- The database backend logical name to disablecheckpointName
- the checkpoint name to store
VirtualDatabaseException
- in case of communication-related errorVirtualDatabaseManagementInterface#disableBackendForCheckpoint(String,
String)
public final void acquireReadLockBackendLists() throws java.lang.InterruptedException
ArrayList
.
java.lang.InterruptedException
- if an error occurspublic final void releaseReadLockBackendLists()
ArrayList
.
public AuthenticationManager getAuthenticationManager()
AuthenticationManager
instancepublic void setAuthenticationManager(AuthenticationManager authenticationManager)
authenticationManager
- the AuthenticationManager
to
setpublic java.util.ArrayList getBackends()
ArrayList
of DatabaseBackend
Objectspublic java.util.ArrayList getAllBackendNames() throws VirtualDatabaseException
VirtualDatabaseException
org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabaseManagementInterface#getAllBackendNames()
public java.lang.String getDatabaseName()
getVirtualDatabaseName()
.
getVirtualDatabaseName()
public VirtualDatabaseMetaData getMetaData()
DatabaseMetaData
public DatabaseSchema getDatabaseSchemaFromActiveBackends() throws java.sql.SQLException
java.sql.SQLException
- if an error occurspublic void setDatabaseSchema(DatabaseSchema schema, boolean isStatic)
schema
- the new database shemaisStatic
- true
if the schema should be staticpublic java.lang.String getGroupName()
String
value. Returns null
if this
virtual database is standalonepublic void setGroupName(java.lang.String groupName)
groupName
- the group name to setpublic RequestManager getRequestManager()
RequestManager
instancepublic void setRequestManager(RequestManager requestManager)
requestManager
- the new request manager.public java.lang.String getVirtualDatabaseName()
public boolean equals(java.lang.Object other)
other
- the object to compare with
true
if the two virtual databases are equalspublic java.lang.String getXmlInformation() throws VirtualDatabaseException
VirtualDatabase
object in xml format
VirtualDatabaseException
- if remote communication failedpublic java.lang.String getInformation()
String
value containing informationpublic java.lang.String getBackendInformation(java.lang.String backendName) throws VirtualDatabaseException
VirtualDatabaseMBean
getBackendInformation
in interface VirtualDatabaseMBean
backendName
- the backend logical name
VirtualDatabaseException
- if an error occursorg.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabaseManagementInterface#getBackendInformation(String)
public java.lang.String getName()
getName
in interface VirtualDatabaseMBean
public int getCurrentNbOfThreads()
public void addCurrentNbOfThread()
public void removeCurrentNbOfThread()
public int getMinNbOfThreads()
public boolean isPoolConnectionThreads()
public void setMinNbOfThreads(int minNbOfThreads)
minNbOfThreads
- The minNbOfThreads to setpublic void setPoolConnectionThreads(boolean poolConnectionThreads)
poolConnectionThreads
- The poolConnectionThreads to setpublic long getMaxThreadIdleTime()
public void setMaxThreadIdleTime(long maxThreadIdleTime)
maxThreadIdleTime
- The maxThreadIdleTime to setpublic int getMaxNbOfConnections()
public int getMaxNbOfThreads()
public java.util.ArrayList getPendingConnections()
public void setMaxNbOfConnections(int maxNbOfConnections)
maxNbOfConnections
- The maxNbOfConnections to setpublic void setMaxNbOfThreads(int maxNbOfThreads)
maxNbOfThreads
- The maxNbOfThreads to setpublic java.util.ArrayList getActiveThreads()
public void addIdleThread()
public void removeIdleThread()
public int getIdleThreads()
public java.util.ArrayList viewAllBackendNames() throws VirtualDatabaseException
VirtualDatabaseMBean
viewAllBackendNames
in interface VirtualDatabaseMBean
ArrayList
of String
representing database backend names
VirtualDatabaseException
- if an error occursVirtualDatabaseMBean.viewAllBackendNames()
public void disableAllBackendForCheckpoint(java.lang.String checkpoint) throws VirtualDatabaseException
VirtualDatabaseMBean
disableAllBackendForCheckpoint
in interface VirtualDatabaseMBean
checkpoint
- the name of the checkpoitn
VirtualDatabaseException
- if failsVirtualDatabaseMBean.disableAllBackendForCheckpoint(java.lang.String)
public void shutdown(int level)
level
- Smart or Fast
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |