-
Notifications
You must be signed in to change notification settings - Fork 49
Getting started with Sirius
======
This tutorial used code snippets from a simple application that uses the Sirius library to provide a simple distribute and consistent data store. We will first walk through the steps to write a Sirius powered application.
When developing with Sirius there are four blocks that you need. A Sirius representation, some class that configures what will be your Sirius Implementation. A RequestHandler class that extends the Sirius RequestHandle trait/interface, overriding the handleGet, handlePut and handleDelete method. A controller class that determines when and what data gets written to or read from Sirius. And finally a implementation of some in memory data store.
Configuring Sirius: Here we configure what the cluster will look like, how many, how often they message
each other etc.
java public SiriusImpl initializeSirius(RequestHandler requestHandler, String siriusLog, String clusterConfig, int siriusPort){
Implementing a RequestHandler: Here we are only interested in the handlePut and handleGet. When you issue an enqueuePut the underlying Sirius library also fires the corresponding RequestHandler’s handlePut method. when you issue an enqueueGet the Sirius library then fires the corresponding RequestHandler’s handleGet method.
public SiriusResult handleGet(String key)
map.get(key)
public SiriusResult handlePut(String key, byte[] data)
map.put(key,data)
public SiriusResult handleDelete(String key)
map.remove(key)
public SiriusResult handlePut(String key, byte[] body){
logger.trace("Handling a PUT {}-size:{}", key, body);
Container container = Container.deserialize(body);
InMemoryDataStore.IMS.createContainer(container);
if(container != null){
return SiriusResult.some(OK);
}
else{
return SiriusResult.none();
}
}
public SiriusResult handleDelete(String key){......}
Storing Data in Sirius: Storing data in Sirius is simple. You can do an enqueueGet, enqueuePut or enqueueDelete.
java Future <SiriusResult> future = sirius.enqueuePut(key, bytes) Future <SiriusResult> future = sirius.enqueueGet(key)
Copyright 2013-2017 Comcast Cable Communications Management, LLC
Using Sirius
Getting started with Sirius
Configuring Sirius
How to Deploy Sirius
Reference Applications
Migrations and Release Notes
Migration Guide 1.1.x to 1.2.x
Release Notes 2.0.0
Migration Guide 1.2.x to 2.0.x
Developing Sirius
Getting Started
Contributing Guildelines
License
Releasing Sirius
Scaladocs
Test Timeout Failures
Transaction Log
Implementation
Live Compaction
waltool
Other