New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GORA-502 Implement Aerospike Data Store #111
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very good @nishadi
Please consider my comments and additionally
- Make sure that every license header is a comment only and not a documentation block e.g. use following
/*
*
*
*/
instead of
/**
*
*
*/
- Also please begin to document EVERY public method as you make your way through the code. This will distinguish your code as of higher quality.
Thank you, this is an excellent start.
SAXBuilder saxBuilder = new SAXBuilder(); | ||
InputStream inputStream = getClass().getClassLoader().getResourceAsStream(mappingFile); | ||
if (inputStream == null) { | ||
LOG.warn("Mapping file '" + mappingFile + "' could not be found!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use parameterized logging.
} | ||
Document document = saxBuilder.build(inputStream); | ||
if (document == null) { | ||
LOG.warn("Mapping file '" + mappingFile + "' could not be found!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use parameterized logging.
@@ -0,0 +1,127 @@ | |||
package org.apache.gora.aerospike.store; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing license header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the header
import java.util.List; | ||
import java.util.Properties; | ||
|
||
import com.aerospike.client.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove wildcard imports please. Use explicit imports. Thank you.
} | ||
|
||
/** | ||
* Aerospike does not support Utf8 format returned from Avro. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is bin? Can you elaborate and make it clearer?
gora-tutorial/conf/gora.properties
Outdated
@@ -16,7 +16,8 @@ | |||
|
|||
##gora.datastore.default is the default detastore implementation to use | |||
##if it is not passed to the DataStoreFactory#createDataStore() method. | |||
gora.datastore.default=org.apache.gora.hbase.store.HBaseStore | |||
gora.datastore.default=org.apache.gora.aerospike.store.AerospikeStore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please retain HBaseStore are default and merely add AerospikeStore to end of list.
pom.xml
Outdated
<groupId>org.apache.gora</groupId> | ||
<artifactId>gora-aerospike</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also include the test artifact e.g.
+ <dependency>
+ <groupId>org.apache.gora</groupId>
+ <artifactId>gora-aerospike</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ </dependency>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the test artifact
gora-aerospike/pom.xml
Outdated
</ciManagement> | ||
|
||
<properties> | ||
<aerospike.version>3.3.2</aerospike.version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to include aerospike.version
here if you have already included in within parent pom.xml.
gora-aerospike/pom.xml
Outdated
<artifactId>junit</artifactId> | ||
</dependency> | ||
|
||
<dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this dependency to parent pom and define version separately.
*/ | ||
public class GoraAerospikeTestDriver extends GoraTestDriver { | ||
|
||
private GenericContainer aerospikeContainer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check whether you can make this test-containers code generic, this can be reused for other datastore which doesn't have java based embedded server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the GoraTestDriver class we can add this field( GenericContaine), and in the instances when we need to use the docker based setup environment, we can provide a separate constructor to handle the container. I will look further into generalizing this further to create the docker instance at the DataStoreTestBase level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final variable?
@nishadi very good work, heading in right direction :) |
@lewismc @djkevincr Thank you for reviewing. Updated the code base as per the given feedback :) |
if (policy != null) { | ||
if (policy.equals("write")) { | ||
WritePolicy writePolicy = new WritePolicy(); | ||
if (policyElement.getAttributeValue("gen") != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems that my comment is not placed when I wrote it. I wrote about that:
Could you check this Apple bug: https://www.imperialviolet.org/2014/02/22/applebug.html
Please put curly braces even they are single line of if statements at your PR.
|
||
private static final Logger LOG = LoggerFactory.getLogger(AerospikeMappingBuilder.class); | ||
|
||
private AerospikeMapping aerospikeMapping; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final variable?
public class GoraAerospikeTestDriver extends GoraTestDriver { | ||
|
||
private GenericContainer aerospikeContainer; | ||
private Properties properties = DataStoreFactory.createProps(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final variable?
@@ -0,0 +1,20 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** -> /*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the doc comment
@@ -0,0 +1,20 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** -> /*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the doc comment
* @param keyClass The key class. | ||
* @param persistentClass The value class. | ||
* @return A new store instance. | ||
* @throws GoraException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@throws -> throws
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the exception description
Schema.Type schemaType = currentSchema.getType(); | ||
if (instanceValue instanceof CharSequence && schemaType.equals(Schema.Type.STRING)) | ||
return unionSchemaPos; | ||
else if (instanceValue instanceof ByteBuffer && schemaType.equals(Schema.Type.BYTES)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else
after a return
statement?
|
||
String policy = policyElement.getAttributeValue("name"); | ||
if (policy != null) { | ||
if (policy.equals("write")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an enum for such policies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String mappingKeyClass = classElement.getAttributeValue("keyClass"); | ||
String mappingClassName = classElement.getAttributeValue("name"); | ||
|
||
if (mappingKeyClass != null && mappingClassName != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and below lines of if statements can be merged.
// Property names | ||
private static final String AS_SERVER_IP = "server.ip"; | ||
|
||
private static final String AS_SERVER_port = "server.port"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AS_SERVER_port -> AS_SERVER_PORT?
* @param fields fields of the persistent class | ||
*/ | ||
public void validateServerBinConfiguration(Field[] fields) { | ||
if (isSingleBinEnabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and below lines of if statements can be merged.
case MAP: | ||
Map<Object, Object> newMap = new HashMap<>(); | ||
Map<?, ?> fieldMap = (Map<?, ?>) object; | ||
for (Object key : fieldMap.keySet()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can iterate over the entrySet
.
public void setUpClass() throws Exception { | ||
|
||
// Wait for the aerospike server to be started in the container | ||
Thread.sleep(5000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we check this condition with a framework like Awaitility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will check for a method to find out whether the server has been started in the docker container, so that we can use this framework in waiting for the status of the server
@kamaci thank you for reviewing. Added changes as suggested |
gora-aerospike/pom.xml
Outdated
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.4.2</version> | ||
<configuration> | ||
<skipTests>true</skipTests> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't do this. Instead use the @ Ignore syntax for JUnit. Please see http://junit.sourceforge.net/javadoc/org/junit/Ignore.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Lewis, This was done basically as I have used Docker to start up the Aerospike server for the test cases. If the build environment does not have Docker environment, the test cases get failed due to the absence of the server. That is the reason why the test cases are made skipped by default as it is done in the couchdb store.
https://lists.apache.org/thread.html/d9816c1e3f3a73fe07a3bc19035c532ffde2163aca5cc43e6d854158@%3Cdev.gora.apache.org%3E
I have added a profile to activate the test cases when we need to run the test cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lewismc Shall I proceed merging the PR to master? Are you done with reviewing/happy with the changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am happy with this +1 from me
gora-aerospike/pom.xml
Outdated
<groupId>org.testcontainers</groupId> | ||
<artifactId>testcontainers</artifactId> | ||
<version>1.1.0</version> | ||
<scope>test</scope> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please define the version separately in parent pom.
Build passes without any issue. [INFO] ------------------------------------------------------------------------ |
Locally tested Aerospike datastore tests with activating maven profile - mvn clean install -P aerospike-with-test Results : Tests run: 33, Failures: 0, Errors: 0, Skipped: 8 |
@nishadi This is really awesome work :) I am really happy to merge your work to the master. As we discussed please create tickets for any remaining work. Once again we are really thankful for your awesome contributions. |
Can you guys possibly upgrade aerospike-client to most recent? |
+1 |
I will update the client to the latest. |
I have sent the PR on the aerospike client update. Thanks a lot @djkevincr for merging to the master. Thanks a lot to the great the support given. :) |
This is a work in progress branch