@Override public void check() { if (s_nodeId <= 0) { throw new CloudRuntimeException("Unable to get the management server node id"); } } }
public <T extends Answer> T getAnswer(final Class<T> clazz) { assert (clazz != Answer.class) : "How do you expect to get a unique answer in this case? huh? How? How? How?....one more time....How?"; for (final Answer answer : _answers) { if (answer.getClass() == clazz) { return (T) answer; } } throw new CloudRuntimeException("Unable to get answer that is of " + clazz); }
public static String formNfsUri(final String host, final String path) { try { final URI uri = new URI("nfs", host, path, null); return uri.toString(); } catch (final URISyntaxException e) { throw new CloudRuntimeException("Unable to form nfs URI: " + host + " - " + path); } }
public static Date parseDateString(final TimeZone tz, final String dateString, final String formatString) { final DateFormat df = new SimpleDateFormat(formatString); df.setTimeZone(tz); try { return df.parse(dateString); } catch (final ParseException e) { throw new CloudRuntimeException("why why ", e); } }
public static String formIscsiUri(final String host, final String iqn, final Integer lun) { try { String path = iqn; if (lun != null) { path += "/" + lun.toString(); } final URI uri = new URI("iscsi", host, path, null); return uri.toString(); } catch (final URISyntaxException e) { throw new CloudRuntimeException("Unable to form iscsi URI: " + host + " - " + iqn + " - " + lun); } }
public static AbstractConfigItemFacade getInstance(final Class<? extends NetworkElementCommand> key) { if (!flyweight.containsKey(key)) { throw new CloudRuntimeException("Unable to process the configuration for " + key.getClass().getName()); } return flyweight.get(key); }
public void set(final Object entity, final Attribute attr, final Object value) { _changes.put(attr.field.getName(), new Ternary<>(attr, null, value)); try { attr.field.set(entity, value); } catch (final IllegalArgumentException e) { throw new CloudRuntimeException("Unable to update " + attr.field.getName() + " with " + value, e); } catch (final IllegalAccessException e) { throw new CloudRuntimeException("Unable to update " + attr.field.getName() + " with " + value, e); } }
public static Version getVersion(final byte[] bytes) throws UnsupportedVersionException { try { return Version.get(bytes[0]); } catch (final UnsupportedVersionException e) { throw new CloudRuntimeException("Unsupported version: " + bytes[0]); } }
@Override public void saveCertificate(final String name, final String certificate, final String key, final String domainSuffix) { if (name == null || name.isEmpty() || certificate == null || certificate.isEmpty() || key == null || key.isEmpty() || domainSuffix == null || domainSuffix.isEmpty()) { throw new CloudRuntimeException("invalid parameter in saveCerticate"); } _ksDao.save(name, certificate, key, domainSuffix); }
public void release() { s_mgr.unregister(_name); try { if (_conn != null) { _conn.close(); } _conn = null; } catch (final SQLException e) { throw new CloudRuntimeException("Problem in closing a connection", e); } }
public boolean isSameKeyAs(final Object obj) { if (this.equals(obj)) { return true; } else if (obj instanceof String) { final String key = (String) obj; return key.equals(_name); } throw new CloudRuntimeException("Comparing ConfigKey to " + obj.toString()); }
public static XmlObject parseFromFile(final String filePath) { final FileInputStream fs; try { fs = new FileInputStream(new File(filePath)); final XmlObjectParser p = new XmlObjectParser(fs); return p.parse(); } catch (final FileNotFoundException e) { throw new CloudRuntimeException(e); } }
public ConnectionConcierge(final String name, final Connection conn, final boolean keepAlive) { _name = name + s_mgr.getNextId(); _keepAlive = keepAlive; try { _autoCommit = conn.getAutoCommit(); _isolationLevel = conn.getTransactionIsolation(); _holdability = conn.getHoldability(); } catch (final SQLException e) { throw new CloudRuntimeException("Unable to get information from the connection object", e); } reset(conn); }
private XmlObject parse() { final SAXParserFactory spfactory = SAXParserFactory.newInstance(); try { final SAXParser saxParser = spfactory.newSAXParser(); final XmlHandler handler = new XmlHandler(); saxParser.parse(is, handler); return handler.getRoot(); } catch (final Exception e) { throw new CloudRuntimeException(e); } }
public boolean lock(final String name, final int timeoutSeconds) { final Merovingian2 lockMaster = Merovingian2.getLockMaster(); if (lockMaster == null) { throw new CloudRuntimeException("There's no support for locking yet"); } return lockMaster.acquire(name, timeoutSeconds); }
public boolean release(final String name) { final Merovingian2 lockMaster = Merovingian2.getLockMaster(); if (lockMaster == null) { throw new CloudRuntimeException("There's no support for locking yet"); } return lockMaster.release(name); }
@Override public void with(final ComponentLifecycle lifecycle) { try { lifecycle.configure(lifecycle.getName(), lifecycle.getConfigParams()); } catch (final ConfigurationException e) { log.error("Failed to configure {}", lifecycle.getName(), e); throw new CloudRuntimeException(e); } } });
private ExecutionResult applyConfigToVR(final String routerAccessIp, final ConfigItem c, final int timeout) { if (c instanceof FileConfigItem) { final FileConfigItem configItem = (FileConfigItem) c; return this._vrDeployer.createFileInVR(routerAccessIp, configItem.getFilePath(), configItem.getFileName(), configItem.getFileContents()); } else if (c instanceof ScriptConfigItem) { final ScriptConfigItem configItem = (ScriptConfigItem) c; return this._vrDeployer.executeInVR(routerAccessIp, configItem.getScript(), configItem.getArgs(), timeout); } throw new CloudRuntimeException("Unable to apply unknown configitem of type " + c.getClass().getSimpleName()); }
public ScopedConfigStorage scoped(final ConfigKey<?> config) { for (final ScopedConfigStorage storage : _scopedStorages) { if (storage.getScope() == config.scope()) { return storage; } } throw new CloudRuntimeException("Unable to find config storage for this scope: " + config.scope() + " for " + config.key()); }
@Override public void execute() { try { final List<SslCertResponse> certResponseList = _certService.listSslCerts(this); final ListResponse<SslCertResponse> response = new ListResponse<>(); response.setResponses(certResponseList); response.setResponseName(getCommandName()); this.setResponseObject(response); } catch (final Exception e) { throw new CloudRuntimeException(e); } }