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:org.apache.kylin.engine.mr.common.HadoopStatusGetter.java

private String getHttpResponseWithKerberosAuth(String url) throws IOException {
    String krb5ConfigPath = System.getProperty("java.security.krb5.conf");
    if (krb5ConfigPath == null) {
        krb5ConfigPath = DEFAULT_KRB5_CONFIG_LOCATION;
    }//  ww  w.  j a  v a 2 s  .c o m
    boolean skipPortAtKerberosDatabaseLookup = true;
    System.setProperty("java.security.krb5.conf", krb5ConfigPath);
    System.setProperty("sun.security.krb5.debug", "true");
    System.setProperty("javax.security.auth.useSubjectCredsOnly", "false");

    DefaultHttpClient client = new DefaultHttpClient();
    AuthSchemeRegistry authSchemeRegistry = new AuthSchemeRegistry();
    authSchemeRegistry.register(AuthPolicy.SPNEGO, new SPNegoSchemeFactory(skipPortAtKerberosDatabaseLookup));
    client.setAuthSchemes(authSchemeRegistry);

    BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    Credentials useJaasCreds = new Credentials() {
        public String getPassword() {
            return null;
        }

        public Principal getUserPrincipal() {
            return null;
        }
    };
    credentialsProvider.setCredentials(new AuthScope(null, -1, null), useJaasCreds);
    client.setCredentialsProvider(credentialsProvider);

    String response = null;
    while (response == null) {
        if (url.startsWith("https://")) {
            registerEasyHttps();
        }
        if (url.contains("anonymous=true") == false) {
            url += url.contains("?") ? "&" : "?";
            url += "anonymous=true";
        }
        HttpGet httpget = new HttpGet(url);
        httpget.addHeader("accept", "application/json");
        try {
            HttpResponse httpResponse = client.execute(httpget);
            String redirect = null;
            org.apache.http.Header h = httpResponse.getFirstHeader("Location");
            if (h != null) {
                redirect = h.getValue();
                if (isValidURL(redirect) == false) {
                    logger.info("Get invalid redirect url, skip it: " + redirect);
                    Thread.sleep(1000L);
                    continue;
                }
            } else {
                h = httpResponse.getFirstHeader("Refresh");
                if (h != null) {
                    String s = h.getValue();
                    int cut = s.indexOf("url=");
                    if (cut >= 0) {
                        redirect = s.substring(cut + 4);

                        if (isValidURL(redirect) == false) {
                            logger.info("Get invalid redirect url, skip it: " + redirect);
                            Thread.sleep(1000L);
                            continue;
                        }
                    }
                }
            }

            if (redirect == null) {
                response = IOUtils.toString(httpResponse.getEntity().getContent(), Charset.defaultCharset());
                logger.debug("Job " + mrJobId + " get status check result.\n");
            } else {
                url = redirect;
                logger.debug("Job " + mrJobId + " check redirect url " + url + ".\n");
            }
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            logger.error(e.getMessage());
        } finally {
            httpget.releaseConnection();
        }
    }

    return response;
}

From source file:net.sf.jcprogress.ProgressThread.java

@Override
public void run() {
    if (!System.getProperty("net.jcprogress.disable", "false").equalsIgnoreCase("true")) {
        try {//from   ww w . ja  v a 2s  . c o m
            while (!askedToStop) {
                update(false);
                sleep(100);
            }

            update(true); //chance to show 100%, if finished
        } catch (InterruptedException e) {
            logger.error("run() - interrupted: " + e.getMessage()); //$NON-NLS-1$
        }

        afterLastInvoking();
    }
}

From source file:co.turnus.analysis.pipelining.SimplePipelining.java

@Override
public SimplePipelingData run() {
    // check if the trace should be loaded
    initTrace();//from w  ww  .  j  a  v a  2  s  .  co  m

    Trace trace = traceProject.getTrace();
    long traceSize = trace.getLength();

    // launch the thread status printer
    ProgressTheadPrinter progressPrinter = new ProgressTheadPrinter("Trace Graph post-processing", traceSize);
    progressPrinter.start();

    // init the actors data
    for (ActorData d : actorsData.values()) {
        d.initData();
    }

    // start the trace analysis
    for (long stepId = 0; stepId < traceSize; stepId++) {
        Step step = trace.getStep(stepId);
        Pair<Actor, Action> pair = traceDecorator.getActorActionPair(step);
        actorsData.get(pair.getA()).addFiring(pair, step.getIncomings());
        progressPrinter.increment();
    }

    // end the analysis
    for (ActorData d : actorsData.values()) {
        d.endAnalysis();
    }

    // stop the progress monitor
    try {
        progressPrinter.finish();
        progressPrinter.join();
    } catch (InterruptedException e) {
        TurnusLogger.warning("Progress monitor stopping error: " + e.getMessage());
    }

    return collectResults();
}

From source file:ai.grakn.client.LoaderClient.java

/**
 * Wait for all of the submitted tasks to have been completed
 *///  w ww .  j  a  v  a 2s  .c  o m
public void waitToFinish() {
    flush();
    while (!futures.values().stream().allMatch(CompletableFuture::isDone)
            && blocker.availablePermits() != blockerSize) {
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            LOG.error(e.getMessage());
        }
    }
}

From source file:net.sf.jcprogress.ProgressThread.java

/**
 * ask to stop and wait until stopped./*from ww  w.j  av a2 s .c  o  m*/
 */
public void waitToStop() {
    try {
        askToStop();
        while (isAlive()) {
            sleep(100);
        }
    } catch (InterruptedException e) {
        logger.error("waitToStop() - interrupted exception: " + e.getMessage()); //$NON-NLS-1$
    }
}

From source file:com.emobc.android.activities.generators.FormActivityGenerator.java

/**
 * Check the contents of a web address to add new data to existing 
 * app.xml file. Then, it goes to the next level.
 * @param activity//from w  ww  .j  av  a  2  s.  com
 */
protected void processSubmit(Activity activity) {
    try {
        List<NameValuePair> parameters = createParameters();
        try {
            URL url = new URL(item.getActionUrl());

            RetreiveFileContentTask task = new RetreiveFileContentTask(parameters, true);
            task.execute(url);
            try {
                String text = task.get();

                ApplicationData.mergeAppDataFromString(activity, text);

                showNextLevel(activity, item.getNextLevel());
            } catch (InterruptedException e) {
                Log.e("FormActivityGenerator: InterruptedException: ", e.getMessage());
            } catch (ExecutionException e) {
                Log.e("FormActivityGenerator: ExecutionException: ", e.getMessage());
            }
        } catch (MalformedURLException e1) {
        }
    } catch (final RequiredFieldException e) {
        final AlertDialog.Builder dlg = new AlertDialog.Builder(activity);
        dlg.setTitle(R.string.form_level_title);
        dlg.setMessage(R.string.form_level_alert_required_fields);
        dlg.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                View view = controlsMap.get(e.getDataItem().getFieldName());
                view.requestFocus();
            }
        });
        dlg.show();
    }
}

From source file:com.ottogroup.bi.spqr.operator.webtrends.source.WebtrendStreamSource.java

/**
 * @see java.lang.Runnable#run()/*from   ww w  .  ja  v a  2 s  .  com*/
 */
public void run() {
    if (logger.isDebugEnabled())
        logger.debug("webtrends stream consumer initialized [id=" + id + "]");

    // keep on consuming until either the consumer or the client is interrupted  
    while (this.isRunning && this.websocketSession.isOpen()) {
        try {
            String msg = streamMessageQueue.poll(100, TimeUnit.MILLISECONDS);
            if (msg != null) {
                this.incomingMessageCallback
                        .onMessage(new StreamingDataMessage(msg.getBytes(), System.currentTimeMillis()));
                this.messageCount++;
            }

        } catch (InterruptedException e) {
            logger.error("Failed to read data from websocket. Error: " + e.getMessage());
        }
    }

    shutdown();

    logger.info("webtrends stream consumer received " + this.messageCount + " messages");
}

From source file:edu.usf.cutr.fdot7.main.Test.java

/**
 * Constructor of the main program. We use this to avoid static variable
 *//*from w  w w .j  a v  a2  s . co m*/
public Test() {
    //initialize logger
    org.apache.log4j.BasicConfigurator.configure();

    _log.info("Please log-in to upload data.");
    SessionForm sf = new SessionForm();

    sf.showDialog();
    try {
        mutex.acquire();
    } catch (InterruptedException ie) {
        _log.error(ie.getMessage());
    }

    sf.dispose();

    if (mainUsername == null || mainPassword == null) {
        _log.error("You must log-in sucessfully before continuing.");
        _log.info("Exit Program!");
        System.exit(0);
    }

    boolean isInputError = false;
    HashSet<String> errorFeeds = new HashSet<String>();
    ArrayList<AgencyInfo> ais = new ArrayList<AgencyInfo>();
    ArrayList<ArrayList<GenericGtfsData>> gtfsAgenciesData = new ArrayList<ArrayList<GenericGtfsData>>();
    _log.info("Reading 'AgencyInfo.csv'");
    ais.addAll(readAgencyInfo(
            System.getProperty("user.dir") + System.getProperty("file.separator") + "AgencyInfo.csv"));
    _log.info(ais.size() + " GTFS feeds to be processed.");

    factory = new XmlBeanFactory(new FileSystemResource(
            System.getProperty("user.dir") + System.getProperty("file.separator") + "data-source.xml"));

    for (int i = 0; i < ais.size(); i++) {
        AgencyInfo ai = ais.get(i);
        try {
            ArrayList<GenericGtfsData> gtfsAgencyData = new ArrayList<GenericGtfsData>();
            gtfsAgencyData.addAll(getDataFromAgency(ai));
            gtfsAgenciesData.add(gtfsAgencyData);
        } catch (IOException e) {
            errorFeeds.add(ai.getName());
            _log.error("Error reading input from " + ai.getName());
            _log.error(e.getMessage());
            isInputError = true;
            continue;
        }
    }

    if (!isInputError) {
        _log.info("Complete checking and reading " + ais.size() + " GTFS feeds.");
        _log.info("Start to upload data.");
        uploadAgenciesData(gtfsAgenciesData, mainUsername, mainPassword);
    } else {
        _log.info("Please check agency dataset from " + errorFeeds.toString()
                + " again! No data will be uploaded.");
    }
}

From source file:gridool.mapred.dht.task.DhtMapShuffleTask.java

private void invokeShuffle(final ArrayQueue<byte[]> queue) {
    assert (kernel != null);

    final ArrayQueue<byte[]> records = hasCombiner() ? combine(queue) : queue;

    if (collectOutputKeys()) {
        shuffleAndCollectKeys(records);//from w w w.jav  a  2s . c om
        return;
    }

    final AddOperation ops = new AddOperation(destTableName);
    ops.setMaxNumReplicas(0);
    final int size = records.size();
    for (int i = 0; i < size; i += 2) {
        byte[] k = records.get(i);
        byte[] v = records.get(i + 1);
        ops.addMapping(k, v);
    }

    shuffleExecPool.execute(new Runnable() {
        public void run() {
            final GridJobFuture<Serializable> future = kernel.execute(DirectoryAddJob.class, ops);
            try {
                future.get(); // wait for execution
            } catch (InterruptedException ie) {
                LOG.error(ie.getMessage(), ie);
            } catch (ExecutionException ee) {
                LOG.error(ee.getMessage(), ee);
            }
        }
    });
}

From source file:com.ottogroup.bi.asap.operator.webtrends.consumer.WebtrendsStreamsConsumer.java

/**
 * @see java.lang.Runnable#run()/* w ww .  j av  a 2s .  c om*/
 */
public void run() {
    if (logger.isDebugEnabled())
        logger.debug("twitter stream consumer initialized [id=" + componentId + "]");

    // keep on consuming until either the consumer or the client is interrupted  
    while (this.isRunning && this.websocketSession.isOpen()) {
        try {
            String msg = streamMessageQueue.poll(100, TimeUnit.MILLISECONDS);
            if (msg != null) {
                this.mailbox
                        .insert(new StreamingDataMessage(this.componentId, msg, System.currentTimeMillis()));
                // TODO back pressure handling
                this.numProcessedMessages++;
            }

        } catch (InterruptedException e) {
            logger.error("Failed to read data from websocket. Error: " + e.getMessage());
        }
    }

    shutdown();

    logger.info("webtrends stream consumer received " + this.numProcessedMessages + " messages");

}