Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ public interface LeaseRecovery {

// Variables used for UI display
private CircularFifoQueue<SyncMetrics> syncMetricsQueue;
private int syncMetricsQueueSize = 0;
private int syncMetricsQueueIndex = 0;

public static class SyncMetrics {
private long timestamp;
Expand Down Expand Up @@ -303,8 +305,8 @@ public void start(int numSlots) throws IOException {
useHsync = conf.getBoolean(USE_HSYNC_CONF_KEY, DEFAULT_USE_HSYNC);

// WebUI
syncMetricsQueue = new CircularFifoQueue<>(
conf.getInt(STORE_WAL_SYNC_STATS_COUNT, DEFAULT_SYNC_STATS_COUNT));
syncMetricsQueueSize = conf.getInt(STORE_WAL_SYNC_STATS_COUNT, DEFAULT_SYNC_STATS_COUNT);
syncMetricsQueue = new CircularFifoQueue<>(syncMetricsQueueSize);

// Init sync thread
syncThread = new Thread("WALProcedureStoreSyncThread") {
Expand Down Expand Up @@ -848,14 +850,24 @@ private void syncLoop() throws Throwable {
StringUtils.humanSize(syncedPerSec)));
}

// update webui circular buffers (TODO: get rid of allocations)
final SyncMetrics syncMetrics = new SyncMetrics();
// update webui circular buffers
SyncMetrics syncMetrics = null;
if (syncMetricsQueue.isAtFullCapacity()) {
if (syncMetricsQueueIndex == syncMetricsQueueSize) {
syncMetricsQueueIndex = 0;
}
syncMetrics = syncMetricsQueue.get(syncMetricsQueueIndex);
syncMetricsQueueIndex ++;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be syncMetricsQueueIndex++; ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, syncMetricsQueueIndex ++ in order reuse next SyncMetrics Object in syncMetricsQueue.

} else {
syncMetrics = new SyncMetrics();
syncMetricsQueue.add(syncMetrics);
}

syncMetrics.timestamp = currentTs;
syncMetrics.syncWaitMs = syncWaitMs;
syncMetrics.syncedEntries = slotIndex;
syncMetrics.totalSyncedBytes = totalSyncedToStore;
syncMetrics.syncedPerSec = syncedPerSec;
syncMetricsQueue.add(syncMetrics);

// sync
inSync.set(true);
Expand Down