Skip to content

Commit

Permalink
cleanup lp logging
Browse files Browse the repository at this point in the history
  • Loading branch information
boriwo committed Jun 13, 2015
1 parent 041c68e commit 74b584b
Showing 1 changed file with 34 additions and 38 deletions.
72 changes: 34 additions & 38 deletions src/com/comcast/cmb/common/controller/CMBControllerServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -644,24 +644,21 @@ public void onComplete(AsyncEvent asyncEvent) throws IOException {
AsyncContext asyncContext = asyncEvent.getAsyncContext();
CQSHttpServletRequest request = (CQSHttpServletRequest)asyncContext.getRequest();
String action = request.getParameter("Action");
if(action.equals("ReceiveMessage")){
String lpValue = (String)request.getAttribute("lp");

if(lpValue!=null){

User user = authModule.getUserByRequest(request);

Object lp_ms = request.getAttribute("lp_ms");
String logLine = null;
if(lp_ms!=null){
logLine = getLogLine(asyncContext, request, user, (Long)request.getAttribute("lp_ms"), "ok");
}else{
logLine = getLogLine(asyncContext, request, user, 0, "ok");
}
logger.info(logLine);

if (action != null && action.equals("ReceiveMessage") && request.getAttribute("lp") != null) {

User user = authModule.getUserByRequest(request);
Object lp_ms = request.getAttribute("lp_ms");
String logLine = null;

if (lp_ms != null) {
logLine = getLogLine(asyncContext, request, user, (Long)request.getAttribute("lp_ms"), "ok");
} else {
logLine = getLogLine(asyncContext, request, user, 0, "ok");
}

logger.info(logLine);
}

}

@Override
Expand Down Expand Up @@ -719,34 +716,33 @@ public void onTimeout(AsyncEvent asyncEvent) throws IOException {
AsyncContext asyncContext = asyncEvent.getAsyncContext();
CQSHttpServletRequest request = (CQSHttpServletRequest)asyncContext.getRequest();
String action = request.getParameter("Action");
if (action.equals("ReceiveMessage")) {
String lpValue = (String)request.getAttribute("lp");
if (lpValue != null) {
String out = CQSMessagePopulator.getReceiveMessageResponseAfterSerializing(new ArrayList<CQSMessage>(), new ArrayList<String>(), new ArrayList<String>());
asyncEvent.getSuppliedResponse().getWriter().println(out);

CQSQueue queue = ((CQSHttpServletRequest)asyncEvent.getSuppliedRequest()).getQueue();

asyncContext = asyncEvent.getAsyncContext();

if (queue != null) {

logger.debug("event=on_timeout queue_url=" + queue.getAbsoluteUrl());
if (action != null && action.equals("ReceiveMessage")) {

String out = CQSMessagePopulator.getReceiveMessageResponseAfterSerializing(new ArrayList<CQSMessage>(), new ArrayList<String>(), new ArrayList<String>());
asyncEvent.getSuppliedResponse().getWriter().println(out);
CQSQueue queue = ((CQSHttpServletRequest)asyncEvent.getSuppliedRequest()).getQueue();
asyncContext = asyncEvent.getAsyncContext();

ConcurrentLinkedQueue<AsyncContext> queueContextsList = CQSLongPollReceiver.contextQueues.get(queue.getArn());
if (queue != null) {

if (queueContextsList != null && asyncContext != null) {
queueContextsList.remove(asyncContext);
}
logger.debug("event=on_timeout queue_url=" + queue.getAbsoluteUrl());
ConcurrentLinkedQueue<AsyncContext> queueContextsList = CQSLongPollReceiver.contextQueues.get(queue.getArn());

} else {
logger.debug("event=on_timeout");
if (queueContextsList != null && asyncContext != null) {
queueContextsList.remove(asyncContext);
}
asyncContext.complete();
return;

} else {
logger.debug("event=on_timeout");
}

asyncContext.complete();
return;
}
//for other Time out show log error and return error response.

//for other timeout show log error and return error response.

int httpCode = CMBErrorCodes.InternalError.getHttpCode();
String code = CMBErrorCodes.InternalError.getCMBCode();
String message = "CMB timeout after "+CMBProperties.getInstance().getCMBRequestTimeoutSec()+" seconds";
Expand All @@ -773,7 +769,6 @@ public void onTimeout(AsyncEvent asyncEvent) throws IOException {
if (queue != null) {

logger.error("event=on_timeout queue_url=" + queue.getAbsoluteUrl());

ConcurrentLinkedQueue<AsyncContext> queueContextsList = CQSLongPollReceiver.contextQueues.get(queue.getArn());

if (queueContextsList != null && asyncContext != null) {
Expand All @@ -783,6 +778,7 @@ public void onTimeout(AsyncEvent asyncEvent) throws IOException {
} else {
logger.error("event=on_timeout "+getLogLine(asyncContext, request, authModule.getUserByRequest(request), 0, "timeout"));
}

asyncContext.complete();
}

Expand Down

0 comments on commit 74b584b

Please sign in to comment.