    private void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {  
        User user = null;
        String action = request.getParameter("Action");
        long ts1 = System.currentTimeMillis();
        try {
            valueAccumulator.initializeAllCounters();
        	requestInit();
            response.setContentType("text/xml");
            if (!isValidAction(action)) {
                throw new CMBException(CMBErrorCodes.InvalidAction, action + " is not a valid action");
            }
            if (isAuthenticationRequired(action)) {
                user = authModule.authenticateByRequest(request);
            } else {
                user = null;
            }
            long ts3 = System.currentTimeMillis();
            valueAccumulator.addToCounter(AccumulatorName.CMBControllerPreHandleAction, (ts3 - ts1));
            boolean actionPerformed = handleAction(action, user, request, response);
            response.setStatus(200);
            long ts2 = System.currentTimeMillis();
            if (action != null && action.equals("ReceiveMessage") && !actionPerformed && user != null && user.getUserName().equals(CMBProperties.getInstance().getCnsUserName())) {
            } else if (action != null && action.equals("GetQueueUrl") && user != null && user.getUserName().equals(CMBProperties.getInstance().getCnsUserName())) {
            } else {
	            logger.info(
	            		"event=handleRequest status=success client_ip=" + request.getRemoteAddr() + " action=" + action + " responseTimeMS=" + (ts2-ts1) + 
	                    (request.getParameter("TopicArn") != null ? " topic_arn=" + request.getParameter("TopicArn") : "") +
	                    (request.getParameter("SubscriptionArn") != null ? " subscription_arn=" + request.getParameter("SubscriptionArn") : "") +
	                    (request.getParameter("Label") != null ? " label=" + request.getParameter("Label") : "") +
	                    (request.getParameter("NextToken") != null ? " next_token=" + request.getParameter("NextToken") : "") +
	                    (request.getParameter("Name") != null ? " name=" + request.getParameter("Name") : "") +
	                    (request.getParameter("Token") != null ? " token=" + request.getParameter("Token") : "") +
	                    (request.getParameter("Endpoint") != null ? " endpoint=" + request.getParameter("Endpoint") : "") +
	                    (request.getParameter("Protocol") != null ? " protocol=" + request.getParameter("Protocol") : "") +
	                    (request.getParameter("ReceiptHandle") != null ? " receipt_handle=" + request.getParameter("ReceiptHandle") : "") +
	                    (request.getParameter("VisibilityTimeout") != null ? " visibility_timeout=" + request.getParameter("VisibilityTimeout") : "") +
	                    (request.getParameter("QueueName") != null ? " queue_name=" + request.getParameter("QueueName") : "") +
	                    (request.getParameter("QueueNamePrefix") != null ? " queue_name_prefix=" + request.getParameter("QueueNamePrefix") : "") +
	                    (request.getParameter("DelaySeconds") != null ? " delay_seconds=" + request.getParameter("DelaySeconds") : "") +
	                    ((this instanceof CQSControllerServlet) ? (" queue_url=" + request.getRequestURL().toString()) : "") +
	            		" CassandraTimeMS=" + valueAccumulator.getCounter(AccumulatorName.CassandraTime) + 
	                    " CassandraReadNum=" + valueAccumulator.getCounter(AccumulatorName.CassandraRead) + 
	                    " CassandraWriteNum=" + valueAccumulator.getCounter(AccumulatorName.CassandraWrite) +
	                    ((this instanceof CNSControllerServlet) ? (" CNSCQSTimeMS=" + CMBControllerServlet.valueAccumulator.getCounter(AccumulatorName.CNSCQSTime)) : "") +
	                    ((this instanceof CQSControllerServlet) ? (" RedisTimeMS=" + valueAccumulator.getCounter(AccumulatorName.RedisTime)) : "") +
	                    (user != null ? " user_name=" + user.getUserName() : "")
	            ); 
            }
        } catch (Exception ex) {
        	long ts2 = System.currentTimeMillis();
            logger.error(
            		"event=handleRequest status=failed client_ip=" + request.getRemoteAddr() + " action=" + action + " responseTimeMS=" + (ts2-ts1) + 
                    (request.getParameter("TopicArn") != null ? " topic_arn=" + request.getParameter("TopicArn") : "") +
                    (request.getParameter("SubscriptionArn") != null ? " subscription_arn=" + request.getParameter("SubscriptionArn") : "") +
                    (request.getParameter("Label") != null ? " label=" + request.getParameter("Label") : "") +
                    (request.getParameter("NextToken") != null ? " next_token=" + request.getParameter("NextToken") : "") +
                    (request.getParameter("Name") != null ? " name=" + request.getParameter("Name") : "") +
                    (request.getParameter("Token") != null ? " token=" + request.getParameter("Token") : "") +
                    (request.getParameter("Endpoint") != null ? " endpoint=" + request.getParameter("Endpoint") : "") +
                    (request.getParameter("Protocol") != null ? " protocol=" + request.getParameter("Protocol") : "") +
                    (request.getParameter("ReceiptHandle") != null ? " receipt_handle=" + request.getParameter("ReceiptHandle") : "") +
                    (request.getParameter("VisibilityTimeout") != null ? " visibility_timeout=" + request.getParameter("VisibilityTimeout") : "") +
                    (request.getParameter("QueueName") != null ? " queue_name=" + request.getParameter("QueueName") : "") +
                    (request.getParameter("QueueNamePrefix") != null ? " queue_name_prefix=" + request.getParameter("QueueNamePrefix") : "") +
                    (request.getParameter("DelaySeconds") != null ? " delay_seconds=" + request.getParameter("DelaySeconds") : "") +
                    ((this instanceof CQSControllerServlet) ? (" queue_url=" + request.getRequestURL().toString()) : "") +
            		" CassandraTimeMS=" + valueAccumulator.getCounter(AccumulatorName.CassandraTime) + 
                    " CassandraReadNum=" + valueAccumulator.getCounter(AccumulatorName.CassandraRead) + 
                    " CassandraWriteNum=" + valueAccumulator.getCounter(AccumulatorName.CassandraWrite) +
                    ((this instanceof CNSControllerServlet) ? (" CNSCQSTimeMS=" + CMBControllerServlet.valueAccumulator.getCounter(AccumulatorName.CNSCQSTime)) : "") +
                    ((this instanceof CQSControllerServlet) ? (" RedisTimeMS=" + valueAccumulator.getCounter(AccumulatorName.RedisTime)) : "") +
                    (user != null ? " user_name=" + user.getUserName() : ""), ex
            ); 
            int httpCode = CMBErrorCodes.InternalError.getHttpCode();
            String code = CMBErrorCodes.InternalError.getCMBCode();
            String message = "There is an internal problem with CMB";
            if (ex instanceof CMBException) {
                httpCode = ((CMBException) ex).getHttpCode();
                code = ((CMBException) ex).getCMBCode();
                message = ex.getMessage();
            }
            String errXml = createErrorResponse(code, message);
            response.setStatus(httpCode);
            response.getWriter().println(errXml);
        } finally {
            valueAccumulator.deleteAllCounters();
        }
    }

    private void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {  
        User user = null;
        String action = request.getParameter("Action");
        long ts1 = System.currentTimeMillis();
        try {
            valueAccumulator.initializeAllCounters();
        	requestInit();
            response.setContentType("text/xml");
            if (!isValidAction(action)) {
                throw new CMBException(CMBErrorCodes.InvalidAction, action + " is not a valid action");
            }
            if (isAuthenticationRequired(action)) {
                user = authModule.authenticateByRequest(request);
            } else {
                user = null;
            }
            long ts3 = System.currentTimeMillis();
            valueAccumulator.addToCounter(AccumulatorName.CMBControllerPreHandleAction, (ts3 - ts1));
            boolean actionPerformed = handleAction(action, user, request, response);
            response.setStatus(200);
            long ts2 = System.currentTimeMillis();
            if (action != null && action.equals("ReceiveMessage") && !actionPerformed && user != null && user.getUserName().equals(CMBProperties.getInstance().getCnsUserName())) {
            } else if (action != null && action.equals("GetQueueUrl") && user != null && user.getUserName().equals(CMBProperties.getInstance().getCnsUserName())) {
            } else {
	            logger.info(
	            		"event=handleRequest status=success client_ip=" + request.getRemoteAddr() + " action=" + action + " responseTimeMS=" + (ts2-ts1) + 
	                    (request.getParameter("TopicArn") != null ? " topic_arn=" + request.getParameter("TopicArn") : "") +
	                    (request.getParameter("SubscriptionArn") != null ? " subscription_arn=" + request.getParameter("SubscriptionArn") : "") +
	                    (request.getParameter("Label") != null ? " label=" + request.getParameter("Label") : "") +
	                    (request.getParameter("NextToken") != null ? " next_token=" + request.getParameter("NextToken") : "") +
	                    (request.getParameter("Name") != null ? " name=" + request.getParameter("Name") : "") +
	                    (request.getParameter("Token") != null ? " token=" + request.getParameter("Token") : "") +
	                    (request.getParameter("Endpoint") != null ? " endpoint=" + request.getParameter("Endpoint") : "") +
	                    (request.getParameter("Protocol") != null ? " protocol=" + request.getParameter("Protocol") : "") +
	                    (request.getParameter("ReceiptHandle") != null ? " receipt_handle=" + request.getParameter("ReceiptHandle") : "") +
	                    (request.getParameter("VisibilityTimeout") != null ? " visibility_timeout=" + request.getParameter("VisibilityTimeout") : "") +
	                    (request.getParameter("QueueName") != null ? " queue_name=" + request.getParameter("QueueName") : "") +
	                    (request.getParameter("QueueNamePrefix") != null ? " queue_name_prefix=" + request.getParameter("QueueNamePrefix") : "") +
	                    (request.getParameter("DelaySeconds") != null ? " delay_seconds=" + request.getParameter("DelaySeconds") : "") +
	                    ((this instanceof CQSControllerServlet) ? (" queue_url=" + request.getRequestURL()) : "") +
	            		" CassandraTimeMS=" + valueAccumulator.getCounter(AccumulatorName.CassandraTime) + 
	                    " CassandraReadNum=" + valueAccumulator.getCounter(AccumulatorName.CassandraRead) + 
	                    " CassandraWriteNum=" + valueAccumulator.getCounter(AccumulatorName.CassandraWrite) +
	                    ((this instanceof CNSControllerServlet) ? (" CNSCQSTimeMS=" + CMBControllerServlet.valueAccumulator.getCounter(AccumulatorName.CNSCQSTime)) : "") +
	                    ((this instanceof CQSControllerServlet) ? (" RedisTimeMS=" + valueAccumulator.getCounter(AccumulatorName.RedisTime)) : "") +
	                    (user != null ? " user_name=" + user.getUserName() : "")
	            ); 
            }
        } catch (Exception ex) {
        	long ts2 = System.currentTimeMillis();
            logger.error(
            		"event=handleRequest status=failed client_ip=" + request.getRemoteAddr() + " action=" + action + " responseTimeMS=" + (ts2-ts1) + 
                    (request.getParameter("TopicArn") != null ? " topic_arn=" + request.getParameter("TopicArn") : "") +
                    (request.getParameter("SubscriptionArn") != null ? " subscription_arn=" + request.getParameter("SubscriptionArn") : "") +
                    (request.getParameter("Label") != null ? " label=" + request.getParameter("Label") : "") +
                    (request.getParameter("NextToken") != null ? " next_token=" + request.getParameter("NextToken") : "") +
                    (request.getParameter("Name") != null ? " name=" + request.getParameter("Name") : "") +
                    (request.getParameter("Token") != null ? " token=" + request.getParameter("Token") : "") +
                    (request.getParameter("Endpoint") != null ? " endpoint=" + request.getParameter("Endpoint") : "") +
                    (request.getParameter("Protocol") != null ? " protocol=" + request.getParameter("Protocol") : "") +
                    (request.getParameter("ReceiptHandle") != null ? " receipt_handle=" + request.getParameter("ReceiptHandle") : "") +
                    (request.getParameter("VisibilityTimeout") != null ? " visibility_timeout=" + request.getParameter("VisibilityTimeout") : "") +
                    (request.getParameter("QueueName") != null ? " queue_name=" + request.getParameter("QueueName") : "") +
                    (request.getParameter("QueueNamePrefix") != null ? " queue_name_prefix=" + request.getParameter("QueueNamePrefix") : "") +
                    (request.getParameter("DelaySeconds") != null ? " delay_seconds=" + request.getParameter("DelaySeconds") : "") +
                    ((this instanceof CQSControllerServlet) ? (" queue_url=" + request.getRequestURL()) : "") +
            		" CassandraTimeMS=" + valueAccumulator.getCounter(AccumulatorName.CassandraTime) + 
                    " CassandraReadNum=" + valueAccumulator.getCounter(AccumulatorName.CassandraRead) + 
                    " CassandraWriteNum=" + valueAccumulator.getCounter(AccumulatorName.CassandraWrite) +
                    ((this instanceof CNSControllerServlet) ? (" CNSCQSTimeMS=" + CMBControllerServlet.valueAccumulator.getCounter(AccumulatorName.CNSCQSTime)) : "") +
                    ((this instanceof CQSControllerServlet) ? (" RedisTimeMS=" + valueAccumulator.getCounter(AccumulatorName.RedisTime)) : "") +
                    (user != null ? " user_name=" + user.getUserName() : ""), ex
            ); 
            int httpCode = CMBErrorCodes.InternalError.getHttpCode();
            String code = CMBErrorCodes.InternalError.getCMBCode();
            String message = "There is an internal problem with CMB";
            if (ex instanceof CMBException) {
                httpCode = ((CMBException) ex).getHttpCode();
                code = ((CMBException) ex).getCMBCode();
                message = ex.getMessage();
            }
            String errXml = createErrorResponse(code, message);
            response.setStatus(httpCode);
            response.getWriter().println(errXml);
        } finally {
            valueAccumulator.deleteAllCounters();
        }
    }
