You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bb...@apache.org on 2022/02/25 00:07:48 UTC
[geode-native] branch develop updated: Allow --handshake and --messages flags to coexist in gnmsg (#935)
This is an automated email from the ASF dual-hosted git repository.
bbender pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git
The following commit(s) were added to refs/heads/develop by this push:
new b7dab15 Allow --handshake and --messages flags to coexist in gnmsg (#935)
b7dab15 is described below
commit b7dab150b3ec7973995e88bbe7e257b59374d100
Author: Blake Bender <bb...@pivotal.io>
AuthorDate: Thu Feb 24 16:07:42 2022 -0800
Allow --handshake and --messages flags to coexist in gnmsg (#935)
---
tools/gnmsg/gnmsg.py | 18 ++-----
tools/gnmsg/handshake_decoder.py | 107 +++++++++++++++++++--------------------
2 files changed, 57 insertions(+), 68 deletions(-)
diff --git a/tools/gnmsg/gnmsg.py b/tools/gnmsg/gnmsg.py
index b616729..d2fd9ad 100755
--- a/tools/gnmsg/gnmsg.py
+++ b/tools/gnmsg/gnmsg.py
@@ -39,24 +39,11 @@ def scan_opened_file(
start_string,
):
separator = start_string
- if dump_handshake:
- handshake_decoder = HandshakeDecoder(output_queue)
- for line in file:
- handshake_decoder.process_line(line.decode("utf-8").rstrip())
- try:
- data = output_queue.get_nowait()
- for key, value in data.items():
- if key == "handshake":
- print(separator + json.dumps(value, indent=2, default=str))
- separator = ","
- except queue.Empty:
- continue
-
- separator = start_string
for line in file:
linestr = line.decode("utf-8").rstrip()
client_decoder.process_line(linestr)
server_decoder.process_line(linestr)
+ handshake_decoder.process_line(linestr)
try:
data = output_queue.get_nowait()
for key, value in data.items():
@@ -68,6 +55,9 @@ def scan_opened_file(
else:
print(separator + json.dumps(value, indent=2, default=str))
separator = ","
+ elif key == "handshake" and dump_handshake:
+ print(separator + json.dumps(value, indent=2, default=str))
+ separator = ","
except queue.Empty:
continue
diff --git a/tools/gnmsg/handshake_decoder.py b/tools/gnmsg/handshake_decoder.py
index dc59aed..669bf0c 100644
--- a/tools/gnmsg/handshake_decoder.py
+++ b/tools/gnmsg/handshake_decoder.py
@@ -64,14 +64,14 @@ class HandshakeDecoder(DecoderBase):
def is_candidate_line(self, line):
return "Helper::sendR" in line or "ake bytes:" in line
- def is_client_connection_request(self, line):
+ def is_locator_request(self, line):
match = self.client_connection_request_expression_.search(line)
if match:
return True
else:
return False
- def get_client_connection_request_parts(self, line, parts):
+ def get_locator_request_parts(self, line, parts):
result = False
match = self.client_connection_request_expression_.search(line)
if match:
@@ -82,14 +82,14 @@ class HandshakeDecoder(DecoderBase):
return result
- def is_client_connection_response(self, line):
+ def is_locator_response(self, line):
match = self.client_connection_response_expression_.search(line)
if match:
return True
else:
return False
- def get_client_connection_response_parts(self, line, parts):
+ def get_locator_response_parts(self, line, parts):
result = False
match = self.client_connection_response_expression_.search(line)
if match:
@@ -425,52 +425,6 @@ class HandshakeDecoder(DecoderBase):
locator_list_request["servergroup"] = server_group
return locator_list_request, offset
- def decode_locator_request(self, line, handshake_request):
- parts = []
- if self.get_client_connection_request_parts(line, parts):
- offset = 0
- handshake_request["Timestamp"] = parts[0]
- handshake_request["tid"] = parts[1]
- handshake_request["Direction"] = "--->"
- request_bytes = parts[2]
-
- (handshake_request["GossipVersion"], offset) = call_reader_function(
- request_bytes, offset, read_int_value
- )
- (handshake_request["ProtocolOrdinal"], offset) = call_reader_function(
- request_bytes, offset, read_short_value
- )
-
- (ds_code, offset) = call_reader_function(
- request_bytes, offset, read_byte_value
- )
-
- (dsfid, offset) = call_reader_function(
- request_bytes, offset, read_byte_value
- )
- request_type = ds_fids[dsfid]
- handshake_request["Type"] = request_type
- if request_type == "ClientConnectionRequest":
- (
- handshake_request["ClientConnectionRequest"],
- offset,
- ) = self.read_client_connection_request(request_bytes, offset)
-
- elif request_type == "QueueConnectionRequest":
- (
- handshake_request["QueueConnectionRequest"],
- offset,
- ) = self.read_queue_connection_request(request_bytes, offset)
-
- elif request_type == "LocatorListRequest":
- (
- handshake_request["LocatorListRequest"],
- offset,
- ) = self.read_locator_list_request(request_bytes, offset)
- else:
- pass
- # TODO: decode other request types (locator list, server list, ...)
-
def read_server_location(self, line, offset):
server_location = {}
(server_location["hostname"], offset) = read_cacheable_ascii_string_value(
@@ -538,16 +492,61 @@ class HandshakeDecoder(DecoderBase):
locator_list_response["LocatorLocations"] = locator_locations
return locator_list_response, offset
+ def decode_locator_request(self, line, handshake_request):
+ parts = []
+ if self.get_locator_request_parts(line, parts):
+ offset = 0
+ handshake_request["Timestamp"] = parts[0]
+ handshake_request["tid"] = parts[1]
+ handshake_request["Direction"] = "--->"
+ request_bytes = parts[2]
+
+ (handshake_request["GossipVersion"], offset) = call_reader_function(
+ request_bytes, offset, read_int_value
+ )
+ (handshake_request["ProtocolOrdinal"], offset) = call_reader_function(
+ request_bytes, offset, read_short_value
+ )
+
+ (ds_code, offset) = call_reader_function(
+ request_bytes, offset, read_byte_value
+ )
+
+ (dsfid, offset) = call_reader_function(
+ request_bytes, offset, read_byte_value
+ )
+ request_type = ds_fids[dsfid]
+ handshake_request["Type"] = request_type
+ if request_type == "ClientConnectionRequest":
+ (
+ handshake_request["ClientConnectionRequest"],
+ offset,
+ ) = self.read_client_connection_request(request_bytes, offset)
+
+ elif request_type == "QueueConnectionRequest":
+ (
+ handshake_request["QueueConnectionRequest"],
+ offset,
+ ) = self.read_queue_connection_request(request_bytes, offset)
+
+ elif request_type == "LocatorListRequest":
+ (
+ handshake_request["LocatorListRequest"],
+ offset,
+ ) = self.read_locator_list_request(request_bytes, offset)
+ else:
+ pass
+ # TODO: decode other request types (locator list, server list, ...)
+
def decode_locator_response(self, line, handshake_response):
parts = []
- if self.get_client_connection_response_parts(line, parts):
+ if self.get_locator_response_parts(line, parts):
handshake_response["Timestamp"] = parts[0]
handshake_response["tid"] = parts[1]
handshake_response["Direction"] = "<---"
response_bytes = parts[2]
offset = 0
- handshake_response["Direction"] = "<---"
(ssl_enabled, offset) = call_reader_function(
response_bytes, offset, read_byte_value
)
@@ -584,10 +583,10 @@ class HandshakeDecoder(DecoderBase):
return
handshake = {}
- if self.is_client_connection_request(line):
+ if self.is_locator_request(line):
self.decode_locator_request(line, handshake)
self.output_queue_.put({"handshake": handshake})
- elif self.is_client_connection_response(line):
+ elif self.is_locator_response(line):
self.decode_locator_response(line, handshake)
self.output_queue_.put({"handshake": handshake})
elif self.is_server_handshake_trace(line):