Skip to content

Commit

Permalink
merge 'main' and resolve some "format" conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
TedHartMS committed Feb 20, 2025
2 parents 2aca4b4 + b37bcc0 commit 29fc9c3
Show file tree
Hide file tree
Showing 45 changed files with 578 additions and 288 deletions.
2 changes: 1 addition & 1 deletion Version.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<!-- VersionPrefix property for builds and packages -->
<PropertyGroup>
<VersionPrefix>1.0.56</VersionPrefix>
<VersionPrefix>1.0.57</VersionPrefix>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions libs/cluster/ClusterFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ namespace Garnet.cluster
public class ClusterFactory : IClusterFactory
{
/// <inheritdoc />
public DeviceLogCommitCheckpointManager CreateCheckpointManager(INamedDeviceFactory deviceFactory, ICheckpointNamingScheme checkpointNamingScheme, bool isMainStore, ILogger logger = default)
=> new ReplicationLogCheckpointManager(deviceFactory, checkpointNamingScheme, isMainStore, logger: logger);
public DeviceLogCommitCheckpointManager CreateCheckpointManager(INamedDeviceFactoryCreator deviceFactoryCreator, ICheckpointNamingScheme checkpointNamingScheme, bool isMainStore, ILogger logger = default)
=> new ReplicationLogCheckpointManager(deviceFactoryCreator, checkpointNamingScheme, isMainStore, logger: logger);

/// <inheritdoc />
public IClusterProvider CreateClusterProvider(StoreWrapper store)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
namespace Garnet.cluster
{
internal sealed class ReplicationLogCheckpointManager(
INamedDeviceFactory deviceFactory,
INamedDeviceFactoryCreator deviceFactoryCreator,
ICheckpointNamingScheme checkpointNamingScheme,
bool isMainStore,
bool removeOutdated = false,
int fastCommitThrottleFreq = 0,
ILogger logger = null) : DeviceLogCommitCheckpointManager(deviceFactory, checkpointNamingScheme, removeOutdated: false, fastCommitThrottleFreq, logger), IDisposable
ILogger logger = null) : DeviceLogCommitCheckpointManager(deviceFactoryCreator, checkpointNamingScheme, removeOutdated: false, fastCommitThrottleFreq, logger), IDisposable
{
public long CurrentSafeAofAddress = 0;
public long RecoveredSafeAofAddress = 0;
Expand Down
5 changes: 4 additions & 1 deletion libs/common/HashSlotUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ public static unsafe ushort HashSlot(byte* keyPtr, int ksize)
var end = keyPtr + ksize;

// Find first occurence of '{'
while (startPtr < end && *startPtr != '{') { startPtr++; }
while (startPtr < end && *startPtr != '{')
{
startPtr++;
}

// Return early if did not find '{'
if (startPtr == end) return (ushort)(Hash(keyPtr, ksize) & 16383);
Expand Down
14 changes: 8 additions & 6 deletions libs/common/StreamProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,21 @@ public static IStreamProvider GetStreamProvider(FileLocationType locationType, s
internal class AzureStreamProvider : StreamProviderBase
{
private readonly string _connectionString;
private readonly AzureStorageNamedDeviceFactoryCreator azureStorageNamedDeviceFactoryCreator;

public AzureStreamProvider(string connectionString)
{
this._connectionString = connectionString;
this.azureStorageNamedDeviceFactoryCreator = new AzureStorageNamedDeviceFactoryCreator(this._connectionString, default);
}

protected override IDevice GetDevice(string path)
{
var fileInfo = new FileInfo(path);
INamedDeviceFactory settingsDeviceFactoryCreator = new AzureStorageNamedDeviceFactory(this._connectionString, default);

// Get the container info, if it does not exist it will be created
settingsDeviceFactoryCreator.Initialize($"{fileInfo.Directory?.Name}");
var settingsDevice = settingsDeviceFactoryCreator.Get(new FileDescriptor("", fileInfo.Name));
var settingsDeviceFactory = azureStorageNamedDeviceFactoryCreator.Create($"{fileInfo.Directory?.Name}");
var settingsDevice = settingsDeviceFactory.Get(new FileDescriptor("", fileInfo.Name));
settingsDevice.Initialize(MaxConfigFileSizeAligned, epoch: null, omitSegmentIdFromFilename: false);
return settingsDevice;
}
Expand All @@ -183,19 +184,20 @@ protected override long GetBytesToWrite(byte[] bytes, IDevice device)
internal class LocalFileStreamProvider : StreamProviderBase
{
private readonly bool readOnly;
private readonly LocalStorageNamedDeviceFactoryCreator localDeviceFactoryCreator;

public LocalFileStreamProvider(bool readOnly = false)
{
this.readOnly = readOnly;
this.localDeviceFactoryCreator = new LocalStorageNamedDeviceFactoryCreator(disableFileBuffering: false, readOnly: readOnly);
}

protected override IDevice GetDevice(string path)
{
var fileInfo = new FileInfo(path);

INamedDeviceFactory settingsDeviceFactoryCreator = new LocalStorageNamedDeviceFactory(disableFileBuffering: false, readOnly: readOnly);
settingsDeviceFactoryCreator.Initialize("");
var settingsDevice = settingsDeviceFactoryCreator.Get(new FileDescriptor(fileInfo.DirectoryName, fileInfo.Name));
var settingsDeviceFactory = localDeviceFactoryCreator.Create("");
var settingsDevice = settingsDeviceFactory.Get(new FileDescriptor(fileInfo.DirectoryName, fileInfo.Name));
settingsDevice.Initialize(-1, epoch: null, omitSegmentIdFromFilename: true);
return settingsDevice;
}
Expand Down
4 changes: 2 additions & 2 deletions libs/host/Configuration/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,8 @@ public GarnetServerOptions GetServerOptions(ILogger logger = null)
ThreadPoolMaxIOCompletionThreads = ThreadPoolMaxIOCompletionThreads,
NetworkConnectionLimit = NetworkConnectionLimit,
DeviceFactoryCreator = useAzureStorage
? () => new AzureStorageNamedDeviceFactory(AzureStorageConnectionString, logger)
: () => new LocalStorageNamedDeviceFactory(useNativeDeviceLinux: UseNativeDeviceLinux.GetValueOrDefault(), logger: logger),
? new AzureStorageNamedDeviceFactoryCreator(AzureStorageConnectionString, logger)
: new LocalStorageNamedDeviceFactoryCreator(useNativeDeviceLinux: UseNativeDeviceLinux.GetValueOrDefault(), logger: logger),
CheckpointThrottleFlushDelayMs = CheckpointThrottleFlushDelayMs,
EnableScatterGatherGet = EnableScatterGatherGet.GetValueOrDefault(),
ReplicaSyncDelayMs = ReplicaSyncDelayMs,
Expand Down
14 changes: 6 additions & 8 deletions libs/host/GarnetServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,14 @@ private void CreateMainStore(IClusterFactory clusterFactory, out string checkpoi
kvSettings.ThrottleCheckpointFlushDelayMs = opts.CheckpointThrottleFlushDelayMs;
kvSettings.CheckpointVersionSwitchBarrier = opts.EnableCluster;

var checkpointFactory = opts.DeviceFactoryCreator();
if (opts.EnableCluster)
{
kvSettings.CheckpointManager = clusterFactory.CreateCheckpointManager(checkpointFactory,
kvSettings.CheckpointManager = clusterFactory.CreateCheckpointManager(opts.DeviceFactoryCreator,
new DefaultCheckpointNamingScheme(checkpointDir + "/Store/checkpoints"), isMainStore: true, logger);
}
else
{
kvSettings.CheckpointManager = new DeviceLogCommitCheckpointManager(checkpointFactory,
kvSettings.CheckpointManager = new DeviceLogCommitCheckpointManager(opts.DeviceFactoryCreator,
new DefaultCheckpointNamingScheme(checkpointDir + "/Store/checkpoints"), removeOutdated: true);
}

Expand All @@ -335,11 +334,11 @@ private void CreateObjectStore(IClusterFactory clusterFactory, CustomCommandMana

if (opts.EnableCluster)
objKvSettings.CheckpointManager = clusterFactory.CreateCheckpointManager(
opts.DeviceFactoryCreator(),
opts.DeviceFactoryCreator,
new DefaultCheckpointNamingScheme(CheckpointDir + "/ObjectStore/checkpoints"),
isMainStore: false, logger);
else
objKvSettings.CheckpointManager = new DeviceLogCommitCheckpointManager(opts.DeviceFactoryCreator(),
objKvSettings.CheckpointManager = new DeviceLogCommitCheckpointManager(opts.DeviceFactoryCreator,
new DefaultCheckpointNamingScheme(CheckpointDir + "/ObjectStore/checkpoints"),
removeOutdated: true);

Expand Down Expand Up @@ -407,9 +406,8 @@ public void Dispose(bool deleteDir = true)
logFactory?.Delete(new FileDescriptor { directoryName = "" });
if (opts.CheckpointDir != opts.LogDir && !string.IsNullOrEmpty(opts.CheckpointDir))
{
var ckptdir = opts.DeviceFactoryCreator();
ckptdir.Initialize(opts.CheckpointDir);
ckptdir.Delete(new FileDescriptor { directoryName = "" });
var checkpointDeviceFactory = opts.DeviceFactoryCreator.Create(opts.CheckpointDir);
checkpointDeviceFactory.Delete(new FileDescriptor { directoryName = "" });
}
}
}
Expand Down
Loading

0 comments on commit 29fc9c3

Please sign in to comment.