@Override public void check() { if (s_nodeId <= 0) { throw new CloudRuntimeException("Unable to get the management server node id"); } } }
@Test public void invalidTypesTest() throws URISyntaxException { final String uri1 = "https://1"; final String uri2 = "bla:0"; final BroadcastDomainType type = BroadcastDomainType.getTypeOf(uri1); try { /* URI result = */ BroadcastDomainType.fromString(uri1); } catch (final CloudRuntimeException e) { Assert.assertEquals("unexpected parameter exception", "string 'https://1' has an unknown BroadcastDomainType.", e.getMessage()); } try { /* URI result = */ BroadcastDomainType.fromString(uri2); } catch (final CloudRuntimeException e) { Assert.assertEquals("unexpected parameter exception", "string 'bla:0' has an unknown BroadcastDomainType.", e.getMessage()); } } }
public ServerApiException(final ApiErrorCode errorCode, final String description, final Throwable cause) { super(description, cause); _errorCode = errorCode; _description = description; if (cause instanceof CloudRuntimeException) { final CloudRuntimeException rt = (CloudRuntimeException) cause; final ArrayList<ExceptionProxyObject> idList = rt.getIdProxyList(); if (idList != null) { for (int i = 0; i < idList.size(); i++) { addProxyObject(idList.get(i)); } } setCSErrorCode(rt.getCSErrorCode()); } else if (cause instanceof CloudException) { final CloudException rt = (CloudException) cause; final ArrayList<String> idList = rt.getIdProxyList(); if (idList != null) { for (int i = 0; i < idList.size(); i++) { addProxyObject(idList.get(i)); } } setCSErrorCode(rt.getCSErrorCode()); } }
s_logger.error("Runtime DB exception ", e.getCause()); if (e.getCause() instanceof ClusterInvalidSessionException) { s_logger.error("Invalid cluster session found, fence it"); queueNotification(new ClusterManagerMessage(ClusterManagerMessage.MessageType.nodeIsolated)); if (isRootCauseConnectionRelated(e.getCause())) { invalidHeartbeatConnection();
@Override public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException { try { final List<Host> devices = nwDeviceMgr.listNetworkDevice(this); final List<NetworkDeviceResponse> nwdeviceResponses = new ArrayList<>(); final ListResponse<NetworkDeviceResponse> listResponse = new ListResponse<>(); for (final Host d : devices) { final NetworkDeviceResponse response = nwDeviceMgr.getApiResponse(d); response.setObjectName("networkdevice"); response.setResponseName(getCommandName()); nwdeviceResponses.add(response); } listResponse.setResponses(nwdeviceResponses); listResponse.setResponseName(getCommandName()); this.setResponseObject(listResponse); } catch (final InvalidParameterValueException ipve) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage()); } catch (final CloudRuntimeException cre) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage()); } }
@Override public void execute() { throw new CloudRuntimeException("LockAccount does not lock accounts. Its implementation is disabled. Use DisableAccount instead"); }
@Override public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException { try { final Host device = nwDeviceMgr.addNetworkDevice(this); final NetworkDeviceResponse response = nwDeviceMgr.getApiResponse(device); response.setObjectName("networkdevice"); response.setResponseName(getCommandName()); this.setResponseObject(response); } catch (final InvalidParameterValueException ipve) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage()); } catch (final CloudRuntimeException cre) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage()); } }
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); }
@Override public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException { try { final boolean result = nwDeviceMgr.deleteNetworkDevice(this); if (result) { final SuccessResponse response = new SuccessResponse(getCommandName()); response.setResponseName(getCommandName()); this.setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete network device:" + getId()); } } catch (final InvalidParameterValueException ipve) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage()); } catch (final CloudRuntimeException cre) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage()); } }
/** * @param cidrSize * @return * @throws CloudRuntimeException */ static long getCidrSizeFromString(final String cidrSize) throws CloudRuntimeException { long cidrSizeNum = -1; try { cidrSizeNum = Integer.parseInt(cidrSize); } catch (final NumberFormatException e) { throw new CloudRuntimeException("cidrsize is not a valid int: " + cidrSize, e); } if (cidrSizeNum > 32 || cidrSizeNum < 0) {// assuming IPv4 throw new CloudRuntimeException("cidr size out of range: " + cidrSizeNum); } return cidrSizeNum; }
@Override public void execute() throws ResourceUnavailableException, ConcurrentOperationException { CallContext.current().setEventDetails("Vm Id: " + getId()); try { final UserVm result = _userVmService.expungeVm(this.getId()); if (result != null) { final SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to expunge vm"); } } catch (final InvalidParameterValueException ipve) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage()); } catch (final CloudRuntimeException cre) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage()); } }
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 <T> URI toUri(final T value) { try { return new URI(scheme + "://" + value.toString()); } catch (final URISyntaxException e) { throw new CloudRuntimeException("Unable to convert to isolation type URI: " + value); } } }
@Override public <T> URI toUri(final T value) { try { return new URI("lswitch", value.toString(), null, null); } catch (final URISyntaxException e) { throw new CloudRuntimeException("Unable to convert to broadcast URI: " + value); } }
/** * The default implementation of toUri returns an uri with the scheme and value as host * * @param value will be put in the host field * @return the resulting URI */ public <T> URI toUri(final T value) { try { return new URI(scheme + "://" + value.toString()); } catch (final URISyntaxException e) { throw new CloudRuntimeException("Unable to convert to broadcast URI: " + value); } }
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 static DataStoreRole getRole(final String role) { if (role == null) { throw new CloudRuntimeException("role can't be empty"); } if (role.equalsIgnoreCase("primary")) { return Primary; } else if (role.equalsIgnoreCase("image")) { return Image; } else if (role.equalsIgnoreCase("imagecache")) { return ImageCache; } else if (role.equalsIgnoreCase("backup")) { return Backup; } else { throw new CloudRuntimeException("can't identify the role"); } }
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); } }