Class OrientGraphFactory

java.lang.Object
com.tinkerpop.blueprints.impls.orient.OrientConfigurableGraph
com.tinkerpop.blueprints.impls.orient.OrientGraphFactory

public class OrientGraphFactory extends OrientConfigurableGraph
Orient Graph factory. It supports also a pool of instances that are recycled.
Author:
Luca Garulli
  • Constructor Details

    • OrientGraphFactory

      public OrientGraphFactory(String iURL)
      Creates a factory that use default admin credentials and pool with maximum amount of connections equal to amount of CPU cores.
      Parameters:
      iURL - to the database
    • OrientGraphFactory

      public OrientGraphFactory(String iURL, boolean createPool)
      Creates a factory that use default admin credentials and pool with maximum amount of connections equal to amount of CPU cores if needed.
      Parameters:
      iURL - to the database
      createPool - flag which indicates whether pool should be created.
    • OrientGraphFactory

      public OrientGraphFactory(String iURL, String iUser, String iPassword)
      Creates a factory with given credentials and pool with maximum amount of connections equal to amount of CPU cores.

      If you wish to change pool settings call com.tinkerpop.blueprints.impls.orient.OrientGraphFactory#setupPool(int, int) method.

      Parameters:
      iURL - to the database
      iUser - name of the user
      iPassword - of the user
    • OrientGraphFactory

      public OrientGraphFactory(String iURL, String iUser, String iPassword, boolean createPool)
      Creates a factory with given credentials and pool with maximum amount of connections equal to amount of CPU cores if that is needed.

      If you wish to change pool settings call com.tinkerpop.blueprints.impls.orient.OrientGraphFactory#setupPool(int, int) method.

      Parameters:
      iURL - to the database
      iUser - name of the user
      iPassword - of the user
      createPool - flag which indicates whether pool should be created.
    • OrientGraphFactory

      public OrientGraphFactory(String iURL, String iUser, String iPassword, OPartitionedDatabasePool pool)
      Creates a factory with given credentials also you may pass pool which you already use in "document part" of your application. It is mandatory to use the same pool for document and graph databases.
      Parameters:
      iURL - to the database
      iUser - name of the user
      iPassword - password of the user
      pool - Pool which is used in "document part" of your application.
  • Method Details

    • close

      public void close()
      Closes all pooled databases and clear the pool.
    • drop

      public void drop()
      Drops current database if such one exists.
    • getTx

      public OrientGraph getTx()
      Gets transactional graph with the database from pool if pool is configured. Otherwise creates a graph with new db instance. The Graph instance inherits the factory's configuration.
      Returns:
      transactional graph
    • getNoTx

      public OrientGraphNoTx getNoTx()
      Gets non transactional graph with the database from pool if pool is configured. Otherwise creates a graph with new db instance. The Graph instance inherits the factory's configuration.
      Returns:
      non transactional graph
    • getTxGraphImplFactory

      public static OrientGraphFactory.OrientGraphImplFactory getTxGraphImplFactory()
    • setTxGraphImplFactory

      public static void setTxGraphImplFactory(OrientGraphFactory.OrientGraphImplFactory factory)
    • getNoTxGraphImplFactory

      public static OrientGraphFactory.OrientGraphImplFactory getNoTxGraphImplFactory()
    • setNoTxGraphImplFactory

      public static void setNoTxGraphImplFactory(OrientGraphFactory.OrientGraphImplFactory factory)
    • getDatabase

      public ODatabaseDocumentTx getDatabase()
      Gives new connection to database. If current factory configured to use pool (see setupPool(int, int) method), retrieves connection from pool. Otherwise creates new connection each time.

      Automatically creates database if database with given URL does not exist

      Shortcut for getDatabase(true)

      Returns:
      database.
    • getDatabase

      public ODatabaseDocumentTx getDatabase(boolean iCreate, boolean iOpen)
      Gives new connection to database. If current factory configured to use pool (see setupPool(int, int) method), retrieves connection from pool. Otherwise creates new connection each time.
      Parameters:
      iCreate - if true automatically creates database if database with given URL does not exist
      iOpen - if true automatically opens the database
      Returns:
      database
    • exists

      public boolean exists()
      Check if the database with path given to the factory exists.

      this api can be used only in embedded mode, and has no need of authentication.

      Returns:
      true if database is exists
    • setupPool

      public OrientGraphFactory setupPool(int iMin, int iMax)
      Setting up the factory to use database pool instead of creation a new instance of database connection each time.
      Parameters:
      iMin - minimum size of pool
      iMax - maximum size of pool
      Returns:
      this
    • getAvailableInstancesInPool

      public int getAvailableInstancesInPool()
      Returns the number of available instances in the pool.
    • getCreatedInstancesInPool

      public int getCreatedInstancesInPool()
      Returns the total number of instances created in the pool.
    • declareIntent

      public void declareIntent(OIntent iIntent)
      Specified by:
      declareIntent in class OrientConfigurableGraph
    • initGraph

      protected void initGraph(OrientBaseGraph g)
    • setProperty

      public Object setProperty(String iName, Object iValue)
      Sets a property value
      Specified by:
      setProperty in class OrientConfigurableGraph
      Parameters:
      iName - Property name
      iValue - new value to set
      Returns:
      The previous value if any, otherwise null
    • getProperty

      public Object getProperty(String iName)
      Gets the property value.
      Specified by:
      getProperty in class OrientConfigurableGraph
      Parameters:
      iName - Property name
      Returns:
      The previous value if any, otherwise null
    • getProperties

      protected Map<String,Object> getProperties()
      Specified by:
      getProperties in class OrientConfigurableGraph