Class DelegatingAdminConnection
- java.lang.Object
-
- com.google.common.collect.ForwardingObject
-
- com.complexible.stardog.api.admin.DelegatingAdminConnection
-
- All Implemented Interfaces:
AdminConnection
,java.lang.AutoCloseable
public class DelegatingAdminConnection extends com.google.common.collect.ForwardingObject implements AdminConnection
- Since:
- 2.2
- Version:
- 5.0.2
- Author:
- Michael Grove
-
-
Field Summary
-
Fields inherited from interface com.complexible.stardog.api.admin.AdminConnection
NO_TIMEOUT
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DelegatingAdminConnection(AdminConnection theConnection)
-
Method Summary
All Methods Instance Methods Concrete 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.java.lang.String
backup(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.String
backupAll()
Create a backup of the server to the default location.java.lang.String
backupAll(java.io.File theLocation)
Create a backup of the server in the specified location.java.lang.String
backupAll(java.lang.String theLocation)
Create a backup of the server in the specified location.DatabaseBuilder
builder(Metadata theOptions)
Deprecated.void
changeEncryptionPassword(java.lang.String theOldPassword, java.lang.String theNewPassword)
Change the user managed encryption password.java.util.Collection<java.lang.String>
checkpoint(java.lang.String theDatabase, Options theOptions)
Perform a checkpoint operation (list, create, restore) against selected database.void
close()
Close this connection.void
createNewEncryptionKey(java.lang.String thePassPhrase, java.lang.String keyName)
Add a new key for encrypting data.java.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.protected AdminConnection
delegate()
void
disableEncryption(java.lang.String thePassPhrase)
Stop the server from using data encryption on all future data.DatabaseBuilder
disk(java.lang.String theName)
Deprecated.java.lang.String
drop(java.lang.String theName)
Drop the database with the given name.java.util.Collection<java.lang.String>
fileKeyList(java.lang.String thePassPhrase)
Return the list of keys which have been used for encryption.java.io.File
generateDiagnosticReport(com.complexible.stardog.util.report.DiagnosticsReport theDiagnosticsReport)
<T> T
get(java.lang.String theName, MetaProperty<T> theOption)
Gets the value of the specified option in the given database.Metadata
get(java.lang.String theName, java.lang.Iterable<? extends MetaProperty<?>> theOptions)
Gets the values of the specified options in the given database.PermissionManager
getPermissionManager()
Return thePermissionManager
for changing user & role permissionscom.complexible.stardog.process.ProcessManager
getProcessManager()
Metadata
getProperty(java.util.Collection<java.lang.String> thePropertyNames)
Gets the property value for a server configuration option.QueryManager
getQueryManager()
Return theQueryManager
for managing running queriesRoleManager
getRoleManager()
Return theRoleManager
to be used for role-centric security changescom.complexible.stardog.StoredFunctions
getStoredFunctions()
Returns the stored functions in this server.StoredQueries
getStoredQueries()
Returns the stored queries in this server.com.complexible.stardog.security.TokenManager
getTokenManager()
Return a link to the object that will allow clients to interact with JWT bearer tokensUserManager
getUserManager()
Return theUserManager
to be used for user-centric security changesboolean
isOpen()
Return whether or not this connection is open.java.util.Collection<java.lang.String>
list()
List all the databases in the Stardog serverDatabaseBuilder
newDatabase(java.lang.String theName)
Create a builder for creating a new database.java.lang.String
offline(java.lang.String theName)
Makes the database offline according to the default strategy and default timeout.java.lang.String
offline(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.String
online(java.lang.String theName)
Makes the database online according to the default strategyjava.lang.String
optimize(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.void
removeEncryptionPassword(java.lang.String thePassword)
Remove the user managed password for the encryption of data.java.lang.String
repair(java.lang.String theName)
Repairs the specified database if it is corrupted.java.lang.String
restore(java.io.File theBackup, boolean theOverwrite, java.lang.String theName)
Restore the database backed up to the given locationjava.lang.String
restore(java.lang.String theBackup, boolean theOverwrite, java.lang.String theName)
<T> java.lang.String
set(java.lang.String theName, MetaProperty<T> theOption, T theValue)
Sets the value of the specified option for the database with the given name.void
setEncryptionPassword(java.lang.String thePassword)
Encrypt all data keys against the given password.java.lang.String
setProperty(java.lang.String thePropertyName, java.lang.String theNewValue)
Requests that the specified server configuration option value be changed to the new value.void
shutdown()
Shutdown the remote Stardog server.java.lang.String
verify(java.lang.String theName)
Verify the integrity of specified database's index.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.complexible.stardog.api.admin.AdminConnection
backup, backup, backup, currentStatus, optimize
-
-
-
-
Constructor Detail
-
DelegatingAdminConnection
protected DelegatingAdminConnection(AdminConnection theConnection)
-
-
Method Detail
-
builder
@Deprecated public DatabaseBuilder builder(Metadata theOptions) throws StardogException
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:
builder
in interfaceAdminConnection
- Returns:
- a builder for a database
- Throws:
StardogException
- if there was an error while creating the db
-
disk
@Deprecated public DatabaseBuilder disk(java.lang.String theName) throws StardogException
Deprecated.Create a new builder for creating disk databases- Specified by:
disk
in 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
protected AdminConnection delegate()
- Specified by:
delegate
in classcom.google.common.collect.ForwardingObject
-
as
public <T extends AdminConnection> T as(java.lang.Class<T> theView) throws StardogException
Return this admin connection viewed as a different type of admin connection.- Specified by:
as
in 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
public void close() throws StardogException
Close this connection. If the connection is already closed, this will have no effect.- Specified by:
close
in interfaceAdminConnection
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
StardogException
- if there was an error while closing
-
isOpen
public boolean isOpen() throws StardogException
Return whether or not this connection is open.- Specified by:
isOpen
in interfaceAdminConnection
- Returns:
- true if it is open, false otherwise
- Throws:
StardogException
- if there was an error with the connection
-
newDatabase
public DatabaseBuilder newDatabase(java.lang.String theName) throws StardogException
Create a builder for creating a new database.- Specified by:
newDatabase
in 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
-
get
public 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 tocontain
all the specified options. Only the values forknown Stardog options
that are should bereadable
will 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:
get
in 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
public <T> T get(java.lang.String theName, MetaProperty<T> theOption) throws StardogException
Gets the value of the specified option in the given database. The function will returnnull
if the option is NOT aknown Stardog options
, or if it is NOTreadable
. The function may also returnnull
if the option is set tonull
value 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:
get
in 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
null
as explained above - Throws:
StardogException
- if there was an error while getting the value
-
set
public <T> java.lang.String set(java.lang.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 online
or it should bewritable
and the database should NOT beonline
.- Specified by:
set
in 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
public 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.- Specified by:
getProperty
in interfaceAdminConnection
- Returns:
- Throws:
StardogException
-
setProperty
public java.lang.String setProperty(java.lang.String thePropertyName, java.lang.String theNewValue) throws StardogException
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:
setProperty
in interfaceAdminConnection
- Returns:
- Throws:
StardogException
-
offline
public java.lang.String offline(java.lang.String theName, long theTime, java.util.concurrent.TimeUnit theTimeUnit) throws StardogException
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:
offline
in 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
public java.lang.String offline(java.lang.String theName) throws StardogException
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:
offline
in interfaceAdminConnection
- Returns:
- the server output of offline
- Throws:
StardogException
-
online
public java.lang.String online(java.lang.String theName) throws StardogException
Makes the database online according to the default strategy- Specified by:
online
in 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
public java.lang.String optimize(java.lang.String theName, Metadata theOptions) throws StardogException
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:
optimize
in 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
public java.util.Collection<java.lang.String> list() throws StardogException
List all the databases in the Stardog server- Specified by:
list
in interfaceAdminConnection
- Returns:
- the list of databases
- Throws:
StardogException
- if there was an error getting the list
-
repair
public java.lang.String repair(java.lang.String theName) throws StardogException
Repairs the specified database if it is corrupted. If the database is not corrupted, nothing will be repaired.- Specified by:
repair
in 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
public java.lang.String verify(java.lang.String theName) throws StardogException
Verify the integrity of specified database's index.- Specified by:
verify
in 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
-
generateDiagnosticReport
public java.io.File generateDiagnosticReport(com.complexible.stardog.util.report.DiagnosticsReport theDiagnosticsReport)
- Specified by:
generateDiagnosticReport
in interfaceAdminConnection
-
shutdown
public void shutdown() throws com.complexible.stardog.security.StardogSecurityException
Shutdown the remote Stardog server. You must be connected to the server as a super-user.- Specified by:
shutdown
in 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
public java.lang.String drop(java.lang.String theName) throws StardogException
Drop the database with the given name.- Specified by:
drop
in 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
-
setEncryptionPassword
public void setEncryptionPassword(java.lang.String thePassword) throws StardogException
Encrypt all data keys against the given password. This will issue a command to Stardog which will set a user managed password for the encryption of data. If this is not set Stardog will fully manage the encryption keys and all secrets that access them.- Specified by:
setEncryptionPassword
in interfaceAdminConnection
- Parameters:
thePassword
- the password that will protect the encryption keys- Throws:
StardogException
-
changeEncryptionPassword
public void changeEncryptionPassword(java.lang.String theOldPassword, java.lang.String theNewPassword) throws StardogException
Change the user managed encryption password.- Specified by:
changeEncryptionPassword
in interfaceAdminConnection
- Parameters:
theOldPassword
- the current passwordtheNewPassword
- the new password- Throws:
StardogException
-
removeEncryptionPassword
public void removeEncryptionPassword(java.lang.String thePassword) throws StardogException
Remove the user managed password for the encryption of data. Once this is removed Stardog will maintain the unencrypted keys which are used to encrypt the data.- Specified by:
removeEncryptionPassword
in interfaceAdminConnection
- Parameters:
thePassword
- the current password- Throws:
StardogException
-
createNewEncryptionKey
public void createNewEncryptionKey(java.lang.String thePassPhrase, java.lang.String keyName) throws StardogException
Add a new key for encrypting data. This will create a new Stardog managed encryption key. All data added after this new key is created will be encrypted with it. Any previously added data will not be affected by it. If a user managed password has been set then it must be passed in.- Specified by:
createNewEncryptionKey
in interfaceAdminConnection
- Parameters:
thePassPhrase
- the current encryption password. If no password is in use this can be an empty stringkeyName
- the name of the key. This must be unique to the system- Throws:
StardogException
-
disableEncryption
public void disableEncryption(java.lang.String thePassPhrase) throws StardogException
Stop the server from using data encryption on all future data. Currently encrypted data will be left encrypted. To re-enable encryption createNewEncryptionKey can be called again.- Specified by:
disableEncryption
in interfaceAdminConnection
- Parameters:
thePassPhrase
- the current encryption password. If no password is in use this can be an empty string- Throws:
StardogException
-
fileKeyList
public java.util.Collection<java.lang.String> fileKeyList(java.lang.String thePassPhrase) throws StardogException
Return the list of keys which have been used for encryption.- Specified by:
fileKeyList
in interfaceAdminConnection
- Parameters:
thePassPhrase
- the current encryption password. If no password is in use this can be an empty string- Returns:
- - the Result of the invocation;
- Throws:
StardogException
- if there is an error performing the backup.
-
backupAll
public java.lang.String backupAll() throws StardogException
Description copied from interface:AdminConnection
Create a backup of the server to the default location.- Specified by:
backupAll
in interfaceAdminConnection
- Returns:
- the output of the backup process
- Throws:
StardogException
- if there is an error performing the backup.
-
backupAll
public java.lang.String backupAll(java.lang.String theLocation) throws StardogException
Description copied from interface:AdminConnection
Create a backup of the server in the specified location.- Specified by:
backupAll
in interfaceAdminConnection
- Parameters:
theLocation
- where to store the backup- Returns:
- the output of the backup process
- Throws:
StardogException
- if there is an error performing the backup.
-
backupAll
public java.lang.String backupAll(java.io.File theLocation) throws StardogException
Description copied from interface:AdminConnection
Create a backup of the server in the specified location.- Specified by:
backupAll
in interfaceAdminConnection
- Parameters:
theLocation
- where to store the backup- Returns:
- the output of the backup process
- Throws:
StardogException
- if there is an error performing the backup.
-
backup
public java.lang.String backup(java.lang.String theDatabase, java.util.Optional<java.lang.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 options
can be specified for the backup operation.- Specified by:
backup
in 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
public java.lang.String restore(java.io.File theBackup, boolean theOverwrite, java.lang.String theName) throws StardogException
Restore the database backed up to the given location- Specified by:
restore
in 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 java.lang.String restore(java.lang.String theBackup, boolean theOverwrite, java.lang.String theName) throws StardogException
- Specified by:
restore
in interfaceAdminConnection
- Throws:
StardogException
-
checkpoint
public java.util.Collection<java.lang.String> checkpoint(java.lang.String theDatabase, Options theOptions) throws StardogException
Perform a checkpoint operation (list, create, restore) against selected database.- Specified by:
checkpoint
in interfaceAdminConnection
- Parameters:
theDatabase
- the name of the database for checkpoint operationtheOptions
- configuration options for the checkpoint- Returns:
- Throws:
StardogException
-
getUserManager
public UserManager getUserManager()
Return theUserManager
to be used for user-centric security changes- Specified by:
getUserManager
in interfaceAdminConnection
- Returns:
- the UserManager
-
getRoleManager
public RoleManager getRoleManager()
Return theRoleManager
to be used for role-centric security changes- Specified by:
getRoleManager
in interfaceAdminConnection
- Returns:
- the RoleManager
-
getPermissionManager
public PermissionManager getPermissionManager()
Return thePermissionManager
for changing user & role permissions- Specified by:
getPermissionManager
in interfaceAdminConnection
- Returns:
- the PermissionManager
-
getQueryManager
public QueryManager getQueryManager()
Return theQueryManager
for managing running queries- Specified by:
getQueryManager
in interfaceAdminConnection
-
getProcessManager
public com.complexible.stardog.process.ProcessManager getProcessManager()
- Specified by:
getProcessManager
in interfaceAdminConnection
- Returns:
- The
ProcessManager
for 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:
getTokenManager
in interfaceAdminConnection
- Returns:
- the TokenManager
-
currentStatus
public java.util.Map<java.lang.String,java.lang.Object> currentStatus(Options theOptions) throws StardogException
Description copied from interface:AdminConnection
Return the server status information, including Server/Protocols running, Stardog Home path, OS, etc. Theoptions
can be used to configure which metrics will be included in the results. The embedded connections do not support any options other thanMetricOptions.DATABASES
.- Specified by:
currentStatus
in 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:
MetricOptions
-
getStoredQueries
public StoredQueries getStoredQueries()
Description copied from interface:AdminConnection
Returns the stored queries in this server. Returned object can be used to add and remove stored queries.- Specified by:
getStoredQueries
in interfaceAdminConnection
- Returns:
- the stored queries
-
getStoredFunctions
public com.complexible.stardog.StoredFunctions getStoredFunctions()
Description copied from interface:AdminConnection
Returns the stored functions in this server. Returned object can be used to add and remove stored functions.- Specified by:
getStoredFunctions
in interfaceAdminConnection
- Returns:
- the stored functions
-
-