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


Java APITrace类代码示例

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


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

示例1: getImage

import org.dasein.cloud.util.APITrace; //导入依赖的package包/类
@Override
public @Nullable MachineImage getImage(@Nonnull String providerImageId) throws CloudException, InternalException {
    APITrace.begin(provider, "Image.getImage");
    try {
        Image image = (Image) getModelById(getProvider(), org.dasein.cloud.digitalocean.models.rest.DigitalOcean.IMAGE, providerImageId);
        return toImage(image);
    }
    catch( CloudException e ) {
        if( e.getHttpCode() == 404 ) {
            return null;
        }
        throw e;
    }
    finally {
        APITrace.end();
    }
}
 
开发者ID:greese,项目名称:dasein-cloud-digitalocean,代码行数:18,代码来源:DOImage.java

示例2: 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

示例3: 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

示例4: 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

示例5: reboot

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

示例6: listRegions

import org.dasein.cloud.util.APITrace; //导入依赖的package包/类
@Override
public Collection<Region> listRegions() throws InternalException, CloudException {
    APITrace.begin(getProvider(), "listRegions");
    try {
        Cache<Region> cache = Cache.getInstance(getProvider(), "regions", Region.class, CacheLevel.CLOUD_ACCOUNT, new TimePeriod<Hour>(10, TimePeriod.HOUR));
        Collection<Region> regions = (Collection<Region>)cache.get(getContext());
        if( regions != null ) {
            return regions;
        }
        regions = new ArrayList<Region>();

        Regions availableRegions = (Regions)DigitalOceanModelFactory.getModel(getProvider(), org.dasein.cloud.digitalocean.models.rest.DigitalOcean.REGIONS);
        for( org.dasein.cloud.digitalocean.models.Region s : availableRegions.getRegions() ) {
            Region vmp = toRegion(s);
            regions.add(vmp);
        }
        cache.put(getContext(), regions);
        return regions;
    }
    finally {
        APITrace.end();
    }
}
 
开发者ID:greese,项目名称:dasein-cloud-digitalocean,代码行数:24,代码来源:DOLocation.java

示例7: getKeypair

import org.dasein.cloud.util.APITrace; //导入依赖的package包/类
@Override
public @Nullable SSHKeypair getKeypair(@Nonnull String providerId) throws InternalException, CloudException {
    APITrace.begin(getProvider(), "Keypair.getKeypair");
    try {
        Key key  = (Key) DigitalOceanModelFactory.getModelById(getProvider(), org.dasein.cloud.digitalocean.models.rest.DigitalOcean.KEY, providerId);
        return toSSHKeypair(key);
    }
    catch( CloudException e ) {
        if( e.getHttpCode() == 404 ) {
            return null; // not found
        }
        logger.error(e.getMessage());
        throw new CloudException(e);
    }
    finally {
        APITrace.end();
    }
}
 
开发者ID:greese,项目名称:dasein-cloud-digitalocean,代码行数:19,代码来源:Keypairs.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: 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

示例10: reboot

import org.dasein.cloud.util.APITrace; //导入依赖的package包/类
@Override
public void reboot(@Nonnull String vmId) throws CloudException, InternalException {
    APITrace.begin(provider, REBOOT_VIRTUAL_MACHINE);
    try {
        try {
            VirtustreamMethod method = new VirtustreamMethod(provider);
            String obj = method.postString("/VirtualMachine/"+vmId+"/RebootOS", "", REBOOT_VIRTUAL_MACHINE);
            if (obj != null && obj.length()> 0) {
                JSONObject json = new JSONObject(obj);
                if (provider.parseTaskId(json) == null) {
                    logger.warn("No confirmation of RebootVM 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

示例11: resume

import org.dasein.cloud.util.APITrace; //导入依赖的package包/类
@Override
public void resume(@Nonnull String vmId) throws CloudException, InternalException {
    APITrace.begin(provider, RESUME_VIRTUAL_MACHINE);
    try {
        try {
            VirtustreamMethod method = new VirtustreamMethod(provider);
            String obj = method.postString("/VirtualMachine/"+vmId+"/PowerOn", "", RESUME_VIRTUAL_MACHINE);
            if (obj != null && obj.length()> 0) {
                JSONObject json = new JSONObject(obj);
                if (provider.parseTaskId(json) == null) {
                    logger.warn("No confirmation of ResumeVM 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

示例12: 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

示例13: 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

示例14: getComputeResourceOfNetwork

import org.dasein.cloud.util.APITrace; //导入依赖的package包/类
private List<String> getComputeResourceOfNetwork(@Nonnull String networkId) throws CloudException, InternalException {
    APITrace.begin(provider, "getNetworkComputeResourceID");
    try {
        Networks services = provider.getNetworkServices().getVlanSupport();
        VLAN vlan = services.getVlan(networkId);
        int length = Integer.parseInt(vlan.getTag("numComputeIds"));
        List<String> list = new ArrayList<String>();
        for (int i = 0; i<length; i++) {
           String tag = "computeResourceID"+i;
           list.add(vlan.getTag(tag));
        }
        return list;

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

示例15: getComputeIDFromResourcePool

import org.dasein.cloud.util.APITrace; //导入依赖的package包/类
private String getComputeIDFromResourcePool(@Nonnull String resourcePoolID) throws InternalException, CloudException {
    APITrace.begin(provider, "Volumes.findResourcePool");
    try {
        try {
            VirtustreamMethod method = new VirtustreamMethod(provider);
            String obj = method.getString("/ResourcePool/"+resourcePoolID+"?$filter=IsRemoved eq false", "Volumes.findResourcePool");

            if (obj != null && obj.length() > 0) {
                JSONObject json = new JSONObject(obj);

                String computeId = json.getString("ComputeResourceID");
                return computeId;
            }
            logger.error("No available resource pool with id "+resourcePoolID);
            throw new CloudException("No available resource pool with id "+resourcePoolID);
        }
        catch (JSONException e) {
            logger.error(e);
            throw new InternalException("Unable to parse JSONObject "+e.getMessage());
        }
    }
    finally {
        APITrace.end();
    }
}
 
开发者ID:greese,项目名称:dasein-cloud-virtustream,代码行数:26,代码来源:Volumes.java


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