mondo-project / mondo-hawk

Heterogeneous model indexing solution, based on NoSQL stores.
Eclipse Public License 2.0
17 stars 5 forks source link

Using the Hawk Thrift Java API #71

Closed beatrizsanchez closed 5 years ago

beatrizsanchez commented 5 years ago

Hi,

I have been trying to run and use hawk programmatically from Java. I have succeeded in interacting with Hawk in a similar way as how the org.hawk.service.cli uses Hawk, that is, consuming the org.hawk.service.api and org.hawk.service.artemis plugins and interacting with the Hawk.Client class. However, I've noticed that the Hawk class from org.hawk.service.api does not offer methods from the Thrift API as indicated in the wiki.

For example, I cannot call

Hawk.createInstance(...)

as in the Thrift API wiki, but instead I have to call

Hawk.Client client = ...;
client.createInstance(...);

I imagine the differences come from the fact that I have not build properly the API as indicated here. The problem I face on how to build the Thrift API is that I cannot find a pom-server-plain.xml file so I have tried the following:

My questions are:

beatrizsanchez commented 5 years ago

Ok, I've installed Thrift in my machine. My bad! I thought that only the dependency was necessary. I've re-ran the generate.sh with Thrift 0.9.3 installed and it worked! I initially tried with Thrift compiler (0.11.0) but brought several compilation issues.

After I ran the generate.sh I executed mvn -f pom-plain.xml install and was able to use the dependency from my local maven repository.

agarciadom commented 5 years ago

Thanks for the update! This is interesting - I thought that would Just Work (TM) without you having to install Thrift, but apparently it doesn't.

I will tweak the Travis build so it does the plain Maven build in addition to the Tycho one, and fix any issues that appear.

agarciadom commented 5 years ago

The pom-plain.xml file does build the API module, so that should just work :-/. Travis is also happy:

https://travis-ci.org/mondo-project/mondo-hawk/jobs/458528114

In any case, yes - you have to use Hawk.Client and not just Hawk. This is because of the way Thrift generates the code - it doesn't have anything to do with whether you use .api as a plugin or as a JAR library. Hawk is interface, and Hawk.Client is the specific implementation that Thrift instantiates for you :-).

beatrizsanchez commented 5 years ago

Thanks Antonio!