public class OPartitionedDatabasePool extends OOrientListenerAbstract
To acquire connection from the pool call acquire()
method but to release connection
you just need to call ODatabase.close()
method.
In case of remote storage database pool will keep connections to the remote storage till you close pool. So in case of remote storage you should close pool at the end of it's usage, it also may be closed on application shutdown but you should not rely on this behaviour.
This pool has one noticeable difference from other pools. If you perform several subsequent acquire calls in the same thread the same instance of database will be returned, but amount of calls to close method should match to amount of acquire calls to release database back in the pool. It will allow you to use such feature as transaction propagation when you perform call of one service from another one.
Given pool has two parameters now, amount of maximum connections for single partition and total amount of connections which may be hold by pool. When you start to use pool it will automatically split by several partitions, each partition is independent from other which gives us very good multicore scalability. Amount of partitions will be close to amount of cores but it is not mandatory and depends how much application is loaded. Amount of connections which may be hold by single partition is defined by user but we suggest to use default parameters if your application load is not extremely high.
If total amount of connections which allowed to be hold by this pool is reached thread will wait till free connection will be available. If total amount of connection is set to value 0 or less it means that there is no connection limit.
Modifier and Type | Field and Description |
---|---|
protected Map<String,Object> |
properties |
Constructor and Description |
---|
OPartitionedDatabasePool(String url,
String userName,
String password) |
OPartitionedDatabasePool(String url,
String userName,
String password,
int maxPartitionSize,
int maxPoolSize) |
Modifier and Type | Method and Description |
---|---|
ODatabaseDocumentTx |
acquire() |
void |
close() |
int |
getAvailableConnections() |
int |
getCreatedInstances() |
int |
getMaxPartitonSize() |
Object |
getProperty(String iName)
Gets the property value.
|
String |
getUrl() |
String |
getUserName() |
boolean |
isAutoCreate() |
boolean |
isClosed() |
void |
onShutdown() |
void |
onStartup() |
protected void |
openDatabase(com.orientechnologies.orient.core.db.OPartitionedDatabasePool.DatabaseDocumentTxPooled db) |
OPartitionedDatabasePool |
setAutoCreate(boolean autoCreate) |
Object |
setProperty(String iName,
Object iValue)
Sets a property value
|
onStorageRegistered, onStorageUnregistered
public OPartitionedDatabasePool(String url, String userName, String password)
public String getUrl()
public String getUserName()
public int getMaxPartitonSize()
public int getAvailableConnections()
public int getCreatedInstances()
public ODatabaseDocumentTx acquire()
public boolean isAutoCreate()
public OPartitionedDatabasePool setAutoCreate(boolean autoCreate)
public boolean isClosed()
protected void openDatabase(com.orientechnologies.orient.core.db.OPartitionedDatabasePool.DatabaseDocumentTxPooled db)
public void onShutdown()
onShutdown
in interface OOrientListener
onShutdown
in interface OOrientShutdownListener
onShutdown
in class OOrientListenerAbstract
public void onStartup()
onStartup
in interface OOrientStartupListener
onStartup
in class OOrientListenerAbstract
public void close()
public Object setProperty(String iName, Object iValue)
iName
- Property nameiValue
- new value to setCopyright © 2009–2020 OrientDB. All rights reserved.