Skip to content
Browse files

Fix key generation to use timestamp of event; still handles empty/mis…

…sing time.
  • Loading branch information...
1 parent 607f809 commit 7502fa82fa1f382b2808dc980075832eb3a0a1f4 @roycamp roycamp committed
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/java/org/apache/cassandra/plugins/SimpleCassandraSink.java
View
6 src/java/org/apache/cassandra/plugins/SimpleCassandraSink.java
@@ -82,7 +82,7 @@ public void append(Event event) throws IOException, InterruptedException {
dataColumn.setTimestamp(timestamp);
// Insert the index
- this.cClient.insert(this.getKey(), this.indexColumnFamily, new Column[] {indexColumn}, ConsistencyLevel.QUORUM);
+ this.cClient.insert(this.getKey(timestamp), this.indexColumnFamily, new Column[] {indexColumn}, ConsistencyLevel.QUORUM);
// Insert the data (row key is the uuid and there is only one column)
this.cClient.insert(uuid.toString().getBytes(), this.dataColumnFamily, new Column[] {dataColumn}, ConsistencyLevel.QUORUM);
super.append(event);
@@ -92,8 +92,10 @@ public void append(Event event) throws IOException, InterruptedException {
* Returns a String representing the current date to be used as
* a key. This has the format "YYYYMMDDHH".
*/
- private byte[] getKey() {
+ private byte[] getKey(long timestamp) {
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+0"));
+ cal.setTimeInMillis(timestamp);
+
int day = cal.get(Calendar.DAY_OF_MONTH);
int month = cal.get(Calendar.MONTH);
int year = cal.get(Calendar.YEAR);

0 comments on commit 7502fa8

Please sign in to comment.
Something went wrong with that request. Please try again.