public class HGEnvironment extends Object
This class provides some facilities to manage several open HyperGraph databases within a single virtual machine. This is useful when one needs to access a currently open database by its location.
The class essentially implements a static map of currently open databases. The
general name HGEnvironment
reflects the intent to eventually
put JVM-wide operations here.
Constructor and Description |
---|
HGEnvironment() |
Modifier and Type | Method and Description |
---|---|
static void |
closeAll()
Close all currently open
HyperGraph instances. |
static void |
configure(String location,
HGConfiguration config)
Configure a HyperGraphDB instance before it is actually opened.
|
static void |
disableShutdownHook()
Disable the HyperGraph JVM shutdown hook.
|
static ExecutorService |
executor()
Return the environment-wide ExecutorService.
|
static boolean |
exists(String location)
Return
true if there is a HyperGraph database at the given location
and false otherwise. |
static HyperGraph |
get(String location)
Retrieve an already opened or open a HyperGraph instance.
|
static HyperGraph |
get(String location,
HGConfiguration config)
Retrieve the HyperGraphDB instance at the specified location and open it
(if not already opened) with the given configuration.
|
static HGConfiguration |
getConfiguration(String location)
Retrieve the configuration of a HyperGraphDB instance.
|
static HyperGraph |
getExistingOnly(String location)
Same as
get , but will return null if there is
no database at that location. |
static MemoryWarningSystem |
getMemoryWarningSystem()
Return the singleton
MemoryWarningSystem attached to this
JVM. |
static HGDatabaseVersionFile |
getVersions(String location)
Return the
HGDatabaseVersionFile containing version information
for the various components on the database instance at the directory
specified by the location parameter. |
static boolean |
isOpen(String location)
Return
true if the database at the given location is already
open and false otherwise. |
public static MemoryWarningSystem getMemoryWarningSystem()
Return the singleton MemoryWarningSystem
attached to this
JVM.
public static HyperGraph get(String location)
Retrieve an already opened or open a HyperGraph instance. Note that a new
database instance will potentially be created via new HyperGraph(location)
if it doesn't already exist.
location
- The location of the HyperGraph instance.public static HyperGraph get(String location, HGConfiguration config)
Retrieve the HyperGraphDB instance at the specified location and open it (if not already opened) with the given configuration. If the instance has already been opened, the configuration parameter is ignored.
location
- The filesystem path of the database instance.config
- The set of configuration parameters.public static HyperGraph getExistingOnly(String location)
Same as get
, but will return null
if there is
no database at that location.
public static boolean exists(String location)
Return true
if there is a HyperGraph database at the given location
and false
otherwise.
public static boolean isOpen(String location)
Return true
if the database at the given location is already
open and false
otherwise.
public static void configure(String location, HGConfiguration config)
Configure a HyperGraphDB instance before it is actually opened. If the instance at that location is already opened, the new configuration will only take effect if you close and re-open the instance.
location
- The filesystem path to the database instance.config
- A HGConfiguration
with the desired parameters set.public static HGConfiguration getConfiguration(String location)
Retrieve the configuration of a HyperGraphDB instance. If no configuration was previously defined, a new one will be created.
location
- The filesystem path to the HyperGraphDB instance.public static HGDatabaseVersionFile getVersions(String location)
Return the HGDatabaseVersionFile
containing version information
for the various components on the database instance at the directory
specified by the location
parameter.
public static void closeAll()
Close all currently open HyperGraph
instances. This is generally
done by a HyperGraphDB internal shutdown hook registered with the JVM. But if
you need more control over the shutdown sequence, this method will gracefully
do so.
public static void disableShutdownHook()
Disable the HyperGraph JVM shutdown hook. The role of the shutdown hook is the close
all open databases gracefully. If you disable, no such process is triggered upon
JVM shutdown. If you have your own shutdown hook that must take upon that task, you can
call the closeAll
method.
public static ExecutorService executor()
Return the environment-wide ExecutorService. The executor service is shared between all opened databases. It is used to submit long running tasks such as queries and wait for them to complete.
Copyright © 2015. All rights reserved.