private final void processMainRequest() {

        sender = getSender();
        startTimeMillis = System.currentTimeMillis();
        timeoutDuration = Duration.create(
                request.getActorMaxOperationTimeoutSec(), TimeUnit.SECONDS);

        actorMaxOperationTimeoutSec = request.getActorMaxOperationTimeoutSec();

        if (request.getProtocol() == RequestProtocol.HTTP 
                || request.getProtocol() == RequestProtocol.HTTPS) {
            String urlComplete = String.format("%s://%s:%d%s", request
                    .getProtocol().toString(), trueTargetNode, request
                    .getPort(), request.getResourcePath());

            // http://stackoverflow.com/questions/1600291/validating-url-in-java
            if (!PcHttpUtils.isUrlValid(urlComplete.trim())) {
                String errMsg = "INVALID_URL";
                logger.error("INVALID_URL: " + urlComplete + " return..");
                replyErrors(errMsg, errMsg, PcConstants.NA, PcConstants.NA_INT);
                return;
            } else {
                logger.debug("url pass validation: " + urlComplete);
            }

            asyncWorker = getContext().actorOf(
                    Props.create(HttpWorker.class, actorMaxOperationTimeoutSec,
                            client, urlComplete, request.getHttpMethod(),
                            request.getPostData(), request.getHttpHeaderMap(), request.getResponseHeaderMeta()));

        } else if (request.getProtocol() == RequestProtocol.SSH ){
            asyncWorker = getContext().actorOf(
                    Props.create(SshWorker.class, actorMaxOperationTimeoutSec,
                            request.getSshMeta(), trueTargetNode));
        } else if (request.getProtocol() == RequestProtocol.TCP ){
            asyncWorker = getContext().actorOf(
                    Props.create(TcpWorker.class, actorMaxOperationTimeoutSec,
                            request.getTcpMeta(), trueTargetNode));            
        } else if (request.getProtocol() == RequestProtocol.UDP ){
            asyncWorker = getContext().actorOf(
                    Props.create(UdpWorker.class, actorMaxOperationTimeoutSec,
                            request.getUdpMeta(), trueTargetNode));                        
        } else if (request.getProtocol() == RequestProtocol.PING ){
            asyncWorker = getContext().actorOf(
                    Props.create(PingWorker.class, actorMaxOperationTimeoutSec, request.getPingMeta(),
                             trueTargetNode));
        }

        asyncWorker.tell(RequestWorkerMsgType.PROCESS_REQUEST, getSelf());

        cancelExistingIfAnyAndScheduleTimeoutCall();

    }
private final void processMainRequest ( ) { sender = getSender ( ) ; startTimeMillis = System . currentTimeMillis ( ) ; timeoutDuration = Duration . create ( request . getActorMaxOperationTimeoutSec ( ) , TimeUnit . SECONDS ) ; actorMaxOperationTimeoutSec = request . getActorMaxOperationTimeoutSec ( ) ; if ( request . getProtocol ( ) == RequestProtocol . HTTP || request . getProtocol ( ) == RequestProtocol . HTTPS ) { String urlComplete = String . format ( "%s://%s:%d%s" , request . getProtocol ( ) . toString ( ) , trueTargetNode , request . getPort ( ) , request . getResourcePath ( ) ) ; if ( ! PcHttpUtils . isUrlValid ( urlComplete . trim ( ) ) ) { String errMsg = "INVALID_URL" ; logger . error ( "INVALID_URL: " + urlComplete + " return.." ) ; replyErrors ( errMsg , errMsg , PcConstants . NA , PcConstants . NA_INT ) ; return ; } else { logger . debug ( "url pass validation: " + urlComplete ) ; } asyncWorker = getContext ( ) . actorOf ( Props . create ( HttpWorker . class , actorMaxOperationTimeoutSec , client , urlComplete , request . getHttpMethod ( ) , request . getPostData ( ) , request . getHttpHeaderMap ( ) , request . getResponseHeaderMeta ( ) ) ) ; } else if ( request . getProtocol ( ) == RequestProtocol . SSH ) { asyncWorker = getContext ( ) . actorOf ( Props . create ( SshWorker . class , actorMaxOperationTimeoutSec , request . getSshMeta ( ) , trueTargetNode ) ) ; } else if ( request . getProtocol ( ) == RequestProtocol . TCP ) { asyncWorker = getContext ( ) . actorOf ( Props . create ( TcpWorker . class , actorMaxOperationTimeoutSec , request . getTcpMeta ( ) , trueTargetNode ) ) ; } else if ( request . getProtocol ( ) == RequestProtocol . UDP ) { asyncWorker = getContext ( ) . actorOf ( Props . create ( UdpWorker . class , actorMaxOperationTimeoutSec , request . getUdpMeta ( ) , trueTargetNode ) ) ; } else if ( request . getProtocol ( ) == RequestProtocol . PING ) { asyncWorker = getContext ( ) . actorOf ( Props . create ( PingWorker . class , actorMaxOperationTimeoutSec , request . getPingMeta ( ) , trueTargetNode ) ) ; } asyncWorker . tell ( RequestWorkerMsgType . PROCESS_REQUEST , getSelf ( ) ) ; cancelExistingIfAnyAndScheduleTimeoutCall ( ) ; }
the 1st request from the manager.