當前位置: 首頁>>代碼示例>>Java>>正文


Java CloudRuntimeException類代碼示例

本文整理匯總了Java中com.cloud.utils.exception.CloudRuntimeException的典型用法代碼示例。如果您正苦於以下問題:Java CloudRuntimeException類的具體用法?Java CloudRuntimeException怎麽用?Java CloudRuntimeException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CloudRuntimeException類屬於com.cloud.utils.exception包,在下文中一共展示了CloudRuntimeException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initialize

import com.cloud.utils.exception.CloudRuntimeException; //導入依賴的package包/類
private static void initialize() {
    final Properties dbProps = DbProperties.getDbProperties();

    if (EncryptionSecretKeyChecker.useEncryption()) {
        final String dbSecretKey = dbProps.getProperty("db.cloud.encrypt.secret");
        if (dbSecretKey == null || dbSecretKey.isEmpty()) {
            throw new CloudRuntimeException("Empty DB secret key in db.properties");
        }

        s_encryptor = new StandardPBEStringEncryptor();
        s_encryptor.setAlgorithm("PBEWithMD5AndDES");
        s_encryptor.setPassword(dbSecretKey);
    } else {
        throw new CloudRuntimeException("Trying to encrypt db values when encrytion is not enabled");
    }
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:17,代碼來源:DBEncryptionUtil.java

示例2: doPingTest

import com.cloud.utils.exception.CloudRuntimeException; //導入依賴的package包/類
public boolean doPingTest(final Connection conn, final String computingHostIp) {
    final com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_host.getIp(), 22);
    try {
        sshConnection.connect(null, 60000, 60000);
        if (!sshConnection.authenticateWithPassword(_username, _password.peek())) {
            throw new CloudRuntimeException("Unable to authenticate");
        }

        final String cmd = "ping -c 2 " + computingHostIp;
        if (!SSHCmdHelper.sshExecuteCmd(sshConnection, cmd)) {
            throw new CloudRuntimeException("Cannot ping host " + computingHostIp + " from host " + _host.getIp());
        }
        return true;
    } catch (final Exception e) {
        s_logger.warn("Catch exception " + e.toString(), e);
        return false;
    } finally {
        sshConnection.close();
    }
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:21,代碼來源:CitrixResourceBase.java

示例3: deletePhysicalNetworkTrafficType

import com.cloud.utils.exception.CloudRuntimeException; //導入依賴的package包/類
public boolean deletePhysicalNetworkTrafficType(final Long id) {
    final PhysicalNetworkTrafficTypeVO trafficType = _pNTrafficTypeDao.findById(id);

    if (trafficType == null) {
        throw new InvalidParameterValueException("Traffic Type with id=" + id + "doesn't exist in the system");
    }

    // check if there are any networks associated to this physical network with this traffic type
    if (TrafficType.Guest.equals(trafficType.getTrafficType())) {
        if (!_networksDao.listByPhysicalNetworkTrafficType(trafficType.getPhysicalNetworkId(), trafficType.getTrafficType()).isEmpty()) {
            throw new CloudRuntimeException("The Traffic Type is not deletable because there are existing networks with this traffic type:" + trafficType.getTrafficType());
        }
    } else if (TrafficType.Storage.equals(trafficType.getTrafficType())) {
        final PhysicalNetworkVO pn = _physicalNetworkDao.findById(trafficType.getPhysicalNetworkId());
        if (_stnwMgr.isAnyStorageIpInUseInZone(pn.getDataCenterId())) {
            throw new CloudRuntimeException("The Traffic Type is not deletable because there are still some storage network ip addresses in use:"
                    + trafficType.getTrafficType());
        }
    }
    return _pNTrafficTypeDao.remove(id);
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:22,代碼來源:NetworkServiceImpl.java

示例4: execute

import com.cloud.utils.exception.CloudRuntimeException; //導入依賴的package包/類
@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());
    }
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:19,代碼來源:ExpungeVMCmd.java

示例5: findById

import com.cloud.utils.exception.CloudRuntimeException; //導入依賴的package包/類
protected T findById(final ID id, final boolean removed, final Boolean lock) {
    final StringBuilder sql = new StringBuilder(_selectByIdSql);
    if (!removed && _removed != null) {
        sql.append(" AND ").append(_removed.first());
    }
    if (lock != null) {
        sql.append(lock ? FOR_UPDATE_CLAUSE : SHARE_MODE_CLAUSE);
    }
    final TransactionLegacy txn = TransactionLegacy.currentTxn();
    PreparedStatement pstmt = null;
    try {
        pstmt = txn.prepareAutoCloseStatement(sql.toString());

        if (_idField.getAnnotation(EmbeddedId.class) == null) {
            prepareAttribute(1, pstmt, _idAttributes.get(_table)[0], id);
        }

        final ResultSet rs = pstmt.executeQuery();
        return rs.next() ? toEntityBean(rs, true) : null;
    } catch (final SQLException e) {
        throw new CloudRuntimeException("DB Exception on: " + pstmt, e);
    }
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:24,代碼來源:GenericDaoBase.java

示例6: execute

import com.cloud.utils.exception.CloudRuntimeException; //導入依賴的package包/類
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
        ResourceAllocationException {
    try {
        final NiciraNvpDeviceVO niciraNvpDeviceVO = niciraNvpElementService.addNiciraNvpDevice(this);
        if (niciraNvpDeviceVO != null) {
            final NiciraNvpDeviceResponse response = niciraNvpElementService.createNiciraNvpDeviceResponse(niciraNvpDeviceVO);
            response.setObjectName("niciranvpdevice");
            response.setResponseName(getCommandName());
            setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Nicira NVP device due to internal error.");
        }
    } catch (final InvalidParameterValueException invalidParamExcp) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
    } catch (final CloudRuntimeException runtimeExcp) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
    }
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:20,代碼來源:AddNiciraNvpDeviceCmd.java

示例7: stopSystemVM

import com.cloud.utils.exception.CloudRuntimeException; //導入依賴的package包/類
@Override
@ActionEvent(eventType = "", eventDescription = "", async = true)
public VMInstanceVO stopSystemVM(final StopSystemVmCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException {
    final Long id = cmd.getId();

    // verify parameters
    final VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(id, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm);
    if (systemVm == null) {
        final InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a system vm with specified vmId");
        ex.addProxyObject(id.toString(), "vmId");
        throw ex;
    }

    try {
        if (systemVm.getType() == VirtualMachine.Type.ConsoleProxy) {
            ActionEventUtils.startNestedActionEvent(EventTypes.EVENT_PROXY_STOP, "stopping console proxy Vm");
            return stopConsoleProxy(systemVm, cmd.isForced());
        } else if (systemVm.getType() == VirtualMachine.Type.SecondaryStorageVm) {
            ActionEventUtils.startNestedActionEvent(EventTypes.EVENT_SSVM_STOP, "stopping secondary storage Vm");
            return stopSecondaryStorageVm(systemVm, cmd.isForced());
        }
        return null;
    } catch (final OperationTimedoutException e) {
        throw new CloudRuntimeException("Unable to stop " + systemVm, e);
    }
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:27,代碼來源:ManagementServerImpl.java

示例8: mount

import com.cloud.utils.exception.CloudRuntimeException; //導入依賴的package包/類
@Override
protected void mount(final String localRootPath, final String remoteDevice, final URI uri) {
    ensureLocalRootPathExists(localRootPath, uri);

    if (mountExists(localRootPath, uri)) {
        return;
    }

    attemptMount(localRootPath, remoteDevice, uri);

    // Change permissions for the mountpoint - seems to bypass authentication
    final Script script = new Script(true, "chmod", _timeout, s_logger);
    script.add("777", localRootPath);
    final String result = script.execute();
    if (result != null) {
        final String errMsg = "Unable to set permissions for " + localRootPath + " due to " + result;
        s_logger.error(errMsg);
        throw new CloudRuntimeException(errMsg);
    }
    s_logger.debug("Successfully set 777 permission for " + localRootPath);

    // XXX: Adding the check for creation of snapshots dir here. Might have
    // to move it somewhere more logical later.
    checkForSnapshotsDir(localRootPath);
    checkForVolumesDir(localRootPath);
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:27,代碼來源:LocalNfsSecondaryStorageResource.java

示例9: checkIfZoneIsDeletableFailureOnVolumeTest

import com.cloud.utils.exception.CloudRuntimeException; //導入依賴的package包/類
@Test(expected = CloudRuntimeException.class)
public void checkIfZoneIsDeletableFailureOnVolumeTest() {
    final VolumeVO volumeVO = Mockito.mock(VolumeVO.class);
    final ArrayList<VolumeVO> arrayList = new ArrayList<>();
    arrayList.add(volumeVO);

    Mockito.when(_hostDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<>());
    Mockito.when(_podDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<>());
    Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
    Mockito.when(_publicIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
    Mockito.when(_vmInstanceDao.listByZoneId(anyLong())).thenReturn(new ArrayList<>());
    Mockito.when(_volumeDao.findByDc(anyLong())).thenReturn(arrayList);
    Mockito.when(_physicalNetworkDao.listByZone(anyLong())).thenReturn(new ArrayList<>());

    configurationMgr.checkIfZoneIsDeletable(new Random().nextLong());
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:17,代碼來源:ConfigurationManagerTest.java

示例10: testScaleVM3

import com.cloud.utils.exception.CloudRuntimeException; //導入依賴的package包/類
@Test(expected = CloudRuntimeException.class)
public void testScaleVM3() throws Exception {

    /*VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);

    Long srcHostId = vm.getHostId();
    Long oldSvcOfferingId = vm.getServiceOfferingId();
    if (srcHostId == null) {
        throw new CloudRuntimeException("Unable to scale the vm because it doesn't have a host id");
    }*/

    when(_vmInstance.getHostId()).thenReturn(null);
    when(_vmInstanceDao.findById(anyLong())).thenReturn(_vmInstance);
    when(_vmInstanceDao.findByUuid(any(String.class))).thenReturn(_vmInstance);
    final DeploymentPlanner.ExcludeList excludeHostList = new DeploymentPlanner.ExcludeList();
    _vmMgr.findHostAndMigrate(_vmInstance.getUuid(), 2l, excludeHostList);
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:18,代碼來源:VirtualMachineManagerImplTest.java

示例11: revertToSnapshot

import com.cloud.utils.exception.CloudRuntimeException; //導入依賴的package包/類
public String revertToSnapshot(final Connection conn, final VM vmSnapshot, final String vmName,
                               final String oldVmUuid, final Boolean snapshotMemory, final String hostUUID)
        throws XenAPIException, XmlRpcException {

    final String results = callHostPluginAsync(conn, "vmopsSnapshot", "revert_memory_snapshot", 10 * 60 * 1000,
            "snapshotUUID", vmSnapshot.getUuid(conn), "vmName", vmName,
            "oldVmUuid", oldVmUuid, "snapshotMemory", snapshotMemory.toString(), "hostUUID", hostUUID);
    String errMsg = null;
    if (results == null || results.isEmpty()) {
        errMsg = "revert_memory_snapshot return null";
    } else {
        if (results.equals("0")) {
            return results;
        } else {
            errMsg = "revert_memory_snapshot exception";
        }
    }
    s_logger.warn(errMsg);
    throw new CloudRuntimeException(errMsg);
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:21,代碼來源:CitrixResourceBase.java

示例12: copyAsync

import com.cloud.utils.exception.CloudRuntimeException; //導入依賴的package包/類
@Override
public void copyAsync(final DataObject srcData, final DataObject destData, final Host destHost, final AsyncCompletionCallback<CopyCommandResult> callback) {
    if (srcData.getDataStore() == null || destData.getDataStore() == null) {
        throw new CloudRuntimeException("can't find data store");
    }

    if (srcData.getDataStore().getDriver().canCopy(srcData, destData)) {
        srcData.getDataStore().getDriver().copyAsync(srcData, destData, callback);
        return;
    } else if (destData.getDataStore().getDriver().canCopy(srcData, destData)) {
        destData.getDataStore().getDriver().copyAsync(srcData, destData, callback);
        return;
    }

    final DataMotionStrategy strategy = storageStrategyFactory.getDataMotionStrategy(srcData, destData);
    if (strategy == null) {
        throw new CloudRuntimeException("Can't find strategy to move data. " + "Source: " + srcData.getType().name() + " '" + srcData.getUuid() + ", Destination: " +
                destData.getType().name() + " '" + destData.getUuid() + "'");
    }

    strategy.copyAsync(srcData, destData, destHost, callback);
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:23,代碼來源:DataMotionServiceImpl.java

示例13: injectSshKeysIntoSystemVmIsoPatch

import com.cloud.utils.exception.CloudRuntimeException; //導入依賴的package包/類
protected void injectSshKeysIntoSystemVmIsoPatch(final String publicKeyPath, final String privKeyPath) {
    s_logger.info("Trying to inject public and private keys into systemvm iso");
    final String injectScript = getInjectScript();
    final String scriptPath = Script.findScript("", injectScript);
    final String systemVmIsoPath = Script.findScript("", "vms/systemvm.iso");
    if (scriptPath == null) {
        throw new CloudRuntimeException("Unable to find key inject script " + injectScript);
    }
    if (systemVmIsoPath == null) {
        throw new CloudRuntimeException("Unable to find systemvm iso vms/systemvm.iso");
    }
    final Script command = new Script("/bin/bash", s_logger);

    command.add(scriptPath);
    command.add(publicKeyPath);
    command.add(privKeyPath);
    command.add(systemVmIsoPath);

    final String result = command.execute();
    s_logger.info("Injected public and private keys into systemvm iso with result : " + result);
    if (result != null) {
        s_logger.warn("Failed to inject generated public key into systemvm iso " + result);
        throw new CloudRuntimeException("Failed to inject generated public key into systemvm iso " + result);
    }
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:26,代碼來源:ConfigurationServerImpl.java

示例14: executeUserRequest

import com.cloud.utils.exception.CloudRuntimeException; //導入依賴的package包/類
@Override
public boolean executeUserRequest(final long hostId, final ResourceState.Event event) throws AgentUnavailableException {
    if (event == ResourceState.Event.AdminAskMaintenace) {
        return doMaintain(hostId);
    } else if (event == ResourceState.Event.AdminCancelMaintenance) {
        return doCancelMaintenance(hostId);
    } else if (event == ResourceState.Event.DeleteHost) {
  /* TODO: Ask alex why we assume the last two parameters are false */
        return doDeleteHost(hostId, false, false);
    } else if (event == ResourceState.Event.Unmanaged) {
        return doUmanageHost(hostId);
    } else if (event == ResourceState.Event.UpdatePassword) {
        return doUpdateHostPassword(hostId);
    } else {
        throw new CloudRuntimeException("Received an resource event we are not handling now, " + event);
    }
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:18,代碼來源:ResourceManagerImpl.java

示例15: evaluateObject

import com.cloud.utils.exception.CloudRuntimeException; //導入依賴的package包/類
public <T> T evaluateObject(final T obj) {
    Class<?> clazz = obj.getClass();
    try {
        do {
            final Field[] fs = clazz.getDeclaredFields();
            for (final Field f : fs) {
                f.setAccessible(true);
                final Object value = get(f.getName());
                f.set(obj, value);
            }
            clazz = clazz.getSuperclass();
        } while (clazz != null && clazz != Object.class);
        return obj;
    } catch (final Exception e) {
        throw new CloudRuntimeException(e);
    }
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:18,代碼來源:XmlObject.java


注:本文中的com.cloud.utils.exception.CloudRuntimeException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。