Add pkt counters and increase grpc timeout
Change-Id: Id53b8a3ee9a279ec53595e62a2ea99a7eae3dadc
diff --git a/ofagent/grpc_client.py b/ofagent/grpc_client.py
index 155f18d..018baa9 100644
--- a/ofagent/grpc_client.py
+++ b/ofagent/grpc_client.py
@@ -51,6 +51,9 @@
self.packet_in_queue = DeferredQueue() # queue to receive PacketIn
self.change_event_queue = DeferredQueue() # queue change events
+ self.count_pkt_in = 0
+ self.count_pkt_out = 0
+
def start(self):
self.log.debug('starting', grpc_timeout=self.grpc_timeout)
self.start_packet_out_stream()
@@ -76,6 +79,8 @@
if self.stopped:
return
else:
+ self.count_pkt_out += 1
+ self.log.debug('counters grpc_client OUT - {}'.format(self.count_pkt_out))
yield packet
def stream_packets_out():
@@ -101,6 +106,8 @@
self.log.debug('enqued-packet-in',
packet_in=packet_in,
queue_len=len(self.packet_in_queue.pending))
+ self.count_pkt_in += 1
+ self.log.debug('counters grpc_client IN - {}'.format(self.count_pkt_in))
except _Rendezvous, e:
self.log.error('grpc-exception', status=e.code())
if e.code() == StatusCode.UNAVAILABLE:
diff --git a/ofagent/main.py b/ofagent/main.py
index 144a0ad..608e1e4 100755
--- a/ofagent/main.py
+++ b/ofagent/main.py
@@ -218,7 +218,7 @@
# May want to specify the gRPC timeout as an arg (in future)
# Right now, set a default value
- self.grpc_timeout = 10
+ self.grpc_timeout = 120
verbosity_adjust = (args.verbose or 0) - (args.quiet or 0)
self.log = setup_logging(self.logconfig,
@@ -262,6 +262,7 @@
reactor.addSystemEventTrigger('before', 'shutdown',
self.shutdown_components)
+ reactor.suggestThreadPoolSize(30)
reactor.run()
diff --git a/ofagent/of_protocol_handler.py b/ofagent/of_protocol_handler.py
index 7deee6d..ec11d0a 100644
--- a/ofagent/of_protocol_handler.py
+++ b/ofagent/of_protocol_handler.py
@@ -50,6 +50,9 @@
self.rpc = rpc
self.role = None
+ self.count_pkt_in = 0
+ self.count_pkt_out = 0
+
@inlineCallbacks
def start(self):
"""A new call is made after a fresh reconnect"""
@@ -190,6 +193,8 @@
def handle_packet_out_request(self, req):
if self.role == ofp.OFPCR_ROLE_MASTER or self.role == ofp.OFPCR_ROLE_EQUAL:
self.rpc.send_packet_out(self.device_id, to_grpc(req))
+ self.count_pkt_out += 1
+ log.debug('counters of_protocol_handler OUT - {}'.format(self.count_pkt_out))
elif self.role == ofp.OFPCR_ROLE_SLAVE:
self.cxn.send(ofp.message.bad_request_error_msg(code=ofp.OFPBRC_IS_SLAVE))
@@ -344,6 +349,8 @@
if self.role == ofp.OFPCR_ROLE_MASTER or self.role == ofp.OFPCR_ROLE_EQUAL:
log.info('sending-packet-in', ofp_packet_in=ofp_packet_in)
self.cxn.send(to_loxi(ofp_packet_in))
+ self.count_pkt_in += 1
+ log.debug('counters of_protocol_handler IN - {}'.format(self.count_pkt_in))
def forward_port_status(self, ofp_port_status):
self.cxn.send(to_loxi(ofp_port_status))