Example usage for java.lang Object wait

List of usage examples for java.lang Object wait

Introduction

In this page you can find the example usage for java.lang Object wait.

Prototype

public final void wait() throws InterruptedException 

Source Link

Document

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Usage

From source file:org.apache.tomcat.maven.plugin.tomcat7.run.AbstractRunMojo.java

/**
 * Causes the current thread to wait indefinitely. This method does not return.
 *///w ww  .j av  a  2  s  .  c om
private void waitIndefinitely() {
    Object lock = new Object();

    synchronized (lock) {
        try {
            lock.wait();
        } catch (InterruptedException exception) {
            getLog().warn(messagesProvider.getMessage("AbstractRunMojo.interrupted"), exception);
        }
    }
}

From source file:org.eclipse.thym.core.engine.internal.cordova.CordovaEngineProvider.java

public void downloadEngine(DownloadableCordovaEngine[] engines, IProgressMonitor monitor) {
    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }//from ww  w  .jav a2 s  .  com

    IRetrieveFileTransfer transfer = HybridCore.getDefault().getFileTransferService();
    IFileID remoteFileID;

    int platformSize = engines.length;
    Object lock = new Object();
    int incompleteCount = platformSize;
    SubMonitor sm = SubMonitor.convert(monitor, platformSize);
    for (int i = 0; i < platformSize; i++) {
        sm.setTaskName("Download Cordova Engine " + engines[i].getVersion());
        try {
            URI uri = URI.create(engines[i].getDownloadURL());
            remoteFileID = FileIDFactory.getDefault().createFileID(transfer.getRetrieveNamespace(), uri);
            if (sm.isCanceled()) {
                return;
            }
            transfer.sendRetrieveRequest(remoteFileID,
                    new EngineDownloadReceiver(engines[i].getVersion(), engines[i].getPlatformId(), lock, sm),
                    null);

        } catch (FileCreateException e) {
            HybridCore.log(IStatus.ERROR, "Engine download file create error", e);
        } catch (IncomingFileTransferException e) {
            HybridCore.log(IStatus.ERROR, "Engine download file transfer error", e);
        }
    }
    synchronized (lock) {
        while (incompleteCount > 0) {
            try {
                lock.wait();
            } catch (InterruptedException e) {
                HybridCore.log(IStatus.INFO, "interrupted while waiting for all engines to download", e);
            }
            incompleteCount--;
            sm.worked(1);
        }
    }
    resetEngineList();
}

From source file:org.trafodion.dtm.HBaseTxClient.java

public short abortTransaction(final long transactionID) throws Exception {
    if (LOG.isDebugEnabled())
        LOG.debug("Enter abortTransaction, txid: " + transactionID);
    TransactionState ts = mapTransactionStates.get(transactionID);

    if (ts == null) {
        LOG.error("Returning from HBaseTxClient:abortTransaction, txid: " + transactionID + " retval: "
                + TransReturnCode.RET_NOTX.toString());
        return TransReturnCode.RET_NOTX.getShort();
    }//from   w w w.j a  v a  2s .  c om

    try {
        ts.setStatus(TransState.STATE_ABORTED);
        if (useTlog) {
            tLog.putSingleRecord(transactionID, "ABORTED", ts.getParticipatingRegions(), false);
        }
    } catch (Exception e) {
        LOG.error("Returning from HBaseTxClient:abortTransaction, txid: " + transactionID
                + " tLog.putRecord: EXCEPTION");
        return TransReturnCode.RET_EXCEPTION.getShort();
    }

    if ((stallWhere == 1) || (stallWhere == 3)) {
        LOG.info("Stalling in phase 2 for abortTransaction");
        Thread.sleep(300000); // Initially set to run every 5 min
    }

    try {
        trxManager.abort(ts);
    } catch (IOException e) {
        synchronized (mapLock) {
            mapTransactionStates.remove(transactionID);
        }
        LOG.error(
                "Returning from HBaseTxClient:abortTransaction, txid: " + transactionID + " retval: EXCEPTION");
        return TransReturnCode.RET_EXCEPTION.getShort();
    } catch (UnsuccessfulDDLException ddle) {
        LOG.error("FATAL DDL Exception from HBaseTxClient:abort, WAITING INDEFINETLY !! retval: "
                + TransReturnCode.RET_EXCEPTION.toString() + " UnsuccessfulDDLException" + " txid: "
                + transactionID);

        //Reaching here means several attempts to perform the DDL operation has failed in abort phase.
        //Generally if only DML operation is involved, returning error causes TM to call completeRequest()
        //which causes a hang(abort work is outstanding forever) due to doAbortX thread holding the
        //commitSendLock (since doAbortX raised an exception and exited without clearing the commitSendLock count).
        //In the case of DDL exception, no doAbortX thread is involved and commitSendLock is not held. Hence to mimic
        //the same hang behaviour, the current worker thread will be put to wait indefinitely for user intervention.
        //Long Term solution to this behaviour is currently TODO.
        Object commitDDLLock = new Object();
        synchronized (commitDDLLock) {
            commitDDLLock.wait();
        }
        return TransReturnCode.RET_EXCEPTION.getShort();
    }
    if (useTlog && useForgotten) {
        if (forceForgotten) {
            tLog.putSingleRecord(transactionID, "FORGOTTEN", null, true);
        } else {
            tLog.putSingleRecord(transactionID, "FORGOTTEN", null, false);
        }
    }
    //     mapTransactionStates.remove(transactionID);

    if (LOG.isTraceEnabled())
        LOG.trace("Exit abortTransaction, retval: OK txid: " + transactionID + " mapsize: "
                + mapTransactionStates.size());
    return TransReturnCode.RET_OK.getShort();
}

From source file:RemoteDeviceDiscovery.java

public static void findDevices() throws IOException, InterruptedException {

    final Object inquiryCompletedEvent = new Object();

    devicesDiscovered.clear();//from  w  w  w  . ja va  2 s .  c o  m

    DiscoveryListener listener = new DiscoveryListener() {

        public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) {
            if (debug)
                System.out.println("#" + "Device " + btDevice.getBluetoothAddress() + " found");
            devicesDiscovered.add(btDevice);
            try {
                if (debug)
                    System.out.println("#" + "     name " + btDevice.getFriendlyName(false));
            } catch (IOException cantGetDeviceName) {
            }
        }

        public void inquiryCompleted(int discType) {
            if (debug)
                System.out.println("#" + "Device Inquiry completed!");
            synchronized (inquiryCompletedEvent) {
                inquiryCompletedEvent.notifyAll();
            }
        }

        public void serviceSearchCompleted(int transID, int respCode) {
        }

        public void servicesDiscovered(int transID, ServiceRecord[] servRecord) {
            if (debug)
                System.out.println("#" + "servicesDiscovered");
        }
    };

    synchronized (inquiryCompletedEvent) {

        //ServiceRecord.

        LocalDevice ld = LocalDevice.getLocalDevice();
        //ld.getRecord()

        if (debug)
            System.out.println("#My Name is:" + ld.getFriendlyName());

        //           boolean started = LocalDevice.getLocalDevice().getDiscoveryAgent().startInquiry(DiscoveryAgent.LIAC, listener);
        //            if (started) {
        //               if (debug) System.out.println("wait for device inquiry to complete...");
        //                inquiryCompletedEvent.wait();
        //                if (debug) System.out.println(devicesDiscovered.size() +  " device(s) found");
        //            }

        boolean started = LocalDevice.getLocalDevice().getDiscoveryAgent().startInquiry(DiscoveryAgent.GIAC,
                listener);
        if (started) {
            if (debug)
                System.out.println("#" + "wait for device inquiry to complete...");
            inquiryCompletedEvent.wait();
            if (debug)
                System.out.println("#" + devicesDiscovered.size() + " device(s) found");
        }
    }

}

From source file:org.trafodion.dtm.HBaseTxClient.java

public short doCommit(long transactionId) throws Exception {
    if (LOG.isDebugEnabled())
        LOG.debug("Enter doCommit, txid: " + transactionId);
    TransactionState ts = mapTransactionStates.get(transactionId);

    if (ts == null) {
        LOG.error("Returning from HBaseTxClient:doCommit, (null tx) retval: "
                + TransReturnCode.RET_NOTX.toString() + " txid: " + transactionId);
        return TransReturnCode.RET_NOTX.getShort();
    }//from  w w  w .ja v a  2 s .c  o  m

    // Set the commitId
    IdTmId commitId = null;
    if (TRANSACTION_ALGORITHM == AlgorithmType.SSCC) {
        try {
            commitId = new IdTmId();
            if (LOG.isTraceEnabled())
                LOG.trace("doCommit getting new commitId");
            idServer.id(ID_TM_SERVER_TIMEOUT, commitId);
            if (LOG.isTraceEnabled())
                LOG.trace("doCommit idServer.id returned: " + commitId.val);
        } catch (IdTmException exc) {
            LOG.error("doCommit: IdTm threw exception " + exc);
            throw new CommitUnsuccessfulException("doCommit: IdTm threw exception " + exc);
        }
    }

    final long commitIdVal = (TRANSACTION_ALGORITHM == AlgorithmType.SSCC) ? commitId.val : -1;
    if (LOG.isTraceEnabled())
        LOG.trace("doCommit setting commitId (" + commitIdVal + ") for tx: " + ts.getTransactionId());
    ts.setCommitId(commitIdVal);

    try {
        ts.setStatus(TransState.STATE_COMMITTED);
        if (useTlog) {
            tLog.putSingleRecord(transactionId, "COMMITTED", ts.getParticipatingRegions(), true);
        }
    } catch (Exception e) {
        LOG.error("Returning from HBaseTxClient:doCommit, txid: " + transactionId
                + " tLog.putRecord: EXCEPTION " + e);
        return TransReturnCode.RET_EXCEPTION.getShort();
    }

    if ((stallWhere == 2) || (stallWhere == 3)) {
        LOG.info("Stalling in phase 2 for doCommit");
        Thread.sleep(300000); // Initially set to run every 5 min
    }

    try {
        trxManager.doCommit(ts);
    } catch (CommitUnsuccessfulException e) {
        LOG.error("Returning from HBaseTxClient:doCommit, retval: " + TransReturnCode.RET_EXCEPTION.toString()
                + " IOException" + " txid: " + transactionId);
        return TransReturnCode.RET_EXCEPTION.getShort();
    } catch (UnsuccessfulDDLException ddle) {
        LOG.error("FATAL DDL Exception from HBaseTxClient:doCommit, WAITING INDEFINETLY !! retval: "
                + TransReturnCode.RET_EXCEPTION.toString() + " UnsuccessfulDDLException" + " txid: "
                + transactionId);

        //Reaching here means several attempts to perform the DDL operation has failed in commit phase.
        //Generally if only DML operation is involved, returning error causes TM to call completeRequest()
        //which causes a hang(commit work is outstanding forever) due to doCommitX thread holding the
        //commitSendLock (since doCommitX raised an exception and exited without clearing the commitSendLock count).
        //In the case of DDL exception, no doCommitX thread is involved and commitSendLock is not held. Hence to mimic
        //the same hang behaviour, the current worker thread will be put to wait indefinitely for user intervention.
        //Long Term solution to this behaviour is currently TODO.
        Object commitDDLLock = new Object();
        synchronized (commitDDLLock) {
            commitDDLLock.wait();
        }
        return TransReturnCode.RET_EXCEPTION.getShort();
    }
    if (useTlog && useForgotten) {
        if (forceForgotten) {
            tLog.putSingleRecord(transactionId, "FORGOTTEN", null, true);
        } else {
            tLog.putSingleRecord(transactionId, "FORGOTTEN", null, false);
        }
    }
    //       mapTransactionStates.remove(transactionId);

    if (LOG.isTraceEnabled())
        LOG.trace("Exit doCommit, retval(ok): " + TransReturnCode.RET_OK.toString() + " txid: " + transactionId
                + " mapsize: " + mapTransactionStates.size());
    return TransReturnCode.RET_OK.getShort();
}

From source file:org.jboss.tools.aerogear.hybrid.engine.internal.cordova.CordovaEngineProvider.java

public void downloadEngine(String version, IProgressMonitor monitor, String... platforms) {
    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }/*from ww w. ja v  a 2s  .  co  m*/

    IRetrieveFileTransfer transfer = HybridCore.getDefault().getFileTransferService();
    IFileID remoteFileID;

    int platformSize = platforms.length;
    Object lock = new Object();
    int incompleteCount = platformSize;
    monitor.beginTask("Download Cordova Engine " + version, platformSize * 100 + 1);
    monitor.worked(1);
    for (int i = 0; i < platformSize; i++) {
        Platform p = getPlatform(platforms[i]);
        Assert.isNotNull(p);
        try {
            URI uri = URI.create(p.uri + ";a=snapshot;h=" + version + ";sf=tgz");
            remoteFileID = FileIDFactory.getDefault().createFileID(transfer.getRetrieveNamespace(), uri);
            SubProgressMonitor sm = new SubProgressMonitor(monitor, 100);
            if (monitor.isCanceled()) {
                return;
            }
            transfer.sendRetrieveRequest(remoteFileID,
                    new EngineDownloadReceiver(version, platforms[i], lock, sm), null);
        } catch (FileCreateException e) {
            HybridCore.log(IStatus.ERROR, "Engine download file create error", e);
        } catch (IncomingFileTransferException e) {
            HybridCore.log(IStatus.ERROR, "Engine download file transfer error", e);
        }
    }
    synchronized (lock) {
        while (incompleteCount > 0) {
            try {
                lock.wait();
            } catch (InterruptedException e) {
                HybridCore.log(IStatus.INFO, "interrupted while waiting for all engines to download", e);
            }
            incompleteCount--;
        }
    }
    monitor.done();
    resetEngineList();
}

From source file:it.anyplace.sync.bep.BlockExchangeConnectionHandler.java

public BlockExchangeConnectionHandler connect() throws Exception {
    checkNotClosed();//from ww  w.j a  v  a 2s . c o  m
    checkArgument(socket == null && !isConnected, "already connected!");
    logger.info("connecting to {}", address.getAddress());

    KeystoreHandler keystoreHandler = KeystoreHandler.newLoader().loadAndStore(configuration);

    try {
        switch (address.getType()) {
        case TCP:
            logger.debug("opening tcp ssl connection");
            socket = keystoreHandler.createSocket(address.getSocketAddress(), BEP);
            break;
        case RELAY: {
            logger.debug("opening relay connection");
            socket = keystoreHandler.wrapSocket(new RelayClient(configuration).openRelayConnection(address),
                    BEP);
            break;
        }
        case HTTP_RELAY:
        case HTTPS_RELAY: {
            logger.debug("opening http relay connection");
            socket = keystoreHandler.wrapSocket(new HttpRelayClient(configuration).openRelayConnection(address),
                    BEP);
            break;
        }
        default:
            throw new UnsupportedOperationException("unsupported address type = " + address.getType());
        }
        in = new DataInputStream(socket.getInputStream());
        out = new DataOutputStream(socket.getOutputStream());

        sendHelloMessage(BlockExchageProtos.Hello.newBuilder().setClientName(configuration.getClientName())
                .setClientVersion(configuration.getClientVersion()).setDeviceName(configuration.getDeviceName())
                .build().toByteArray());
        markActivityOnSocket();

        BlockExchageProtos.Hello hello = receiveHelloMessage();
        logger.trace("received hello message = {}", hello);
        connectionInfo = new ConnectionInfo();
        connectionInfo.setClientName(hello.getClientName());
        connectionInfo.setClientVersion(hello.getClientVersion());
        connectionInfo.setDeviceName(hello.getDeviceName());
        logger.info("connected to device = {}", connectionInfo);
        keystoreHandler.checkSocketCerificate((SSLSocket) socket, address.getDeviceId());
        {
            ClusterConfig.Builder clusterConfigBuilder = ClusterConfig.newBuilder();
            for (String folder : configuration.getFolderNames()) {
                Folder.Builder folderBuilder = clusterConfigBuilder.addFoldersBuilder().setId(folder);
                {
                    //our device
                    Device.Builder deviceBuilder = folderBuilder.addDevicesBuilder()
                            .setId(ByteString.copyFrom(deviceIdStringToHashData(configuration.getDeviceId())));
                    if (indexHandler != null) {
                        deviceBuilder.setIndexId(indexHandler.getSequencer().indexId())
                                .setMaxSequence(indexHandler.getSequencer().currentSequence());
                    }
                }
                {
                    //other device
                    Device.Builder deviceBuilder = folderBuilder.addDevicesBuilder()
                            .setId(ByteString.copyFrom(deviceIdStringToHashData(address.getDeviceId())));
                    if (indexHandler != null) {
                        IndexInfo indexSequenceInfo = indexHandler.getIndexRepository()
                                .findIndexInfoByDeviceAndFolder(address.getDeviceId(), folder);
                        if (indexSequenceInfo != null) {
                            deviceBuilder.setIndexId(indexSequenceInfo.getIndexId())
                                    .setMaxSequence(indexSequenceInfo.getLocalSequence());
                            logger.info(
                                    "send delta index info device = {} index = {} max (local) sequence = {}",
                                    indexSequenceInfo.getDeviceId(), indexSequenceInfo.getIndexId(),
                                    indexSequenceInfo.getLocalSequence());
                        }
                    }
                }
                //TODO other devices??
            }
            sendMessage(clusterConfigBuilder.build());
        }
        final Object clusterConfigWaitingLock = new Object();
        synchronized (clusterConfigWaitingLock) {
            Object listener = new Object() {
                @Subscribe
                public void handleClusterConfigMessageProcessedEvent(ClusterConfigMessageProcessedEvent event) {
                    synchronized (clusterConfigWaitingLock) {
                        clusterConfigWaitingLock.notifyAll();
                    }
                }

                @Subscribe
                public void handleConnectionClosedEvent(ConnectionClosedEvent event) {
                    synchronized (clusterConfigWaitingLock) {
                        clusterConfigWaitingLock.notifyAll();
                    }
                }
            };
            eventBus.register(listener);
            startMessageListenerService();
            while (clusterConfigInfo == null && !isClosed()) {
                logger.debug("wait for cluster config");
                clusterConfigWaitingLock.wait();
            }
            checkNotNull(clusterConfigInfo, "unable to retrieve cluster config from peer!");
            eventBus.unregister(listener);
        }
        for (String folder : configuration.getFolderNames()) {
            if (hasFolder(folder)) {
                sendIndexMessage(folder);
            }
        }
        periodicExecutorService.scheduleWithFixedDelay(new Runnable() {
            @Override
            public void run() {
                sendPing();
            }
        }, 90, 90, TimeUnit.SECONDS);
    } catch (Exception ex) {
        close();
        throw ex;
    }
    isConnected = true;
    return this;
}

From source file:ubic.pubmedgate.mallet.SimpleMalletRunner.java

public void run() throws Exception {
    InstanceList instanceList = getInstanceList(documents);
    Pipe pipes = getPipe();//from  w ww . ja va  2s  .  co  m
    // send the docs through the folds, then expand and classify
    Iterator<InstanceList[]> folds = instanceList.crossValidationIterator(numFolds, seed);

    Object notifyWhenDone = new Object();
    int fold = 0;

    int foldRunnersSize = Config.config.getInt("whitetext.max_threads");
    if (numFolds < foldRunnersSize)
        foldRunnersSize = numFolds;
    foldRunners = new FoldRunner[foldRunnersSize];
    boolean allDone = false;
    // while there is folds to do, do em
    synchronized (notifyWhenDone) {
        while (!allDone) {
            // init threads
            for (int i = 0; i < foldRunners.length; i++) {
                FoldRunner foldRunner = foldRunners[i];
                // if we have something to do, and this thread is empty or done, then do it
                if (folds.hasNext() && (foldRunner == null || foldRunner.isDone())) {
                    log.info("Starting fold:" + ++fold + " of " + numFolds);

                    InstanceList[] foldInstances = folds.next();

                    log.info("Training size:" + foldInstances[0].size() + " Testing size:"
                            + foldInstances[1].size());

                    // TokenSequence tt;
                    InstanceList training = new InstanceList(pipes);
                    training.addThruPipe(foldInstances[0].iterator());

                    InstanceList testing = new InstanceList(pipes);
                    testing.addThruPipe(foldInstances[1].iterator());

                    foldRunners[i] = new FoldRunner(fold, training, testing, notifyWhenDone, this);
                    // start it going
                    new Thread(foldRunners[i], "Thread-" + i).start();
                }
            }

            int stillRunning = 0;
            for (FoldRunner thread : foldRunners) {
                if (thread != null && !thread.isDone())
                    stillRunning++;
            }

            log.info("Main thread is waiting on " + stillRunning + " threads");
            if (fold < numFolds)
                log.info("Next fold is " + (fold + 1) + "of " + numFolds);

            notifyWhenDone.wait();

            // check for all done
            allDone = !folds.hasNext();
            // if we ran out of folds then check to see if everyone is done
            if (allDone) {
                for (FoldRunner thread : foldRunners) {
                    allDone = allDone && thread.isDone();
                }
            }

        }
        // log.info( "Abstract cache size:" + pipes.cacheSize() );
        log.info("Before window size = " + windowBefore + " after window size = " + windowAfter);
        log.info("Pipes(" + brainPipes.size() + "):" + brainPipes.toString());

    }

}

From source file:org.apache.stratos.integration.common.TopologyHandler.java

/**
 * Assert application Inactive status/*  w w  w  .  ja va2  s.com*/
 *
 * @param applicationId
 * @param timeout
 */
public void assertApplicationInActiveStatus(final String applicationId, final int timeout)
        throws InterruptedException {
    log.info(String.format(
            "Asserting application status INACTIVE for [application-id] %s within [timeout] %d ms...",
            applicationId, timeout));
    final long startTime = System.currentTimeMillis();
    final Object synObject = new Object();
    ApplicationInstanceInactivatedEventListener inactivatedEventListener = new ApplicationInstanceInactivatedEventListener() {
        @Override
        protected void onEvent(Event event) {
            Application application = ApplicationManager.getApplications().getApplication(applicationId);
            if (application == null || application.getStatus() == ApplicationStatus.Inactive) {
                synchronized (synObject) {
                    synObject.notify();
                }
            }
        }
    };
    applicationsEventReceiver.addEventListener(inactivatedEventListener);

    Future future = executorService.submit(new Runnable() {
        @Override
        public void run() {
            Application application = ApplicationManager.getApplications().getApplication(applicationId);
            while (!((application != null) && (application.getStatus() == ApplicationStatus.Inactive))) {
                if ((System.currentTimeMillis() - startTime) > timeout) {
                    log.error(String.format(
                            "Application [application-id] %s did not become inactive within [timeout] %d",
                            applicationId, timeout));
                    break;
                }
                ApplicationStatus currentStatus = (application != null) ? application.getStatus() : null;
                log.info(String.format(
                        "Waiting for [application-id] %s [current-status] %s to become [status] %s...",
                        applicationId, currentStatus, ApplicationStatus.Inactive));
                sleep(10000);
                application = ApplicationManager.getApplications().getApplication(applicationId);
            }
            synchronized (synObject) {
                synObject.notify();
            }
        }
    });

    synchronized (synObject) {
        synObject.wait();
        future.cancel(true);
        applicationsEventReceiver.removeEventListener(inactivatedEventListener);
    }
    Application application = ApplicationManager.getApplications().getApplication(applicationId);
    ApplicationStatus currentStatus = (application != null) ? application.getStatus() : null;
    log.info(String.format(
            "Assert application inactive status for [application-id] %s [current-status] %s took %d ms",
            applicationId, currentStatus, System.currentTimeMillis() - startTime));
    assertNotNull(String.format("Application is not found: [application-id] %s", applicationId), application);
    assertEquals(
            String.format("Application status did not change to %s: [application-id] %s",
                    ApplicationStatus.Inactive, applicationId),
            ApplicationStatus.Inactive, application.getStatus());
}

From source file:edu.umass.cs.reconfiguration.Reconfigurator.java

private String spawnMergeeStopAndFetchStateTasks(Set<WaitAckStopEpoch<NodeIDType>> stopTasks, Object monitor,
        String mergerGroup, int mergerGroupEpoch) {

    Map<String, String> finalStates = new ConcurrentHashMap<String, String>();

    log.log(Level.INFO, "{0} starting wait on stop task monitors {1}", new Object[] { this, stopTasks });

    // FIXME: should start tasks inside synchronized?
    for (WaitAckStopEpoch<NodeIDType> stopTask : stopTasks)
        assert (this.protocolExecutor.spawnIfNotRunning(stopTask));

    synchronized (monitor) {
        while (!stopTasks.isEmpty())
            try {
                monitor.wait();
                for (Iterator<WaitAckStopEpoch<NodeIDType>> iter = stopTasks.iterator(); iter.hasNext();) {
                    WaitAckStopEpoch<NodeIDType> stopTask = iter.next();
                    String finalState = stopTask.getFinalState();
                    if (finalState != null) {
                        iter.remove();/*w ww .ja va 2 s  .c o m*/
                        finalStates.put(stopTask.startEpoch.getPrevGroupName() + ":"
                                + stopTask.startEpoch.getPrevEpochNumber(), finalState);
                    }
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
                log.log(Level.INFO, "{0} interrupted while waiting on tasks {1}",
                        new Object[] { this, stopTasks });
                throw new RuntimeException("Task to spawn merge/split fetch tasks interrupted");
            }
    }
    log.log(Level.INFO, "{0} finished waiting on all stop task monitors {1}", new Object[] { this, stopTasks });
    // merge mergee checkpoints
    return this.DB.app.fetchAndAggregateMergeeStates(finalStates, mergerGroup, mergerGroupEpoch);
    // can create the mergeGroup now with all the fetched states
}