Example usage for java.lang InterruptedException getLocalizedMessage

List of usage examples for java.lang InterruptedException getLocalizedMessage

Introduction

In this page you can find the example usage for java.lang InterruptedException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:org.mifos.test.framework.util.DbUnitDataImportExport.java

private void dumpSql(String fileName) {
    // execute mysqldump and provide a reasonable error message if
    // mysqldump isn't found on the $PATH.

    System.out.print("dumping sql to: " + fileName + " ... ");

    try {//  w w  w  . j  ava2 s. c om
        Runtime rt = Runtime.getRuntime();
        Process proc = rt.exec("mysqldump --password=" + password + " --user=" + user + " --result-file="
                + fileName + " " + databaseName);
        int exitVal = proc.waitFor();

        if (exitVal == 0) {
            System.out.println("done!");
        } else {
            System.err.println("ERROR: Wrong username, password and/or database name!");
        }
    } catch (IOException ioe) {
        System.err.println("ERROR: " + ioe.getMessage());

        System.err.println(
                "Please make sure that \"mysqldump\" is in your PATH.\nSee http://www.mifos.org/developers/install-mifos/install-windows#add-required-environment-variables for an example %Path on Windows.\nOn linux, run \"which mysqldump\" to find out which directory mysqldump is in, and add it to PATH.");
    } catch (InterruptedException ie) {
        System.err.println("ERROR (interruption): " + ie.getLocalizedMessage());
    }
}

From source file:it.geosolutions.geoserver.jms.client.JMSContainer.java

/**
 * try to disconnect/*from w w  w  . ja  v  a  2  s .  co m*/
 * 
 * @return true if success
 */
public boolean disconnect() {
    if (isRunning()) {
        LOGGER.info("Disconnecting...");
        stop();
        for (int rep = 1; rep <= max; ++rep) {
            LOGGER.info("Unregistering...");
            if (!isRunning()) {
                LOGGER.info("Succesfully un-registered from the destination topic");
                LOGGER.warning(
                        "You will (probably) loose next incoming events from other instances!!! (depending on how you have configured the broker)");
                return true;
            }
            LOGGER.info("Waiting for connection shutdown...(" + rep + "/" + max + ")");
            try {
                Thread.sleep(maxWait);
            } catch (InterruptedException e) {
                LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
            }
        }
    } else {
        LOGGER.severe("Connection is already stopped");
    }

    return false;
}

From source file:it.geosolutions.geoserver.jms.client.JMSContainer.java

/**
 * try to connect//from w ww.  ja  v  a2 s .  com
 * 
 * @return true in success case, false otherwise
 */
public boolean connect() {
    if (!isRunning()) {
        LOGGER.info("Connecting...");
        start();
        if (isRunning()) {
            for (int repReg = 1; repReg <= max; ++repReg) {
                LOGGER.info("Registration...");
                if (isRegisteredWithDestination()) {
                    LOGGER.info("Now GeoServer is registered with the destination");
                    return true;
                } else if (repReg == max) {
                    LOGGER.log(Level.SEVERE, "Registration aborted due to a connection problem");
                    stop();
                    LOGGER.info("Disconnected");
                } else {
                    LOGGER.info("Impossible to register GeoServer with destination, waiting...");
                }
                LOGGER.info("Waiting for registration...(" + repReg + "/" + max + ")");
                try {
                    Thread.sleep(maxWait);
                } catch (InterruptedException e) {
                    LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
                }
            }
        } else {
            LOGGER.severe("Impossible to start a connection to destination.");
            stop();
            LOGGER.info("Disconnected");
            return false;
        }
    } else {
        LOGGER.severe("Connection is already running");
    }
    return false;
}

From source file:org.polymap.core.data.operation.FeatureOperationContainer.java

public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
    try {/*from w w  w . j a  va2  s .  c  o m*/
        // preset task name without beginTask()
        monitor.setTaskName(getLabel());

        switch (delegate.redo(monitor)) {
        case OK:
            return Status.OK_STATUS;
        case Cancel:
            return Status.CANCEL_STATUS;
        default:
            return Status.CANCEL_STATUS;
        }
    } catch (InterruptedException e) {
        return Status.CANCEL_STATUS;
    } catch (ExecutionException e) {
        throw e;
    } catch (Exception e) {
        throw new ExecutionException(e.getLocalizedMessage(), e);
    }
}

From source file:org.polymap.core.data.operation.FeatureOperationContainer.java

public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
    try {/*from  www  .ja  v  a  2 s . c  o m*/
        // preset task name without beginTask()
        monitor.setTaskName(getLabel());

        switch (delegate.undo(monitor)) {
        case OK:
            return Status.OK_STATUS;
        case Cancel:
            return Status.CANCEL_STATUS;
        default:
            return Status.CANCEL_STATUS;
        }
    } catch (InterruptedException e) {
        return Status.CANCEL_STATUS;
    } catch (ExecutionException e) {
        throw e;
    } catch (Exception e) {
        throw new ExecutionException(e.getLocalizedMessage(), e);
    }
}

From source file:org.polymap.core.data.operation.FeatureOperationContainer.java

public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
    try {//from  ww w  .  ja v  a  2  s.  c  o  m
        // add info to context
        DefaultOperationContext context = (DefaultOperationContext) delegate.getContext();
        context.addAdapter(info);

        // preset task name without beginTask()
        monitor.setTaskName(getLabel());

        switch (delegate.execute(monitor)) {
        case OK:
            return Status.OK_STATUS;
        case Cancel:
            return Status.CANCEL_STATUS;
        default:
            return Status.CANCEL_STATUS;
        }
    } catch (InterruptedException e) {
        return Status.CANCEL_STATUS;
    } catch (ExecutionException e) {
        throw e;
    } catch (Exception e) {
        throw new ExecutionException(e.getLocalizedMessage(), e);
    }
}

From source file:org.eclipse.jubula.client.internal.impl.AUTAgentImpl.java

/**
 * @param startResponse//from  w ww.  j ava 2s  . c o  m
 *            the AUT start response
 * @return the AUT or <code>null<code> if problem during start
 */
private AutIdentifier handleResponse(int startResponse) throws CommunicationException {
    if (startResponse == AUTStartResponse.OK) {
        Object autIdentifier;
        try {
            autIdentifier = Synchronizer.instance().exchange(null);
            if (autIdentifier instanceof AutIdentifier) {
                return (AutIdentifier) autIdentifier;
            }
            log.error("Unexpected AUT identifier received: " //$NON-NLS-1$
                    + String.valueOf(autIdentifier));
        } catch (InterruptedException e) {
            log.error(e.getLocalizedMessage(), e);
            throw new CommunicationException(e);
        }
    }

    return null;
}

From source file:org.orekit.time.UTCScaleTest.java

@Test
public void testMultithreading() {

    // generate reference offsets using a single thread
    RandomGenerator random = new Well1024a(6392073424l);
    List<AbsoluteDate> datesList = new ArrayList<AbsoluteDate>();
    List<Double> offsetsList = new ArrayList<Double>();
    AbsoluteDate reference = utc.getFirstKnownLeapSecond().shiftedBy(-Constants.JULIAN_YEAR);
    double testRange = utc.getLastKnownLeapSecond().durationFrom(reference) + Constants.JULIAN_YEAR;
    for (int i = 0; i < 10000; ++i) {
        AbsoluteDate randomDate = reference.shiftedBy(random.nextDouble() * testRange);
        datesList.add(randomDate);//w w  w.  ja v  a 2  s . c om
        offsetsList.add(utc.offsetFromTAI(randomDate));
    }

    // check the offsets in multi-threaded mode
    ExecutorService executorService = Executors.newFixedThreadPool(100);

    for (int i = 0; i < datesList.size(); ++i) {
        final AbsoluteDate date = datesList.get(i);
        final double offset = offsetsList.get(i);
        executorService.execute(new Runnable() {
            public void run() {
                Assert.assertEquals(offset, utc.offsetFromTAI(date), 1.0e-12);
            }
        });
    }

    try {
        executorService.shutdown();
        executorService.awaitTermination(3, TimeUnit.SECONDS);
    } catch (InterruptedException ie) {
        Assert.fail(ie.getLocalizedMessage());
    }

}

From source file:com.photon.maven.plugins.android.standalonemojos.RobotiumMultiDeviceExecutorMojo.java

private void joinThreads() {
    for (int i = 0; i < threadObj.size(); i++) {
        try {/*from   w  w w  . ja  va 2s .  c om*/
            threadObj.get(i).join();
            //            getLog().info(threadObj.get(i).getName() + ": thread joined");
        } catch (InterruptedException e) {
            getLog().info(
                    threadObj.get(i).getName() + ": joinThreads - Exception = " + e.getLocalizedMessage());
        }
    }
}

From source file:de.uni_potsdam.hpi.asg.common.io.Invoker.java

private ProcessReturn invoke(String[] cmd, List<String> params, File folder, int timeout) {
    List<String> command = new ArrayList<String>();
    command.addAll(Arrays.asList(cmd));
    command.addAll(params);/*  ww w .  ja va2s  . co m*/
    ProcessReturn retVal = new ProcessReturn(Arrays.asList(cmd), params);
    Process process = null;
    try {
        logger.debug("Exec command: " + command.toString());
        //System.out.println(timeout + ": " + command.toString());
        ProcessBuilder builder = new ProcessBuilder(command);
        builder.directory(folder);
        builder.environment(); // bugfix setting env in test-mode (why this works? i dont know..)
        process = builder.start();

        Thread timeoutThread = null;
        if (timeout > 0) {
            timeoutThread = new Thread(new Timeout(Thread.currentThread(), timeout));
            timeoutThread.setName("Timout for " + command.toString());
            timeoutThread.start();
        }
        IOStreamReader ioreader = new IOStreamReader(process);
        Thread streamThread = new Thread(ioreader);
        streamThread.setName("StreamReader for " + command.toString());
        streamThread.start();
        process.waitFor();
        streamThread.join();
        if (timeoutThread != null) {
            timeoutThread.interrupt();
        }
        String out = ioreader.getResult();
        //System.out.println(out);
        if (out == null) {
            //System.out.println("out = null");
            retVal.setStatus(Status.noio);
        }
        retVal.setCode(process.exitValue());
        retVal.setStream(out);
        retVal.setStatus(Status.ok);
    } catch (InterruptedException e) {
        process.destroy();
        retVal.setTimeout(timeout);
        retVal.setStatus(Status.timeout);
    } catch (IOException e) {
        logger.error(e.getLocalizedMessage());
        retVal.setStatus(Status.ioexception);
    }
    return retVal;
}