Permalink
Browse files

Merge pull request #184 from zznate/timestamp_fix

Handler utils add autotimestamp method
  • Loading branch information...
2 parents 0cc0f0f + 3ed7544 commit b3b75408976c03374cdb8ccf4cc0af6c7b58f7e5 @zznate committed Apr 9, 2013
@@ -29,12 +29,11 @@ public void handle(Message<JsonObject> event) {
Object val = row.getField("value");
Integer ttl = row.getInteger("ttl");
if (ttl == null) {
- // TODO add autoTimestamp and nanotime to the state object sent in the event bus message
rm.add(qp, HandlerUtils.byteBufferForObject(HandlerUtils.resolveObject(val)),
- System.nanoTime());
+ HandlerUtils.determineTimestamp(params, state, row));
} else {
rm.add(qp, HandlerUtils.byteBufferForObject(HandlerUtils.resolveObject(val)),
- System.nanoTime(), ttl);
+ HandlerUtils.determineTimestamp(params, state, row), ttl);
}
mutations.add(rm);
}
@@ -74,6 +74,20 @@ public static ConsistencyLevel determineConsistencyLevel(JsonObject state){
: ConsistencyLevel.valueOf(state.getString("consistency"));
}
+ /*Determine the time for the operation */
+ public static long determineTimestamp(JsonObject params, JsonObject state, JsonObject row){
+ long timestamp = 0;
+ if (row != null && row.getLong("timestamp") != null){
+ timestamp = row.getLong("timestamp");
+ } else if (params.getLong("timestamp") != null){
+ timestamp = params.getLong("timestamp");
+ } else if (state.getBoolean("autotimestamp")!= null && state.getBoolean("autotimestamp") == true){
+ timestamp = System.nanoTime();
+ }
+ return timestamp;
+ }
+
+
/*
* Determine columnfamily first look in the row for a string named keyspace, then look in the op,
* then look in the state. The row is only currently provided in batchset

0 comments on commit b3b7540

Please sign in to comment.