In This Section

Overview

A blogger is a simple, easy to use logger for binary data. The blogger is layered on top of a standalone ODS store and, therefore, inherits all the benefits of the store and the X transaction log i.e. zero-garbage, high performance, detached persistence, object replay, SQL based structured queries,compaction, CDC (i.e. tailing) and ICR (for decoupled replication to a remote node etc).

In its present incarnation the blogger can be used in the following fashion:

Working with the Blogger

Creating a Blogger

Blogger blogger = Blogger.create(name).registerFactory(myObjectFactory);
blogger.setLocation(dataDir.getAbsolutePath());
blogger.setMaxLogSize(1024);
blogger.open();

The above calls will create a transaction log in the data directory with the given name. 

Writing to a Blogger

Presuming you've used ADM to model a class called SensorDataUpdate, it can be written to the blogger as follows:

SensorDataUpdate update = SensorDataUpdate.create(); 
update.setSensorName("MySensor");
update.setValue(10);
update.setSensorTimestamp(System.currentTimeMillis()); 
 
blogger.log(update); 
update.dispose();

Tailing a Blogger

Continuing with the SensorData example from above, let's say we now want to write the sensor data out to legacy system (that is potentially slower or less reliable)

PreparedStatement updateStatement = con.prepareStatement(
        "update " + dbName + ".SENSORS" +
        "SET Timestamp = ?, Value = ? " +
        "where SensorName = ?"); 
blogger.tail(new TailListener() {
  public void onObject(IRogNode node) {
    if(node instanceof SensorDataUpdate) {
       SensoreDataUpdate update = (SensorDataUpdate) node; 
       updateSensorData.setLong(1, update.getSensorTimestampAsLong());
       updateSensorData.setInt(2, update.getValue());
       updateSensorData.setString(3, update.getSensorNAme());
       updateStatement.executeUpdate();
       con.commit();
    } 
  }
});

As the above entries are processed the blogger will keep track of the cursor in the underlying transaction log, so that even if the blogger is restarted, tailing will start over where it left off.

The Blogger can be configured with a compaction threshold after which enties that have been passed to the TailListener will be discarded and the log will be compacted. 

Features Coming Soon

Querying with the Blogger API

The blogger's store is backed by standard transaction logs, the transaction log tool and transaction log query apis can be used on its logs. See Querying Transaction Logs

The blogger API itself does not yet provide direct support for XQL queries, but support is expected to be added in a future release for added convenience. 

Configuring the Blogger for ICR

At this time the blogger API has not enabled support for configuring ICR, but it is expected to be added in future releases.