@SuppressWarnings("resource") private void initCluster(File clusterCfg) { // TODO Auto-generated method stub if (!clusterCfg.exists()) throw new RuntimeException(clusterCfg.getAbsolutePath() + " not found"); BufferedInputStream br = null; try { byte[] raw = new byte[(int) clusterCfg.length()]; new BufferedInputStream(new FileInputStream(clusterCfg)).read(raw); clusterConfList = JsonUtil.decode(new String(raw), ClusterConfList.class); if (!verifyClusterConf(clusterConfList)) throw new RuntimeException("verification of cluster configuration failed"); ResourceFactory.initializeCluster(clusterConfList); } catch (Exception ex) { ex.printStackTrace(); } finally { if (br != null) { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } } }
private void init(File cfg) { if (!cfg.exists()) throw new RuntimeException(cfg.getAbsolutePath() + " not found"); // resource initialization - how message are processed BufferedInputStream br = null; try { byte[] raw = new byte[(int) cfg.length()]; br = new BufferedInputStream(new FileInputStream(cfg)); br.read(raw); conf = JsonUtil.decode(new String(raw), ServerConf.class); if (!verifyConf(conf)) throw new RuntimeException("verification of configuration failed"); ResourceFactory.initialize(conf); } catch (Exception ex) { ex.printStackTrace(); } finally { if (br != null) { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } } }