当前位置: 首页>>代码示例>>Java>>正文


Java APITrace.end方法代码示例

本文整理汇总了Java中org.dasein.cloud.util.APITrace.end方法的典型用法代码示例。如果您正苦于以下问题:Java APITrace.end方法的具体用法?Java APITrace.end怎么用?Java APITrace.end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.dasein.cloud.util.APITrace的用法示例。


在下文中一共展示了APITrace.end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isSubscribed

import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Override
public boolean isSubscribed() throws CloudException, InternalException {
    APITrace.begin(provider, IS_SUBSCRIBED);
    try {
        try {
            VirtustreamMethod method = new VirtustreamMethod(provider);
            method.getString("/VirtualMachine?$filter=IsTemplate eq false and IsRemoved eq false", IS_SUBSCRIBED);
            return true;
        }
        catch (Throwable ignore) {
            return false;
        }
    }
    finally {
        APITrace.end();
    }
}
 
开发者ID:greese,项目名称:dasein-cloud-virtustream,代码行数:18,代码来源:VirtualMachines.java

示例2: start

import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Override
public void start(@Nonnull String vmId) throws InternalException, CloudException {
    APITrace.begin(provider, START_VIRTUAL_MACHINE);
    try {
        try {
            VirtustreamMethod method = new VirtustreamMethod(provider);
            String obj = method.postString("/VirtualMachine/"+vmId+"/PowerOn", "", START_VIRTUAL_MACHINE);
            if (obj != null && obj.length()> 0) {
                JSONObject json = new JSONObject(obj);
                if (provider.parseTaskId(json) == null) {
                    logger.warn("No confirmation of StartVM task completion but no error either");
                }
            }
        }
        catch (JSONException e) {
            logger.error(e);
            throw new InternalException("Unable to parse JSONObject "+e.getMessage());
        }
    }
    finally {
        APITrace.end();
    }
}
 
开发者ID:greese,项目名称:dasein-cloud-virtustream,代码行数:24,代码来源:VirtualMachines.java

示例3: isSubscribed

import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Override
public boolean isSubscribed() throws CloudException, InternalException {
    APITrace.begin(provider, IS_SUBSCRIBED);
    try {
        try {
            VirtustreamMethod method = new VirtustreamMethod(provider);
            method.getString("/Network", IS_SUBSCRIBED);
            return true;
        }
        catch (Throwable ignore){
            return false;
        }
    }
    finally {
        APITrace.end();
    }
}
 
开发者ID:greese,项目名称:dasein-cloud-virtustream,代码行数:18,代码来源:Networks.java

示例4: upload

import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Nonnull
@Override
public Blob upload(@Nonnull File sourceFile, @Nullable String bucket, @Nonnull String objectName) throws CloudException, InternalException {
    APITrace.begin(getProvider(), UPLOAD_FILE);
    try {
        if( bucket == null ) {
            logger.error("No bucket was specified for this request");
            throw new OperationNotSupportedException("No bucket was specified for this request");
        }
        if( !exists(bucket) ) {
            logger.error("Creating new bucket not supported for cloud");
            throw new OperationNotSupportedException("Creating new bucket not supported for cloud");
        }

        put(bucket, objectName, sourceFile);
        return getObject(bucket, objectName);
    }
    finally {
        APITrace.end();
    }
}
 
开发者ID:greese,项目名称:dasein-cloud-virtustream,代码行数:22,代码来源:BlobStore.java

示例5: start

import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Override
public void start(@Nonnull String instanceId) throws InternalException, CloudException {
    APITrace.begin(getProvider(), "startVM");
    try {
        waitForAllDropletEventsToComplete(instanceId, 5);
        VirtualMachine vm = getVirtualMachine(instanceId);
        if( vm == null ) {
            throw new CloudException("No such instance: " + instanceId);
        }
        // only start if droplet is stopped, otherwise DO will give us an error
        if( VmState.STOPPED.equals(vm.getCurrentState() ) ) {
            DigitalOceanModelFactory.performAction(getProvider(), new Start(), instanceId);
        }
    } catch( CloudException e ) {
        logger.error(e.getMessage());
        throw new CloudException(e);
    } finally {
        APITrace.end();
    }
}
 
开发者ID:greese,项目名称:dasein-cloud-digitalocean,代码行数:21,代码来源:DOInstance.java

示例6: getVirtualMachine

import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Override
public @Nullable VirtualMachine getVirtualMachine(@Nonnull String instanceId) throws InternalException, CloudException {
    APITrace.begin(getProvider(), "getVirtualMachine");
    try {
        Droplet d = (Droplet) DigitalOceanModelFactory.getModelById(getProvider(), org.dasein.cloud.digitalocean.models.rest.DigitalOcean.DROPLET, instanceId);
        if (d != null) {
            VirtualMachine server = toVirtualMachine(d);
            if (server != null && server.getProviderVirtualMachineId().equals(instanceId)) {
                return server;
            }
        }
        return null;
    } catch( CloudException e ) {
        if( e.getHttpCode() == HttpServletResponse.SC_NOT_FOUND) {
            return null;
        }
        logger.error(e.getMessage());
        throw new CloudException(e);
    } finally {
        APITrace.end();
    }
}
 
开发者ID:greese,项目名称:dasein-cloud-digitalocean,代码行数:23,代码来源:DOInstance.java

示例7: suspend

import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Override
public void suspend(@Nonnull String vmId) throws CloudException, InternalException {
    APITrace.begin(provider, SUSPEND_VIRTUAL_MACHINE);
    try {
        try {
            VirtustreamMethod method = new VirtustreamMethod(provider);
            String obj = method.postString("/VirtualMachine/"+vmId+"/Suspend", "", SUSPEND_VIRTUAL_MACHINE);
            if (obj != null && obj.length()> 0) {
                JSONObject json = new JSONObject(obj);
                if (provider.parseTaskId(json) == null) {
                    logger.warn("No confirmation of SuspendVM task completion but no error either");
                }
            }
        }
        catch (JSONException e) {
            logger.error(e);
            throw new InternalException("Unable to parse JSONObject "+e.getMessage());
        }
    }
    finally {
        APITrace.end();
    }
}
 
开发者ID:greese,项目名称:dasein-cloud-virtustream,代码行数:24,代码来源:VirtualMachines.java

示例8: importKeypair

import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Override
public @Nonnull SSHKeypair importKeypair(@Nonnull String name, @Nonnull String publicKey) throws InternalException, CloudException {
    APITrace.begin(getProvider(), "Keypair.importKeypair");
    try {
        String regionId = getContext().getRegionId();
        if( regionId == null ) {
            throw new CloudException("No region was set for this request.");
        }

        Create action = new Create(name, publicKey);

        Key k = (Key)DigitalOceanModelFactory.performAction(getProvider(), action, org.dasein.cloud.digitalocean.models.rest.DigitalOcean.KEY);

        SSHKeypair kp = toSSHKeypair(k);
        if( kp != null ) {
            return kp;
        }
        else {
            throw new CloudException("Unable to import keypair "+name);
        }
    }
    finally {
        APITrace.end();
    }
}
 
开发者ID:greese,项目名称:dasein-cloud-digitalocean,代码行数:26,代码来源:Keypairs.java

示例9: stop

import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Override
public void stop(@Nonnull String instanceId, boolean force) throws InternalException, CloudException {
    APITrace.begin(getProvider(), "stopVM");
    try {
        waitForAllDropletEventsToComplete(instanceId, 5);
        VirtualMachine vm = getVirtualMachine(instanceId);
        if( vm == null ) {
            throw new CloudException("No such instance: " + instanceId);
        }
        // only stop if droplet is running, otherwise DO will give us an error
        if( VmState.RUNNING.equals(vm.getCurrentState() ) ) {
            DigitalOceanModelFactory.performAction(getProvider(), new Stop(), instanceId);
        }
    } finally {
        APITrace.end();
    }
}
 
开发者ID:greese,项目名称:dasein-cloud-digitalocean,代码行数:18,代码来源:DOInstance.java

示例10: findAvailableResourcePool

import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
public String findAvailableResourcePool(@Nonnull DataCenter dataCenter, @Nonnull String networkComputeResourceID) throws InternalException, CloudException {
    APITrace.begin(provider, FIND_RESOURCE_POOL);
    try {
        try {
            VirtustreamMethod method = new VirtustreamMethod(provider);
            String obj = method.getString("/ResourcePool?$filter=IsRemoved eq false and Hypervisor/Site/SiteID eq '"+dataCenter.getProviderDataCenterId()+"'", FIND_RESOURCE_POOL);

            if (obj != null && obj.length() > 0) {
                JSONArray list = new JSONArray(obj);
                for (int i=0; i<list.length(); i++) {
                    JSONObject json = list.getJSONObject(i);

                    String id = json.getString("ResourcePoolID");
                    String computeId = json.getString("ComputeResourceID");
                    if (computeId.equals(networkComputeResourceID)) {
                        storageComputeId = computeId;
                        return id;
                    }
                }
            }
            logger.warn("No available resource pool in datacenter "+dataCenter.getName());
            return null;
        }
        catch (JSONException e) {
            logger.error(e);
            throw new InternalException("Unable to parse JSONObject "+e.getMessage());
        }
    }
    finally {
        APITrace.end();
    }
}
 
开发者ID:greese,项目名称:dasein-cloud-virtustream,代码行数:33,代码来源:VirtualMachines.java

示例11: deleteKeypair

import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Override
public void deleteKeypair(@Nonnull String providerId) throws InternalException, CloudException {
       APITrace.begin(getProvider(), "Keypair.deleteKeypair");
       try {
           DigitalOceanModelFactory.performAction(getProvider(), new Destroy(), providerId);
       }
       finally {
           APITrace.end();
       }
}
 
开发者ID:greese,项目名称:dasein-cloud-digitalocean,代码行数:11,代码来源:Keypairs.java

示例12: getImage

import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Nullable
@Override
public MachineImage getImage(@Nonnull String providerImageId) throws CloudException, InternalException {
    APITrace.begin(getProvider(), GET_IMAGE);
    try {
        VirtustreamMethod method = new VirtustreamMethod(getProvider());
        String obj = method.getString("VirtualMachine/"+providerImageId+"?$filter=IsRemoved eq false", GET_IMAGE);
        if (obj != null && obj.length()> 0 ) {
            try {
                JSONObject json = new JSONObject(obj);
                MachineImage img = toImage(json);

                if (img != null) {
                    return img;
                }
            }
            catch (JSONException e) {
                logger.error(e);
                throw new InternalException("Unable to parse JSON "+e.getMessage());
            }
        }

        return null;
    }
    finally {
        APITrace.end();
    }
}
 
开发者ID:greese,项目名称:dasein-cloud-virtustream,代码行数:29,代码来源:Templates.java

示例13: isSubscribed

import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Override
public boolean isSubscribed() throws CloudException, InternalException {
    APITrace.begin(getProvider(), IS_SUBSCRIBED);
    try {
        VirtustreamMethod method = new VirtustreamMethod(getProvider());
        method.getString("/Storage?$filter=IsRemoved eq false", LIST_STORAGE);
        return true;
    }
    catch (Throwable ignore) {
        return false;
    }
    finally {
        APITrace.end();
    }
}
 
开发者ID:greese,项目名称:dasein-cloud-virtustream,代码行数:16,代码来源:BlobStore.java

示例14: listImages

import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Override
public
@Nonnull
Iterable<MachineImage> listImages(final @Nullable ImageFilterOptions options) throws CloudException, InternalException {
    final ImageFilterOptions opts;

    if (options == null) {
        opts = ImageFilterOptions.getInstance();
    } else {
        opts = options;
    }
    // this method only works for machine images in DO
    if( opts.getImageClass() != null && !opts.getImageClass().equals(ImageClass.MACHINE)) {
        return Collections.emptyList();
    }

    provider.hold();
    PopulatorThread<MachineImage> populator = new PopulatorThread<MachineImage>(new JiteratorPopulator<MachineImage>() {
        @Override
        public void populate(@Nonnull Jiterator<MachineImage> iterator) throws Exception {
            APITrace.begin(getProvider(), "Image.listImages");
            try {
                for (MachineImage img : executeImageSearch(false, opts)) {
                    if( options.matches(img) ) {
                        iterator.push(img);
                    }
                }
            }
            finally {
                provider.release();
                APITrace.end();
            }
        }
    });

    populator.populate();
    return populator.getResult();
}
 
开发者ID:greese,项目名称:dasein-cloud-digitalocean,代码行数:39,代码来源:DOImage.java

示例15: searchPublicImages

import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Override
public
@Nonnull
Iterable<MachineImage> searchPublicImages(final @Nonnull ImageFilterOptions options) throws CloudException, InternalException {
    provider.hold();
    PopulatorThread<MachineImage> populator = new PopulatorThread<MachineImage>(new JiteratorPopulator<MachineImage>() {
        @Override
        public void populate(@Nonnull Jiterator<MachineImage> iterator) throws Exception {
            APITrace.begin(getProvider(), "searchPublicImages");
            try {
                try {
                    for (MachineImage img : executeImageSearch(true, options)) {
                        if( options.matches(img) ) {
                            iterator.push(img);
                        }
                    }
                } finally {
                    provider.release();
                }
            } finally {
                APITrace.end();
            }
        }
    });

    populator.populate();
    return populator.getResult();
}
 
开发者ID:greese,项目名称:dasein-cloud-digitalocean,代码行数:29,代码来源:DOImage.java


注:本文中的org.dasein.cloud.util.APITrace.end方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。