Package com.complexible.stardog.api

# Class KernelAdminConnection

java.lang.Object
com.complexible.stardog.api.admin.AbstractAdminConnection
com.complexible.stardog.api.KernelAdminConnection

All Implemented Interfaces:
  `AdminConnection`, `AutoCloseable`

public final class KernelAdminConnection extends AbstractAdminConnection

Since:
  5.0
Version:
  5.0
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
  Constructor
  Description
  `KernelAdminConnection(com.complexible.stardog.Kernel theKernel)`
  `KernelAdminConnection(com.complexible.stardog.Kernel theKernel, org.apache.shiro.subject.Subject theSubject, Options theOptions, Views<AdminConnection> theViews)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `_close()`
  `protected Metadata`
  `_get(String theName, Iterable<? extends MetaProperty<?>> theOptions)`
  `protected <T> String`
  `_set(String theName, MetaProperty<T> theOption, T theValue)`
  `String`
  `backup(String theDatabase, Optional<String> theBackupUrl, Options theOptions)`
  Create a backup of the given database in the specified location.
  `String`
  `backupAll(Options theOptions)`
  Create a backup of the server in the specified location.
  `<T> T`
  `call(Callable<T> theAction)`
  `Collection<String>`
  `checkpoint(String theDatabase, Options theOptions)`
  Perform a checkpoint operation (list, create, restore) against selected database.
  `Map<String,Object>`
  `currentStatus(Options theOptions)`
  Return the server status information, including Server/Protocols running, Stardog Home path, OS, etc.
  `String`
  `drop(String theName)`
  Drop the database with the given name.
  `File`
  `generateDiagnosticReport(com.complexible.stardog.util.report.DiagnosticsReport theDiagnosticsReport)`
  `Path`
  `getLogs(Options options)`
  Generates a zip file containing the server logs.
  `PermissionManager`
  `getPermissionManager()`
  Return the `PermissionManager` for changing user & role permissions
  `com.complexible.stardog.process.ProcessManager`
  `getProcessManager()`
  `Metadata`
  `getProperty(Collection<String> thePropertyNames)`
  Gets the property value for a server configuration option.
  `QueryManager`
  `getQueryManager()`
  Return the `QueryManager` for managing running queries
  `RoleManager`
  `getRoleManager()`
  Return the `RoleManager` to be used for role-centric security changes
  `com.complexible.stardog.StoredFunctions`
  `getStoredFunctions()`
  Returns the stored functions in this server.
  `com.complexible.stardog.InternalStoredQueries`
  `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 tokens
  `UserManager`
  `getUserManager()`
  Return the `UserManager` to be used for user-centric security changes
  `Collection<String>`
  `list()`
  List all the databases in the Stardog server
  `DatabaseBuilder`
  `newDatabaseBuilder()`
  `String`
  `offline(String theName, long theTime, TimeUnit theTimeUnit)`
  Take the database offline waiting up to the specified timeout before performing a hard off-line.
  `String`
  `online(String theName)`
  Makes the database online according to the default strategy
  `String`
  `optimize(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`
  `renameDatabase(String theOldName, String theNewName)`
  Rename an existing database to a new one
  `String`
  `repair(String theName)`
  Repairs the specified database if it is corrupted.
  `String`
  `replayTransactionLog(String theDb, Path theInputLog, boolean validateLog)`
  Replays the transaction log from the specified file into the given database.
  `String`
  `restore(File theBackup, boolean theOverwrite, String theName)`
  Restore the database backed up to the given location
  `String`
  `restore(String theBackup, boolean theOverwrite, String theName)`
  `void`
  `run(Runnable theAction)`
  `String`
  `setProperty(String thePropertyName, String theNewValue)`
  Requests that the specified server configuration option value be changed to the new value.
  `void`
  `shutdown()`
  Shutdown the remote Stardog server.
  `void`
  `transactionLog(String theDb, AdminConnection.TxLogRange range, AdminConnection.StreamConsumer theStreamConsumer)`
  Streams the transaction log for the specified database and range to the provided consumer.
  `String`
  `verify(String theName)`
  Verify the integrity of specified database's index.
  `String`
  `whoami()`
  Returns the username associated with this connection.

  ### Methods inherited from class com.complexible.stardog.api.admin.AbstractAdminConnection

  `as, assertOpen, assertValidName, builder, close, disk, get, get, isOpen, newDatabase, offline, set`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface com.complexible.stardog.api.admin.AdminConnection

  `backup, backup, backup, currentStatus, optimize`

- ## Constructor Details

  - ### KernelAdminConnection

    public KernelAdminConnection(com.complexible.stardog.Kernel theKernel)

  - ### KernelAdminConnection

    public KernelAdminConnection(com.complexible.stardog.Kernel theKernel, org.apache.shiro.subject.Subject theSubject, Options theOptions, Views<AdminConnection> theViews)

- ## Method Details

  - ### _close

    protected void _close()
    Specified by:
      `_close` in class `AbstractAdminConnection`

  - ### newDatabaseBuilder

    public DatabaseBuilder newDatabaseBuilder()
    Specified by:
      `newDatabaseBuilder` in class `AbstractAdminConnection`

  - ### renameDatabase

    public void renameDatabase(String theOldName, String theNewName) throws StardogException
    Description copied from interface: `AdminConnection`
    Rename an existing database to a new one
    Parameters:
      `theOldName` - the old database name
      `theNewName` - the new database name
    Throws:
      `StardogException` - if the database name is invalid or if the database is not offline.

  - ### _get

    protected Metadata _get(String theName, Iterable<? extends MetaProperty<?>> theOptions) throws StardogException
    Specified by:
      `_get` in class `AbstractAdminConnection`
    Throws:
      `StardogException`

  - ### _set

    protected <T> String _set(String theName, MetaProperty<T> theOption, T theValue) throws StardogException
    Specified by:
      `_set` in class `AbstractAdminConnection`
    Throws:
      `StardogException`

  - ### getProperty

    public Metadata getProperty(Collection<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

    public String setProperty(String thePropertyName, 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.
    Parameters:
      `thePropertyName` -
      `theNewValue` -
    Returns:
    Throws:
      `StardogException`

  - ### offline

    public String offline(String theName, long theTime, 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.

    Parameters:
      `theName` - name of the database
      `theTime` - timeout duration, must be a positive number
      `theTimeUnit` - 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

  - ### online

    public String online(String theName) throws StardogException
    Makes 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

    public String optimize(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.

    Parameters:
      `theName` - the name of the database to optimize
      `theOptions` - 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 Collection<String> list() throws StardogException
    List all the databases in the Stardog server
    Returns:
      the list of databases
    Throws:
      `StardogException` - if there was an error getting the list

  - ### repair

    public String repair(String theName) throws StardogException
    Repairs 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

  - ### verify

    public String verify(String theName) throws StardogException
    Verify the integrity of specified database's index.
    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

    public String whoami()
    Description copied from interface: `AdminConnection`
    Returns the username associated with this connection. Useful when API tokens are used to establish the connection.
    Returns:
      username

  - ### transactionLog

    public void transactionLog(String theDb, AdminConnection.TxLogRange range, AdminConnection.StreamConsumer theStreamConsumer)
    Description copied from interface: `AdminConnection`
    Streams the transaction log for the specified database and range to the provided consumer.
    Parameters:
      `theDb` - the database name
      `range` - the range of transaction logs to retrieve
      `theStreamConsumer` - the consumer that will process the transaction log stream

  - ### replayTransactionLog

    public String replayTransactionLog(String theDb, Path theInputLog, boolean validateLog)
    Description copied from interface: `AdminConnection`
    Replays the transaction log from the specified file into the given database.
    Parameters:
      `theDb` - the database name
      `theInputLog` - the input log file path
      `validateLog` - 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

  - ### 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.
    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 String drop(String theName) throws StardogException
    Drop 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

    public String backup(String theDatabase, Optional<String> theBackupUrl, Options theOptions) throws StardogException
    Description copied from interface: `AdminConnection`
    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.
    Parameters:
      `theDatabase` - the name of the database to back up
      `theBackupUrl` - where to store the backup or empty if the default location should be used
      `theOptions` - configuration options to use for backups
    Returns:
    Throws:
      `StardogException`

  - ### backupAll

    public 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

    public String restore(File theBackup, boolean theOverwrite, String theName) throws StardogException
    Restore the database backed up to the given location
    Parameters:
      `theBackup` - the location of the backup
      `theOverwrite` - whether or not to overwrite any existing database
      `theName` - 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
    Throws:
      `StardogException`

  - ### checkpoint

    public Collection<String> checkpoint(String theDatabase, Options theOptions) throws StardogException
    Description copied from interface: `AdminConnection`
    Perform a checkpoint operation (list, create, restore) against selected database.
    Parameters:
      `theDatabase` - the name of the database for checkpoint operation
      `theOptions` - configuration options for the checkpoint
    Returns:
    Throws:
      `StardogException`

  - ### getUserManager

    public UserManager getUserManager()
    Return the `UserManager` to be used for user-centric security changes
    Returns:
      the UserManager

  - ### getRoleManager

    public RoleManager getRoleManager()
    Return the `RoleManager` to be used for role-centric security changes
    Returns:
      the RoleManager

  - ### getPermissionManager

    public PermissionManager getPermissionManager()
    Return the `PermissionManager` for changing user & role permissions
    Returns:
      the PermissionManager

  - ### getQueryManager

    public QueryManager getQueryManager()
    Return the `QueryManager` for managing running queries

  - ### getProcessManager

    public com.complexible.stardog.process.ProcessManager getProcessManager()
    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
    Returns:
      the TokenManager

  - ### currentStatus

    public Map<String,Object> currentStatus(Options theOptions) throws StardogException
    Return the server status information, including Server/Protocols running, Stardog Home path, OS, etc. The `options` can be used to configure which metrics will be included in the results.
    Parameters:
      `theOptions` -
    Returns:
      the metrics showing the server status
    Throws:
      `StardogException` - if there was an error retrieving the DBMS info
    See Also:
      - `MetricOptions`

  - ### generateDiagnosticReport

    public File generateDiagnosticReport(com.complexible.stardog.util.report.DiagnosticsReport theDiagnosticsReport)

  - ### getLogs

    public Path getLogs(Options options)
    Generates a zip file containing the server logs.
    Parameters:
      `options` - the `log options`
    Returns:
      a zip file containing the server logs

  - ### getStoredQueries

    public com.complexible.stardog.InternalStoredQueries getStoredQueries()
    Returns the stored queries in this server. Returned object can be used to add and remove stored queries.
    Returns:
      the stored queries

  - ### getStoredFunctions

    public 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

  - ### run

    public void run(Runnable theAction)

  - ### call

    public <T> T call(Callable<T> theAction)