Search in sources :

Example 31 with Exception

use of java.lang.Exception in project coprhd-controller by CoprHD.

the class Main method applyIpinfo.

private static void applyIpinfo(ClusterIpInfo ipinfo, String nodeid, int node_count, boolean bNewIp) throws Exception {
    log.info("applying ip info: {}", ipinfo.toString());
    String isoFilePath = "/tmp/ovf-env.iso";
    File isoFile = new File(isoFilePath);
    try {
        String tmpstr = PlatformUtils.genOvfenvPropertyKVString(ipinfo, nodeid, node_count);
        PlatformUtils.genOvfenvIsoImage(tmpstr, isoFilePath);
        String ovfenv_part = PlatformUtils.probeOvfenvPartition();
        Path path = Paths.get(isoFilePath);
        byte[] data = Files.readAllBytes(path);
        FileUtils.writePlainFile(ovfenv_part, data);
        log.info("Succeed to apply the ip info : {} to ovfenv partition", ipinfo.toString());
    } catch (Exception e) {
        log.error("Applying ip info to ovfenv partition failed with exception: {}", e.getMessage());
    } finally {
        isoFile.delete();
    }
    if (bNewIp) {
        FileUtils.deleteFile(IpReconfigConstants.NEWIP_PATH);
        FileUtils.deleteFile(IpReconfigConstants.NEWIP_EXPIRATION);
    } else {
        IpReconfigUtil.writeNodeStatusFile(IpReconfigConstants.NodeStatus.LOCAL_ROLLBACK.toString());
        FileUtils.deleteFile(IpReconfigConstants.OLDIP_PATH);
    }
}
Also used : Path(java.nio.file.Path) File(java.io.File) Exception(java.lang.Exception)

Example 32 with Exception

use of java.lang.Exception in project java-docs-samples by GoogleCloudPlatform.

the class GaeInfoServlet method fetchMetadata.

// Fetch Metadata
String fetchMetadata(String key) throws IOException {
    try {
        Request request = new Request.Builder().url(metadata + key).addHeader("Metadata-Flavor", "Google").get().build();
        Response response = ok.newCall(request).execute();
        return response.body().string();
    } catch (Exception e) {
        log("fetchMetadata - " + metadata + key + ": ", e);
    }
    return "";
}
Also used : Response(okhttp3.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) GsonBuilder(com.google.gson.GsonBuilder) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(okhttp3.Request) IOException(java.io.IOException) Exception(java.lang.Exception)

Aggregations

Exception (java.lang.Exception)32 IOException (java.io.IOException)15 ParseException (java.text.ParseException)12 Test (org.junit.Test)12 String (java.lang.String)11 SQLException (java.sql.SQLException)11 SQLTimeoutException (java.sql.SQLTimeoutException)11 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)11 ExpectedException (org.junit.rules.ExpectedException)11 PreparedStatement (java.sql.PreparedStatement)8 ResultSet (java.sql.ResultSet)7 RuntimeException (java.lang.RuntimeException)6 Statement (java.sql.Statement)6 ArrayList (java.util.ArrayList)5 IllegalArgumentException (java.lang.IllegalArgumentException)4 File (java.io.File)3 FileNotFoundException (java.io.FileNotFoundException)3 IllegalStateException (java.lang.IllegalStateException)3 NumberFormatException (java.lang.NumberFormatException)3 Object (java.lang.Object)3