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.cloudbees.plugins.deployer.impl.run.RunEngineImpl.java

@Override
public void validate(FilePath applicationFile) throws DeployException {
    try {/*ww  w .  j av a2 s. c  o  m*/
        if (!Boolean.TRUE.equals(applicationFile.act(new IsFileCallable()))) {
            throw new DeployException("Not a valid archive for deployment: " + applicationFile);
        }
    } catch (InterruptedException e) {
        throw new DeployException(e.getMessage(), e);
    } catch (IOException e) {
        throw new DeployException(e.getMessage(), e);
    }
}

From source file:ch.cyberduck.core.s3.S3MultipartCopyFeature.java

@Override
protected void copy(final Path source, final S3Object destination, final TransferStatus status)
        throws BackgroundException {
    try {//from  w ww.  j ava  2  s .c  om
        final List<MultipartPart> completed = new ArrayList<MultipartPart>();
        // ID for the initiated multipart upload.
        final MultipartUpload multipart = session.getClient().multipartStartUpload(destination.getBucketName(),
                destination);
        if (log.isDebugEnabled()) {
            log.debug(String.format("Multipart upload started for %s with ID %s", multipart.getObjectKey(),
                    multipart.getUploadId()));
        }
        final long size = status.getLength();
        long remaining = size;
        long offset = 0;
        final List<Future<MultipartPart>> parts = new ArrayList<Future<MultipartPart>>();
        for (int partNumber = 1; remaining > 0; partNumber++) {
            // Last part can be less than 5 MB. Adjust part size.
            final Long length = Math.min(
                    Math.max((size / S3DefaultMultipartService.MAXIMUM_UPLOAD_PARTS), partsize), remaining);
            // Submit to queue
            parts.add(this.submit(source, multipart, partNumber, offset, length));
            remaining -= length;
            offset += length;
        }
        for (Future<MultipartPart> future : parts) {
            try {
                completed.add(future.get());
            } catch (InterruptedException e) {
                log.error("Part upload failed with interrupt failure");
                throw new ConnectionCanceledException(e);
            } catch (ExecutionException e) {
                log.warn(String.format("Part upload failed with execution failure %s", e.getMessage()));
                if (e.getCause() instanceof BackgroundException) {
                    throw (BackgroundException) e.getCause();
                }
                throw new BackgroundException(e.getCause());
            }
        }
        // Combining all the given parts into the final object. Processing of a Complete Multipart Upload request
        // could take several minutes to complete. Because a request could fail after the initial 200 OK response
        // has been sent, it is important that you check the response body to determine whether the request succeeded.
        final MultipartCompleted complete = session.getClient().multipartCompleteUpload(multipart, completed);
        if (log.isDebugEnabled()) {
            log.debug(String.format("Completed multipart upload for %s with checksum %s",
                    complete.getObjectKey(), complete.getEtag()));
        }
    } catch (ServiceException e) {
        throw new S3ExceptionMappingService().map("Cannot copy {0}", e, source);
    } finally {
        pool.shutdown(false);
    }
}

From source file:hws.core.ExecutorThread.java

public void run(String[] args) throws IOException, ClassNotFoundException, InstantiationException,
        IllegalAccessException, ParseException {
    Options options = new Options();
    options.addOption(OptionBuilder.withLongOpt("app-id").withDescription("String of the Application Id")
            .hasArg().withArgName("AppId").create("aid"));
    options.addOption(OptionBuilder.withLongOpt("container-id").withDescription("String of the Container Id")
            .hasArg().withArgName("ContainerId").create("cid"));
    options.addOption(OptionBuilder.withLongOpt("load").withDescription("load module instance").hasArg()
            .withArgName("Json-Base64").create());
    options.addOption(OptionBuilder.withLongOpt("zk-servers").withDescription("List of the ZooKeeper servers")
            .hasArgs().withArgName("zkAddrs").create("zks"));
    CommandLineParser parser = new BasicParser();
    CommandLine cmd = parser.parse(options, args);

    String appIdStr = null;//from  w ww .ja v a2  s . c om
    String containerIdStr = null;
    String instanceInfoBase64 = null;
    String instanceInfoJson = null;
    InstanceInfo instanceInfo = null;

    if (cmd.hasOption("aid")) {
        appIdStr = cmd.getOptionValue("aid");
    }
    if (cmd.hasOption("cid")) {
        containerIdStr = cmd.getOptionValue("cid");
    }
    String zksArgs = "";
    String[] zkServers = null;
    if (cmd.hasOption("zks")) {
        zksArgs = "-zks";
        zkServers = cmd.getOptionValues("zks");
        for (String zks : zkServers) {
            zksArgs += " " + zks;
        }
    }

    //Logger setup
    Configuration conf = new Configuration();
    FileSystem fileSystem = FileSystem.get(conf);
    FSDataOutputStream writer = fileSystem
            .create(new Path("hdfs:///hws/apps/" + appIdStr + "/logs/" + containerIdStr + ".log"));
    Logger.addOutputStream(writer);

    Logger.info("Processing Instance");

    if (cmd.hasOption("load")) {
        instanceInfoBase64 = cmd.getOptionValue("load");
        instanceInfoJson = StringUtils.newStringUtf8(Base64.decodeBase64(instanceInfoBase64));
        instanceInfo = Json.loads(instanceInfoJson, InstanceInfo.class);
    }

    Logger.info("Instance info: " + instanceInfoJson);

    this.latch = new CountDownLatch(instanceInfo.inputChannels().keySet().size());
    Logger.info("Latch Countdowns: " + instanceInfo.inputChannels().keySet().size());

    ZkClient zk = new ZkClient(zkServers[0]); //TODO select a ZooKeeper server

    Logger.info("Load Instance " + instanceInfo.instanceId());
    loadInstance(instanceInfo, zk, "/hadoop-watershed/" + appIdStr + "/");

    IZkChildListener producersHaltedListener = createProducersHaltedListener();
    String znode = "/hadoop-watershed/" + appIdStr + "/" + instanceInfo.filterInfo().name() + "/halted";
    Logger.info("halting znode: " + znode);
    zk.subscribeChildChanges(znode, producersHaltedListener);

    ExecutorService serverExecutor = Executors.newCachedThreadPool();

    //wait for a start command from the ApplicationMaster via ZooKeeper
    znode = "/hadoop-watershed/" + appIdStr + "/" + instanceInfo.filterInfo().name() + "/start";
    Logger.info("starting znode: " + znode);
    zk.waitUntilExists(znode, TimeUnit.MILLISECONDS, 250);
    Logger.info("Exists: " + zk.exists(znode));
    /*
    while(!zk.waitUntilExists(znode,TimeUnit.MILLISECONDS, 500)){
       //out.println("TIMEOUT waiting for start znode: "+znode);
       //out.flush();
    }*/
    //start and execute this instance
    Logger.info("Starting Instance");
    startExecutors(serverExecutor);
    Logger.info("Instance STARTED");

    Logger.info("Waiting TERMINATION");

    try {
        this.latch.await(); //await the input threads to finish
    } catch (InterruptedException e) {
        // handle
        Logger.severe("Waiting ERROR: " + e.getMessage());
    }

    Logger.info("Finishing Instance");
    finishExecutors();
    Logger.info("FINISHED Instance " + instanceInfo.instanceId());
    String finishZnode = "/hadoop-watershed/" + appIdStr + "/" + instanceInfo.filterInfo().name() + "/finish/"
            + instanceInfo.instanceId();
    zk.createPersistent(finishZnode, "");
}

From source file:com.ottogroup.bi.spqr.pipeline.component.emitter.EmitterRuntimeEnvironment.java

/**
 * @see java.lang.Runnable#run()/*from  www  . j a va2  s . c o m*/
 */
public void run() {

    // fetch the wait strategy attached to the queue (provided through the queue consumer)
    StreamingMessageQueueWaitStrategy queueWaitStrategy = this.queueConsumer.getWaitStrategy();
    while (running) {

        try {
            // fetch message from queue consumer via strategy
            StreamingDataMessage message = queueWaitStrategy.waitFor(this.queueConsumer);
            if (message != null && message.getBody() != null) {

                @SuppressWarnings("resource") // context#close() calls context#stop -> avoid additional call, thus accept warning
                Timer.Context timerContext = (this.messageEmitDurationTimer != null
                        ? this.messageEmitDurationTimer.time()
                        : null);

                this.emitter.onMessage(message);

                if (timerContext != null)
                    timerContext.stop();

                if (this.messageCounter != null)
                    this.messageCounter.inc();
            }

        } catch (InterruptedException e) {
            // do nothing - waiting was interrupted            
        } catch (Exception e) {
            logger.error("processing error [node=" + this.processingNodeId + ", pipeline=" + this.pipelineId
                    + ", emitter=" + this.emitterId + "]: " + e.getMessage(), e);
            // TODO add handler for responding to errors
        }
    }
}

From source file:edu.ucsb.eucalyptus.transport.http.Axis2HttpWorker.java

public void service(final AxisHttpRequest request, final AxisHttpResponse response,
        final MessageContext msgContext) throws HttpException, IOException {

    ConfigurationContext configurationContext = msgContext.getConfigurationContext();
    final String servicePath = configurationContext.getServiceContextPath();
    final String contextPath = (servicePath.startsWith("/") ? servicePath : "/" + servicePath) + "/";

    String uri = request.getRequestURI();
    String method = request.getMethod();
    String soapAction = HttpUtils.getSoapAction(request);
    Handler.InvocationResponse pi = null;
    msgContext.setProperty(REAL_HTTP_REQUEST, request);
    msgContext.setProperty(REAL_HTTP_RESPONSE, response);

    Header[] headers = request.getHeaders(HTTP.CONTENT_LEN);
    if (headers != null && headers.length > 0) {
        String contentLength = headers[0].getValue();
        msgContext.setProperty(HTTP.CONTENT_LEN, contentLength);
    }//  ww w  . j a v a  2s.co m

    if (method.equals(HTTPConstants.HEADER_GET)) {
        if ((uri.startsWith("/latest/") || uri.matches("/\\d\\d\\d\\d-\\d\\d-\\d\\d/.*"))
                && handleMetaData(response, msgContext, uri))
            return;
        if (!uri.startsWith(contextPath)) {
            response.setStatus(HttpStatus.SC_MOVED_PERMANENTLY);
            response.addHeader(new BasicHeader("Location", (contextPath + uri).replaceAll("//", "/")));
            return;
        }
        if (uri.endsWith("services/")) {
            handleServicesList(response, configurationContext);
            return;
        }
        if (uri.endsWith("?wsdl")) {
            handleWSDL(response);
            return;
        }
        pi = handleGet(request, response, msgContext);
    } else if (method.equals(HTTPConstants.HEADER_POST)) {
        String contentType = request.getContentType();
        if (HTTPTransportUtils.isRESTRequest(contentType))
            pi = Axis2HttpWorker.processXMLRequest(msgContext, request.getInputStream(),
                    response.getOutputStream(), contentType);
        else {
            String ip = (String) msgContext.getProperty(MessageContext.TRANSPORT_ADDR);
            if (ip != null)
                uri = ip + uri;
            pi = HTTPTransportUtils.processHTTPPostRequest(msgContext, request.getInputStream(),
                    response.getOutputStream(), contentType, soapAction, uri);
        }
    } else if (method.equals(HTTPConstants.HEADER_PUT)) {
        String contentType = request.getContentType();
        msgContext.setProperty(Constants.Configuration.CONTENT_TYPE, contentType);

        pi = Axis2HttpWorker.processXMLRequest(msgContext, request.getInputStream(), response.getOutputStream(),
                contentType);
    } else if (method.equals(HTTPConstants.HEADER_DELETE))
        pi = Axis2HttpWorker.processURLRequest(msgContext, response.getOutputStream(), null);
    else if (method.equals("HEAD"))
        pi = Axis2HttpWorker.processURLRequest(msgContext, response.getOutputStream(), null);
    else
        throw new MethodNotSupportedException(method + " method not supported");

    Boolean holdResponse = (Boolean) msgContext.getProperty(RequestResponseTransport.HOLD_RESPONSE);
    if (pi.equals(Handler.InvocationResponse.SUSPEND)
            || (holdResponse != null && Boolean.TRUE.equals(holdResponse)))
        try {
            ((RequestResponseTransport) msgContext.getProperty(RequestResponseTransport.TRANSPORT_CONTROL))
                    .awaitResponse();
        } catch (InterruptedException e) {
            throw new IOException("We were interrupted, so this may not function correctly:" + e.getMessage());
        }
    RequestResponseTransport requestResponseTransportControl = (RequestResponseTransport) msgContext
            .getProperty(RequestResponseTransport.TRANSPORT_CONTROL);
    if (TransportUtils.isResponseWritten(msgContext)
            || ((requestResponseTransportControl != null) && requestResponseTransportControl.getStatus()
                    .equals(RequestResponseTransport.RequestResponseTransportStatus.SIGNALLED)))
        ;
    else
        response.setStatus(HttpStatus.SC_ACCEPTED);
    Integer status = (Integer) msgContext.getProperty(HTTP_STATUS);
    if (status != null)
        response.setStatus(status);
}

From source file:com.yahoo.gondola.container.impl.ZookeeperShardManagerServer.java

private void writeStat(Integer memberId, ZookeeperStat zookeeperStat) {
    trace("[{}-{}] Update stat stat={}", gondola.getHostId(), memberId, zookeeperStat);
    try {// w w w. j a  v  a2s  .co m
        client.setData().forPath(ZookeeperUtils.statPath(serviceName, memberId),
                objectMapper.writeValueAsBytes(zookeeperStat));
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    } catch (Exception e) {
        logger.warn("[{}-{}] Write stat failed, reason={}", gondola.getHostId(), memberId, e.getMessage());
    }
}

From source file:com.aurel.track.admin.server.dbbackup.DatabaseBackupAction.java

/**
 * Start the backup background thread//  w w w .  j a  v  a  2  s. c  o m
 * @return
 */
public String backup() {
    loadFirst = false;
    errors = new ArrayList<LabelValueBean>();
    ApplicationBean.getInstance().setBackupErrors(errors); // reset error list

    ApplicationBean appBean = ApplicationBean.getInstance();
    synchronized (appBean) {
        if (appBean.isBackupInProgress()) {
            errors.add(new LabelValueBean(getText("admin.server.databaseBackup.error.backupInProgress"), ""));
            backupSuccess = false;
            return createResponse();
        }
        appBean.setBackupInProgress(true);

        BackupThread backupThread;
        if (!sendNotifyEmail) {
            backupThread = new BackupThread(appBean, backupName, includeAttachments);
        } else {
            Locale locale = (Locale) session.get(Constants.LOCALE_KEY);
            TPersonBean person = (TPersonBean) session.get(Constants.USER_KEY);
            StringBuilder messageBody = new StringBuilder();
            messageBody.append(getText("admin.server.databaseBackup.lbl.backupSuccessfully"));
            messageBody.append("\n\n");
            messageBody.append(getText("admin.server.databaseBackup.lbl.backupName")).append(":");
            messageBody.append(" ").append(backupName).append(".zip").append("\n\n");
            messageBody.append(getText("admin.server.databaseBackup.lbl.includeAttachments")).append(":");
            messageBody.append(" ").append(includeAttachments).append("\n\n");

            backupThread = new BackupThread(appBean, backupName, includeAttachments, person, locale,
                    messageBody);
        }

        // Catch early errors
        Object monitor = new Object();
        try {
            new Thread(backupThread).start();
            boolean backupIsRunning = !backupThread.isDone();
            int i = 0;

            synchronized (monitor) {
                while (backupIsRunning && i < 5) {
                    ++i;
                    monitor.wait(1000);
                    backupIsRunning = !backupThread.isDone();
                }
            }
        } catch (InterruptedException ie) {
            LOGGER.error(ie.getMessage());
        }

        backupSuccess = ApplicationBean.getInstance().getBackupErrors() == null
                || ApplicationBean.getInstance().getBackupErrors().isEmpty();
        prepare();
        return createResponse();
    }
}

From source file:com.boundlessgeo.geoserver.api.controllers.ThumbnailController.java

/**
 * Clears any cached thumbnail information (called by {@link ThumbnailInvalidatingCatalogListener} when a layer is removed).
 * //from ww  w.j  av a2  s.  c  o m
 * @param layer
 * @throws InterruptedException 
 */
public void clearThumbnail(PublishedInfo layer) {
    Semaphore s = semaphores.get(layer);
    try {
        s.acquire();
    } catch (InterruptedException e) {
        LOG.finer("Unable to clear thumbnail for " + layer.prefixedName() + ":" + e.getMessage());
        return;
    }
    try {
        File loRes = config.cacheFile(thumbnailFilename(layer));
        if (loRes.exists()) {
            boolean removed = loRes.delete();
            if (!removed) {
                loRes.deleteOnExit();
            }
        }
        File hiRes = config.cacheFile(thumbnailFilename(layer, true));
        if (hiRes.exists()) {
            boolean removed = hiRes.delete();
            if (!removed) {
                hiRes.deleteOnExit();
            }
        }
    } finally {
        s.release();
    }
}

From source file:org.obiba.mica.search.JoinQueryExecutor.java

private boolean acquireSemaphorePermit() {
    try {/* ww w . j a v a  2 s .c om*/
        return esJoinQueriesSemaphore.tryAcquire(concurrentJoinQueriesWaitTimeout, TimeUnit.MILLISECONDS);
    } catch (InterruptedException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}

From source file:com.fluidops.iwb.deepzoom.ImageLoader.java

public void loadAllImages(Repository rep, URI img, String collection) {

    List<Statement> images = null;
    /* try/* w  ww  . j a  v a 2s .  c om*/
    {
    con = WikiServlet.repository.getConnection();
            
    images = con.getStatements(null, Vocabulary.DEPICTION, null, false).asList();
    }
    catch (RepositoryException e)
    {
    logger.error(e.getMessage(), e);
    }
    for(Statement s:images)
    {*/

    try {
        RepositoryConnection con = rep.getConnection();
        TupleQuery q = null;
        try {
            q = con.prepareTupleQuery(QueryLanguage.SPARQL,
                    "SELECT ?uri ?img { ?uri <http://dbpedia.org/ontology/thumbnail> ?img }");

            TupleQueryResult res = q.evaluate();
            int rowCounter = 0;
            while (res.hasNext()) {

                BindingSet stmt = res.next();

                String imgURL = stmt.getBinding("img").getValue().stringValue();
                URI uri = (URI) stmt.getBinding("uri").getValue();
                if (threadCounter > 50)
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        logger.error(e.getMessage(), e);
                    }
                Loader t = new Loader(uri, null, imgURL, collection);
                t.start();
                threadCounter++;
            }

        } finally {
            con.close();
        }
    } catch (RuntimeException e) {
        logger.error(e.getMessage(), e);
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}