Class DelegatingAdminConnection
java.lang.Object
com.google.common.collect.ForwardingObject
com.complexible.stardog.api.admin.DelegatingAdminConnection
- All Implemented Interfaces:
AdminConnection,AutoCloseable
public class DelegatingAdminConnection
extends com.google.common.collect.ForwardingObject
implements AdminConnection
- Since:
- 2.2
- Version:
- 5.0.2
- Author:
- Michael Grove
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.complexible.stardog.api.admin.AdminConnection
AdminConnection.StreamConsumer, AdminConnection.TxLogRange -
Field Summary
Fields inherited from interface com.complexible.stardog.api.admin.AdminConnection
NO_TIMEOUT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends AdminConnection>
TReturn this admin connection viewed as a different type of admin connection.Create a backup of the given database in the specified location.Create a backup of the server in the specified location.Deprecated.checkpoint(String theDatabase, Options theOptions) Perform a checkpoint operation (list, create, restore) against selected database.voidclose()Close this connection.currentStatus(Options theOptions) Return the server status information, including Server/Protocols running, Stardog Home path, OS, etc.protected AdminConnectiondelegate()Deprecated.Drop the database with the given name.generateDiagnosticReport(com.complexible.stardog.util.report.DiagnosticsReport theDiagnosticsReport) <T> Tget(String theName, MetaProperty<T> theOption) Gets the value of the specified option in the given database.get(String theName, Iterable<? extends MetaProperty<?>> theOptions) Gets the values of the specified options in the given database.Generates a zip file containing the server logs.Return thePermissionManagerfor changing user & role permissionscom.complexible.stardog.process.ProcessManagergetProperty(Collection<String> thePropertyNames) Gets the property value for a server configuration option.Return theQueryManagerfor managing running queriesReturn theRoleManagerto be used for role-centric security changescom.complexible.stardog.StoredFunctionsReturns the stored functions in this server.Returns the stored queries in this server.com.complexible.stardog.security.TokenManagerReturn a link to the object that will allow clients to interact with JWT bearer tokensReturn theUserManagerto be used for user-centric security changesbooleanisOpen()Return whether or not this connection is open.list()List all the databases in the Stardog servernewDatabase(String theName) Create a builder for creating a new database.Makes the database offline according to the default strategy and default timeout.Take the database offline waiting up to the specified timeout before performing a hard off-line.Makes the database online according to the default strategyOptimizes the indexes of a given database for query answering and disk utilization after the database has been heavily modified.voidrenameDatabase(String theOldName, String theNewName) Rename an existing database to a new oneRepairs the specified database if it is corrupted.replayTransactionLog(String theDb, Path theInputLog, boolean validateLog) Replays the transaction log from the specified file into the given database.Restore the database backed up to the given location<T> Stringset(String theName, MetaProperty<T> theOption, T theValue) Sets the value of the specified option for the database with the given name.setProperty(String thePropertyName, String theNewValue) Requests that the specified server configuration option value be changed to the new value.voidshutdown()Shutdown the remote Stardog server.voidtransactionLog(String theDb, AdminConnection.TxLogRange range, AdminConnection.StreamConsumer theStreamConsumer) Streams the transaction log for the specified database and range to the provided consumer.Verify the integrity of specified database's index.whoami()Returns the username associated with this connection.Methods inherited from class com.google.common.collect.ForwardingObject
toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.complexible.stardog.api.admin.AdminConnection
backup, backup, backup, currentStatus, optimize
-
Constructor Details
-
DelegatingAdminConnection
-
-
Method Details
-
builder
Deprecated.Convenience 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.- Specified by:
builderin interfaceAdminConnection- Returns:
- a builder for a database
- Throws:
StardogException- if there was an error while creating the db
-
disk
Deprecated.Create a new builder for creating disk databases- Specified by:
diskin interfaceAdminConnection- 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
-
delegate
- Specified by:
delegatein classcom.google.common.collect.ForwardingObject
-
as
Return this admin connection viewed as a different type of admin connection.- Specified by:
asin interfaceAdminConnection- 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
Close this connection. If the connection is already closed, this will have no effect.- Specified by:
closein interfaceAdminConnection- Specified by:
closein interfaceAutoCloseable- Throws:
StardogException- if there was an error while closing
-
isOpen
Return whether or not this connection is open.- Specified by:
isOpenin interfaceAdminConnection- Returns:
- true if it is open, false otherwise
- Throws:
StardogException- if there was an error with the connection
-
newDatabase
Create a builder for creating a new database.- Specified by:
newDatabasein interfaceAdminConnection- 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
Description copied from interface:AdminConnectionRename an existing database to a new one- Specified by:
renameDatabasein interfaceAdminConnection- 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
public Metadata get(String theName, 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.- Specified by:
getin interfaceAdminConnection- 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
Gets 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,AdminConnection.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.- Specified by:
getin interfaceAdminConnection- 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
public <T> String set(String theName, MetaProperty<T> theOption, T theValue) throws StardogException Sets 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.- Specified by:
setin interfaceAdminConnection- 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
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.- Specified by:
getPropertyin interfaceAdminConnection- 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
Requests 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.- Specified by:
setPropertyin interfaceAdminConnection- Parameters:
thePropertyName-theNewValue-- Returns:
- Throws:
StardogException
-
offline
Take 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.
- Specified by:
offlinein interfaceAdminConnection- 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
Makes the database offline according to the default strategy and default timeout. Offline databases cannot be queried or updated and will be inaccessible to users.- Specified by:
offlinein interfaceAdminConnection- Returns:
- the server output of offline
- Throws:
StardogException
-
online
Makes the database online according to the default strategy- Specified by:
onlinein interfaceAdminConnection- 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
Optimizes 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.
- Specified by:
optimizein interfaceAdminConnection- 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
List all the databases in the Stardog server- Specified by:
listin interfaceAdminConnection- Returns:
- the list of databases
- Throws:
StardogException- if there was an error getting the list
-
repair
Repairs the specified database if it is corrupted. If the database is not corrupted, nothing will be repaired.- Specified by:
repairin interfaceAdminConnection- 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
-
verify
Verify the integrity of specified database's index.- Specified by:
verifyin interfaceAdminConnection- Parameters:
theName- 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
Description copied from interface:AdminConnectionReturns the username associated with this connection. Useful when API tokens are used to establish the connection.- Specified by:
whoamiin interfaceAdminConnection- Returns:
- username
-
generateDiagnosticReport
public File generateDiagnosticReport(com.complexible.stardog.util.report.DiagnosticsReport theDiagnosticsReport) - Specified by:
generateDiagnosticReportin interfaceAdminConnection
-
getLogs
Generates a zip file containing the server logs.- Specified by:
getLogsin interfaceAdminConnection- Parameters:
options- thelog options- Returns:
- a zip file containing the server logs
-
shutdown
public void shutdown() throws com.complexible.stardog.security.StardogSecurityExceptionShutdown the remote Stardog server. You must be connected to the server as a super-user.- Specified by:
shutdownin interfaceAdminConnection- 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
Drop the database with the given name.- Specified by:
dropin interfaceAdminConnection- 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
-
backupAll
Create a backup of the server in the specified location.- Specified by:
backupAllin interfaceAdminConnection- Parameters:
theOptions- Collection of BackupOptions- Returns:
- the output of the backup process
- Throws:
StardogException- if there is an error performing the backup.
-
backup
public String backup(String theDatabase, Optional<String> theBackupUrl, Options theOptions) throws StardogException Create 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.- Specified by:
backupin interfaceAdminConnection- 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
-
restore
Restore the database backed up to the given location- Specified by:
restorein interfaceAdminConnection- 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
public String restore(String theBackup, boolean theOverwrite, String theName) throws StardogException - Specified by:
restorein interfaceAdminConnection- Throws:
StardogException
-
checkpoint
public Collection<String> checkpoint(String theDatabase, Options theOptions) throws StardogException Perform a checkpoint operation (list, create, restore) against selected database.- Specified by:
checkpointin interfaceAdminConnection- Parameters:
theDatabase- the name of the database for checkpoint operationtheOptions- configuration options for the checkpoint- Returns:
- Throws:
StardogException
-
getUserManager
Return theUserManagerto be used for user-centric security changes- Specified by:
getUserManagerin interfaceAdminConnection- Returns:
- the UserManager
-
getRoleManager
Return theRoleManagerto be used for role-centric security changes- Specified by:
getRoleManagerin interfaceAdminConnection- Returns:
- the RoleManager
-
getPermissionManager
Return thePermissionManagerfor changing user & role permissions- Specified by:
getPermissionManagerin interfaceAdminConnection- Returns:
- the PermissionManager
-
getQueryManager
Return theQueryManagerfor managing running queries- Specified by:
getQueryManagerin interfaceAdminConnection
-
getProcessManager
public com.complexible.stardog.process.ProcessManager getProcessManager()- Specified by:
getProcessManagerin interfaceAdminConnection- Returns:
- The
ProcessManagerfor managing running queries
-
getTokenManager
public com.complexible.stardog.security.TokenManager getTokenManager()Return a link to the object that will allow clients to interact with JWT bearer tokens- Specified by:
getTokenManagerin interfaceAdminConnection- Returns:
- the TokenManager
-
currentStatus
Description copied from interface:AdminConnectionReturn 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.- Specified by:
currentStatusin interfaceAdminConnection- 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:
-
getStoredQueries
Description copied from interface:AdminConnectionReturns the stored queries in this server. Returned object can be used to add and remove stored queries.- Specified by:
getStoredQueriesin interfaceAdminConnection- Returns:
- the stored queries
-
getStoredFunctions
public com.complexible.stardog.StoredFunctions getStoredFunctions()Description copied from interface:AdminConnectionReturns the stored functions in this server. Returned object can be used to add and remove stored functions.- Specified by:
getStoredFunctionsin interfaceAdminConnection- Returns:
- the stored functions
-
transactionLog
public void transactionLog(String theDb, AdminConnection.TxLogRange range, AdminConnection.StreamConsumer theStreamConsumer) throws com.complexible.stardog.server.UnknownTransactionException Description copied from interface:AdminConnectionStreams the transaction log for the specified database and range to the provided consumer.- Specified by:
transactionLogin interfaceAdminConnection- Parameters:
theDb- the database namerange- the range of transaction logs to retrievetheStreamConsumer- the consumer that will process the transaction log stream- Throws:
com.complexible.stardog.server.UnknownTransactionException
-
replayTransactionLog
Description copied from interface:AdminConnectionReplays the transaction log from the specified file into the given database.- Specified by:
replayTransactionLogin interfaceAdminConnection- Parameters:
theDb- the database nametheInputLog- the input log file pathvalidateLog- Validates that the first transaction in the log matches the last transaction in the database before replaying.- Returns:
- The output of the tx replay operation
-