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.geotools.utils.coveragetiler.CoverageTiler.java

/**
 * @param args/*from ww w  . jav a2  s  .c  o m*/
 * @throws MalformedURLException
 * @throws InterruptedException
 */
public static void main(String[] args) throws MalformedURLException, InterruptedException {

    final CoverageTiler coverageTiler = new CoverageTiler();
    coverageTiler.addProcessingEventListener(coverageTiler);
    if (coverageTiler.parseArgs(args)) {
        final Thread t = new Thread(coverageTiler, NAME);
        t.setPriority(coverageTiler.getPriority());
        t.start();
        try {
            t.join();
        } catch (InterruptedException e) {
            LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
        }

    } else
        LOGGER.fine("Exiting...");
}

From source file:thobe.logfileviewer.server.EthSource.java

public static void main(String[] args) {
    Arguments parsedArgs = parseCommandLine(args);
    System.out.println("Connecting to localhost at port=" + parsedArgs.getPort() + ", reading file='"
            + parsedArgs.getFilename() + "'");

    try {/* www  . java  2 s  . c om*/
        EthSource ethSource = new EthSource(parsedArgs.getPort(), new File(parsedArgs.getFilename()));
        ethSource.setLinesPerSecond(parsedArgs.getLps());
        ethSource.setInfiniteMode(parsedArgs.isInfiniteMode());
        ethSource.start();

        try {
            ethSource.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    } catch (IOException e) {
        System.err.println("Error opening connection: " + e.getLocalizedMessage());
        System.exit(1);
    }
}

From source file:org.geotools.utils.imagepyramid.PyramidBuilder.java

/**
 * This tool is designed to be used by the command line using this main
 * class but it can also be used from an GUI by using the setters and
 * getters./*from ww  w .j  ava2  s . c  o m*/
 * 
 * @param args
 * @throws IOException
 * @throws IllegalArgumentException
 * @throws InterruptedException
 */
public static void main(String[] args) throws IllegalArgumentException, IOException, InterruptedException {

    // creating an overviews embedder
    final PyramidBuilder builder = new PyramidBuilder();
    // adding the embedder itself as a listener
    builder.addProcessingEventListener(builder);
    // parsing input argumentBuilder
    if (builder.parseArgs(args)) {
        // creating a thread to execute the request process, with the
        // provided priority
        final Thread t = new Thread(builder, "PyramidBuilder");
        t.setPriority(builder.getPriority());
        t.start();
        try {
            t.join();
        } catch (InterruptedException e) {
            LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
        }

    } else if (LOGGER.isLoggable(Level.FINE))
        LOGGER.fine("Unable to parse command line argumentBuilder, exiting...");

}

From source file:org.geotools.utils.imagepyramid.PyramidLayerBuilder.java

/**
 * /*from  w  w w.  j a  v a 2 s  . c  o m*/
 * @param args
 * @throws IOException
 * @throws IllegalArgumentException
 * @throws InterruptedException
 */
public static void main(String[] args) throws IllegalArgumentException, IOException, InterruptedException {

    final PyramidLayerBuilder pyramidBuilder = new PyramidLayerBuilder();
    pyramidBuilder.addProcessingEventListener(pyramidBuilder);
    if (pyramidBuilder.parseArgs(args)) {
        final Thread t = new Thread(pyramidBuilder, "PyramidBuilder");
        t.setPriority(pyramidBuilder.getPriority());
        t.start();
        try {
            t.join();
        } catch (InterruptedException e) {
            LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
        }

    } else
        LOGGER.fine("Exiting...");

}

From source file:org.geotools.utils.imagemosaic.MosaicIndexBuilder.java

/**
 * Entry point for the index builder.//from  www . j a v  a2 s .  c  om
 * 
 * @param args
 */
public static void main(String[] args) {

    final MosaicIndexBuilder mosaicIndexBuilder = new MosaicIndexBuilder();
    mosaicIndexBuilder.addProcessingEventListener(mosaicIndexBuilder);
    if (mosaicIndexBuilder.parseArgs(args)) {
        final Thread t = new Thread(mosaicIndexBuilder, "MosaicIndexBuilder");
        t.setPriority(mosaicIndexBuilder.getPriority());
        t.start();
        try {
            t.join();
        } catch (InterruptedException e) {
            LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
        }

    } else
        LOGGER.fine("Exiting...");

}

From source file:org.geotools.utils.imageoverviews.OverviewsEmbedder.java

/**
 * This tool is designed to be used by the command line using this main
 * class but it can also be used from an GUI by using the setters and
 * getters./*  ww w .jav  a2 s  .  com*/
 * 
 * @param args
 * @throws IOException
 * @throws IllegalArgumentException
 * @throws InterruptedException
 */
public static void main(String[] args) throws IllegalArgumentException, IOException, InterruptedException {

    // creating an overviews embedder
    final OverviewsEmbedder overviewsEmbedder = new OverviewsEmbedder();
    // adding the embedder itself as a listener
    overviewsEmbedder.addProcessingEventListener(overviewsEmbedder);
    // parsing input argumentBuilder
    if (overviewsEmbedder.parseArgs(args)) {
        // creating a thread to execute the request process, with the
        // provided priority
        final Thread t = new Thread(overviewsEmbedder, "OverviewsEmbedder");
        t.setPriority(overviewsEmbedder.getPriority());
        t.start();
        try {
            t.join();
        } catch (InterruptedException e) {
            LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
        }

    } else if (LOGGER.isLoggable(Level.FINE))
        LOGGER.fine("Unable to parse command line argumentBuilder, exiting...");

}

From source file:com.meetingninja.csse.database.AgendaDatabaseAdapter.java

public static JsonNode update(String agendaID, Map<String, String> key_values)
        throws JsonGenerationException, IOException, InterruptedException {
    // prepare POST payload
    ByteArrayOutputStream json = new ByteArrayOutputStream();
    // this type of print stream allows us to get a string easily
    PrintStream ps = new PrintStream(json);

    // Create a generator to build the JSON string
    JsonGenerator jgen = JFACTORY.createGenerator(ps, JsonEncoding.UTF8);
    for (String key : key_values.keySet()) {
        jgen.flush();//from   ww  w.  j a va  2s  .c o m
        // Build JSON Object
        jgen.writeStartObject();
        jgen.writeStringField(Keys.Agenda.ID, agendaID);
        jgen.writeStringField("field", key);
        jgen.writeStringField("value", key_values.get(key));
        jgen.writeEndObject();
        jgen.writeRaw("\f"); // write a form-feed to separate the payloads
    }

    jgen.close();
    // Get JSON Object payload from print stream
    String payload = json.toString("UTF8");
    ps.close();
    // The backend can only update a single field at a time
    String[] payloads = payload.split("\f\\s*"); // split at each form-feed
    Thread t = new Thread(new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.getLocalizedMessage();
            }
        }
    }));
    String response = "";
    for (String p : payloads) {
        t.run();
        response = updateHelper(p);
    }
    return MAPPER.readTree(response);
}

From source file:it.geosolutions.tools.io.file.FileGarbageCollector.java

/**
 * Return a initialized instance of this singleton
 * @return initialized instance of this singleton
 * @throws InterruptedException - if Unable to get the lock
 *//*from  w ww.j a v a 2s. co  m*/
public static FileCleaningTracker getFileCleaningTracker() {
    if (singleton == null) {
        try {
            lock.tryLock(LOCK_WAIT_TIME, TimeUnit.MILLISECONDS);
            build(singleton);
        } catch (InterruptedException ie) {
            StringBuilder message = new StringBuilder("Unable to get lock on the ");
            message.append(FileGarbageCollector.class.toString());
            message.append(" message: " + ie.getLocalizedMessage());
            if (LOGGER.isErrorEnabled()) {
                LOGGER.error(message.toString());
            }
        } finally {
            lock.unlock();
        }
    }
    return singleton;
}

From source file:com.meetingninja.csse.database.UserDatabaseAdapter.java

public static User update(String userID, Map<String, String> key_values)
        throws JsonGenerationException, IOException, InterruptedException {
    // prepare POST payload
    ByteArrayOutputStream json = new ByteArrayOutputStream();
    // this type of print stream allows us to get a string easily
    PrintStream ps = new PrintStream(json);

    // Create a generator to build the JSON string
    JsonGenerator jgen = JFACTORY.createGenerator(ps, JsonEncoding.UTF8);
    for (String key : key_values.keySet()) {
        if (key.equals(Keys.User.EMAIL) && !Utilities.isValidEmailAddress(key_values.get(Keys.User.EMAIL)))
            throw new IOException("Error : [Update User] Incorrect email format");
        else {//w  w w  .java  2  s  .  com
            jgen.flush();
            // Build JSON Object
            jgen.writeStartObject();
            jgen.writeStringField(Keys.User.ID, userID);
            jgen.writeStringField("field", key);
            jgen.writeStringField("value", key_values.get(key));
            jgen.writeEndObject();
            jgen.writeRaw("\f");
        }
    }

    jgen.close();
    // Get JSON Object payload from print stream
    String payload = json.toString("UTF8");
    ps.close();
    String[] payloads = payload.split("\f\\s*");

    Thread t = new Thread(new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.getLocalizedMessage();
            }
        }
    }));
    String response = "";
    for (String p : payloads) {
        t.run();
        response = updateHelper(p);
    }
    return parseUser(MAPPER.readTree(response));
}

From source file:Main.java

/**
 * Causes runnable to have its run method called in the dispatch thread of
 * the event queue. This will happen after all pending events are processed.
 * The call blocks until this has happened.
 *///  ww w  .j  a v  a  2 s.  c o m
public static void invokeAndWait(final Runnable runnable) {
    if (EventQueue.isDispatchThread()) {
        runnable.run();
    } else {
        try {
            EventQueue.invokeAndWait(runnable);
        } catch (InterruptedException exception) {
            // Someone don't want to let us sleep. Go back to work.
        } catch (InvocationTargetException target) {
            final Throwable exception = target.getTargetException();
            if (exception instanceof RuntimeException) {
                throw (RuntimeException) exception;
            }
            if (exception instanceof Error) {
                throw (Error) exception;
            }
            // Should not happen, since {@link Runnable#run} do not allow checked exception.
            throw new UndeclaredThrowableException(exception, exception.getLocalizedMessage());
        }
    }
}