@Override
    public void handle(
        final HttpRequest request,
        final HttpResponse response,
        final HttpContext context) throws HttpException, IOException {
        
        //System.out.println("request received");
        String method = request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH);
        if (!method.equals("GET") && !method.equals("HEAD") && !method.equals("POST")) {
                throw new MethodNotSupportedException(method + " method not supported");
        }

        if (request instanceof HttpEntityEnclosingRequest) {
            HttpEntity httpEntity = ((HttpEntityEnclosingRequest) request).getEntity();
            String entity = EntityUtils.toString(httpEntity);

            // Parse HTTP request
            String parseResult = parseLateBindingRequest(entity, jobMap);
            StringEntity stringEntity = new StringEntity("");
            // if new job received from a client, start executing late binding policy
            if (parseResult.contains("new-job")) {
                response.setStatusCode(HttpStatus.SC_OK);
                String pieces[] = parseResult.split(":");
                taskCommExecutor.execute(new LateBindingProbeThread(Integer.parseInt(pieces[1]), 
                                                                                                             Integer.parseInt(pieces[2])));
                response.setEntity(new StringEntity("result:success"));
            }
            // else if probe response from worker, handle it accordingly
            else if (parseResult.contains("probe-response")) {
                //StatsLog.writeToLog("received probe-response");
                response.setStatusCode(HttpStatus.SC_OK);
                String[] pieces = parseResult.split(":");
                int jobID = Integer.parseInt(pieces[1]);
              
                Task task = jobMap.getTask(jobID);
                // send NOOP if task queue empty for specified job
                if (task == null) {
                    response.setStatusCode(HttpStatus.SC_OK);
                    try {
                        stringEntity = new StringEntity("NOOP");
                    } catch (UnsupportedEncodingException ex) {
                        Logger.getLogger(LateBindingTaskSubmitThread.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    System.out.println("Responding with NOOP");
                }
                // else send job id, task id and task commmand to worker
                else {
                    try {
                        stringEntity = new StringEntity(String.valueOf(task.getDuration())) ;
                    } catch (UnsupportedEncodingException ex) {
                        Logger.getLogger(LateBindingTaskSubmitThread.class.getName()).log(Level.SEVERE, null, ex);
                    }
                     //System.out.println("Responding with task duration: " + task.getDuration());
                }
                response.setEntity(stringEntity);    
            }
        }
    }