Class ODatabasePoolBase<DB extends ODatabaseInternal>

java.lang.Object
java.lang.Thread
com.orientechnologies.orient.core.db.ODatabasePoolBase<DB>
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
ODatabaseDocumentPool, OObjectDatabasePool

public abstract class ODatabasePoolBase<DB extends ODatabaseInternal> extends Thread
Database pool base class.
Author:
Luca Garulli (l.garulli--(at)--orientdb.com)
  • Field Details

  • Constructor Details

    • ODatabasePoolBase

      protected ODatabasePoolBase()
    • ODatabasePoolBase

      protected ODatabasePoolBase(String iURL, String iUserName, String iUserPassword)
  • Method Details

    • setup

      public ODatabasePoolBase<DB> setup()
    • setup

      public ODatabasePoolBase<DB> setup(int iMinSize, int iMaxSize)
    • setup

      public ODatabasePoolBase<DB> setup(int iMinSize, int iMaxSize, long idleTimeout, long timeBetweenEvictionRunsMillis)
    • acquire

      public DB acquire()
      Acquires a connection from the pool using the configured URL, user-name and user-password. If the pool is empty, then the caller thread will wait for it.
      Returns:
      A pooled database instance
    • acquire

      public DB acquire(String iName, String iUserName, String iUserPassword)
      Acquires a connection from the pool. If the pool is empty, then the caller thread will wait for it.
      Parameters:
      iName - Database name
      iUserName - User name
      iUserPassword - User password
      Returns:
      A pooled database instance
    • getAvailableConnections

      public int getAvailableConnections(String name, String userName)
      Returns amount of available connections which you can acquire for given source and user name. Source id is consist of "source name" and "source user name".
      Parameters:
      name - Source name.
      userName - User name which is used to acquire source.
      Returns:
      amount of available connections which you can acquire for given source and user name.
    • getCreatedInstances

      public int getCreatedInstances(String name, String userName)
    • acquire

      public DB acquire(String iName, String iUserName, String iUserPassword, Map<String,Object> iOptionalParams)
      Acquires a connection from the pool specifying options. If the pool is empty, then the caller thread will wait for it.
      Parameters:
      iName - Database name
      iUserName - User name
      iUserPassword - User password
      Returns:
      A pooled database instance
    • getConnectionsInCurrentThread

      public int getConnectionsInCurrentThread(String name, String userName)
    • release

      public void release(DB iDatabase)
      Don't call it directly but use database.close().
      Parameters:
      iDatabase -
    • close

      public void close()
      Closes the entire pool freeing all the connections.
    • getMaxSize

      public int getMaxSize()
      Returns the maximum size of the pool
    • getPools

      public Map<String,OReentrantResourcePool<String,DB>> getPools()
      Returns all the configured pools.
    • remove

      public void remove(String iName, String iUser)
      Removes a pool by name/user
    • run

      public void run()
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • createResource

      protected abstract DB createResource(Object owner, String iDatabaseName, Object... iAdditionalArgs)