Github user jdye64 commented on a diff in the pull request:
https://github.com/apache/nifi-minifi-cpp/pull/63#discussion_r105259757
--- Diff: libminifi/include/FlowControlProtocol.h ---
@@ -45,297 +51,269 @@ class FlowController;
//! FlowControl Protocol Msg Type
typedef enum {
- REGISTER_REQ, // Device Register Request from device to server which
contain device serial number, current running flow YAML version
- REGISTER_RESP, // Device Register Respond from server to device, may
contain new flow.YAML from server ask device to apply and also device report
interval
- REPORT_REQ, // Period Device Report from device to server which contain
device serial number, current running flow YAML name/version and other period
report info
- REPORT_RESP, // Report Respond from server to device, may ask device to
update flow YAML or processor property
- MAX_FLOW_CONTROL_MSG_TYPE
+ REGISTER_REQ, // Device Register Request from device to server which
contain device serial number, current running flow YAML version
+ REGISTER_RESP, // Device Register Respond from server to device, may
contain new flow.YAML from server ask device to apply and also device report
interval
+ REPORT_REQ, // Period Device Report from device to server which contain
device serial number, current running flow YAML name/version and other period
report info
+ REPORT_RESP, // Report Respond from server to device, may ask device to
update flow YAML or processor property
+ MAX_FLOW_CONTROL_MSG_TYPE
} FlowControlMsgType;
//! FlowControl Protocol Msg Type String
-static const char *FlowControlMsgTypeStr[MAX_FLOW_CONTROL_MSG_TYPE] =
-{
- "REGISTER_REQ",
- "REGISTER_RESP",
- "REPORT_REQ",
- "REPORT_RESP"
-};
+static const char *FlowControlMsgTypeStr[MAX_FLOW_CONTROL_MSG_TYPE] = {
+ "REGISTER_REQ", "REGISTER_RESP", "REPORT_REQ", "REPORT_RESP" };
//! Flow Control Msg Type to String
-inline const char *FlowControlMsgTypeToStr(FlowControlMsgType type)
-{
- if (type < MAX_FLOW_CONTROL_MSG_TYPE)
- return FlowControlMsgTypeStr[type];
- else
- return NULL;
+inline const char *FlowControlMsgTypeToStr(FlowControlMsgType type) {
+ if (type < MAX_FLOW_CONTROL_MSG_TYPE)
+ return FlowControlMsgTypeStr[type];
+ else
+ return NULL;
}
//! FlowControll Protocol Msg ID (Some Messages are fix length, Some are
variable length (TLV)
typedef enum {
- //Fix length 8 bytes: client to server in register request, required
field
- FLOW_SERIAL_NUMBER,
- // Flow YAML name TLV: client to server in register request and report
request, required field
- FLOW_YML_NAME,
- // Flow YAML content, TLV: server to client in register respond, option
field in case server want to ask client to load YAML from server
- FLOW_YML_CONTENT,
- // Fix length, 4 bytes Report interval in msec: server to client in
register respond, option field
- REPORT_INTERVAL,
- // Processor Name TLV: server to client in report respond, option
field in case server want to ask client to update processor property
- PROCESSOR_NAME,
- // Processor Property Name TLV: server to client in report respond,
option field in case server want to ask client to update processor property
- PROPERTY_NAME,
- // Processor Property Value TLV: server to client in report respond,
option field in case server want to ask client to update processor property
- PROPERTY_VALUE,
- // Report Blob TLV: client to server in report request, option field in
case client want to pickyback the report blob in report request to server
- REPORT_BLOB,
- MAX_FLOW_MSG_ID
+ //Fix length 8 bytes: client to server in register request, required
field
+ FLOW_SERIAL_NUMBER,
+ // Flow YAML name TLV: client to server in register request and report
request, required field
+ FLOW_YML_NAME,
+ // Flow YAML content, TLV: server to client in register respond, option
field in case server want to ask client to load YAML from server
+ FLOW_YML_CONTENT,
+ // Fix length, 4 bytes Report interval in msec: server to client in
register respond, option field
+ REPORT_INTERVAL,
+ // Processor Name TLV: server to client in report respond, option field
in case server want to ask client to update processor property
+ PROCESSOR_NAME,
+ // Processor Property Name TLV: server to client in report respond,
option field in case server want to ask client to update processor property
+ PROPERTY_NAME,
+ // Processor Property Value TLV: server to client in report respond,
option field in case server want to ask client to update processor property
+ PROPERTY_VALUE,
+ // Report Blob TLV: client to server in report request, option field in
case client want to pickyback the report blob in report request to server
+ REPORT_BLOB,
+ MAX_FLOW_MSG_ID
} FlowControlMsgID;
//! FlowControl Protocol Msg ID String
-static const char *FlowControlMsgIDStr[MAX_FLOW_MSG_ID] =
-{
- "FLOW_SERIAL_NUMBER",
- "FLOW_YAML_NAME",
- "FLOW_YAML_CONTENT",
- "REPORT_INTERVAL",
- "PROCESSOR_NAME"
- "PROPERTY_NAME",
- "PROPERTY_VALUE",
- "REPORT_BLOB"
-};
+static const char *FlowControlMsgIDStr[MAX_FLOW_MSG_ID] = {
+ "FLOW_SERIAL_NUMBER", "FLOW_YAML_NAME", "FLOW_YAML_CONTENT",
+ "REPORT_INTERVAL", "PROCESSOR_NAME"
+ "PROPERTY_NAME", "PROPERTY_VALUE", "REPORT_BLOB" };
#define TYPE_HDR_LEN 4 // Fix Hdr Type
#define TLV_HDR_LEN 8 // Type 4 bytes and Len 4 bytes
//! FlowControl Protocol Msg Len
-inline int FlowControlMsgIDEncodingLen(FlowControlMsgID id, int payLoadLen)
-{
- if (id == FLOW_SERIAL_NUMBER)
- return (TYPE_HDR_LEN + 8);
- else if (id == REPORT_INTERVAL)
- return (TYPE_HDR_LEN + 4);
- else if (id < MAX_FLOW_MSG_ID)
- return (TLV_HDR_LEN + payLoadLen);
- else
- return -1;
+inline int FlowControlMsgIDEncodingLen(FlowControlMsgID id, int
payLoadLen) {
+ if (id == FLOW_SERIAL_NUMBER)
+ return (TYPE_HDR_LEN + 8);
+ else if (id == REPORT_INTERVAL)
+ return (TYPE_HDR_LEN + 4);
+ else if (id < MAX_FLOW_MSG_ID)
+ return (TLV_HDR_LEN + payLoadLen);
+ else
+ return -1;
}
//! Flow Control Msg Id to String
-inline const char *FlowControlMsgIdToStr(FlowControlMsgID id)
-{
- if (id < MAX_FLOW_MSG_ID)
- return FlowControlMsgIDStr[id];
- else
- return NULL;
+inline const char *FlowControlMsgIdToStr(FlowControlMsgID id) {
+ if (id < MAX_FLOW_MSG_ID)
+ return FlowControlMsgIDStr[id];
+ else
+ return NULL;
}
//! Flow Control Respond status code
typedef enum {
- RESP_SUCCESS,
- RESP_TRIGGER_REGISTER, // Server respond to client report to re trigger
register
- RESP_START_FLOW_CONTROLLER, // Server respond to client to start flow
controller
- RESP_STOP_FLOW_CONTROLLER, // Server respond to client to stop flow
controller
- RESP_FAILURE,
- MAX_RESP_CODE
+ RESP_SUCCESS,
+ RESP_TRIGGER_REGISTER, // Server respond to client report to re trigger
register
+ RESP_START_FLOW_CONTROLLER, // Server respond to client to start flow
controller
+ RESP_STOP_FLOW_CONTROLLER, // Server respond to client to stop flow
controller
+ RESP_FAILURE,
+ MAX_RESP_CODE
} FlowControlRespCode;
//! FlowControl Resp Code str
-static const char *FlowControlRespCodeStr[MAX_RESP_CODE] =
-{
- "RESP_SUCCESS",
- "RESP_TRIGGER_REGISTER",
- "RESP_START_FLOW_CONTROLLER",
- "RESP_STOP_FLOW_CONTROLLER",
- "RESP_FAILURE"
-};
+static const char *FlowControlRespCodeStr[MAX_RESP_CODE] = {
"RESP_SUCCESS",
+ "RESP_TRIGGER_REGISTER", "RESP_START_FLOW_CONTROLLER",
+ "RESP_STOP_FLOW_CONTROLLER", "RESP_FAILURE" };
//! Flow Control Resp Code to String
-inline const char *FlowControlRespCodeToStr(FlowControlRespCode code)
-{
- if (code < MAX_RESP_CODE)
- return FlowControlRespCodeStr[code];
- else
- return NULL;
+inline const char *FlowControlRespCodeToStr(FlowControlRespCode code) {
+ if (code < MAX_RESP_CODE)
+ return FlowControlRespCodeStr[code];
+ else
+ return NULL;
}
//! Common FlowControlProtocol Header
typedef struct {
- uint32_t msgType; //! Msg Type
- uint32_t seqNumber; //! Seq Number to match Req with Resp
- uint32_t status; //! Resp Code, see FlowControlRespCode
- uint32_t payloadLen; //! Msg Payload length
+ uint32_t msgType; //! Msg Type
+ uint32_t seqNumber; //! Seq Number to match Req with Resp
+ uint32_t status; //! Resp Code, see FlowControlRespCode
+ uint32_t payloadLen; //! Msg Payload length
} FlowControlProtocolHeader;
//! FlowControlProtocol Class
-class FlowControlProtocol
-{
-public:
- //! Constructor
- /*!
- * Create a new control protocol
- */
- FlowControlProtocol(FlowController *controller) {
- _controller = controller;
- logger_ = Logger::getLogger();
- configure_ = Configure::getConfigure();
- _socket = 0;
- _serverName = "localhost";
- _serverPort = DEFAULT_NIFI_SERVER_PORT;
- _registered = false;
- _seqNumber = 0;
- _reportBlob = NULL;
- _reportBlobLen = 0;
- _reportInterval = DEFAULT_REPORT_INTERVAL;
- _running = false;
+class FlowControlProtocol {
+ public:
+ //! Constructor
+ /*!
+ * Create a new control protocol
+ */
+ FlowControlProtocol(FlowController *controller) {
+ _controller = controller;
+ logger_ = logging::Logger::getLogger();
+ configure_ = Configure::getConfigure();
+ _socket = 0;
+ _serverName = "localhost";
+ _serverPort = DEFAULT_NIFI_SERVER_PORT;
+ _registered = false;
+ _seqNumber = 0;
+ _reportBlob = NULL;
+ _reportBlobLen = 0;
+ _reportInterval = DEFAULT_REPORT_INTERVAL;
+ _running = false;
--- End diff --
Can you move "_" to end of class data member to adhere to Google C++ Style
guide? Same for all variables here.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---