We would like to customize OpenEMS to store device data to Cassandra (similar to OpenEMS’s TimeData InfluxDB implementation).
We have taken the latest OpenEMS develop branch. Following DataStax’s Java drivers for Cassandra (available as an OSGi bundle) will be used.
java-driver-core-4.13.0.jar
java-driver-query-builder-4.13.0.jar
java-driver-mapper-runtime-4.13.0.jar
Following entries have been added to openems/cnf/pom.xml:
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-core</artifactId>
<version>4.13.0</version>
</dependency>
<!-- added similar entries for -->
<artifactId>java-driver-query-builder</artifactId>
<artifactId>java-driver-mapper</artifactId>
Added cassandra.bnd in the newly created directory openems/io.openems.edge.timedata.cassandra.
To add API specifications, we used OpenEMS’s InfluxDB io.openems.wrapper/influxdb-java.bnd as reference and added openems/io.openems.wrapper/cassandra-java.bnd.
Project build shows the following error:
® ‘io.openems.wrapper.cassandra-java: Can not find JAR file java-driver-core-4.13.0.jar, java-driver-query-builder-4.13.0.jar and java-driver-mapper-runtime-4,13.0.jar
There are issues with the above mentioned procedure.
I kindly request to guide on creating the bnd file and the addition of dependency entries (for API specification).
My apologies for the late response. I was not able to respond earlier.
We have created the following public repository containing the changes for Cassandra:
CassandraSample class in EdgeApp.java has been added for verifying the successful connectivity from OpenEMS.
The jar has been built successfully. ErrorLog-Cassandra.log - Contains the error log when the generated openems_edge.jar is run.
I Kindly request to guide us to resolve the missing requirement error.
Changes in openems-community with respect to OpenEMS:
cnf/pom.xml - Contains the changes for including the dependencies for Cassandra
io.openems.edge.application/EdgeApp.bndrun - Change in “-runproperties” for entries felix.cm.dir and openems.data.dir
io.openems.edge.application/bnd.bnd - Added “com.datastax.oss.driver.core” in “-buildpath”
io.openems.edge.application/src/io/openems/edge/application/EdgeApp.java - Added class CassandraSample and changes in activate() to call CassandraSample.doCRUDOperations()
io.openems.wrapper/*.jar files - Added the DataStax Java driver jar files for Cassandra
io.openems.edge.application/EdgeApp.bndrun - Added entry (line 336) for Cassandra in “runbundles”
ErrorLog-Cassandra.log - Contains the error log when the generated openems_edge.jar is run
Things were a bit complicated, because you did not use the Github “Fork” feature, but instead created a completely new repository and as such lost the entire git history. This will make merging future improvements from OpenEMS to your branch complicated; and will also make it complicated to contribute back to OpenEMS - which would be very welcomed for such an improvement. See Fork a repo - GitHub Docs for more information.
Hi Stefan,
Thank you very much for your response. We have added your id to the repository.
I am sorry. I am not aware about GitHub’s Fork feature. The repository which we have provided has port number changes also for Edge server and Backend server. We will create a new repository by using GitHub Fork feature to create fork of OpenEMS and apply changes for integrating Cassandra by tomorrow. I will inform once the repository is created.
The datastax library comes with full OSGi support, i.e. the MANIFEST file inside the jar library file provides all the information needed for OSGi. Because of this it is not required to create a wrapper inside io.openems.wrapper.
What I typically do to solve the dependencies problem is to strip down my workspace by closing all unnecessary projects in Eclipse IDE and remove everything from the EdgeApp.bndrun, that I do not need. This speeds up the build in Eclipse IDE and makes the Resolve feature faster. Then I start adding the first dependency, check if it has the required OSGi headers in the MANIFEST and try to Resolve EdgeApp.bndrun. If this points me to a missing runtime dependency, I add that one as well, and so on.
It is great that with your changes, connecting to Cassandra server from OpenEMS environment has been done successfully. Thank you very much for your commits. It is a great help for our team.
Regarding Point 3 - This information will be useful for us. We have kept all the projects open all the time.
Following is the summary of changes:
(This may be useful for anyone who wants to use Cassandra from OpenEMS)
Addition of DataStax Java driver entries to cnf/pom.xml
dependency and resolve problems in OSGi are unforunately very often difficult to solve.
The best and most specific guide on the topic is this one, but it is also complicated to understand. In rest, usually the existing wrappers in OpenEMS provide good examples.
Regarding the usage of Cassandra in OpenEMS. Instead of asking everybody who would like to see this feature in OpenEMS to follow your steps, the Open-Source way would be to create a Pull-Request and have this feature natively available in OpenEMS.
Could you start such a Pull-Request from a Fork (see documentation on Github) so that the community and I can review it and eventually merge it to OpenEMS?
Thank you Stefan. I will refer the bnd guide that you have mentioned. After resolving the dependency problems, I will create Pull-Request for integrating the changes done for Cassandra to OpenEMS.