public class NoSQLAvroCacheStore implements CacheStore, XmlConfigurable
CacheStoreinterface. This implementation is Avro-aware and will convert database values which are stored in Avro format to Object format using Avro binding objects.
Users are not expected to directly interact with this class. It is expected that the class is managed by Oracle Coherence as the result of XML configuration supplied to Oracle Coherence at program startup. The documentation contained in this class is intended primarily to explain the XML configuration options.
NoSQLAvroCacheStoremodule, you must configure an Oracle Coherence cache to use it.
CacheStore, which implies that the cache must be defined as part of a
distributed-scheme. In addition, you would typically want to pair the
NoSQLAvroSerializeras shown in the example below.
This implementation handles requests to load data into the cache when a key is not present, to store data when changes are made to the cache, and to delete a KV entry when a remove is performed on the cache. These operations require converting the Oracle Coherence application's representation of a cache key and a cache value into a form that meets the needs of Oracle NoSQL Database.
In the default mode of operation, the cache key objects can be specified as
String objects or as
Key objects. When specified in
String form, the key may either be in the form documented in
Key.toString(), or may omit the leading '/'. If specified in relative
form (no leading '/', a key string passed to the cache will be prefixed
by the major components indicated by the
keyPrefix option, if
specified. The resulting concatenation must follow the formatting rules
dictated by the
If an application needs greater control over the way in which Oracle
Coherence keys are mapped to Oracle NoSQL Database
Key objects, the
cache can be configured with a
keyMapper, which can provide
arbitrary translation of key types. This
keyMapper must implement
The Oracle Coherence value objects are required to be one of the following types:
RawRecordtypes are Avro schema-based types.
Binaryrepresents a non-Avro type that has been serialized by the application.
Valuecan represent either an Avro or non-Avro type.
In order to simplify application development, we provide a companion
NoSQLAvroSerializer, which understands how to serialize the object
types listed above without the need to write additional serialization code.
NoSQLAvroCacheStore also needs to access an Oracle NoSQL database
instance. In addition to the basic information needed to connect to the
database, a number of additional store interaction properties are also
configurable, allowing the developer to set Durability, Consistency
in the cache configuration.
<kv:XXX>style elements, where
store-name - (Required) The KVStore instance name that is used to
provide persistence for your Oracle Coherence cache.
helper-hosts - (Required) A comma-separated list of helperHost:port
values that serve as the gateway to the Oracle NoSQL Database instance.
key-prefix - (Optional) A prefix to apply to relative keys. Not
valid in conjunction with the
keyMapper option. The value
specified must begin with a '/' character and indicates zero or more major
key path components to prepend to any String key passed to the cache store
that is in relative form (i.e. not starting with a '/').
key-mapper - (Optional) Names a class with a no-arg constructor and
which implements the
CacheKeyMapper interface. Provides application
rules for mapping Oracle Coherence cache keys to Oracle NoSQL Database keys.
This is not valid in conjunction with
avro-format - (Optional) Specifies the preferred object representation
for Avro schema-based objects. Valid values (case insensitive) are:
schema-files - (Optional) When Generic or Json format is selected,
The application needs to identify the specific version of the schema that
it expects. It does this by providing a comma separated list of schema
definition files. Each file is located as a system resource and should
be named in resource form (e.g. /my/path/to/schema.avsc). Be sure to include
the schema file paths to your java classpath otherwise a
MissingResourceException will be thrown.
consistency- (Optional) Specifies the type of consistency to use during lookups. Valid values are:
consistency-time-lag - (Optional) Specifies the maximum time lag
for valid consistency. Time durations can be specified using standard
Oracle Coherence time unit suffixes (e.g. 1ns, 1us, 1ms, 1s)
consistency-timeout - (Optional) Specifies the timeout for waiting
for consistency. Time durations can be specified using standard
Oracle Coherence time unit suffixes (e.g. 1ns, 1us, 1ms, 1s)
durability-master-sync - (Optional) Specifies the Durability
completeness for writes at the master replication node. Valid values are:
durability-replica-sync - (Optional) Specifies the Durability
completeness for writes at replica nodes. Valid values are as shown for
durability-replica-ack - (Optional) Specifies the Durability
completeness for replica nodes. Valid values are:
NoSQLAvroCacheStoremodule in conjunction with the
<distributed-scheme> <scheme-name>MyAvroCacheScheme</scheme-name> <service-name>MyAvroCacheService</service-name> <serializer> <instance> <class-name>oracle.kv.coherence.NoSQLAvroSerializer</class-name> <init-params> <init-param> <param-name>storeName</param-name> <param-value>kvstore</param-value> </init-param> <init-param> <param-name>helperHosts</param-name> <param-value>myhost:5000</param-value> </init-param> <init-param> <param-name>schemaFiles</param-name> <param-value>my/app/datatype.avsc,my/app/othertype.avsc</param-value> </init-param> </init-params> </instance> </serializer> <backing-map-scheme> <read-write-backing-map-scheme> <internal-cache-scheme> <local-scheme /> </internal-cache-scheme> <cachestore-scheme> <kv:avro-cache-store> <kv:store-name>kvstore</kv:store-name> <kv:helper-hosts>localhost:5000</kv:helper-hosts> <kv:avro-format>SPECIFIC</kv:avro-format> <kv:schema-files>my/app/datatype.avsc,my/app/othertype.avsc</kv:schema-files> </kv:avro-cache-store> </cachestore-scheme> </read-write-backing-map-scheme> </backing-map-scheme> <autostart>true</autostart> </distributed-scheme>
Copyright (c) 2011, 2014 Oracle and/or its affiliates. All rights reserved.