@Override public String readContent(String location) { try { return Resources.toString(new URL(ZkWorkItemRepositoryFactory.SCHEME + ":" + location), Charsets.UTF_8); } catch (Exception e) { throw FabricException.launderThrowable(e); } }
@Override public String readContent(String location) { try { return Resources.toString(new URL(ProfileWorkItemRepositoryFactory.SCHME + ":" + location), Charsets.UTF_8); } catch (Exception e) { throw FabricException.launderThrowable(e); } }
private static String toString(Properties properties) { StringWriter writer = new StringWriter(); try { properties.store(writer, ""); } catch (IOException e) { throw FabricException.launderThrowable(e); } return writer.toString(); }
private static Properties mergeProperties(String left, Properties right) { Properties p = new Properties(); try { p.load(new StringReader(left)); } catch (IOException e) { throw FabricException.launderThrowable(e); } return mergeProperties(p, right); }
@Override public synchronized void stop() { if (partitionCache != null) { try { partitionCache.close(); partitionCache = null; } catch (IOException e) { throw FabricException.launderThrowable(e); } } }
@Override public String resolve(FabricService fabricService, Map<String, Map<String, String>> configs, String pid, String key, String value) { try { return new String(ZkPath.loadURL(fabricService.adapt(CuratorFramework.class), value), "UTF-8"); } catch (KeeperException.NoNodeException e) { LOGGER.warn("Could not load property value: {}. Ignoring.", value, e); return ""; } catch (Exception e) { throw FabricException.launderThrowable(e); } } }
public <T> T getMBean(JMXConnector connector, Class<T> type, String domain, String ... params) { try { return JMX.newMBeanProxy(connector.getMBeanServerConnection(), safeObjectName(domain, params), type); } catch (IOException e) { throw FabricException.launderThrowable(e); } }
private void releaseLock() { try { if (lock.isAcquiredInThisProcess()) { lock.release(); } } catch (Exception e) { throw FabricException.launderThrowable(e); } }
public void stop() { repository.removeListener(this); try { group.close(); } catch (IOException e) { throw FabricException.launderThrowable(e); } }
@Override public String getIp() { try { return ZooKeeperUtils.getSubstitutedPath(curator.get(), CONTAINER_IP.getPath(runtimeIdentity)); } catch (Exception e) { throw FabricException.launderThrowable(e); } } };
@Override public String getContainerVersion(String containerId) { assertValid(); try { return getStringData(configCache, ZkPath.CONFIG_CONTAINER.getPath(containerId)); } catch (Exception e) { throw FabricException.launderThrowable(e); } }
private String getAlgorithm(FabricService fabricService) { try { return getStringData(fabricService.adapt(CuratorFramework.class), AUTHENTICATION_CRYPT_ALGORITHM.getPath()); } catch (Exception e) { throw FabricException.launderThrowable(e); } }
@Override public void setRequirements(FabricRequirements requirements) throws IOException { assertValid(); try { String json = RequirementsJson.toJSON(requirements); setData(curator.get(), REQUIREMENTS_JSON_PATH, json); } catch (Exception e) { throw FabricException.launderThrowable(e); } }
public void stop() { worker.stop(context); cache.getListenable().removeListener(this); try { cache.close(); } catch (IOException e) { throw FabricException.launderThrowable(e); } }
@Override public String getClusterId() { assertValid(); try { return getStringData(curator.get(), ZkPath.CONFIG_ENSEMBLES.getPath()); } catch (Exception e) { throw FabricException.launderThrowable(e); } }
@Override public boolean isContainerAlive(String id) { assertValid(); try { return exists(curator.get(), ZkPath.CONTAINER_ALIVE.getPath(id)) != null; } catch (KeeperException.NoNodeException e) { return false; } catch (Exception e) { throw FabricException.launderThrowable(e); } }
@Override public void setDefaultVersion(String versionId) { assertValid(); try { setData(curator.get(), ZkPath.CONFIG_DEFAULT_VERSION.getPath(), versionId); } catch (Exception e) { throw FabricException.launderThrowable(e); } }
private String getPassword(FabricService fabricService) { try { String pw = getStringData(fabricService.adapt(CuratorFramework.class), AUTHENTICATION_CRYPT_PASSWORD.getPath()); // the password may be encoded, so we need to decode if needed return PasswordEncoder.decode(pw); } catch (Exception e) { throw FabricException.launderThrowable(e); } }
public void start() { try { ZooKeeperUtils.createDefault(curator, workerPath, null); cache.getListenable().addListener(this); cache.start(true); cache.rebuild(); } catch (Exception e) { throw FabricException.launderThrowable(e); } }
@Override public void setContainerMetadata(CreateContainerMetadata metadata) { assertValid(); //We encode the metadata so that they are more friendly to import/export. try { setData(curator.get(), ZkPath.CONTAINER_METADATA.getPath(metadata.getContainerName()), Base64Encoder.encode(ObjectUtils.toBytes(metadata))); } catch (Exception e) { throw FabricException.launderThrowable(e); } }