Skip to content

Commit

Permalink
Return Redis Protocol Version through INFO command (#153)
Browse files Browse the repository at this point in the history
* add redis protocol version and cleanup GarnetInfoMetrics

* code cleanup
  • Loading branch information
vazois committed Mar 27, 2024
1 parent fefac91 commit f87f530
Show file tree
Hide file tree
Showing 9 changed files with 218 additions and 209 deletions.
25 changes: 14 additions & 11 deletions libs/cluster/Server/ClusterProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,19 +241,22 @@ public MetricsItem[] GetReplicationInfo()
}

/// <inheritdoc />
public void GetGossipInfo(MetricsItem[] statsInfo, int startOffset, bool metricsDisabled)
public MetricsItem[] GetGossipStats(bool metricsDisabled)
{
var gossipStats = clusterManager.gossipStats;
statsInfo[startOffset] = (new("meet_requests_recv", metricsDisabled ? "0" : gossipStats.meet_requests_recv.ToString()));
statsInfo[startOffset + 1] = (new("meet_requests_succeed", metricsDisabled ? "0" : gossipStats.meet_requests_succeed.ToString()));
statsInfo[startOffset + 2] = (new("meet_requests_failed", metricsDisabled ? "0" : gossipStats.meet_requests_failed.ToString()));
statsInfo[startOffset + 3] = (new("gossip_success_count", metricsDisabled ? "0" : gossipStats.gossip_success_count.ToString()));
statsInfo[startOffset + 4] = (new("gossip_failed_count", metricsDisabled ? "0" : gossipStats.gossip_failed_count.ToString()));
statsInfo[startOffset + 5] = (new("gossip_timeout_count", metricsDisabled ? "0" : gossipStats.gossip_timeout_count.ToString()));
statsInfo[startOffset + 6] = (new("gossip_full_send", metricsDisabled ? "0" : gossipStats.gossip_full_send.ToString()));
statsInfo[startOffset + 7] = (new("gossip_empty_send", metricsDisabled ? "0" : gossipStats.gossip_empty_send.ToString()));
statsInfo[startOffset + 8] = (new("gossip_bytes_send", metricsDisabled ? "0" : gossipStats.gossip_bytes_send.ToString()));
statsInfo[startOffset + 9] = (new("gossip_bytes_recv", metricsDisabled ? "0" : gossipStats.gossip_bytes_recv.ToString()));
return
[
new("meet_requests_recv", metricsDisabled ? "0" : gossipStats.meet_requests_recv.ToString()),
new("meet_requests_succeed", metricsDisabled ? "0" : gossipStats.meet_requests_succeed.ToString()),
new("meet_requests_failed", metricsDisabled ? "0" : gossipStats.meet_requests_failed.ToString()),
new("gossip_success_count", metricsDisabled ? "0" : gossipStats.gossip_success_count.ToString()),
new("gossip_failed_count", metricsDisabled ? "0" : gossipStats.gossip_failed_count.ToString()),
new("gossip_timeout_count", metricsDisabled ? "0" : gossipStats.gossip_timeout_count.ToString()),
new("gossip_full_send", metricsDisabled ? "0" : gossipStats.gossip_full_send.ToString()),
new("gossip_empty_send", metricsDisabled ? "0" : gossipStats.gossip_empty_send.ToString()),
new("gossip_bytes_send", metricsDisabled ? "0" : gossipStats.gossip_bytes_send.ToString()),
new("gossip_bytes_recv", metricsDisabled ? "0" : gossipStats.gossip_bytes_recv.ToString())
];
}

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license.

using System;
using System.IO;
using Microsoft.Extensions.Logging;
using Tsavorite.core;

Expand Down
7 changes: 6 additions & 1 deletion libs/host/GarnetServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public class GarnetServer : IDisposable
// IMPORTANT: Keep the version in sync with .azure\pipelines\azure-pipelines-external-release.yml line ~6.
readonly string version = "1.0.1";

/// <summary>
/// Resp protocol version
/// </summary>
readonly string redisProtocolVersion = "6.2.11";

/// <summary>
/// Metrics API
/// </summary>
Expand Down Expand Up @@ -269,7 +274,7 @@ private void InitializeServer()
server = new GarnetServerTcp(opts.Address, opts.Port, 0, opts.TlsOptions, opts.NetworkSendThrottleMax, logger);
}

storeWrapper = new StoreWrapper(version, server, store, objectStore, objectStoreSizeTracker, customCommandManager, appendOnlyFile, opts, clusterFactory: clusterFactory, loggerFactory: loggerFactory);
storeWrapper = new StoreWrapper(version, redisProtocolVersion, server, store, objectStore, objectStoreSizeTracker, customCommandManager, appendOnlyFile, opts, clusterFactory: clusterFactory, loggerFactory: loggerFactory);

// Create session provider for Garnet
Provider = new GarnetProvider(storeWrapper, kvBroker, broker);
Expand Down
1 change: 1 addition & 0 deletions libs/server/AOF/AofProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public sealed unsafe partial class AofProcessor

var replayAofStoreWrapper = new StoreWrapper(
storeWrapper.version,
storeWrapper.redisProtocolVersion,
null,
storeWrapper.store,
storeWrapper.objectStore,
Expand Down
4 changes: 2 additions & 2 deletions libs/server/Cluster/IClusterProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public interface IClusterProvider : IDisposable
void FlushConfig();

/// <summary>
/// Get gossip info
/// Get gossip stats
/// </summary>
void GetGossipInfo(MetricsItem[] statsInfo, int startOffset, bool metricsDisabled);
MetricsItem[] GetGossipStats(bool metricsDisabled);

/// <summary>
/// Get replication info
Expand Down

0 comments on commit f87f530

Please sign in to comment.