Example usage for java.io IOException toString

List of usage examples for java.io IOException toString

Introduction

In this page you can find the example usage for java.io IOException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.intuit.tank.harness.AmazonUtil.java

/**
 * gets if we are using EIP from user data
 * //from   w  ww .j  av  a  2 s . c  om
 * @return
 */
public static boolean usingEip() {
    boolean ret = false;
    try {
        ret = getUserDataAsMap().get(TankConstants.KEY_USING_BIND_EIP) != null;
    } catch (IOException e) {
        LOG.warn("Error getting is using EIP: " + e.toString());
    }
    return ret;
}

From source file:com.intuit.tank.harness.AmazonUtil.java

/**
 * gets the project name for user data//from www.j a  v a2s. c  om
 * 
 * @return
 */
public static String getProjectName() {
    String ret = null;
    try {
        ret = getUserDataAsMap().get(TankConstants.KEY_PROJECT_NAME);
    } catch (IOException e) {
        LOG.warn("Error getting Project  Name: " + e.toString());
    }
    return ret != null ? ret : "unknown";
}

From source file:com.intuit.tank.harness.AmazonUtil.java

/**
 * gewts controller base form user data/*from w  w w . ja va  2s .c  om*/
 * 
 * @return
 */
public static String getControllerBaseUrl() {
    String ret = null;
    try {
        ret = getUserDataAsMap().get(TankConstants.KEY_CONTROLLER_URL);
    } catch (IOException e) {
        LOG.warn("Error getting controller url: " + e.toString());
    }
    return ret != null ? ret : "http://localhost:8080/";
}

From source file:de.adesso.referencer.search.helper.ElasticConfig.java

public static String sendBulkHttpRequest(String requestBody) {
    String reply;/*w  w  w  . j a v  a 2 s. c  o  m*/
    try {
        reply = ElasticConfig.sendHttpRequest(ElasticConfig.bulkURL(), requestBody, "Post");
    } catch (IOException ex) {
        reply = "Http Error" + ex.toString();
    }
    return reply;
}

From source file:com.uber.hoodie.hive.TestUtil.java

@SuppressWarnings({ "unchecked", "deprecation" })
private static void generateParquetData(Path filePath, boolean isParquetSchemaSimple)
        throws IOException, URISyntaxException, InterruptedException {
    Schema schema = (isParquetSchemaSimple ? SchemaTestUtil.getSimpleSchema()
            : SchemaTestUtil.getEvolvedSchema());
    org.apache.parquet.schema.MessageType parquetSchema = new AvroSchemaConverter().convert(schema);
    BloomFilter filter = new BloomFilter(1000, 0.0001);
    HoodieAvroWriteSupport writeSupport = new HoodieAvroWriteSupport(parquetSchema, schema, filter);
    ParquetWriter writer = new ParquetWriter(filePath, writeSupport, CompressionCodecName.GZIP,
            120 * 1024 * 1024, ParquetWriter.DEFAULT_PAGE_SIZE, ParquetWriter.DEFAULT_PAGE_SIZE,
            ParquetWriter.DEFAULT_IS_DICTIONARY_ENABLED, ParquetWriter.DEFAULT_IS_VALIDATING_ENABLED,
            ParquetWriter.DEFAULT_WRITER_VERSION, fileSystem.getConf());

    List<IndexedRecord> testRecords = (isParquetSchemaSimple ? SchemaTestUtil.generateTestRecords(0, 100)
            : SchemaTestUtil.generateEvolvedTestRecords(100, 100));
    testRecords.forEach(s -> {//from w w  w  . j  a va2 s . co m
        try {
            writer.write(s);
        } catch (IOException e) {
            fail("IOException while writing test records as parquet" + e.toString());
        }
    });
    writer.close();
}

From source file:com.cisco.oss.foundation.message.RabbitMQMessagingFactory.java

static Channel getChannel() {
    try {// w ww.j  a  v  a2s. co m
        if (channelThreadLocal.get() == null) {
            if (connection != null) {
                Channel channel = connection.createChannel();
                channelThreadLocal.set(channel);
                channels.put(channel.getChannelNumber(), channel);
            } else {
                throw new QueueException("RabbitMQ appears to be down. Please try again later.");
            }
        }

        return channelThreadLocal.get();
    } catch (IOException e) {
        throw new QueueException("can't create channel: " + e.toString(), e);
    }

}

From source file:io.github.retz.mesosc.MesosHTTPFetcher.java

public static List<Map<String, Object>> fetchTasks(String master, String frameworkId, int offset, int limit)
        throws MalformedURLException {
    String addr = "http://" + master + "/tasks?offset=" + offset + "&limit=" + limit;
    try (UrlConnector conn = new UrlConnector(addr, "GET", true)) {
        return parseTasks(conn.getInputStream(), frameworkId);
    } catch (IOException e) {
        LOG.error(e.toString(), e);
        return Collections.emptyList();
    }/*from   w w w  .jav  a2 s  .c o m*/
}

From source file:com.nuvolect.deepdive.util.OmniUtil.java

public static boolean writeFile(OmniFile file, String fileContents) {

    boolean success = true;
    try {/*  w  ww. j ava  2s  . co m*/
        OutputStream out = null;

        OmniUtil.forceMkdirParent(file);

        out = new BufferedOutputStream(new FileOutputStream(file.getStdFile()));

        out.write(fileContents.getBytes());

        if (out != null)
            out.close();
    } catch (IOException e) {
        LogUtil.log(OmniUtil.class, "File write failed: " + e.toString());
        success = false;
    }
    return success;
}

From source file:io.github.retz.web.JobRequestHandler.java

static String getDir(spark.Request req, spark.Response res) throws JsonProcessingException {
    Optional<Job> job;/*ww w.j av a2  s .  c  om*/
    try {
        job = getJobAndVerify(req);
    } catch (IOException e) {
        return MAPPER.writeValueAsString(new ErrorResponse(e.toString()));
    }

    String path = req.queryParams("path");
    LOG.debug("get-path: path={}", path);
    res.type("application/json");

    // Translating default as SparkJava's router doesn't route '.' or empty string
    if (ListFilesRequest.DEFAULT_SANDBOX_PATH.equals(path)) {
        path = "";
    }

    List ret;
    if (job.isPresent() && job.get().url() != null) {
        try {
            Pair<Integer, String> maybeJson = MesosHTTPFetcher.fetchHTTPDir(job.get().url(), path);
            if (maybeJson.left() == 200) {
                ret = MAPPER.readValue(maybeJson.right(), new TypeReference<List<DirEntry>>() {
                });
            } else {
                return MAPPER.writeValueAsString(
                        new ErrorResponse(path + ":" + maybeJson.left() + " " + maybeJson.right()));
            }
        } catch (FileNotFoundException e) {
            res.status(404);
            LOG.warn("path {} not found", path);
            return MAPPER.writeValueAsString(new ErrorResponse(path + " not found"));
        } catch (IOException e) {
            return MAPPER.writeValueAsString(new ErrorResponse(e.toString()));
        }
    } else {
        ret = Arrays.asList();
    }

    ListFilesResponse listFilesResponse = new ListFilesResponse(job, ret);
    listFilesResponse.status("ok");
    return MAPPER.writeValueAsString(listFilesResponse);
}

From source file:erainformatica.utility.JSONHelper.java

public static TelegramRequestResult<JSONObject> readJsonFromUrl(String url, InputFile file) {
    CloseableHttpClient httpClient = HttpClients.createDefault();
    HttpPost uploadFile = new HttpPost(url);

    MultipartEntityBuilder builder = MultipartEntityBuilder.create();
    //builder.addTextBody("field1", "yes", ContentType.TEXT_PLAIN);
    builder.addBinaryBody(file.getName(), file.getFile_content(), ContentType.APPLICATION_OCTET_STREAM,
            file.getName() + "." + file.getExtension());
    HttpEntity multipart = builder.build();

    uploadFile.setEntity(multipart);//from w ww  .  j a va2  s .  c  o  m

    CloseableHttpResponse response = null;
    try {
        response = httpClient.execute(uploadFile);
    } catch (IOException ex) {
        Logger.getLogger(JSONHelper.class.getName()).log(Level.SEVERE, null, ex);
    }
    HttpEntity responseEntity = response.getEntity();

    try {
        return readJsonFromInputStream(responseEntity.getContent());
    } catch (Exception ex) {
        return new TelegramRequestResult<>(false, ex.toString(), null);
    }

}