Skip to content

Commit

Permalink
init metric calculate
Browse files Browse the repository at this point in the history
  • Loading branch information
wanghuaiyuan committed Jan 22, 2025
1 parent 4803ec7 commit 5fe5a6c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,11 @@ public interface TimerMessageKVStore {
* @return the checkpoint of the timer message kv store.
*/
long getCheckpoint(byte[] columnFamily);

/**
* Sync the metric of the timer message kv store.
* @param key the key of the metric.
* @param update the value of the metric.
*/
void syncMetric(int key, int update);
}
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ public long getCheckpoint(byte[] columnFamily) {
}
}

@Override
public void syncMetric(int key, int update) {
// TODO sync metric
}

private void syncCheckpoint(byte[] columnFamily, long checkpoint, WriteBatch writeBatch) {
try {
writeBatch.put(columnFamily, ByteBuffer.allocate(8).putLong(checkpoint).array());
Expand All @@ -274,12 +279,4 @@ private void syncCommitOffset(long offset, WriteBatch writeBatch) {
throw new RuntimeException("Sync commit offset error", e);
}
}

private void syncMetric(int key, int update, WriteBatch writeBatch) {
try {
writeBatch.put(metricColumnFamilyHandle, ByteBuffer.allocate(4).putInt(key).array(), ByteBuffer.allocate(4).putInt(update).array());
} catch (RocksDBException e) {
throw new RuntimeException("Sync metric error", e);
}
}
}

0 comments on commit 5fe5a6c

Please sign in to comment.