class PollService extends ExternalTaskUtils {

    public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
        mdcSetup.setupMDC(externalTask);
        logger.trace("Executing External Task Poll Service");
        Map<String, Object> variables = new HashMap<>();
        MutableBoolean success = new MutableBoolean();
        String errorMessage = null;
        try {
            String xmlRequest = externalTask.getVariable("openstackAdapterTaskRequest");
            if (xmlRequest != null) {
                Optional<String> requestType = findRequestType(xmlRequest);
                if ("createVolumeGroupRequest".equals(requestType.get())) {
                    determineCreateVolumeGroupStatus(xmlRequest, externalTask, success);
                } else if ("createVfModuleRequest".equals(requestType.get())) {
                    determineCreateVfModuleStatus(xmlRequest, externalTask, success);
                } else if ("deleteVfModuleRequest".equals(requestType.get())) {
                    logger.debug("Executing External Task Poll Service for Delete Vf Module");
                    DeleteVfModuleRequest req =
                            JAXB.unmarshal(new StringReader(xmlRequest), DeleteVfModuleRequest.class);
                    pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
                } else if ("deleteVolumeGroupRequest".equals(requestType.get())) {
                    logger.debug("Executing External Task Poll Service for Delete Volume Group");
                    DeleteVolumeGroupRequest req =
                            JAXB.unmarshal(new StringReader(xmlRequest), DeleteVolumeGroupRequest.class);
                    pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
                } else if ("createNetworkRequest".equals(requestType.get())) {
                    determineCreateNetworkStatus(xmlRequest, externalTask, success);
                } else if ("deleteNetworkRequest".equals(requestType.get())) {
                    logger.debug("Executing External Task Poll Service for Delete Network");
                    DeleteNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), DeleteNetworkRequest.class);
                    pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
                } else if ("updateNetworkRequest".equals(requestType.get())) {
                    UpdateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), UpdateNetworkRequest.class);
                    pollUpdateResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
                }
            }
        } catch (Exception e) {
            logger.error("Error during External Task Poll Service", e);
            errorMessage = e.getMessage();
        }

        variables.put("OpenstackPollSuccess", success.booleanValue());
        variables.put("openstackAdapterErrorMessage", errorMessage);
        if (success.isTrue()) {
            externalTaskService.complete(externalTask, variables);
            logger.debug("The External Task Id: {}  Successful", externalTask.getId());
        } else {
            if (externalTask.getRetries() == null) {
                logger.debug("The External Task Id: {}  Failed, Setting Retries to Default Start Value: {}",
                        externalTask.getId(), getRetrySequence().length);
                externalTaskService.handleFailure(externalTask, "errorMessage", "errorDetails",
                        getRetrySequence().length, 10000);
            } else if (externalTask.getRetries() != null && externalTask.getRetries() - 1 == 0) {
                logger.debug("The External Task Id: {}  Failed, All Retries Exhausted", externalTask.getId());
                externalTaskService.complete(externalTask, variables);
            } else {
                logger.debug("The External Task Id: {}  Failed, Decrementing Retries: {} , Retry Delay: {}",
                        externalTask.getId(), externalTask.getRetries() - 1,
                        calculateRetryDelay(externalTask.getRetries()));
                externalTaskService.handleFailure(externalTask, "errorMessage", "errorDetails",
                        externalTask.getRetries() - 1, calculateRetryDelay(externalTask.getRetries()));
            }
        }
    }

    public  PollService();

}