Class Allocator

java.lang.Object
io.narayana.db.Allocator
Direct Known Subclasses:
CIPostgreAllocator, DBAllocator, ExternalDBAllocator, H2Allocator, PostgreContainerAllocator

public abstract class Allocator extends Object
Start databases according to the profile. The goal is to be able to work both with platform independent simple H2 example, locally started databases in containers, e.g. Postgres, and with remote databases configured via REST API, e.g. MS SQL, Oracle, Maria and more.
Author:
Michal Karm Babacek
  • Constructor Details

    • Allocator

      public Allocator()
  • Method Details

    • getInstance

      public static Allocator getInstance() throws IOException
      Throws:
      IOException
    • allocateDB

      public abstract DB allocateDB(int expiryMinutes)
    • allocateDB

      public abstract DB allocateDB()
    • deallocateDB

      public abstract boolean deallocateDB(DB db)
    • reallocateDB

      public abstract boolean reallocateDB(int expiryMinutes, DB db)
    • reallocateDB

      public abstract boolean reallocateDB(DB db)
    • cleanDB

      public abstract boolean cleanDB(DB db)
    • executeTestStatement

      public static boolean executeTestStatement(DB db, String pathToDriverJar) throws ClassNotFoundException, MalformedURLException, IllegalAccessException, InstantiationException, SQLException
      Loads proper driver dynamically. Credit: http://www.kfu.com/%7Ensayer/Java/dyn-jdbc.html

      Executes a simple SELECT 1 statement to verify the DB actually does something.

      Parameters:
      db - , used as: dbUrl JDBC connection URL user DB user pass DB password driverClass e.g. org.postgresql.Driver pathToDriverJar Either a downloaded driver jar or a one from ShrinkWrap Maven resolver overallTimeoutMs How long do we keep trying with 1000ms pause in between
      Returns:
      true on success
      Throws:
      ClassNotFoundException - Fix the driver class name
      MalformedURLException - Fix the driver jar path
      IllegalAccessException
      InstantiationException
      SQLException
    • getProp

      public static String getProp(String prop)