Example usage for java.lang InterruptedException getMessage

List of usage examples for java.lang InterruptedException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.joseflavio.unhadegato.Concentrador.java

/**
 * @param args [0] = Diretrio de configuraes.
 *///ww  w.  j av  a  2  s .c o m
public static void main(String[] args) {

    log.info(Util.getMensagem("unhadegato.iniciando"));

    try {

        /***********************/

        if (args.length > 0) {
            if (!args[0].isEmpty()) {
                configuracao = new File(args[0]);
                if (!configuracao.isDirectory()) {
                    String msg = Util.getMensagem("unhadegato.diretorio.incorreto");
                    System.out.println(msg);
                    log.error(msg);
                    System.exit(1);
                }
            }
        }

        if (configuracao == null) {
            configuracao = new File(System.getProperty("user.home") + File.separator + "unhadegato");
            configuracao.mkdirs();
        }

        log.info(Util.getMensagem("unhadegato.diretorio.endereco", configuracao.getAbsolutePath()));

        /***********************/

        File confGeralArq = new File(configuracao, "unhadegato.conf");

        if (!confGeralArq.exists()) {
            try (InputStream is = Concentrador.class.getResourceAsStream("/unhadegato.conf");
                    OutputStream os = new FileOutputStream(confGeralArq);) {
                IOUtils.copy(is, os);
            }
        }

        Properties confGeral = new Properties();

        try (FileInputStream fis = new FileInputStream(confGeralArq)) {
            confGeral.load(fis);
        }

        String prop_porta = confGeral.getProperty("porta");
        String prop_porta_segura = confGeral.getProperty("porta.segura");
        String prop_seg_pri = confGeral.getProperty("seguranca.privada");
        String prop_seg_pri_senha = confGeral.getProperty("seguranca.privada.senha");
        String prop_seg_pri_tipo = confGeral.getProperty("seguranca.privada.tipo");
        String prop_seg_pub = confGeral.getProperty("seguranca.publica");
        String prop_seg_pub_senha = confGeral.getProperty("seguranca.publica.senha");
        String prop_seg_pub_tipo = confGeral.getProperty("seguranca.publica.tipo");

        if (StringUtil.tamanho(prop_porta) == 0)
            prop_porta = "8885";
        if (StringUtil.tamanho(prop_porta_segura) == 0)
            prop_porta_segura = "8886";
        if (StringUtil.tamanho(prop_seg_pri) == 0)
            prop_seg_pri = "servidor.jks";
        if (StringUtil.tamanho(prop_seg_pri_senha) == 0)
            prop_seg_pri_senha = "123456";
        if (StringUtil.tamanho(prop_seg_pri_tipo) == 0)
            prop_seg_pri_tipo = "JKS";
        if (StringUtil.tamanho(prop_seg_pub) == 0)
            prop_seg_pub = "cliente.jks";
        if (StringUtil.tamanho(prop_seg_pub_senha) == 0)
            prop_seg_pub_senha = "123456";
        if (StringUtil.tamanho(prop_seg_pub_tipo) == 0)
            prop_seg_pub_tipo = "JKS";

        /***********************/

        File seg_pri = new File(prop_seg_pri);
        if (!seg_pri.isAbsolute())
            seg_pri = new File(configuracao.getAbsolutePath() + File.separator + prop_seg_pri);

        if (seg_pri.exists()) {
            System.setProperty("javax.net.ssl.keyStore", seg_pri.getAbsolutePath());
            System.setProperty("javax.net.ssl.keyStorePassword", prop_seg_pri_senha);
            System.setProperty("javax.net.ssl.keyStoreType", prop_seg_pri_tipo);
        }

        File seg_pub = new File(prop_seg_pub);
        if (!seg_pub.isAbsolute())
            seg_pub = new File(configuracao.getAbsolutePath() + File.separator + prop_seg_pub);

        if (seg_pub.exists()) {
            System.setProperty("javax.net.ssl.trustStore", seg_pub.getAbsolutePath());
            System.setProperty("javax.net.ssl.trustStorePassword", prop_seg_pub_senha);
            System.setProperty("javax.net.ssl.trustStoreType", prop_seg_pub_tipo);
        }

        /***********************/

        new Thread() {

            File arquivo = new File(configuracao, "copaibas.conf");

            long ultimaData = -1;

            @Override
            public void run() {

                while (true) {

                    long data = arquivo.lastModified();

                    if (data > ultimaData) {
                        executarCopaibas(arquivo);
                        ultimaData = data;
                    }

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

                }

            }

        }.start();

        /***********************/

        log.info(Util.getMensagem("unhadegato.conexao.esperando"));

        log.info(Util.getMensagem("copaiba.porta.normal.abrindo", prop_porta));
        Portal portal1 = new Portal(new SocketServidor(Integer.parseInt(prop_porta), false, true));

        log.info(Util.getMensagem("copaiba.porta.segura.abrindo", prop_porta_segura));
        Portal portal2 = new Portal(new SocketServidor(Integer.parseInt(prop_porta_segura), true, true));

        portal1.start();
        portal2.start();

        portal1.join();

        /***********************/

    } catch (Exception e) {

        log.error(e.getMessage(), e);

    } finally {

        for (CopaibaGerenciador gerenciador : gerenciadores.values())
            gerenciador.encerrar();
        gerenciadores.clear();
        gerenciadores = null;

    }

}

From source file:com.bt.aloha.util.CollectionHelper.java

public static void destroy(ConcurrentMap<String, Map<String, Object>> transients, String classname) {
    log.debug(String.format("Destroy method called on collection: %s", classname));
    for (Map<String, Object> element : transients.values()) {
        ScheduledFuture<?> future = (ScheduledFuture<?>) element.get("future");
        if (future == null || future.isCancelled() || future.isDone())
            continue;
        if (future.getDelay(TimeUnit.MILLISECONDS) > ONE_HUNDRED) {
            future.cancel(true);//  w w  w . j  av a  2 s.  c o  m
            continue;
        }
        int counter = 0;
        while (!future.isDone() && counter++ < THREE) {
            try {
                log.debug("Waiting for future to get done for some call...");
                Thread.sleep(ONE_THOUSAND);
            } catch (InterruptedException e) {
                log.warn(e.getMessage());
                continue;
            }
        }
    }
}

From source file:com.cloudera.kitten.TestKittenDistributedShell.java

@BeforeClass
public static void setup() throws InterruptedException, IOException {
    LOG.info("Starting up YARN cluster");
    conf.setInt("yarn.scheduler.fifo.minimum-allocation-mb", 128);
    if (yarnCluster == null) {
        yarnCluster = new MiniYARNCluster(TestKittenDistributedShell.class.getName(), 1, 1, 1);
        yarnCluster.init(conf);/*from w w  w  .j av a  2 s.  c  o  m*/
        yarnCluster.start();
    }
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        LOG.info("setup thread sleep interrupted. message=" + e.getMessage());
    }
}

From source file:edu.cwru.jpdg.Dotty.java

/**
 * Compiles the graph to dotty.//from w  w w.j a  v  a  2  s. c om
 */
public static String dotty(String graph) {

    byte[] bytes = graph.getBytes();

    try {
        ProcessBuilder pb = new ProcessBuilder("dotty");
        pb.redirectError(ProcessBuilder.Redirect.INHERIT);
        Process p = pb.start();
        OutputStream stdin = p.getOutputStream();
        stdin.write(bytes);
        stdin.close();

        String line;
        BufferedReader stdout = new BufferedReader(new InputStreamReader(p.getInputStream()));
        List<String> stdout_lines = new ArrayList<String>();
        line = stdout.readLine();
        while (line != null) {
            stdout_lines.add(line);
            line = stdout.readLine();
        }
        if (p.waitFor() != 0) {
            throw new RuntimeException("javac failed");
        }

        return StringUtils.join(stdout_lines, "\n");
    } catch (InterruptedException e) {
        throw new RuntimeException(e.getMessage());
    } catch (IOException e) {
        throw new RuntimeException(e.getMessage());
    }
}

From source file:com.liferay.nativity.test.TestDriver.java

private static void _enableFileIcons(FileIconControl fileIconControl) {
    fileIconControl.enableFileIcons();/*from w ww .jav a 2s .  co m*/

    try {
        Thread.sleep(_waitTime);
    } catch (InterruptedException e) {
        _logger.error(e.getMessage(), e);
    }
}

From source file:com.liferay.nativity.test.TestDriver.java

private static void _registerFileIcon(FileIconControl fileIconControl) {
    fileIconControl.registerIconWithId(_fileIconPath, "", Integer.toString(_fileIconId));

    try {//from   w w w . ja v  a2 s  .com
        Thread.sleep(_waitTime);
    } catch (InterruptedException e) {
        _logger.error(e.getMessage(), e);
    }
}

From source file:com.liferay.nativity.test.TestDriver.java

private static void _setFilterPath(NativityControl nativityControl) {
    nativityControl.setFilterFolder(_testRootFolder);

    try {/*from   w  ww. j  av  a 2s.c o  m*/
        Thread.sleep(_waitTime);
    } catch (InterruptedException e) {
        _logger.error(e.getMessage(), e);
    }
}

From source file:com.liferay.nativity.test.TestDriver.java

private static void _setSystemFolder(NativityControl nativityControl) {
    nativityControl.setSystemFolder(_testRootFolder);

    try {// w  w  w .  jav  a  2  s .c o  m
        Thread.sleep(_waitTime);
    } catch (InterruptedException e) {
        _logger.error(e.getMessage(), e);
    }
}

From source file:com.liferay.nativity.test.TestDriver.java

private static void _clearFileIcon(FileIconControl fileIconControl) {
    if (_list) {//from w  w  w. ja  va  2 s .  c  o  m
        String[] paths = new String[] { _testFolder, _testFile };

        fileIconControl.removeFileIcons(paths);
    } else {
        fileIconControl.removeFileIcon(_testFolder);
    }

    try {
        Thread.sleep(_waitTime);
    } catch (InterruptedException e) {
        _logger.error(e.getMessage(), e);
    }
}

From source file:com.liferay.nativity.test.TestDriver.java

private static void _updateFileIcon(FileIconControl fileIconControl) {
    if (_list) {/*ww w.j  av a  2 s . c o  m*/
        Map<String, Integer> map = new HashMap<String, Integer>();

        map.put(_testFolder, _fileIconId);
        map.put(_testFile, _fileIconId);

        fileIconControl.setFileIcons(map);
    } else {
        fileIconControl.setFileIcon(_testFolder, _fileIconId);
    }

    try {
        Thread.sleep(_waitTime);
    } catch (InterruptedException e) {
        _logger.error(e.getMessage(), e);
    }
}