|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.franz.ag.AllegroGraphConnection
This class implements access to AllegroGraph triple stores through a server interface.
One instance of this class can support access to several open triple stores, each with its own AllegroGraph instance. A Java application may connect to multiple servers by creating multiple instances of this class.
Constructor Summary | |
AllegroGraphConnection()
Create an instance of a connection to an AllegroGraph Server. |
Method Summary | |
AllegroGraph |
access(AllegroGraph ag)
Connect an AllegroGraph instance to a triple store. |
AllegroGraph |
access(java.lang.String name,
java.lang.String directory)
Create an instance that accesses an existing AllegroGraph triple store or a freshly created new empty triple store. |
AllegroGraph |
create(AllegroGraph ag)
Connect an AllegroGraph instance to a triple store. |
AllegroGraph |
create(java.lang.String name,
java.lang.String directory)
Create an AllegroGraph instance that accesses a new empty AllegroGraph triple store. |
void |
deleteStore(java.lang.String name)
Delete the triple store with the given name. |
void |
deleteStore(java.lang.String name,
java.lang.String directory)
Delete the triple store with the given name. |
void |
disable()
Disable the interface. |
void |
disable(boolean close)
Disable the interface. |
boolean |
enable()
Enable the interface by connecting to an AllegroGraph server. |
void |
enableHasValueReasoning()
Enable reasoning with the hasValue predicate. |
java.lang.Object[] |
evalInServer(java.lang.String expression)
Evaluate a Lisp expession in the AllegroGraph server. |
boolean |
exists(java.lang.String name,
java.lang.String directory)
Determine if an AllegroGraph triple store exists. |
AllegroGraph |
federate(java.lang.String name,
AllegroGraph[] parts,
boolean supersede)
Combine several open triple stores into one federated triple store. |
AllegroGraph |
findStore(java.lang.String name)
Find an open triple store with the given name. |
AllegroGraph |
findStore(java.lang.String name,
java.lang.String directory)
Find an open triple store with the given name. |
long |
getChunkSize()
Query the indexing chunk size in the AllegroGraph server. |
java.lang.String |
getCommand()
Retrieve the command used to start an AllegroGraph server. |
int |
getDebug()
Retrieve the debug flag. |
static java.lang.String |
getDefaultCommand()
Retrieve the static default command used to start an AllegroGraph server. |
static int |
getDefaultDebug()
Retrieve the static default debug flag. |
long |
getDefaultExpectedResources()
Get the current server default value for the expected number of unique resources in a new triple store. |
static java.lang.String |
getDefaultHost()
Retrieve the static default host name. |
static java.lang.String |
getDefaultMode()
Retrieve the static default connection mode. |
static int |
getDefaultPollCount()
Retrieve the static default value of the poll count parameter. |
static int |
getDefaultPollInterval()
Retrieve the static default value of the poll interval parameter. |
static int |
getDefaultPort()
Retrieve the static default primary port number. |
static int |
getDefaultPort2()
Retrieve the static default secondary port number. |
static boolean |
getDefaultServerKeep()
Retrieve the static default value of the Server Keep flag. |
static int |
getDefaultTimeout()
Retrieve the static default value of the connection timeout. |
java.lang.String |
getHost()
Retrieve the host name. |
static NamespaceRegistry |
getInitialNamespaceRegistry()
Query the current initial namespace registry. |
java.lang.String |
getMode()
Retrieve the connection mode. |
NamespaceRegistry |
getNamespaceRegistry()
|
java.lang.String[] |
getNamespaces()
Query the namespace definitions in the AllegroGraph server. |
int |
getPollCount()
Retrieve the current value of the poll count parameter. |
int |
getPollInterval()
Retrieve the current value of the poll interval parameter. |
int |
getPort()
Retrieve the primary port number. |
int |
getPort2()
Retrieve the secondary port number. |
boolean |
getServerKeep()
Retrieve the value of the Server Keep flag. |
int |
getTimeout()
Retrieve the current timeout value for this connection. |
int |
interrupt()
Attempt to interrupt an operation in the AllegroGraph server. |
boolean |
isBusy()
Query the state of the AllegroGraph/Java connection. |
boolean |
isEnabled()
Query the state of the AllegroGraph/Java connection. |
static void |
main(java.lang.String[] args)
Run this method to set the default AllegroGraph server command once per installation. |
AllegroGraph |
open(AllegroGraph ag)
Connect an AllegroGraph instance to a triple store. |
AllegroGraph |
open(java.lang.String name,
java.lang.String directory)
Create an instance that accesses an existing AllegroGraph triple store. |
void |
registerNamespace(java.lang.String prefix,
java.lang.String full)
Register one namespace definition. |
void |
registerNamespaces(java.lang.String[] defs)
Register several namespace definitions. |
AllegroGraph |
renew(AllegroGraph ag)
Connect an AllegroGraph instance to a triple store. |
AllegroGraph |
renew(java.lang.String name,
java.lang.String directory)
Create an instance that accesses an AllegroGraph triple store. |
AllegroGraph |
replace(AllegroGraph ag)
Connect an AllegroGraph instance to a triple store. |
AllegroGraph |
replace(java.lang.String name,
java.lang.String directory)
Create an instance that accesses an AllegroGraph triple store. |
boolean |
serverLevel(int level)
Query the implementation level of the AllegroGraph server. |
int |
serverTrace(boolean onoff)
Change the trace state in the AllegroGraph server. |
int |
serverTrace(java.lang.String outFile)
Start tracing calls from Java in the AllegroGraph server. |
void |
setChunkSize(long s)
Set the indexing chunk size in the AllegroGraph server. |
void |
setCommand(java.lang.String cmd)
Set the command used to start an AllegroGraph server. |
void |
setDebug(int db)
Set the debug flag. |
static void |
setDefaultCommand(java.lang.String cmd)
Set the static default command used to start an AllegroGraph server. |
static void |
setDefaultDebug(int db)
Set the static default debug flag. |
void |
setDefaultExpectedResources(long s)
Set the current server default value for the expected number of unique resources in a new triple store. |
static void |
setDefaultHost(java.lang.String host)
Set the static default host name. |
static void |
setDefaultPolling(int count,
int interval)
Set the static default values of the poll count and poll interval parameters. |
static void |
setDefaultPort(int port)
Set the static default primary port number. |
static void |
setDefaultPort2(int port)
Set the static default secondary port number. |
void |
setDefaultServerKeep(boolean v)
Set the static default value of the Server Keep flag. |
static void |
setDefaultTimeout(int defaultTimeout)
Set the default timeout value for connection attempts. |
void |
setHost(java.lang.String newhost)
Set the host name. |
static void |
setInitialNamespaceRegistry(NamespaceRegistry ns)
Set the current initial namespace registry. |
void |
setNamespaceRegistry(NamespaceRegistry ns)
Register several namespace definitions. |
void |
setPolling(int count,
int interval)
Set the current values of the poll count and poll interval parameters. |
void |
setPort(int p)
Set the primary port number. |
void |
setPort2(int p)
Set the secondary port number. |
void |
setServerKeep(boolean v)
Set the value of the Server Keep flag. |
void |
setTimeout(int timeout)
Set the timeout value for connection attempts. |
void |
startServer()
Start a system process running an AllegroGraph server. |
void |
startServer(java.lang.String log)
Start a system process running an AllegroGraph server. |
int |
stopServer()
Stop an AllegroGraph server process that was started by this Java application. |
int |
stopServer(boolean killNotStarted)
Stop an AllegroGraph server process. |
java.lang.String |
toString()
Display some details about the server instance. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public AllegroGraphConnection()
Method Detail |
public static NamespaceRegistry getInitialNamespaceRegistry()
public static void setInitialNamespaceRegistry(NamespaceRegistry ns)
ns
- the instance to set. If this is set to null, then there is no
default namespace registry.
The initial value is NamespaceRegistry.RDFandOwl.
public static int getDefaultPollCount()
public static int getDefaultPollInterval()
public int getPollCount()
public int getPollInterval()
public static void setDefaultPolling(int count, int interval)
count
- an integer that determines the number of connection attemptsinterval
- an integer that determines the interval between
attempts to connect
A positive value greater than zero is used to set the corresponding parameter. If a zero or negative value is specified, the corresponding parameter is unchanged.
The initial static defaults are 2 for poll count and 500 for poll interval.
public void setPolling(int count, int interval)
count
- an integer that determines the number of connection attemptsinterval
- an integer that determines the interval between
attempts to connect
A positive value greater than zero is used to set the corresponding parameter.
If a zero value is specified, set the current value of the parameter from the static default value.
If a negative value is specified, the corresponding parameter is unchanged.
The inital values are set from the static default values.
If an application encounters timeout exceptions when attempting a connection one or both of these parameters should be given a larger value.
public static java.lang.String getDefaultMode()
public java.lang.String getMode()
public static int getDefaultPort()
public static void setDefaultPort(int port)
port
- A port number.public int getPort()
public void setPort(int p)
p
- A port number.public static int getDefaultPort2()
public static void setDefaultPort2(int port)
port
- A port number.public int getPort2()
public void setPort2(int p)
p
- A port number.public static java.lang.String getDefaultHost()
public static void setDefaultHost(java.lang.String host)
host
- A host name string. The empty string denotes the
loopback host "localhost".public java.lang.String getHost()
public void setHost(java.lang.String newhost)
newhost
- A host name string. The empty string denotes the
loopback host "localhost".public static int getDefaultDebug()
public static void setDefaultDebug(int db)
db
- When true, new instances of AllegroGraphConnection are
created in debug mode and produce additional progress messages.
A zero value suppresses all output. Values 1 to 4 produce
increasing amounts of output.public int getDebug()
public void setDebug(int db)
db
- When >0, new instances of AllegroGraphConnection are
created in debug mode and produce additional progress messages.public static java.lang.String getDefaultCommand()
public static void setDefaultCommand(java.lang.String cmd)
cmd
- A command string that will start the AllegroGraph
server process in the local machine.
If the static default command is not set explicitly, it is looked up in the Java System property "com.franz.ag.exec". If it set to " ", the string containing one space. then a value is obtained from
public java.lang.String getCommand()
public void setCommand(java.lang.String cmd)
cmd
- A command string that will start the AllegroGraph
server process in the local machine.public static boolean getDefaultServerKeep()
public void setDefaultServerKeep(boolean v)
The Server Keep flag determines the behavior when an instance of AllegroGraphConnection is discarded. If the instance called startServer() and the Server Keep flag is false, then the server process is terminated. Otherwise the server process is left running.
v
- public boolean getServerKeep()
getDefaultServerKeep()
public void setServerKeep(boolean v)
The Server Keep flag determines the behavior when an instance of AllegroGraphConnection is discarded. If the instance called startServer() and the Server Keep flag is false, then the server process is terminated. Otherwise the server process is left running.
v
- public boolean enable() throws java.io.IOException, AllegroGraphException
java.io.IOException
- if the interface cannot be enabled.
Only one instance with mode "jlinker" can be enabled at any one time in each running Java application.
AllegroGraphException
public int interrupt() throws AllegroGraphException, java.io.IOException
AllegroGraphException
java.io.IOException
public void disable() throws AllegroGraphException
AllegroGraphException
public void disable(boolean close)
close
- If true, close any open triple stores before disabling the
interface.
All remote references to AllegroGraph data are invalidated by this call.
If called with a false arguments, any open triple stores will remain open for a while, at most until the AllegroGraph server is shut down. This option should be used only if the application is such that any open AllegroGraph instances will never be used again.
public boolean isEnabled()
public boolean isBusy()
public AllegroGraph create(java.lang.String name, java.lang.String directory) throws AllegroGraphException
triple stores are created with the methods access(), create(), open(), renew(), and replace().
name
- the name of the triple store or a pathname string that specifies
the name and location of the triple store. If the name argument is a
pathname string then the directory argument must be null.directory
- the directory where the data base does or will reside.
If this argument is a non-null string, then the name argument must
be a simple name.
AllegroGraphException
- if the triple store exists already,
or if the new triple store cannot be created for any other reason.public AllegroGraph create(AllegroGraph ag) throws AllegroGraphException
This form is useful when additional attributes must be set
with AllegroGraph.setAttribute(String, Object)
before connecting to the triple store.
ag
- An unconnected AllegroGraph instance.
AllegroGraphException
public AllegroGraph open(java.lang.String name, java.lang.String directory) throws AllegroGraphException
triple stores are created with the methods access(), create(), open(), renew(), and replace().
name
- the name of the triple store or a pathname string that specifies
the name and location of the triple store. If the name argument is a
pathname string then the directory argument must be null.directory
- the directory where the data base does or will reside.
If this argument is a non-null string, then the name argument must
be a simple name.
AllegroGraphException
- if the triple store does not exist
or if it cannot be opened for any other reason.public AllegroGraph open(AllegroGraph ag) throws AllegroGraphException
This form is useful when additional attributes must be set
with AllegroGraph.setAttribute(String, Object)
before connecting to the triple store.
ag
- An unconnected AllegroGraph instance.
AllegroGraphException
public boolean exists(java.lang.String name, java.lang.String directory) throws AllegroGraphException
name
- the name of the triple store or a pathname string that specifies
the name and location of the triple store. If the name argument is a
pathname string then the directory argument must be null.directory
- the directory where the data base does or will reside.
If this argument is a non-null string, then the name argument must
be a simple name.
AllegroGraphException
- if the call fails for some reason.
If this method returns true, then creating an AllegroGraph instance with the open() method will succeed.
public AllegroGraph access(java.lang.String name, java.lang.String directory) throws AllegroGraphException
Triple stores are created with the methods access(), create(), open(), renew(), and replace().
name
- the name of the triple store or a pathname string that specifies
the name and location of the triple store. If the name argument is a
pathname string then the directory argument must be null.directory
- the directory where the data base does or will reside.
If this argument is a non-null string, then the name argument must
be a simple name.
AllegroGraphException
- if the triple store cannot be opened or created.public AllegroGraph access(AllegroGraph ag) throws AllegroGraphException
This form is useful when additional attributes must be set
with AllegroGraph.setAttribute(String, Object)
before connecting to the triple store.
ag
- An unconnected AllegroGraph instance.
AllegroGraphException
public AllegroGraph renew(java.lang.String name, java.lang.String directory) throws AllegroGraphException
Triple stores are created with the methods access(), create(), open(), renew(), and replace().
name
- the name of the triple store or a pathname string that specifies
the name and location of the triple store. If the name argument is a
pathname string then the directory argument must be null.directory
- the directory where the data base does or will reside.
If this argument is a non-null string, then the name argument must
be a simple name.
If the operation implies the deletion of a triple store, the entire directory is deleted.
AllegroGraphException
- if the triple store cannot be accessed or
created.public AllegroGraph renew(AllegroGraph ag) throws AllegroGraphException
This form is useful when additional attributes must be set
with AllegroGraph.setAttribute(String, Object)
before connecting to the triple store.
ag
- An unconnected AllegroGraph instance.
AllegroGraphException
public AllegroGraph replace(java.lang.String name, java.lang.String directory) throws AllegroGraphException
Triple stores are created with the methods access(), create(), open(), renew(), and replace().
name
- the name of the triple store or a pathname string that specifies
the name and location of the triple store. If the name argument is a
pathname string then the directory argument must be null.directory
- the directory where the data base does or will reside.
If this argument is a non-null string, then the name argument must
be a simple name.
Since the operation implies the deletion of a triple store, the entire directory is deleted.
AllegroGraphException
- if the triple store does not exist,
or if it cannot be replaced for any reason.public AllegroGraph replace(AllegroGraph ag) throws AllegroGraphException
This form is useful when additional attributes must be set
with AllegroGraph.setAttribute(String, Object)
before connecting to the triple store.
ag
- An unconnected AllegroGraph instance.
AllegroGraphException
public long getChunkSize() throws AllegroGraphException
AllegroGraphException
public void setChunkSize(long s) throws AllegroGraphException
s
- the desired chunk size
The built-in default value is 1,048,576 (2 to the 20th) on 32-bit platforms and 2,097,152 (2 to the 21st) on 64-bit platforms.
Note that this is a global value that affects all the triple stores in a server.
AllegroGraphException
public long getDefaultExpectedResources() throws AllegroGraphException
AllegroGraphException
public void setDefaultExpectedResources(long s) throws AllegroGraphException
If the number is too small, performance may suffer during triple store creation. A rough rule of thumb is to specify a number that is one third of the number of triples. The built-in default is 100000.
s
- the new value.
AllegroGraphException
public java.lang.Object[] evalInServer(java.lang.String expression) throws AllegroGraphException
expression
- A string containing a well-formed Lisp expression.
AllegroGraphException
- * Usage:
This method allows a Java application to run programs in the AllegroGraph server. Using this method can change the state of the server and the content of triple stores. It is provided as a diagnostic aid, and as a tool for advanced users.
By default, this method is disabled in the server. It must be enabled by starting the server with a file of permitted expression patterns. See the server reference for details.
Most uses of this method will require some knowledge of the Lisp programing language, and an understanding of the AllegroGraph implementation.
The evaluation environment contains bindings for *package*, *readtable*. Each AllegroGraphConnection instance defines a distinct default environment.
The initial value of *package* is the db.agraph.user package. It uses :cl, :excl, :db.agraph, and :prolog. If the value of *package* is modified, the change persists for subsequent calls to evalInServer on the same connection.
The initial value of *readtable* is a copy of the standard Common Lisp readtable. If the value of *readtable* is modified, the change persists for subsequent calls to evalInServer on the same connection.
Side-effects on the environment persist as long as the connection is maintained.
If a Java application needs to mention symbols in a fixed application package (maybe mentioned in a source file), it may be advisable to evaluate an in-package form in the environment.
The variable *db* is bound if AllegroGraph.evalInServer is called but if modified, the change will not persist.
public int serverTrace(boolean onoff)
onoff
- true to turn on tracing.
When tracing is turned on in the AllegroGraph server, every call from Java to the server causes some output on the server console. This output may be useful in diagnosing some problems. Since tracing may produce large quantities of output it should be used with caution and only around critical sections of code.
The trace state is global for all connections to the server.
public boolean serverLevel(int level) throws AllegroGraphException
level
- A positive integer.
AllegroGraphException
public int serverTrace(java.lang.String outFile)
outFile
- the name and path for a file where the trace output will go.
When tracing is turned on in the AllegroGraph server, every call from Java to the server causes some output on the server console. This output may be useful in diagnosing some problems. Since tracing may produce large quantities of output it should be used with caution and only around critical sections of code.
The trace state is global for all connections to the server.
public java.lang.String[] getNamespaces() throws AllegroGraphException
AllegroGraphException
public NamespaceRegistry getNamespaceRegistry()
public void registerNamespace(java.lang.String prefix, java.lang.String full)
prefix
- the prefixfull
- The full namespace text. If the full text is null
or "", then the prefix is removed from the table.
AllegroGraphException
public void registerNamespaces(java.lang.String[] defs)
defs
- An array of strings. The even numbered elements are prefixes
and the following odd numbered element is the full namespace text.
If the full text is null or "", then the prefix is removed
from the table.public void setNamespaceRegistry(NamespaceRegistry ns)
ns
- the source of the definitions.public java.lang.String toString()
public void startServer() throws java.io.IOException
startServer(null)
.
java.io.IOException
public void startServer(java.lang.String log) throws java.io.IOException
log
- The name of a log file or null. If non-null, the AG server
writes a log to this file in the home directory.
java.io.IOException
- from Runtime.exec().
If the command was specified with setCommand(String)
or with setDefaultCommand(String)
then the command
specified by the program is used.
If the command is specified as "" or " " and the system property "com.franz.ag.exec" is set then the property value is used.
If the command is specified " " then system and user Preferences are examined. The Preferences values may be set by executing the main() method in this class.
public int stopServer() throws java.io.IOException, AllegroGraphException
java.io.IOException
AllegroGraphException
public int stopServer(boolean killNotStarted) throws java.io.IOException, AllegroGraphException
killNotStarted
- if false, stop the server if it was started
by this application; if true, stop the server even if it was
started some other way.
java.io.IOException
AllegroGraphException
public static void main(java.lang.String[] args)
args
- The arguments to the JVM invocation.
java AllegroGraphConnection [-system command] [-user command]If the
-system
argument is supplied, set the
default for all users.
If the -user
argument is supplied, set the
default for the current user only.
The command argument is the absolute pathname to the AllegroGraphJavaServer executable.
public void enableHasValueReasoning() throws AllegroGraphException
AllegroGraphException
public AllegroGraph federate(java.lang.String name, AllegroGraph[] parts, boolean supersede) throws AllegroGraphException
name
- A name for the federation. It is best to use a unique name.parts
- The triple stores that will be federated.
All the compoent triple stores must be open and must be connected through
the same connection.supersede
- When false, throw an exception if a triple store with the
same name is already open. When true, and an open triple store with the
same name is found, then close the triple store before making the
federation. If the existing triple store was a federated store, it is
destroyed by closing it; If the existing triple store is a persisitent
store, then closing it simply makes it unavailable until reopened.
AllegroGraphException
public AllegroGraph findStore(java.lang.String name) throws AllegroGraphException
name
- The name of a triple store. This can be a simple name
or a pathname string.
AllegroGraphException
- if the name is not found or ambiguous.public AllegroGraph findStore(java.lang.String name, java.lang.String directory) throws AllegroGraphException
name
- The name of a triple store.directory
- The directory where the triple store is filed. This
argument can be used to identify one of several triple stores with
the same name. If this argument is a non-null string, then the name
argument must be a simple name.
AllegroGraphException
- if the name is not found or ambiguous.public void deleteStore(java.lang.String name) throws AllegroGraphException
name
- The name of a triple store. This can be a simple name
or a pathname string.
AllegroGraphException
- if the name is not found or ambiguous.public void deleteStore(java.lang.String name, java.lang.String directory) throws AllegroGraphException
name
- The name of a triple store.directory
- The directory where the triple store is filed. This
argument can be used to identify one of several triple stores with
the same name. If this argument is a non-null string, then the name
argument must be a simple name.
AllegroGraphException
- if the name is not found or ambiguous.public static int getDefaultTimeout()
getTimeout()
.public static void setDefaultTimeout(int defaultTimeout)
defaultTimeout
- the defaultTimeout to set in milliseconds.
See also setTimeout(int)
.public int getTimeout()
getDefaultTimeout()
.
The value is modified with setTimeout(int)
.
public void setTimeout(int timeout)
timeout
- the timeout to set in milliseconds.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |