Each persisting resource can export the set of database data definition language (DDL) statements that it uses to construct the tables it requires for maintaining state. This is of particular importance when automatic data definitions updates are disabled for a persisting resource, meaning an administrator is required to manually set up the database before the persisting resource can use it.

To export persisting resource data definition statements, use the following rhino-console command or related MBean operations.

Console command: exportpersistingresourcedatadefinitions

Command

exportpersistingresourcedatadefinitions -variant <variant> [-file
<filename.zip>]
  Description
    Export the data definitions (i.e. database schemas) used by the persisting
    resources currently configured in Rhino, such as the key/value store and session
    ownership store. Currently supported resource variants are: [CASSANDRA]. If an
    optional filename argument is provided then the statements will be written to
    that file instead of output to the console

Example

This example outputs the Cassandra persisting resource DDL statements to the console:

$ ./rhino-console exportpersistingresourcedatadefinitions -variant cassandra
Found CASSANDRA resource "poolmaintenance" with keyspaces: [rhino_pool_maintenance]
CREATE KEYSPACE IF NOT EXISTS rhino_pool_maintenance WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 3} AND DURABLE_WRITES = true;
CREATE TABLE IF NOT EXISTS rhino_pool_maintenance.heartbeat (  partition_id    text,  node_id         text,  heartbeat_update_time    timestamp,  metadata_update_time     timestamp,  PRIMARY KEY (partition_id, node_id)) WITH gc_grace_seconds = 172800;
CREATE TABLE IF NOT EXISTS rhino_pool_maintenance.node_metadata (  partition_id        text,  node_id             text,  update_time         timestamp,  rhino_version       text,  boot_time           timestamp,  node_state          text,  actual_slee_state   text,  grpc_address        text,  jmx_address         text,  PRIMARY KEY (partition_id, node_id)) WITH gc_grace_seconds = 86400;

Found CASSANDRA resource "kvstore" with name "cassandra" with keyspaces: [rhino_kv_default]
CREATE KEYSPACE IF NOT EXISTS rhino_kv_default WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 3} AND DURABLE_WRITES = true;
CREATE TABLE IF NOT EXISTS rhino_kv_default.keyvaluedatabase_rhino_internal_activityd127e95b (  partition    int,  key          blob,  data_version text,  data         blob,  PRIMARY KEY (partition, key, data_version)) WITH comment = 'KeyValueDatabase_Rhino internal activity context naming support:ActivityContextNamingNamespaceReplicatedOptimisticOCBB'  AND gc_grace_seconds = 900;
CREATE TABLE IF NOT EXISTS rhino_kv_default.keyvaluedatabase_rhino_internal_activity_918eaef (  partition    int,  key          blob,  data_version text,  data         blob,  PRIMARY KEY (partition, key, data_version)) WITH comment = 'KeyValueDatabase_Rhino internal activity context naming support:ActivityContextNamingNamespaceReplicatedOptimisticOCBB:name'  AND gc_grace_seconds = 900;
...

Found CASSANDRA resource "sessionownership" with keyspaces: [rhino_session_ownership_default]
CREATE KEYSPACE IF NOT EXISTS rhino_session_ownership_default WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 3} AND DURABLE_WRITES = true;
CREATE TABLE IF NOT EXISTS rhino_session_ownership_default.additional_keys (  additional_key  text,  primary_key     text,  schema_version  text,  owner_uris      set<text>,  sequence        int,  attributes      map<text,text>,  PRIMARY KEY (additional_key, schema_version, primary_key)) WITH gc_grace_seconds = 900;
CREATE TABLE IF NOT EXISTS rhino_session_ownership_default.sessions (  primary_key     text,  schema_version  text,  additional_keys set<text>,  owner_uris      set<text>,  sequence        int,  attributes      map<text,text>,  PRIMARY KEY (primary_key, schema_version)) WITH gc_grace_seconds = 900;

This example saves the DDL statements to a zip file to make it easier to import the statements into a database:

$ ./rhino-console exportpersistingresourcedatadefinitions -variant cassandra -file ddl.zip
Found CASSANDRA resource "poolmaintenance" with keyspaces: [rhino_pool_maintenance]
Found CASSANDRA resource "kvstore" with name "cassandra" with keyspaces: [rhino_kv_default]
Found CASSANDRA resource "sessionownership" with keyspaces: [rhino_session_ownership_default]
Data definitions written to zip file ddl.zip

$ unzip -v ddl.zip
Archive:  ddl.zip
Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
     792  Defl:N      334  58% 11-22-2022 16:15 d5d93e05  poolmaintenance.rhino_pool_maintenance
    2597  Defl:N      456  82% 11-22-2022 16:15 bd91c269  kvstore.cassandra.rhino_kv_default
     779  Defl:N      310  60% 11-22-2022 16:15 2a61f08a  sessionownership.rhino_session_ownership_default
--------          -------  ---                            -------
    4168             1100  74%                            3 files

$ unzip -q -c ddl.zip sessionownership.rhino_session_ownership_default
CREATE KEYSPACE IF NOT EXISTS rhino_session_ownership_default WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 3} AND DURABLE_WRITES = true;
CREATE TABLE IF NOT EXISTS rhino_session_ownership_default.additional_keys (  additional_key  text,  primary_key     text,  schema_version  text,  owner_uris      set<text>,  sequence        int,  attributes      map<text,text>,  PRIMARY KEY (additional_key, schema_version, primary_key)) WITH gc_grace_seconds = 900;
CREATE TABLE IF NOT EXISTS rhino_session_ownership_default.sessions (  primary_key     text,  schema_version  text,  additional_keys set<text>,  owner_uris      set<text>,  sequence        int,  attributes      map<text,text>,  PRIMARY KEY (primary_key, schema_version)) WITH gc_grace_seconds = 900;

MBean operation: getKeyspaces

MBean

Rhino operation

public String[] getKeyspaces()
    throws ManagementException;

MBean operation: getDataDefinitions

MBean

Rhino operation

Get data definitions for a single keyspace name
public String getDataDefinitions(String keyspaceName)
    throws NullPointerException, UnrecognizedKeyspaceException, ManagementException;

Rhino operation

Get data definitions for an array of keyspace names
public String[] getDataDefinitions(String[] keyspaceNames)
    throws NullPointerException, InvalidArgumentException, ManagementException;
Previous page Next page
Rhino Version 3.2