This is the main documentation for the gora-aerospike module. gora-aerospike module enables Aerospike backend support for Gora.
gora.datastore.default=org.apache.gora.aerospike.store.AerospikeStore
- Implementation of the persistent Java storage class for Aerospikegora.aerospikestore.server.ip=localhost
- Property pointing to the host where the server is runninggora.aerospikestore.server.port=3000
- Property pointing to the port where the server is runninggora.datastore.mapping.file=gora-aerospike-mapping.xml
- The XML mapping file to be used. If no value is used this defaults to gora-aerospike-mapping.xmlgora.aerospikestore.server.username=user_name
- An optional property defining the username of the server if availablegora.aerospikestore.server.password=password
- An optional property defining the password of the server if availableYou should then create a gora-aerospike-mapping.xml which will describe how you want to store each of your Gora persistent objects along with the read and write policies in Aerospike:
<gora-otd>
<policy name="write" gen="NONE" recordExists="UPDATE" commitLevel="COMMIT_ALL" durableDelete="false"/>
<policy name="read" priority="DEFAULT" consistencyLevel="CONSISTENCY_ONE" replica="SEQUENCE" maxRetries="2"/>
<class name="org.apache.gora.examples.generated.Employee" keyClass="java.lang.String" set="Employee" namespace = "test">
<field name="name" bin="name"/>
<field name="dateOfBirth" bin="dateOfBirth"/>
<field name="ssn" bin="ssn"/>
<field name="salary" bin="salary"/>
<field name="boss" bin="boss"/>
<field name="webpage" bin="webpage"/>
</class>
</gora-otd>
Here you can see that we require the definition of child elements within the gora-otd
mapping configuration. We can define the classes and the policies.
Each class element should contain the following elements;
a parameter defining the Persistent class name e.g. org.apache.gora.examples.generated.Employee,
a parameter defining the keyClass e.g. java.lang.String which specifies the key which maps to the field values,
a parameter defining the Aerospike set e.g. Employee which will be used to persist each Gora object,
a parameter defining the Aerospike namespace e.g. test which will be used to persist each Gora object,
In addition, within the class field we should specify the fields and for which bin each field value maps to. We do not need to explicitly specify the type of each field, as the type is automatically detected in Aerospike server when creating the bin values. Thus each field should contain the field name and the corresponding bin it gets mapped to. e.g. name="webpage" bin="webpage"
Further, we can define the policies on reading and writing data from/to the server.
Write policy can have following fields and each field values are the default values supported by Aerospike Write Policy API
gen - generation policy (values: EXPECT_GEN_EQUAL, EXPECT_GEN_GT, NONE)
recordExists - record exists action (values: CREATE_ONLY, REPLACE, REPLACE_ONLY, UPDATE, UPDATE_ONLY)
commitLevel - commit level (values: COMMIT_ALL, COMMIT_MASTER)
durableDelete - durable delete (values: true, false)
expiration - record expiration (values: 0, 10)
Read policy can have following fields and each field values are the default values supported by Aerospike Read Policy API
priority - priority policy (values: DEFAULT, HIGH, LOW, MEDIUM)
consistencyLevel - consistency level (values: CONSISTENCY_ALL, CONSISTENCY_ONE)
replica - replica (values: MASTER, MASTER_PROLES, RANDOM, SEQUENCE)
socketTimeout - socket timeout (values: timeout in milliseconds)
totalTimeout - total timeout (values: timeout in milliseconds)
timeoutDelay - timeout delay (values: timeout in milliseconds)
maxRetries - max retries (values: int of max num of retries)