Interface AdminConnection
-
- All Superinterfaces:
java.lang.AutoCloseable
- All Known Subinterfaces:
ClusterAdminConnection,ComputeAdminConnection,VirtualGraphAdminConnection
- All Known Implementing Classes:
AbstractAdminConnection,DelegatingAdminConnection,KernelAdminConnection
public interface AdminConnection extends java.lang.AutoCloseableA connection to the Stardog DBMS allowing access to the administrative functions provided by Stardog.
Any methods which return Strings are the information output returned from the server as a result of the invocation.
- Since:
- 2.0
- Version:
- 5.0.2
- Author:
- Michael Grove
-
-
Field Summary
Fields Modifier and Type Field Description static longNO_TIMEOUTConstant for specifying no timeout whenofflininga database.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description <T extends AdminConnection>
Tas(java.lang.Class<T> theView)Return this admin connection viewed as a different type of admin connection.default java.lang.Stringbackup(java.lang.String theDatabase)Deprecated.default java.lang.Stringbackup(java.lang.String theDatabase, java.io.File theLocation)Deprecated.Usebackup(String, Optional, Options)insteaddefault java.lang.Stringbackup(java.lang.String theDatabase, java.lang.String theBackupUrl)Deprecated.Usebackup(String, Optional, Options)insteadjava.lang.Stringbackup(java.lang.String theDatabase, java.util.Optional<java.lang.String> theBackupUrl, Options theOptions)Create a backup of the given database in the specified location.java.lang.StringbackupAll(Options theOptions)Create a backup of the server in the specified location.DatabaseBuilderbuilder(Metadata theOptions)Deprecated.To be removed in 5.1java.util.Collection<java.lang.String>checkpoint(java.lang.String theDatabase, Options theOptions)Perform a checkpoint operation (list, create, restore) against selected database.voidclose()Close this connection.default java.util.Map<java.lang.String,java.lang.Object>currentStatus(boolean theIncludeDbStatus)Deprecated.UsecurrentStatus(Options)insteadjava.util.Map<java.lang.String,java.lang.Object>currentStatus(Options theOptions)Return the server status information, including Server/Protocols running, Stardog Home path, OS, etc.DatabaseBuilderdisk(java.lang.String theName)Deprecated.UsenewDatabase(String)insteadjava.lang.Stringdrop(java.lang.String theName)Drop the database with the given name.java.io.FilegenerateDiagnosticReport(com.complexible.stardog.util.report.DiagnosticsReport theDiagnosticsReport)<T> Tget(java.lang.String theName, MetaProperty<T> theOption)Gets the value of the specified option in the given database.Metadataget(java.lang.String theName, java.lang.Iterable<? extends MetaProperty<?>> theOptions)Gets the values of the specified options in the given database.java.nio.file.PathgetLogs(Options options)Generates a zip file containing the server logs.PermissionManagergetPermissionManager()Return thePermissionManagerfor changing user & role permissionscom.complexible.stardog.process.ProcessManagergetProcessManager()MetadatagetProperty(java.util.Collection<java.lang.String> thePropertyNames)Gets the property value for a server configuration option.QueryManagergetQueryManager()Return theQueryManagerfor managing running queriesRoleManagergetRoleManager()Return theRoleManagerto be used for role-centric security changescom.complexible.stardog.StoredFunctionsgetStoredFunctions()Returns the stored functions in this server.StoredQueriesgetStoredQueries()Returns the stored queries in this server.com.complexible.stardog.security.TokenManagergetTokenManager()Return a link to the object that will allow clients to interact with JWT bearer tokensUserManagergetUserManager()Return theUserManagerto be used for user-centric security changesbooleanisOpen()Return whether or not this connection is open.java.util.Collection<java.lang.String>list()List all the databases in the Stardog serverDatabaseBuildernewDatabase(java.lang.String theName)Create a builder for creating a new database.java.lang.Stringoffline(java.lang.String theName)Makes the database offline according to the default strategy and default timeout.java.lang.Stringoffline(java.lang.String theName, long theTime, java.util.concurrent.TimeUnit theTimeUnit)Take the database offline waiting up to the specified timeout before performing a hard off-line.java.lang.Stringonline(java.lang.String theName)Makes the database online according to the default strategydefault java.lang.Stringoptimize(java.lang.String theName)Optimizesthe database with default options.java.lang.Stringoptimize(java.lang.String theName, Metadata theOptions)Optimizes the indexes of a given database for query answering and disk utilization after the database has been heavily modified.voidrenameDatabase(java.lang.String theOldName, java.lang.String theNewName)Rename an existing database to a new onejava.lang.Stringrepair(java.lang.String theName)Repairs the specified database if it is corrupted.java.lang.Stringrestore(java.io.File theBackup, boolean theOverwrite, java.lang.String theName)Restore the database backed up to the given locationjava.lang.Stringrestore(java.lang.String theBackupUrl, boolean theOverwrite, java.lang.String theName)<T> java.lang.Stringset(java.lang.String theName, MetaProperty<T> theOption, T theValue)Sets the value of the specified option for the database with the given name.java.lang.StringsetProperty(java.lang.String thePropertyName, java.lang.String theNewValue)Requests that the specified server configuration option value be changed to the new value.voidshutdown()Shutdown the remote Stardog server.java.lang.Stringverify(java.lang.String theDb)Verify the integrity of specified database's index.java.lang.Stringwhoami()Returns the username associated with this connection.
-
-
-
Field Detail
-
NO_TIMEOUT
static final long NO_TIMEOUT
Constant for specifying no timeout whenofflininga database.- See Also:
- Constant Field Values
-
-
Method Detail
-
as
<T extends AdminConnection> T as(java.lang.Class<T> theView) throws StardogException
Return this admin connection viewed as a different type of admin connection.- Type Parameters:
T- the connection view to return- Parameters:
theView- the type of connection to view this object as- Returns:
- the new view of the connection.
- Throws:
StardogException- if the connection cannot be viewed as the provided type. This could be from the parent connection having been closed or it does not support the provided view.
-
close
void close() throws StardogExceptionClose this connection. If the connection is already closed, this will have no effect.- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
StardogException- if there was an error while closing
-
isOpen
boolean isOpen() throws StardogExceptionReturn whether or not this connection is open.- Returns:
- true if it is open, false otherwise
- Throws:
StardogException- if there was an error with the connection
-
builder
@Deprecated DatabaseBuilder builder(Metadata theOptions) throws StardogException
Deprecated.To be removed in 5.1Convenience method to create a database builder with the given options. The provided options should include at least two options: the name of the database and the index type.- Returns:
- a builder for a database
- Throws:
StardogException- if there was an error while creating the db
-
disk
@Deprecated DatabaseBuilder disk(java.lang.String theName) throws StardogException
Deprecated.UsenewDatabase(String)insteadCreate a new builder for creating disk databases- Parameters:
theName- the name of the disk database to create- Returns:
- a builder for a disk database
- Throws:
StardogException- if the name of the database is invalid
-
newDatabase
DatabaseBuilder newDatabase(java.lang.String theName) throws StardogException
Create a builder for creating a new database.- Parameters:
theName- the name of the database to create- Returns:
- a builder for a database
- Throws:
StardogException- if the name of the database is invalid
-
renameDatabase
void renameDatabase(java.lang.String theOldName, java.lang.String theNewName) throws StardogExceptionRename an existing database to a new one- Parameters:
theOldName- the old database nametheNewName- the new database name- Throws:
StardogException- if the database name is invalid or if the database is not offline.
-
get
Metadata get(java.lang.String theName, java.lang.Iterable<? extends MetaProperty<?>> theOptions) throws StardogException
Gets the values of the specified options in the given database. The returned map is not guaranteed tocontainall the specified options. Only the values forknown Stardog optionsthat are should bereadablewill be contained in the result. This function will throw an exception if the user does not have read access to the database metadata.- Parameters:
theName- database nametheOptions- options for which values will be retrieved- Returns:
- metadata that contains values for the specified met properties
- Throws:
StardogException- if an error occurs while retrieving option values
-
get
<T> T get(java.lang.String theName, MetaProperty<T> theOption) throws StardogExceptionGets the value of the specified option in the given database. The function will returnnullif the option is NOT aknown Stardog options, or if it is NOTreadable. The function may also returnnullif the option is set tonullvalue for the database. To differentiate these cases,get(String, Iterable)function can be used instead. This function will throw an exception if the user does not have read access to the database metadata.- Type Parameters:
T- type of the option value- Parameters:
theName- name of the databasetheOption- the option to get- Returns:
- current value of the option in the database or
nullas explained above - Throws:
StardogException- if there was an error while getting the value
-
set
<T> java.lang.String set(java.lang.String theName, MetaProperty<T> theOption, T theValue) throws StardogExceptionSets the value of the specified option for the database with the given name. For this function to complete without an exception, the logged in user should have write access to the database metadata for the specified database, the option should be aknown Stardog option, the provided value should bevalid, and either the option should bewritable onlineor it should bewritableand the database should NOT beonline.- Type Parameters:
T- type of the option value- Parameters:
theName- name of the databasetheOption- option to settheValue- option value- Throws:
StardogException- if an error occurs trying to set the option value
-
getProperty
Metadata getProperty(java.util.Collection<java.lang.String> thePropertyNames) throws StardogException
Gets the property value for a server configuration option. This value will be the default for the option or the override in the properties file.- Parameters:
thePropertyNames- filter for the properties to return. Empty set will match all properties.- Returns:
- Metadata created with config values "MetaProperty.config(key, value).temporary().build()"
- Throws:
StardogException
-
setProperty
java.lang.String setProperty(java.lang.String thePropertyName, java.lang.String theNewValue) throws StardogExceptionRequests that the specified server configuration option value be changed to the new value. This method will notify any listening server modules about the change request. It is not guaranteed that the listening module will update the value.- Parameters:
thePropertyName-theNewValue-- Returns:
- Throws:
StardogException
-
offline
java.lang.String offline(java.lang.String theName, long theTime, java.util.concurrent.TimeUnit theTimeUnit) throws StardogExceptionTake the database offline waiting up to the specified timeout before performing a hard off-line. A database going offline will allow open connections to complete, but will not accept new, incoming connections.
Offline databases cannot be queried or updated and will be unaccessible to users.
Specifying a timeout of 0 will immediately shut down the database severing all open connections, i.e. a hard shutdown.
- Parameters:
theName- name of the databasetheTime- timeout duration, must be a positive numbertheTimeUnit- the unit of time for the timeout, cannot be null- Returns:
- the server output of offline
- Throws:
StardogException- if there was an error while offlining the database
-
offline
java.lang.String offline(java.lang.String theName) throws StardogExceptionMakes the database offline according to the default strategy and default timeout. Offline databases cannot be queried or updated and will be inaccessible to users.- Returns:
- the server output of offline
- Throws:
StardogException
-
online
java.lang.String online(java.lang.String theName) throws StardogExceptionMakes the database online according to the default strategy- Parameters:
theName- the name of the database- Returns:
- the server output of onlining the database
- Throws:
StardogException- if there was an error while onlining the database
-
optimize
default java.lang.String optimize(java.lang.String theName) throws StardogExceptionOptimizesthe database with default options.- Parameters:
theName- the name of the database to optimize- Returns:
- the server output of optimize
- Throws:
StardogException- if an error occurs during optimization
-
optimize
java.lang.String optimize(java.lang.String theName, Metadata theOptions) throws StardogExceptionOptimizes the indexes of a given database for query answering and disk utilization after the database has been heavily modified. If a database has been modified with a large number of additions or removals, some internal structures may become less optimized for query answering. This utility will perform several operations that will help with query answering performance. Which operations are performed depends on the options given.Optimization will NOT modify the database contents. The data layout, indexes and other internal structures might change but the data stored in the database will remain same.
- Parameters:
theName- the name of the database to optimizetheOptions- options specifying the specific optimization steps to perform or empty for default optimizations- Returns:
- the server output of optimize
- Throws:
StardogException- if an error occurs during optimization
-
list
java.util.Collection<java.lang.String> list() throws StardogExceptionList all the databases in the Stardog server- Returns:
- the list of databases
- Throws:
StardogException- if there was an error getting the list
-
repair
java.lang.String repair(java.lang.String theName) throws StardogExceptionRepairs the specified database if it is corrupted. If the database is not corrupted, nothing will be repaired.- Parameters:
theName- the name of the database to repair- Returns:
- the server output of the repair
- Throws:
StardogException- if there was an error while repairing
-
shutdown
void shutdown() throws com.complexible.stardog.security.StardogSecurityExceptionShutdown the remote Stardog server. You must be connected to the server as a super-user.- Throws:
com.complexible.stardog.security.StardogSecurityException- if you are attempting to shut down the embedded server or if you are not a super-user and are trying to shut down a remote server.
-
drop
java.lang.String drop(java.lang.String theName) throws StardogExceptionDrop the database with the given name.- Parameters:
theName- the name of the database to drop- Returns:
- the Result of the invocation
- Throws:
StardogException- if there was an error while dropping the database
-
backup
@Deprecated default java.lang.String backup(java.lang.String theDatabase) throws StardogExceptionDeprecated.Create a backup of the given database to the default location.- Parameters:
theDatabase- the name of the database to back up- Returns:
- the output of the backup process
- Throws:
StardogException- if there is an error performing the backup.
-
backup
@Deprecated default java.lang.String backup(java.lang.String theDatabase, java.io.File theLocation) throws StardogExceptionDeprecated.Usebackup(String, Optional, Options)insteadCreate a backup of the given database in the specified location.- Parameters:
theDatabase- the name of the database to back uptheLocation- where to store the backup- Returns:
- the output of the backup process
- Throws:
StardogException- if there is an error performing the backup.
-
backup
@Deprecated default java.lang.String backup(java.lang.String theDatabase, java.lang.String theBackupUrl) throws StardogExceptionDeprecated.Usebackup(String, Optional, Options)insteadCreate a backup of the given database in the specified location.- Parameters:
theDatabase- the name of the database to back uptheBackupUrl- where to store the backup- Returns:
- the output of the backup process
- Throws:
StardogException- if there is an error performing the backup.
-
backup
java.lang.String backup(java.lang.String theDatabase, java.util.Optional<java.lang.String> theBackupUrl, Options theOptions) throws StardogExceptionCreate a backup of the given database in the specified location. The location can be a file path on the server or a URL pointing to S3 or GCP.Configuration optionscan be specified for the backup operation.- Parameters:
theDatabase- the name of the database to back uptheBackupUrl- where to store the backup or empty if the default location should be usedtheOptions- configuration options to use for backups- Returns:
- Throws:
StardogException
-
backupAll
java.lang.String backupAll(Options theOptions) throws StardogException
Create a backup of the server in the specified location.- Parameters:
theOptions- Collection of BackupOptions- Returns:
- the output of the backup process
- Throws:
StardogException- if there is an error performing the backup.
-
restore
java.lang.String restore(java.io.File theBackup, boolean theOverwrite, java.lang.String theName) throws StardogExceptionRestore the database backed up to the given location- Parameters:
theBackup- the location of the backuptheOverwrite- whether or not to overwrite any existing databasetheName- a new name for the restored database- Returns:
- the output of the restore process
- Throws:
StardogException- if there was an error restoring the database from a backup
-
restore
java.lang.String restore(java.lang.String theBackupUrl, boolean theOverwrite, java.lang.String theName) throws StardogException- Throws:
StardogException
-
checkpoint
java.util.Collection<java.lang.String> checkpoint(java.lang.String theDatabase, Options theOptions) throws StardogExceptionPerform a checkpoint operation (list, create, restore) against selected database.- Parameters:
theDatabase- the name of the database for checkpoint operationtheOptions- configuration options for the checkpoint- Returns:
- Throws:
StardogException
-
getUserManager
UserManager getUserManager()
Return theUserManagerto be used for user-centric security changes- Returns:
- the UserManager
-
getRoleManager
RoleManager getRoleManager()
Return theRoleManagerto be used for role-centric security changes- Returns:
- the RoleManager
-
getPermissionManager
PermissionManager getPermissionManager()
Return thePermissionManagerfor changing user & role permissions- Returns:
- the PermissionManager
-
getQueryManager
QueryManager getQueryManager()
Return theQueryManagerfor managing running queries
-
getProcessManager
com.complexible.stardog.process.ProcessManager getProcessManager()
- Returns:
- The
ProcessManagerfor managing running queries
-
getTokenManager
com.complexible.stardog.security.TokenManager getTokenManager()
Return a link to the object that will allow clients to interact with JWT bearer tokens- Returns:
- the TokenManager
-
currentStatus
@Deprecated default java.util.Map<java.lang.String,java.lang.Object> currentStatus(boolean theIncludeDbStatus) throws StardogExceptionDeprecated.UsecurrentStatus(Options)insteadReturn the server status information, including Server/Protocols running, Stardog Home path, OS, etc- Parameters:
theIncludeDbStatus- if true thedatabase statusinformation about each database is included- Returns:
- the Metadata with the DBMS information
- Throws:
StardogException- if there was an error retrieving the DBMS info
-
currentStatus
java.util.Map<java.lang.String,java.lang.Object> currentStatus(Options theOptions) throws StardogException
Return the server status information, including Server/Protocols running, Stardog Home path, OS, etc. Theoptionscan be used to configure which metrics will be included in the results.- Parameters:
theOptions- the options for customizing the metrics that will be returned- Returns:
- the metrics showing the server status
- Throws:
StardogException- if there was an error retrieving the DBMS info- See Also:
MetricOptions
-
getStoredQueries
StoredQueries getStoredQueries()
Returns the stored queries in this server. Returned object can be used to add and remove stored queries.- Returns:
- the stored queries
- Since:
- 4.2
-
getStoredFunctions
com.complexible.stardog.StoredFunctions getStoredFunctions()
Returns the stored functions in this server. Returned object can be used to add and remove stored functions.- Returns:
- the stored functions
- Since:
- 5.1
-
verify
java.lang.String verify(java.lang.String theDb)
Verify the integrity of specified database's index.- Parameters:
theDb- the name of the database to verify- Returns:
- the output of the verify operation
- Throws:
StardogException- if there was an error while verifying the database
-
whoami
java.lang.String whoami()
Returns the username associated with this connection. Useful when API tokens are used to establish the connection.- Returns:
- username
-
generateDiagnosticReport
java.io.File generateDiagnosticReport(com.complexible.stardog.util.report.DiagnosticsReport theDiagnosticsReport)
-
getLogs
java.nio.file.Path getLogs(Options options)
Generates a zip file containing the server logs.- Parameters:
options- thelog options- Returns:
- a zip file containing the server logs
-
-