-
Notifications
You must be signed in to change notification settings - Fork 550
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into list-commands
- Loading branch information
Showing
20 changed files
with
296 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,50 @@ | ||
# This is a placeholder for Azure Mirror Github pipeline | ||
resources: | ||
repositories: | ||
- repository: GarnetGithubRepo | ||
type: github | ||
name: microsoft/garnet | ||
endpoint: ADO_to_Github_ServiceConnection | ||
trigger: | ||
branches: | ||
include: | ||
- main | ||
|
||
pool: | ||
vmImage: 'ubuntu-latest' | ||
|
||
jobs: | ||
- job: MirrorGithubToADO | ||
displayName: 'Mirror GitHub main to Azure DevOps main' | ||
pool: | ||
vmImage: 'ubuntu-latest' | ||
steps: | ||
- checkout: GarnetGithubRepo | ||
clean: true | ||
persistCredentials: true | ||
|
||
- script: | | ||
# Set up Git identity | ||
git config user.email "$(GIT_USER_EMAIL)" | ||
git config user.name "$(GIT_USER_NAME)" | ||
git config --global credential.helper 'cache --timeout=3600' | ||
# Fetch the latest changes from the GitHub main branch | ||
git fetch origin main | ||
# Check out main branch locally | ||
# git checkout main | ||
# Ensure the local main branch is checked out and reset to match origin/main | ||
git checkout -B main origin/main | ||
# Reset the main branch to match the origin/main branch | ||
# git reset --hard origin/main | ||
# Push the updated main branch to Azure DevOps | ||
git -c http.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" push https://dev.azure.com/msresearch/_git/Garnet main | ||
displayName: 'Mirror GitHub main to Azure DevOps main' | ||
env: | ||
GIT_USER_EMAIL: $(GIT_USER_EMAIL) | ||
GIT_USER_NAME: $(GIT_USER_NAME) | ||
SYSTEM_ACCESSTOKEN: $(System.AccessToken) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Garnet.common; | ||
|
||
namespace Garnet.server | ||
{ | ||
static class ServerConfig | ||
{ | ||
public static readonly HashSet<ServerConfigType> DefaultConfigType = Enum.GetValues<ServerConfigType>(). | ||
Where(e => e switch | ||
{ | ||
ServerConfigType.NONE => false, | ||
ServerConfigType.ALL => false, | ||
_ => true | ||
}).ToHashSet(); | ||
|
||
public static unsafe ServerConfigType GetConfig(Span<byte> parameter) | ||
{ | ||
ConvertUtils.MakeUpperCase(parameter); | ||
return parameter switch | ||
{ | ||
_ when parameter.SequenceEqual("TIMEOUT"u8) => ServerConfigType.TIMEOUT, | ||
_ when parameter.SequenceEqual("SAVE"u8) => ServerConfigType.SAVE, | ||
_ when parameter.SequenceEqual("APPENDONLY"u8) => ServerConfigType.APPENDONLY, | ||
_ when parameter.SequenceEqual("SLAVE-READ-ONLY"u8) => ServerConfigType.SLAVE_READ_ONLY, | ||
_ when parameter.SequenceEqual("DATABASES"u8) => ServerConfigType.DATABASES, | ||
_ when parameter.SequenceEqual("CLUSTER-NODE-TIMEOUT"u8) => ServerConfigType.CLUSTER_NODE_TIMEOUT, | ||
_ when parameter.SequenceEqual("*"u8) => ServerConfigType.ALL, | ||
_ => ServerConfigType.NONE, | ||
}; | ||
} | ||
} | ||
|
||
internal sealed unsafe partial class RespServerSession : ServerSessionBase | ||
{ | ||
private bool NetworkConfigGet(ReadOnlySpan<byte> bufSpan, int count, out bool errorFlag) | ||
{ | ||
errorFlag = false; | ||
if (count < 2) | ||
{ | ||
if (!DrainCommands(bufSpan, count - 1)) | ||
return false; | ||
errorFlag = true; | ||
return true; | ||
} | ||
|
||
// Extract requested parameters | ||
HashSet<ServerConfigType> parameters = []; | ||
var returnAll = false; | ||
for (var i = 0; i < count - 1; i++) | ||
{ | ||
var parameter = GetCommand(bufSpan, out bool success2); | ||
if (!success2) return false; | ||
var serverConfigType = ServerConfig.GetConfig(parameter); | ||
|
||
if (returnAll) continue; | ||
if (serverConfigType == ServerConfigType.ALL) | ||
{ | ||
parameters = ServerConfig.DefaultConfigType; | ||
returnAll = true; | ||
continue; | ||
} | ||
|
||
if (serverConfigType != ServerConfigType.NONE) | ||
_ = parameters.Add(serverConfigType); | ||
} | ||
|
||
// Generate response for matching parameters | ||
if (parameters.Count > 0) | ||
{ | ||
while (!RespWriteUtils.WriteArrayLength(parameters.Count * 2, ref dcurr, dend)) | ||
SendAndReset(); | ||
|
||
foreach (var parameter in parameters) | ||
{ | ||
var parameterValue = parameter switch | ||
{ | ||
ServerConfigType.TIMEOUT => "$7\r\ntimeout\r\n$1\r\n0\r\n"u8, | ||
ServerConfigType.SAVE => "$4\r\nsave\r\n$0\r\n\r\n"u8, | ||
ServerConfigType.APPENDONLY => storeWrapper.serverOptions.EnableAOF ? "$10\r\nappendonly\r\n$3\r\nyes\r\n"u8 : "$10\r\nappendonly\r\n$2\r\nno\r\n"u8, | ||
ServerConfigType.SLAVE_READ_ONLY => clusterSession == null || clusterSession.ReadWriteSession ? "$15\r\nslave-read-only\r\n$2\r\nno\r\n"u8 : "$15\r\nslave-read-only\r\n$3\r\nyes\r\n"u8, | ||
ServerConfigType.DATABASES => storeWrapper.serverOptions.EnableCluster ? "$9\r\ndatabases\r\n$1\r\n1\r\n"u8 : "$9\r\ndatabases\r\n$2\r\n16\r\n"u8, | ||
ServerConfigType.CLUSTER_NODE_TIMEOUT => Encoding.ASCII.GetBytes($"$20\r\ncluster-node-timeout\r\n${storeWrapper.serverOptions.ClusterTimeout.ToString().Length}\r\n{storeWrapper.serverOptions.ClusterTimeout}\r\n"), | ||
ServerConfigType.NONE => throw new NotImplementedException(), | ||
ServerConfigType.ALL => throw new NotImplementedException(), | ||
_ => throw new NotImplementedException() | ||
}; | ||
|
||
while (!RespWriteUtils.WriteDirect(parameterValue, ref dcurr, dend)) | ||
SendAndReset(); | ||
} | ||
} | ||
else | ||
{ | ||
while (!RespWriteUtils.WriteDirect(CmdStrings.RESP_EMPTYLIST, ref dcurr, dend)) | ||
SendAndReset(); | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
namespace Garnet.server | ||
{ | ||
internal enum ServerConfigType : int | ||
{ | ||
NONE, | ||
ALL, | ||
TIMEOUT, | ||
SAVE, | ||
APPENDONLY, | ||
SLAVE_READ_ONLY, | ||
DATABASES, | ||
CLUSTER_NODE_TIMEOUT | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.