This is a complete example how to start the platform, set up a runtime, start it, and let it write text to a file.
We assume that you have downloaded and extracted the Coral platform on your machine, and that Cassandra is running. In this tutorial, we assume that you use the latest version of the Coral platform. We will also assume that you use curl
to send commands to Coral. As stated in the section Prerequisites, however, you can use any HTTP client you want.
The following headers should be used to access the API:
header | value |
---|---|
Content-Type | application-json |
Accept | application-json |
Authorization | Basic YWRtaW46cGFzc3dvcmQ= |
Where the Authorization header contains your encrypted user name and password. If you use curl
, you can issue the command in a terminal as follows:
Download the .tar.gz file and issue the following command:
First, a user needs to be created. To do this, enter the following command, where the values that should be filled in are described in the table below.
The program asks you to enter a password for the user and asks you to confirm the password. We will use the password “thematrix”. If successful, a user with the following properties is now inserted into the database:
short | long | property | value |
---|---|---|---|
n | uniquename | Unique name | neo |
f | fullname | Full name | Thomas Anderson |
e | mranderson@metacortex.com | ||
m | mobile | Mobile phone | 555-1234 |
d | department | Department | Meta Cortex programming division |
You could also directly insert the user into the database, but the disadvantage of this approach is that you need to generate a UUID yourself and that you need to hash the password of the user yourself. This is not recommended, it is probably easier to use this program.
There are three different ways to set parameters for the Coral platform:
In this tutorial, we will only use the first option.
To start the platform, enter the following command:
These options are explained in the table below:
short | long name | explanation |
---|---|---|
ai | apiinterface | Incoming HTTP requests on this interface are accepted. |
p | apiport | HTTP traffic on this port is accepted. |
ah | akkahostname | This is the interface that Akka binds to. |
ap | akkaport | This is the port that Akka binds to. |
am | authenticationmode | Sets the authentication mode. |
ccp | contactpoints | The Cassandra node(s) that Coral will connect with. |
cp | cassandraport | The port on which a connection with Cassandra will be made. |
k | keyspace | The name of the Cassandra keyspace that will be used. |
nc | nocluster | Tells Coral that this node will not be connected to a cluster. |
ll | loglevel | Sets the log level. |
Coral will print debug messages to the console, stating that it is now “Bound to /0.0.0.0:8000”.
This means that the Coral platform can now be approached using the HTTP interface on “http://127.0.0.1:8000”.
To test whether this is actually working, issue the following command:
The platform will respond with
This is a JSON array showing the runtimes currently running on the platform. As there are no runtimes on the platform yet, it returns an empty array.
We will set up a runtime with a generator actor and a log actor that writes the generated data to file. The definition of the runtime is as follows:
This runtime generates the text “Hello, world!” 10 times per second and writes this text to the file “/tmp/runtime1.log” until it is stopped. You can change the location of the text file, but make sure you check the output in the correct file.
To create the runtime, send the following command:
The platform responds by returning the following information:
The UUID’s and the created time in your response may vary from the ones shown here. The runtime has now been created.
The runtime is now created but is not started yet. To start the runtime, issue a PATCH commmand as follows:
The platform responds with:
The start time in your response may vary from the one shown here. The runtime is now started and will generate a “Hello, World!” every second, and it will write these messages to “/tmp/runtime1.log”.
To see the output of the platform, issue the following command:
If everything was set up right, this will show the following output, one new line per second:
There we have it! The output of our very first Coral pipeline.