Example usage for java.util.concurrent Future cancel

List of usage examples for java.util.concurrent Future cancel

Introduction

In this page you can find the example usage for java.util.concurrent Future cancel.

Prototype

boolean cancel(boolean mayInterruptIfRunning);

Source Link

Document

Attempts to cancel execution of this task.

Usage

From source file:lineage2.gameserver.model.Creature.java

/**
 * Method stopAttackStanceTask.//  www. j a va2s  . c  o  m
 */
public void stopAttackStanceTask() {
    _stanceEndTime = 0L;
    final Future<?> task = _stanceTask;
    if (task != null) {
        task.cancel(false);
        _stanceTask = null;
        broadcastPacket(new AutoAttackStop(getObjectId()));
    }
}

From source file:lineage2.gameserver.model.Creature.java

/**
 * Method startAttackStanceTask0./* w w w  .j  a v  a 2s .co m*/
 */
protected void startAttackStanceTask0() {
    if (isInCombat()) {
        _stanceEndTime = System.currentTimeMillis() + 15000L;
        return;
    }
    _stanceEndTime = System.currentTimeMillis() + 15000L;
    broadcastPacket(new AutoAttackStart(getObjectId()));
    final Future<?> task = _stanceTask;
    if (task != null) {
        task.cancel(false);
    }
    _stanceTask = LazyPrecisionTaskManager.getInstance().scheduleAtFixedRate(
            _stanceTaskRunnable == null ? _stanceTaskRunnable = new AttackStanceTask() : _stanceTaskRunnable,
            1000L, 1000L);
}

From source file:lineage2.gameserver.model.Creature.java

/**
 * Method abortCast./*from w  w w . j  a v a  2 s . co m*/
 * @param force boolean
 * @param message boolean
 */
public final void abortCast(boolean force, boolean message) {
    if (isCastingNow() && (force || canAbortCast())) {
        final Skill castingSkill = _castingSkill;
        final Future<?> skillTask = _skillTask;
        final Future<?> skillLaunchedTask = _skillLaunchedTask;
        final Future<?> skillDoubleTask = _skillDoubleTask;
        final Future<?> skillDoubleLaunchedTask = _skillDoubleLaunchedTask;
        finishFly();
        clearCastVars();
        if (skillTask != null) {
            skillTask.cancel(false);
        }
        if (skillLaunchedTask != null) {
            skillLaunchedTask.cancel(false);
        }
        if (skillDoubleTask != null) {
            skillDoubleTask.cancel(false);
        }
        if (skillDoubleLaunchedTask != null) {
            skillDoubleLaunchedTask.cancel(false);
        }
        if (castingSkill != null) {
            if (castingSkill.isUsingWhileCasting()) {
                Creature target = getAI().getAttackTarget();
                if (target != null) {
                    target.getEffectList().stopEffect(castingSkill.getId());
                }
            }
            removeSkillMastery(castingSkill.getId());
        }
        broadcastPacket(new MagicSkillCanceled(getObjectId()));
        getAI().setIntention(AI_INTENTION_ACTIVE);
        if (isPlayer() && message) {
            sendPacket(Msg.CASTING_HAS_BEEN_INTERRUPTED);
        }
    }
}

From source file:com.cloud.hypervisor.vmware.mo.VirtualMachineMO.java

public boolean unmountToolsInstaller() throws Exception {
    // Monitor VM questions
    final Boolean[] flags = { false };
    final VirtualMachineMO vmMo = this;
    final boolean[] encounterQuestion = new boolean[1];
    encounterQuestion[0] = false;/*from  w  w  w .  j  a v a 2 s  .  co m*/
    Future<?> future = MonitorServiceExecutor.submit(new Runnable() {
        @Override
        public void run() {
            s_logger.info("VM Question monitor started...");

            while (!flags[0]) {
                try {
                    VirtualMachineRuntimeInfo runtimeInfo = vmMo.getRuntimeInfo();
                    VirtualMachineQuestionInfo question = runtimeInfo.getQuestion();
                    if (question != null) {
                        encounterQuestion[0] = true;
                        if (s_logger.isTraceEnabled()) {
                            s_logger.trace("Question id: " + question.getId());
                            s_logger.trace("Question text: " + question.getText());
                        }

                        if (question.getMessage() != null) {
                            for (VirtualMachineMessage msg : question.getMessage()) {
                                if (s_logger.isTraceEnabled()) {
                                    s_logger.trace("msg id: " + msg.getId());
                                    s_logger.trace("msg text: " + msg.getText());
                                }
                                if ("msg.cdromdisconnect.locked".equalsIgnoreCase(msg.getId())) {
                                    s_logger.info(
                                            "Found that VM has a pending question that we need to answer programmatically, question id: "
                                                    + msg.getId()
                                                    + ", for safe operation we will automatically decline it");
                                    vmMo.answerVM(question.getId(), "1");
                                    break;
                                }
                            }
                        } else if (question.getText() != null) {
                            String text = question.getText();
                            String msgId;
                            String msgText;
                            if (s_logger.isDebugEnabled()) {
                                s_logger.debug("question text : " + text);
                            }
                            String[] tokens = text.split(":");
                            msgId = tokens[0];
                            msgText = tokens[1];
                            if ("msg.cdromdisconnect.locked".equalsIgnoreCase(msgId)) {
                                s_logger.info(
                                        "Found that VM has a pending question that we need to answer programmatically, question id: "
                                                + question.getId() + ". Message id : " + msgId
                                                + ". Message text : " + msgText
                                                + ", for safe operation we will automatically decline it.");
                                vmMo.answerVM(question.getId(), "1");
                            }
                        }

                        ChoiceOption choice = question.getChoice();
                        if (choice != null) {
                            for (ElementDescription info : choice.getChoiceInfo()) {
                                if (s_logger.isTraceEnabled()) {
                                    s_logger.trace("Choice option key: " + info.getKey());
                                    s_logger.trace("Choice option label: " + info.getLabel());
                                }
                            }
                        }
                    }
                } catch (Throwable e) {
                    s_logger.error("Unexpected exception: ", e);
                }

                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                }
            }

            s_logger.info("VM Question monitor stopped");
        }
    });

    try {
        _context.getService().unmountToolsInstaller(_mor);
    } finally {
        flags[0] = true;
        future.cancel(true);
    }
    if (encounterQuestion[0]) {
        s_logger.warn("cdrom is locked by VM. Failed to detach the ISO.");
        return false;
    } else {
        s_logger.info("Successfully unmounted tools installer from VM.");
        return true;
    }
}

From source file:com.cloud.hypervisor.vmware.mo.VirtualMachineMO.java

public void detachIso(String isoDatastorePath) throws Exception {
    if (s_logger.isTraceEnabled())
        s_logger.trace("vCenter API trace - detachIso(). target MOR: " + _mor.getValue()
                + ", isoDatastorePath: " + isoDatastorePath);

    VirtualDevice device = getIsoDevice();
    if (device == null) {
        if (s_logger.isTraceEnabled())
            s_logger.trace("vCenter API trace - detachIso() done(failed)");
        throw new Exception("Unable to find a CDROM device");
    }/*  www.  j a  v a 2  s  . c  o  m*/

    VirtualCdromRemotePassthroughBackingInfo backingInfo = new VirtualCdromRemotePassthroughBackingInfo();
    backingInfo.setDeviceName("");
    device.setBacking(backingInfo);

    VirtualMachineConfigSpec reConfigSpec = new VirtualMachineConfigSpec();
    //VirtualDeviceConfigSpec[] deviceConfigSpecArray = new VirtualDeviceConfigSpec[1];
    VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec();

    deviceConfigSpec.setDevice(device);
    deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.EDIT);

    //deviceConfigSpecArray[0] = deviceConfigSpec;
    reConfigSpec.getDeviceChange().add(deviceConfigSpec);

    ManagedObjectReference morTask = _context.getService().reconfigVMTask(_mor, reConfigSpec);

    // Monitor VM questions
    final Boolean[] flags = { false };
    final VirtualMachineMO vmMo = this;
    Future<?> future = MonitorServiceExecutor.submit(new Runnable() {
        @Override
        public void run() {
            s_logger.info("VM Question monitor started...");

            while (!flags[0]) {
                try {
                    VirtualMachineRuntimeInfo runtimeInfo = vmMo.getRuntimeInfo();
                    VirtualMachineQuestionInfo question = runtimeInfo.getQuestion();
                    if (question != null) {
                        if (s_logger.isTraceEnabled()) {
                            s_logger.trace("Question id: " + question.getId());
                            s_logger.trace("Question text: " + question.getText());
                        }
                        if (question.getMessage() != null) {
                            for (VirtualMachineMessage msg : question.getMessage()) {
                                if (s_logger.isTraceEnabled()) {
                                    s_logger.trace("msg id: " + msg.getId());
                                    s_logger.trace("msg text: " + msg.getText());
                                }
                                if ("msg.cdromdisconnect.locked".equalsIgnoreCase(msg.getId())) {
                                    s_logger.info(
                                            "Found that VM has a pending question that we need to answer programmatically, question id: "
                                                    + msg.getId()
                                                    + ", for safe operation we will automatically decline it");
                                    vmMo.answerVM(question.getId(), "1");
                                    break;
                                }
                            }
                        } else if (question.getText() != null) {
                            String text = question.getText();
                            String msgId;
                            String msgText;
                            if (s_logger.isDebugEnabled()) {
                                s_logger.debug("question text : " + text);
                            }
                            String[] tokens = text.split(":");
                            msgId = tokens[0];
                            msgText = tokens[1];
                            if ("msg.cdromdisconnect.locked".equalsIgnoreCase(msgId)) {
                                s_logger.info(
                                        "Found that VM has a pending question that we need to answer programmatically, question id: "
                                                + question.getId() + ". Message id : " + msgId
                                                + ". Message text : " + msgText
                                                + ", for safe operation we will automatically decline it.");
                                vmMo.answerVM(question.getId(), "1");
                            }
                        }

                        ChoiceOption choice = question.getChoice();
                        if (choice != null) {
                            for (ElementDescription info : choice.getChoiceInfo()) {
                                if (s_logger.isTraceEnabled()) {
                                    s_logger.trace("Choice option key: " + info.getKey());
                                    s_logger.trace("Choice option label: " + info.getLabel());
                                }
                            }
                        }
                    }
                } catch (Throwable e) {
                    s_logger.error("Unexpected exception: ", e);
                }
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                }
            }
            s_logger.info("VM Question monitor stopped");
        }
    });
    try {
        boolean result = _context.getVimClient().waitForTask(morTask);
        if (!result) {
            if (s_logger.isDebugEnabled())
                s_logger.trace("vCenter API trace - detachIso() done(failed)");
            throw new Exception("Failed to detachIso due to " + TaskMO.getTaskFailureInfo(_context, morTask));
        }
        _context.waitForTaskProgressDone(morTask);
        s_logger.trace("vCenter API trace - detachIso() done(successfully)");
    } finally {
        flags[0] = true;
        future.cancel(true);
    }
}

From source file:com.eucalyptus.blockstorage.S3SnapshotTransfer.java

/**
 * Compresses the snapshot and uploads it to a bucket in objectstorage gateway as a single or multipart upload based on the configuration in
 * {@link StorageInfo}. Bucket name should be configured before invoking this method. It can be looked up and initialized by {@link #prepareForUpload()} or
 * explicitly set using {@link #setBucketName(String)}
 * //from   ww  w. j  a v  a  2s .  c  o  m
 * @param sourceFileName
 *            absolute path to the snapshot on the file system
 */
@Override
public void upload(String sourceFileName) throws SnapshotTransferException {
    validateInput(); // Validate input
    loadTransferConfig(); // Load the transfer configuration parameters from database
    SnapshotProgressCallback progressCallback = new SnapshotProgressCallback(snapshotId); // Setup the progress callback

    Boolean error = Boolean.FALSE;
    ArrayBlockingQueue<SnapshotPart> partQueue = null;
    SnapshotPart part = null;
    SnapshotUploadInfo snapUploadInfo = null;
    Future<List<PartETag>> uploadPartsFuture = null;
    Future<String> completeUploadFuture = null;

    byte[] buffer = new byte[READ_BUFFER_SIZE];
    Long readOffset = 0L;
    Long bytesRead = 0L;
    Long bytesWritten = 0L;
    int len;
    int partNumber = 1;

    try {
        // Get the uncompressed file size for uploading as metadata
        Long uncompressedSize = getFileSize(sourceFileName);

        // Setup the snapshot and part entities.
        snapUploadInfo = SnapshotUploadInfo.create(snapshotId, bucketName, keyName);
        Path zipFilePath = Files.createTempFile(keyName + '-', '-' + String.valueOf(partNumber));
        part = SnapshotPart.createPart(snapUploadInfo, zipFilePath.toString(), partNumber, readOffset);

        FileInputStream inputStream = new FileInputStream(sourceFileName);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        GZIPOutputStream gzipStream = new GZIPOutputStream(baos);
        FileOutputStream outputStream = new FileOutputStream(zipFilePath.toString());

        try {
            LOG.debug("Reading snapshot " + snapshotId + " and compressing it to disk in chunks of size "
                    + partSize + " bytes or greater");
            while ((len = inputStream.read(buffer)) > 0) {
                bytesRead += len;
                gzipStream.write(buffer, 0, len);

                if ((bytesWritten + baos.size()) < partSize) {
                    baos.writeTo(outputStream);
                    bytesWritten += baos.size();
                    baos.reset();
                } else {
                    gzipStream.close();
                    baos.writeTo(outputStream); // Order is important. Closing the gzip stream flushes stuff
                    bytesWritten += baos.size();
                    baos.reset();
                    outputStream.close();

                    if (partNumber > 1) {// Update the part status
                        part = part.updateStateCreated(bytesWritten, bytesRead, Boolean.FALSE);
                    } else {// Initialize multipart upload only once after the first part is created
                        LOG.info("Uploading snapshot " + snapshotId
                                + " to objectstorage using multipart upload");
                        progressCallback.setUploadSize(uncompressedSize);
                        uploadId = initiateMulitpartUpload(uncompressedSize);
                        snapUploadInfo = snapUploadInfo.updateUploadId(uploadId);
                        part = part.updateStateCreated(uploadId, bytesWritten, bytesRead, Boolean.FALSE);
                        partQueue = new ArrayBlockingQueue<SnapshotPart>(queueSize);
                        uploadPartsFuture = Threads.enqueue(serviceConfig, UploadPartTask.class, poolSize,
                                new UploadPartTask(partQueue, progressCallback));
                    }

                    // Check for the future task before adding part to the queue.
                    if (uploadPartsFuture != null && uploadPartsFuture.isDone()) {
                        // This task shouldn't be done until the last part is added. If it is done at this point, then something might have gone wrong
                        throw new SnapshotUploadPartException(
                                "Error uploading parts, aborting part creation process. Check previous log messages for the exact error");
                    }

                    // Add part to the queue
                    partQueue.put(part);

                    // Prep the metadata for the next part
                    readOffset += bytesRead;
                    bytesRead = 0L;
                    bytesWritten = 0L;

                    // Setup the part entity for next part
                    zipFilePath = Files.createTempFile(keyName + '-', '-' + String.valueOf((++partNumber)));
                    part = SnapshotPart.createPart(snapUploadInfo, zipFilePath.toString(), partNumber,
                            readOffset);

                    gzipStream = new GZIPOutputStream(baos);
                    outputStream = new FileOutputStream(zipFilePath.toString());
                }
            }

            gzipStream.close();
            baos.writeTo(outputStream);
            bytesWritten += baos.size();
            baos.reset();
            outputStream.close();
            inputStream.close();

            // Update the part status
            part = part.updateStateCreated(bytesWritten, bytesRead, Boolean.TRUE);

            // Update the snapshot upload info status
            snapUploadInfo = snapUploadInfo.updateStateCreatedParts(partNumber);
        } catch (Exception e) {
            LOG.error("Failed to upload " + snapshotId + " due to: ", e);
            error = Boolean.TRUE;
            throw new SnapshotTransferException("Failed to upload " + snapshotId + " due to: ", e);
        } finally {
            if (inputStream != null) {
                inputStream.close();
            }
            if (gzipStream != null) {
                gzipStream.close();
            }
            if (outputStream != null) {
                outputStream.close();
            }
            baos.reset();
        }

        if (partNumber > 1) {
            // Check for the future task before adding the last part to the queue.
            if (uploadPartsFuture != null && uploadPartsFuture.isDone()) {
                // This task shouldn't be done until the last part is added. If it is done at this point, then something might have gone wrong
                throw new SnapshotUploadPartException(
                        "Error uploading parts, aborting part upload process. Check previous log messages for the exact error");
            }
            // Add the last part to the queue
            partQueue.put(part);
            // Kick off the completion task
            completeUploadFuture = Threads.enqueue(serviceConfig, CompleteMpuTask.class, poolSize,
                    new CompleteMpuTask(uploadPartsFuture, snapUploadInfo, partNumber));
        } else {
            try {
                LOG.info("Uploading snapshot " + snapshotId
                        + " to objectstorage as a single object. Compressed size of snapshot (" + bytesWritten
                        + " bytes) is less than minimum part size (" + partSize
                        + " bytes) for multipart upload");
                PutObjectResult putResult = uploadSnapshotAsSingleObject(zipFilePath.toString(), bytesWritten,
                        uncompressedSize, progressCallback);
                markSnapshotAvailable();
                try {
                    part = part.updateStateUploaded(putResult.getETag());
                    snapUploadInfo = snapUploadInfo.updateStateUploaded(putResult.getETag());
                } catch (Exception e) {
                    LOG.debug("Failed to update status in DB for " + snapUploadInfo);
                }
                LOG.info("Uploaded snapshot " + snapshotId + " to objectstorage");
            } catch (Exception e) {
                error = Boolean.TRUE;
                LOG.error("Failed to upload snapshot " + snapshotId + " due to: ", e);
                throw new SnapshotTransferException("Failed to upload snapshot " + snapshotId + " due to: ", e);
            } finally {
                deleteFile(zipFilePath);
            }
        }
    } catch (SnapshotTransferException e) {
        error = Boolean.TRUE;
        throw e;
    } catch (Exception e) {
        error = Boolean.TRUE;
        LOG.error("Failed to upload snapshot " + snapshotId + " due to: ", e);
        throw new SnapshotTransferException("Failed to upload snapshot " + snapshotId + " due to: ", e);
    } finally {
        if (error) {
            abortUpload(snapUploadInfo);
            if (uploadPartsFuture != null && !uploadPartsFuture.isDone()) {
                uploadPartsFuture.cancel(true);
            }
            if (completeUploadFuture != null && !completeUploadFuture.isDone()) {
                completeUploadFuture.cancel(true);
            }
        }
    }
}

From source file:de.fiz.ddb.aas.auxiliaryoperations.ThreadOrganisationSetApprove.java

@PreAuthorize(privileges = { PrivilegeEnum.ADMIN }, scope = Scope.ORGANIZATION, cacheUpdate = true)
public Organisation call() throws AASUnauthorizedException, ExecutionException, IllegalAccessException {
    if (ConstEnumOrgStatus.approved.equals(this._organisation.getStatus())) {
        throw new ExecutionException("Die Institution ist bereits in der Status 'approved'.", null);
    }//  w w w  .  ja va 2s. c o  m
    Future<Organisation> submitOrgOnWorkDir = null;
    Future<Organisation> submitOrgOnLicencedDir = null;

    Future<Organisation> submitOrgParentOnLicencedDir = null;
    Future<Organisation> submitOrgParentOnWorkDir = null;

    Organisation vOrgParentOnLicenceDir = null;
    Organisation vOrgParentOnWorkDir = null;

    try {
        // -- set a new status:
        this._organisation.setStatus(ConstEnumOrgStatus.approved);
        // -- save status:
        ThreadOrganisationUpdate threadOrganisationUpdate = new ThreadOrganisationUpdate(_ready, _organisation,
                false, _performer);
        threadOrganisationUpdate.setChangeOfStatus(true);
        submitOrgOnWorkDir = LDAPConnector.getSingletonInstance().getExecutorServiceOne()
                .submit(threadOrganisationUpdate);

        // -- Ist diese Organisation unter Licensed schon vorhanden?
        // -- Read organization on the license directory:
        ThreadOrganisationRead threadOrgOnLicencedDirRead = new ThreadOrganisationRead(
                new OIDs(this._organisation.getOIDs().getOrgName(), false), this.getPerformer());
        // -- the request goes to the branch with licensed organizations:
        threadOrgOnLicencedDirRead.setLicensedOrgs(true);
        submitOrgOnLicencedDir = LDAPConnector.getSingletonInstance().getExecutorServiceOne()
                .submit(threadOrgOnLicencedDirRead);

        // -- Operations in the licensed area...
        Boolean vIsOrgParentLicense = null;
        if (this._organisation.getOrgParent() != null) {

            // -- Parent on the license directory:
            ThreadOrganisationRead threadOrgParentOnLicencedDirRead = new ThreadOrganisationRead(
                    new OIDs(this._organisation.getOrgParent(), false), this.getPerformer());
            // -- the request goes to the branch with licensed organizations:
            threadOrgParentOnLicencedDirRead.setLicensedOrgs(true);
            submitOrgParentOnLicencedDir = LDAPConnector.getSingletonInstance().getExecutorServiceOne()
                    .submit(threadOrgParentOnLicencedDirRead);

            // -- Parent on the work directory:
            ThreadOrganisationRead threadOrgParentOnWorkDirRead = new ThreadOrganisationRead(
                    new OIDs(this._organisation.getOrgParent(), false), this.getPerformer());
            // -- the request goes to the branch with licensed organizations:
            submitOrgParentOnWorkDir = LDAPConnector.getSingletonInstance().getExecutorServiceOne()
                    .submit(threadOrgParentOnWorkDirRead);

            // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            // -- Parent on the license directory:
            try {
                //vIsOrgParentLicense = (threadOrgParentOnLicencedDirRead.call() != null);
                vIsOrgParentLicense = ((vOrgParentOnLicenceDir = submitOrgParentOnLicencedDir.get(3,
                        TimeUnit.SECONDS)) != null);
            }
            /*
            catch (NameNotFoundException ex) {
            // hier gibt es keinen Grund zur Panik! ;-)
            vIsOrgParentLicense = Boolean.FALSE;
            }
             */
            catch (ExecutionException ex) {
                if ((ex.getCause() != null)
                        && (ex.getCause().getClass().isAssignableFrom(NameNotFoundException.class))) {
                    // hier gibt es keinen Grund zur Panik! ;-)
                    vIsOrgParentLicense = Boolean.FALSE;
                } else {
                    throw ex;
                }
            } catch (InterruptedException ex) {
                throw new ExecutionException(ex);
            } catch (TimeoutException ex) {
                throw new ExecutionException(ex);
            }
        }

        try {

            // -- Update abwarten
            this._organisation = submitOrgOnWorkDir.get(3, TimeUnit.SECONDS);

            // -- die Organisation wenn mglich in der lizenzierte Verzeichnis schreiben:
            if ((vIsOrgParentLicense == null) || (vIsOrgParentLicense.booleanValue())) {
                // -- ! This institution is classified to the licensed organizations:
                Organisation vOrgOnLicensedDir = null;
                try {
                    vOrgOnLicensedDir = submitOrgOnLicencedDir.get(3, TimeUnit.SECONDS);
                    if (!vOrgOnLicensedDir.getOrgRDN().equalsIgnoreCase(this._organisation.getOrgRDN())) {
                        /*
                         * The shift operation works beautifully but may cause to error, because there are 
                         * potential changes from the sub-organizations in the Work Directory will not be included.
                         * ...therefore the Orgnanisation is first deleted and then will be re-copied
                        ThreadOrganisationMove threadOrganisationMove =
                        new ThreadOrganisationMove(vOrgOnLicensedDir.getOIDs().getOrgName(), this._organisation
                            .getOrgParent(), true, _performer);
                        vOrgOnLicensedDir = threadOrganisationMove.call();
                         */
                        this.deletingFromLicensedOrgsDir(vOrgOnLicensedDir);
                        // -- !!! very important for further processing:
                        vOrgOnLicensedDir = null;
                    }
                }
                /*
                catch (NameNotFoundException ex) {
                // es gibt keinen Grund zur Panik! ;-)
                }
                 */
                catch (ExecutionException ex) {
                    if ((ex.getCause() != null)
                            && (ex.getCause().getClass().isAssignableFrom(NameNotFoundException.class))) {
                        // hier gibt es keinen Grund zur Panik...
                    } else {
                        // hier aber schon...
                        throw ex;
                    }
                } catch (InterruptedException ex) {
                    throw new ExecutionException(ex);
                } catch (TimeoutException ex) {
                    throw new ExecutionException(ex);
                }

                if (vOrgOnLicensedDir != null) {
                    if (!ConstEnumOrgStatus.revised.equals(this._oldStatus)) {
                        // -- This should be never happen:
                        LOG.log(Level.WARNING,
                                "The old status is not ''revised'' but this organization is between the Licensed: this should never be happen! Old status: ''{0}''",
                                this._oldStatus.name());
                    }
                    // -- !!! The organization could not be moved:
                    if (vOrgOnLicensedDir.getOrgRDN().equals(this._organisation.getOrgRDN())) {
                        // -- Update licensed organization:
                        try {
                            threadOrganisationUpdate = new ThreadOrganisationUpdate(_ready, _organisation,
                                    false, _performer);
                            threadOrganisationUpdate.setUpdatingOfLicensedOrgs(true);
                            threadOrganisationUpdate.call();
                        } catch (NameNotFoundException ex) {
                            throw new ExecutionException(ex);
                        } catch (AttributeModificationException ex) {
                            throw new ExecutionException(ex);
                        }
                    } else {
                        LOG.log(Level.WARNING, "The licensed (RDN='" + vOrgOnLicensedDir.getOrgRDN()
                                + "') organization can not be updated because it has been postponed to new RDN='"
                                + this._organisation.getOrgRDN() + "'");
                    }
                } else {
                    // -- Der Knoten sollte kopiert werden aber nur unter einem Bedingung...
                    if (submitOrgParentOnWorkDir != null) {
                        // -- Parent on the work directory:
                        try {
                            vOrgParentOnWorkDir = submitOrgParentOnWorkDir.get(3, TimeUnit.SECONDS);
                        } catch (ExecutionException ex) {
                            if ((ex.getCause() != null) && (ex.getCause().getClass()
                                    .isAssignableFrom(NameNotFoundException.class))) {
                                // hier gibt es keinen Grund zur Panik! ;-)
                            } else {
                                throw ex;
                            }
                        } catch (InterruptedException ex) {
                            throw new ExecutionException(ex);
                        } catch (TimeoutException ex) {
                            throw new ExecutionException(ex);
                        }
                    }
                    // ...dass die RDN des Parnts- Knoten stimmt, das heit, dass die nicht verschoben wurde:
                    if (((vOrgParentOnWorkDir != null) && (vOrgParentOnLicenceDir != null)
                            && (vOrgParentOnWorkDir.getOrgRDN().equals(vOrgParentOnLicenceDir.getOrgRDN())))
                            || ((vOrgParentOnWorkDir == null) && (vOrgParentOnLicenceDir == null))) {
                        this.copyingToLicensedOrgs(_organisation);
                    }
                }

            }
        } catch (InterruptedException ex) {
            throw new ExecutionException(ex);
        } catch (TimeoutException ex) {
            throw new ExecutionException(ex);
        }
    } finally {
        if ((submitOrgOnWorkDir != null) && (!submitOrgOnWorkDir.isDone())
                && (!submitOrgOnWorkDir.isCancelled())) {
            submitOrgOnWorkDir.cancel(true);
        }
        if ((submitOrgOnLicencedDir != null) && (!submitOrgOnLicencedDir.isDone())
                && (!submitOrgOnLicencedDir.isCancelled())) {
            submitOrgOnLicencedDir.cancel(true);
        }
        if ((submitOrgParentOnWorkDir != null) && (!submitOrgParentOnWorkDir.isDone())
                && (!submitOrgParentOnWorkDir.isCancelled())) {
            submitOrgParentOnWorkDir.cancel(true);
        }
        if ((submitOrgParentOnLicencedDir != null) && (!submitOrgParentOnLicencedDir.isDone())
                && (!submitOrgParentOnLicencedDir.isCancelled())) {
            submitOrgParentOnLicencedDir.cancel(true);
        }
    }
    return this._organisation;
}