Commit 6ed17a99 authored by Marc Gravell's avatar Marc Gravell

WILL NEED TO REVERT: pong ident (breaks RedisLabs)

parent 82d2ac49
...@@ -240,13 +240,13 @@ internal void KeepAlive() ...@@ -240,13 +240,13 @@ internal void KeepAlive()
switch (ConnectionType) switch (ConnectionType)
{ {
case ConnectionType.Interactive: case ConnectionType.Interactive:
msg = ServerEndPoint.GetTracerMessage(false); msg = ServerEndPoint.GetTracerMessage(false, "pong hb");
msg.SetSource(ResultProcessor.Tracer, null); msg.SetSource(ResultProcessor.Tracer, null);
break; break;
case ConnectionType.Subscription: case ConnectionType.Subscription:
if (commandMap.IsAvailable(RedisCommand.PING) && ServerEndPoint.GetFeatures().PingOnSubscriber) if (commandMap.IsAvailable(RedisCommand.PING) && ServerEndPoint.GetFeatures().PingOnSubscriber)
{ {
msg = Message.Create(-1, CommandFlags.FireAndForget, RedisCommand.PING); msg = Message.Create(-1, CommandFlags.FireAndForget, RedisCommand.PING, (RedisValue)"pong sub");
msg.SetSource(ResultProcessor.Tracer, null); msg.SetSource(ResultProcessor.Tracer, null);
} }
else if (commandMap.IsAvailable(RedisCommand.UNSUBSCRIBE)) else if (commandMap.IsAvailable(RedisCommand.UNSUBSCRIBE))
......
...@@ -103,7 +103,7 @@ private ResultProcessor.TimingProcessor.TimerMessage GetTimerMessage(CommandFlag ...@@ -103,7 +103,7 @@ private ResultProcessor.TimingProcessor.TimerMessage GetTimerMessage(CommandFlag
// do the best we can with available commands // do the best we can with available commands
var map = multiplexer.CommandMap; var map = multiplexer.CommandMap;
if(map.IsAvailable(RedisCommand.PING)) if(map.IsAvailable(RedisCommand.PING))
return ResultProcessor.TimingProcessor.CreateMessage(-1, flags, RedisCommand.PING); return ResultProcessor.TimingProcessor.CreateMessage(-1, flags, RedisCommand.PING, "pong time");
if(map.IsAvailable(RedisCommand.TIME)) if(map.IsAvailable(RedisCommand.TIME))
return ResultProcessor.TimingProcessor.CreateMessage(-1, flags, RedisCommand.TIME); return ResultProcessor.TimingProcessor.CreateMessage(-1, flags, RedisCommand.TIME);
if (map.IsAvailable(RedisCommand.ECHO)) if (map.IsAvailable(RedisCommand.ECHO))
......
...@@ -555,13 +555,13 @@ public Task HyperLogLogMergeAsync(RedisKey destination, RedisKey[] sourceKeys, C ...@@ -555,13 +555,13 @@ public Task HyperLogLogMergeAsync(RedisKey destination, RedisKey[] sourceKeys, C
public EndPoint IdentifyEndpoint(RedisKey key = default(RedisKey), CommandFlags flags = CommandFlags.None) public EndPoint IdentifyEndpoint(RedisKey key = default(RedisKey), CommandFlags flags = CommandFlags.None)
{ {
var msg = key.IsNull ? Message.Create(-1, flags, RedisCommand.PING) : Message.Create(Database, flags, RedisCommand.EXISTS, key); var msg = key.IsNull ? Message.Create(-1, flags, RedisCommand.PING, (RedisValue)"pong ident") : Message.Create(Database, flags, RedisCommand.EXISTS, key);
return ExecuteSync(msg, ResultProcessor.ConnectionIdentity); return ExecuteSync(msg, ResultProcessor.ConnectionIdentity);
} }
public Task<EndPoint> IdentifyEndpointAsync(RedisKey key = default(RedisKey), CommandFlags flags = CommandFlags.None) public Task<EndPoint> IdentifyEndpointAsync(RedisKey key = default(RedisKey), CommandFlags flags = CommandFlags.None)
{ {
var msg = key.IsNull ? Message.Create(-1, flags, RedisCommand.PING) : Message.Create(Database, flags, RedisCommand.EXISTS, key); var msg = key.IsNull ? Message.Create(-1, flags, RedisCommand.PING, (RedisValue)"pong ident") : Message.Create(Database, flags, RedisCommand.EXISTS, key);
return ExecuteAsync(msg, ResultProcessor.ConnectionIdentity); return ExecuteAsync(msg, ResultProcessor.ConnectionIdentity);
} }
......
...@@ -17,14 +17,21 @@ public static readonly CommandBytes ...@@ -17,14 +17,21 @@ public static readonly CommandBytes
no = "no", no = "no",
OK = "OK", OK = "OK",
one = "1", one = "1",
PONG = "PONG",
QUEUED = "QUEUED", QUEUED = "QUEUED",
READONLY = "READONLY ", READONLY = "READONLY ",
slave_read_only = "slave-read-only", slave_read_only = "slave-read-only",
timeout = "timeout", timeout = "timeout",
wildcard = "*", wildcard = "*",
yes = "yes", yes = "yes",
zero = "0"; zero = "0",
pong_sub = "pong sub",
pong_hb = "pong hb",
pong_test = "pong test",
pong_time = "pong time",
pong_tran = "pong tran",
PONG = "PONG";
} }
internal static class RedisLiterals internal static class RedisLiterals
{ {
......
...@@ -122,8 +122,8 @@ private Message CreateMessage(CommandFlags flags, out ResultProcessor<bool> proc ...@@ -122,8 +122,8 @@ private Message CreateMessage(CommandFlags flags, out ResultProcessor<bool> proc
processor = null; processor = null;
return null; // they won't notice if we don't do anything... return null; // they won't notice if we don't do anything...
} }
processor = ResultProcessor.DemandPONG; processor = ResultProcessor.DemandPONG_TRAN;
return Message.Create(-1, flags, RedisCommand.PING); return Message.Create(-1, flags, RedisCommand.PING, (RedisValue)"pong tran");
} }
processor = TransactionProcessor.Default; processor = TransactionProcessor.Default;
return new TransactionMessage(Database, flags, cond, work); return new TransactionMessage(Database, flags, cond, work);
......
...@@ -15,7 +15,7 @@ internal abstract class ResultProcessor ...@@ -15,7 +15,7 @@ internal abstract class ResultProcessor
public static readonly ResultProcessor<bool> public static readonly ResultProcessor<bool>
Boolean = new BooleanProcessor(), Boolean = new BooleanProcessor(),
DemandOK = new ExpectBasicStringProcessor(CommonReplies.OK), DemandOK = new ExpectBasicStringProcessor(CommonReplies.OK),
DemandPONG = new ExpectBasicStringProcessor(CommonReplies.PONG), DemandPONG_TRAN = new ExpectBasicStringProcessor(CommonReplies.pong_tran),
DemandZeroOrOne = new DemandZeroOrOneProcessor(), DemandZeroOrOne = new DemandZeroOrOneProcessor(),
AutoConfigure = new AutoConfigureProcessor(), AutoConfigure = new AutoConfigureProcessor(),
TrackSubscriptions = new TrackSubscriptionsProcessor(), TrackSubscriptions = new TrackSubscriptionsProcessor(),
...@@ -1817,7 +1817,7 @@ public override bool SetResult(PhysicalConnection connection, Message message, R ...@@ -1817,7 +1817,7 @@ public override bool SetResult(PhysicalConnection connection, Message message, R
} }
return final; return final;
} }
protected override bool SetResultCore(PhysicalConnection connection, Message message, RawResult result) protected override bool SetResultCore(PhysicalConnection connection, Message message, RawResult result)
{ {
bool happy; bool happy;
...@@ -1827,10 +1827,13 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes ...@@ -1827,10 +1827,13 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
happy = result.Type == ResultType.BulkString && (!establishConnection || result.IsEqual(connection.BridgeCouldBeNull?.Multiplexer?.UniqueId)); happy = result.Type == ResultType.BulkString && (!establishConnection || result.IsEqual(connection.BridgeCouldBeNull?.Multiplexer?.UniqueId));
break; break;
case RedisCommand.PING: case RedisCommand.PING:
// there are two different PINGs; "interactive" is a +PONG or +{your message}, // there are two different PINGs; "interactive" is a +PONG or ${your message},
// but subscriber returns a bulk-array of [ "pong", {your message} ] // but subscriber returns a bulk-array of [ "pong", {your message} ]
switch (result.Type) switch (result.Type)
{ {
case ResultType.BulkString:
happy = result.IsEqual(CommonReplies.pong_hb) || result.IsEqual(CommonReplies.pong_test);
break;
case ResultType.SimpleString: case ResultType.SimpleString:
happy = result.IsEqual(CommonReplies.PONG); happy = result.IsEqual(CommonReplies.PONG);
break; break;
...@@ -1838,7 +1841,7 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes ...@@ -1838,7 +1841,7 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
if (result.ItemsCount == 2) if (result.ItemsCount == 2)
{ {
var items = result.GetItems(); var items = result.GetItems();
happy = items[0].IsEqual(CommonReplies.PONG) && items[1].Payload.IsEmpty; happy = items[0].IsEqual(CommonReplies.PONG) && items[1].IsEqual(CommonReplies.pong_sub);
} }
else else
{ {
......
...@@ -411,7 +411,7 @@ internal string GetStormLog(RedisCommand command) ...@@ -411,7 +411,7 @@ internal string GetStormLog(RedisCommand command)
return bridge?.GetStormLog(); return bridge?.GetStormLog();
} }
internal Message GetTracerMessage(bool assertIdentity) internal Message GetTracerMessage(bool assertIdentity, string preferredMessage)
{ {
// different configurations block certain commands, as can ad-hoc local configurations, so // different configurations block certain commands, as can ad-hoc local configurations, so
// we'll do the best with what we have available. // we'll do the best with what we have available.
...@@ -426,7 +426,7 @@ internal Message GetTracerMessage(bool assertIdentity) ...@@ -426,7 +426,7 @@ internal Message GetTracerMessage(bool assertIdentity)
} }
else if (map.IsAvailable(RedisCommand.PING)) else if (map.IsAvailable(RedisCommand.PING))
{ {
msg = Message.Create(-1, flags, RedisCommand.PING); msg = Message.Create(-1, flags, RedisCommand.PING, (RedisValue)preferredMessage);
} }
else if (map.IsAvailable(RedisCommand.TIME)) else if (map.IsAvailable(RedisCommand.TIME))
{ {
...@@ -586,7 +586,7 @@ internal void ReportNextFailure() ...@@ -586,7 +586,7 @@ internal void ReportNextFailure()
internal Task<bool> SendTracer(TextWriter log = null) internal Task<bool> SendTracer(TextWriter log = null)
{ {
var msg = GetTracerMessage(false); var msg = GetTracerMessage(false, "pong test");
msg = LoggingMessage.Create(log, msg); msg = LoggingMessage.Create(log, msg);
return WriteDirectAsync(msg, ResultProcessor.Tracer); return WriteDirectAsync(msg, ResultProcessor.Tracer);
} }
...@@ -704,7 +704,7 @@ private Task HandshakeAsync(PhysicalConnection connection, TextWriter log) ...@@ -704,7 +704,7 @@ private Task HandshakeAsync(PhysicalConnection connection, TextWriter log)
AutoConfigure(connection); AutoConfigure(connection);
} }
Multiplexer.LogLocked(log, "Sending critical tracer: {0}", bridge); Multiplexer.LogLocked(log, "Sending critical tracer: {0}", bridge);
var tracer = GetTracerMessage(true); var tracer = GetTracerMessage(true, "pong test");
tracer = LoggingMessage.Create(log, tracer); tracer = LoggingMessage.Create(log, tracer);
WriteDirectOrQueueFireAndForget(connection, tracer, ResultProcessor.EstablishConnection); WriteDirectOrQueueFireAndForget(connection, tracer, ResultProcessor.EstablishConnection);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment