nlu90 commented on a change in pull request #2941: add tmaster physical plan 
endpoint
URL: https://github.com/apache/incubator-heron/pull/2941#discussion_r198898859
 
 

 ##########
 File path: heron/tmaster/src/cpp/manager/tcontroller.cpp
 ##########
 @@ -262,6 +269,38 @@ void 
TController::HandleUpdateRuntimeConfigRequestDone(IncomingHTTPRequest* requ
   delete request;
 }
 
+void TController::HandleGetCurPPlanRequest(IncomingHTTPRequest* request) {
+  LOG(INFO) << "Got a GetCurPPlan request from " << request->GetRemoteHost() 
<< ":"
+              << request->GetRemotePort();
+
+  // make sure all the stream managers are alive, in case that when container 
is fail,
+  // physical plan is still available at TMaster but not a valid one.
+  if (tmaster_->GetStmgrsRegSummary()->absent_stmgrs_size() != 0) {
+      http_server_->SendErrorReply(request, 400);
+      delete request;
+      return;
+  }
+
+  if (tmaster_->getPhysicalPlan() == NULL) {
+    http_server_->SendErrorReply(request, 400);
+    delete request;
+    return;
+  } else {
+    std::string pplanString;
+    tmaster_->getPhysicalPlan()->SerializeToString(&pplanString);
+
+    // SerializeToString() returns object in binary format which needs to be 
encoded
+    const unsigned char * encodeString = (unsigned char *)pplanString.c_str();
+    std::string pplanStringFixed = cereal::base64::encode(encodeString, 
pplanString.size());
+
+    const std::string message("Get current physical plan");
+    LOG(INFO) << message;
+    OutgoingHTTPResponse* response = new OutgoingHTTPResponse(request);
+    response->AddResponse(pplanStringFixed);
+    http_server_->SendReply(request, 200, response);
 
 Review comment:
   In the `else {...}` case, `request` is not deleted. This will lead to memory 
leak issue.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to