-
Notifications
You must be signed in to change notification settings - Fork 38
Home
skovzhaw edited this page Jul 26, 2017
·
28 revisions
+ We are updating this page due to Cyclops 3.0 release.
- Java 8 and Maven 3
- PostgreSQL 9.6: set up the database tables as per instructions in
Install/schema.sh
- RabbitMQ 3.6: set up queues, exchanges and bindings as per instructions in
Install/bindings.sh
- Execute
mvn package assembly:single
in UDR, CDR, Coin and Billing folders - Fill information and credentials in each microservice's configuration file
- Start compiled JARs with their respective configuration file
java -jar service.jar service.conf
Upload usage data representing consumption of your services/users to the UDR micro service
- via RabbitMQ's queue
cyclops.udr.consume
- via HTTP POST at
IP:PORT/usage
Both accept data in JSON and require metric
, account
, usage
and unit
fields to be present. Time
field is either provided in milliseconds or generated automatically, where remaining data you might have goes into data
, as in the example below.
{
"metric": "Memory",
"account": "Martin",
"time": 1493450936000,
"usage": 1024,
"unit": "MB",
"data": {
"project": "ABC",
"host": "gentoo"
}
}
Rule engine sitting between UDR and CDR micro service expects pricing rules via HTTP POST at IP:PORT/rule
as plain text. The full documentation is available here.
An example pricing rule rating Storage
metric (3 CHF per unit of storage):
import ch.icclab.cyclops.facts.Usage;
import ch.icclab.cyclops.facts.Charge;
rule "Static rating for Storage"
salience 50
when
$usage: Usage(metric == "Storage")
then
Charge charge = new Charge($usage);
charge.setCharge(3 * $usage.getUsage());
charge.setCurrency("CHF");
retract($usage);
insert(charge);
end
And system rule that always needs to be present:
import ch.icclab.cyclops.facts.Charge;
import java.util.List;
global ch.icclab.cyclops.publish.Messenger messenger;
rule "Broadcast charge data"
salience 20
when
$charge: List( size > 0 ) from collect ( Charge() )
then
messenger.broadcast($charge);
$charge.forEach(c->retract(c));
end