To create a persistence instance, use the following rhino-console command or related MBean operation.

Console command: createpersistenceinstance

Command

createpersistenceinstance <name> <type> [-ds <datasource-class-name>]
[-set-property (<property-name> <property-type> <property-value)*]
  Description
    Create a persistence instance configuration.  The type may be 'jdbc' or
    'cassandra'.  A datasource class name must be specified for 'jdbc'
    configurations.

Example

This example creates a new persistence instance with the following configuration properties:

  • Name: oracle

  • Type: jdbc

  • Datasource class name: oracle.jdbc.pool.OracleDataSource

  • JavaBean properties:

    • name: URL
      type: java.lang.String
      value: jdbc:oracle:thin:@oracle_host:1521:db

    • name: user
      type: java.lang.String
      value: ${MANAGEMENT_DATABASE_USER}

    • name: password
      type: java.lang.String
      value: ${MANAGEMENT_DATABASE_PASSWORD}

    • name: loginTimeout
      type: java.lang.Integer
      value: 30

$ ./rhino-console createpersistenceinstance oracle jdbc \
    -ds oracle.jdbc.pool.OracleDataSource \
    -set-property URL java.lang.String jdbc:oracle:thin:@oracle_host:1521:db \
    -set-property user java.lang.String '${MANAGEMENT_DATABASE_USER}' \
    -set-property password java.lang.String '${MANAGEMENT_DATABASE_PASSWORD}' \
    -set-property loginTimeout java.lang.Integer 30
Created persistence instance oracle

Configuration properties

JDBC persistence instances

A JDBC persistence instance has configuration properties defined by the JavaBean properties of the target datasource class. Reference must be made to the datasource documentation for the available properties.

Cassandra persistence instances

A Cassandra persistence instance can be configured using any configuration property names recognised by the DataStax Java Driver, for example basic.contact-points, advanced.reconnection-policy.class, etc. The reference configuration (used in Rhino as the base configuration) provides a comprehensive list of the configuration properties recognised by the driver. Driver execution profiles are supported for application use using appropriately flattened configuration property names such as profiles.myprofile.basic.request.timeout. Driver metrics can be enabled by configuring the advanced.metrics.session.enabled or advanced.metrics.node.enabled configuration properties as described in the reference configuration. Metrics are exposed over JMX from the Rhino MBean server with the object name domain com.datastax.oss.driver.

Note

If the basic.contact-points configuration property is specified in a persistence instance configuration, the driver requires that the basic.load-balancing-policy.local-datacenter configuration property is also specified to provide the name of the datacentre. If the datacentre name is not specified, the driver may still successfully connect to the contact points but will refuse to utilise any of the database servers due to datacentre name mismatch.

The Java type of all Cassandra persistence instance configuration properties for the DataStax Java Driver must be java.lang.String. This is to accommodate things like duration properties being specified with values containing unit qualifiers such as 100ms.

A Cassandra persistence instance that is used in a persistence resource referenced by a memdb configuration in rhino-config.xml, such as the ManagementDatabase or ProfileDatabase, must specify the basic.session-keyspace configuration property with the name of the Cassandra keyspace where persistent state will be stored. In any other case, specifying the keyspace in configuration is optional. An application may, for example, specify the desired keyspace at runtime using CQL queries instead.

Finally, all Cassandra persistence instances must define the Rhino-specific configuration property rhino.ddl-statement-timeout of type java.lang.String. This property defines the timeout duration that Rhino will use, if configured to use the persistence instance for internal functions such as the key/value store or session ownership store, when executing schema-altering statements such as CREATE TABLE and DROP TABLE.

An example Cassandra persistence instance configuration (as it would appear in the $RHINO_HOME/config/persistence.xml file) is illustrated below:

<persistence-instance name="cassandra" type="cassandra">
  <parameter name="rhino.ddl-statement-timeout" type="java.lang.String" value="10s"/>
  <parameter name="basic.contact-points" type="java.lang.String" value="${CASSANDRA_CONTACT_POINTS}"/>
  <parameter name="basic.load-balancing-policy.local-datacenter" type="java.lang.String" value="${CASSANDRA_DATACENTRE}"/>
  <parameter name="advanced.reconnection-policy.class" type="java.lang.String" value="ConstantReconnectionPolicy"/>
  <parameter name="advanced.reconnection-policy.base-delay" type="java.lang.String" value="5000ms"/>
  <parameter name="basic.request.consistency" type="java.lang.String" value="LOCAL_QUORUM"/>
</persistence-instance>

MBean operation: createPersistenceInstance

MBean

Rhino operation

public void createPersistenceInstance(String name, PersistenceInstanceType type, String dsClassName, ConfigProperty[] configProperties)
    throws NullPointerException, InvalidArgumentException,
      DuplicateNameException, ConfigurationException;
Previous page Next page
Rhino Version 3.2