本文整理汇总了Java中org.dasein.cloud.util.APITrace.begin方法的典型用法代码示例。如果您正苦于以下问题:Java APITrace.begin方法的具体用法?Java APITrace.begin怎么用?Java APITrace.begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dasein.cloud.util.APITrace
的用法示例。
在下文中一共展示了APITrace.begin方法的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("/Network", IS_SUBSCRIBED);
return true;
}
catch (Throwable ignore){
return false;
}
}
finally {
APITrace.end();
}
}
示例2: 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();
}
}
示例3: 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();
}
}
示例4: getVlan
import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Override
public VLAN getVlan(@Nonnull String vlanId) throws CloudException, InternalException {
APITrace.begin(provider, GET_NETWORK);
try {
try {
VirtustreamMethod method = new VirtustreamMethod(provider);
String obj = method.getString("/Network/"+vlanId+"?$filter=IsRemoved eq false", GET_NETWORK);
if (obj != null && obj.length() > 0) {
JSONObject json = new JSONObject(obj);
VLAN vlan = toVlan(json);
if (vlan != null){
return vlan;
}
}
}
catch (JSONException e) {
logger.error(e);
throw new InternalException("Unable to parse JSONObject "+e.getMessage());
}
return null;
}
finally {
APITrace.end();
}
}
示例5: listVirtualMachines
import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Nonnull
@Override
public Iterable<VirtualMachine> listVirtualMachines(@Nullable VMFilterOptions options) throws InternalException, CloudException {
APITrace.begin(provider, LIST_VIRTUAL_MACHINES);
try {
try {
VirtustreamMethod method = new VirtustreamMethod(provider);
List<VirtualMachine> list = new ArrayList<VirtualMachine>();
String obj = method.getString("/VirtualMachine?$filter=IsTemplate eq false and IsRemoved eq false", LIST_VIRTUAL_MACHINES);
if (obj != null && obj.length() > 0) {
JSONArray json = new JSONArray(obj);
for (int i= 0; i<json.length(); i++) {
VirtualMachine vm = toVirtualMachine(json.getJSONObject(i));
if (vm != null && (options == null || options.matches(vm))) {
list.add(vm);
}
}
}
return list;
}
catch (JSONException e) {
logger.error(e);
throw new InternalException("Unable to parse JSONObject "+e.getMessage());
}
}
finally {
APITrace.end();
}
}
示例6: 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();
}
}
示例7: isSubscribed
import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Override
public boolean isSubscribed() throws CloudException, InternalException {
APITrace.begin(provider, IS_SUBSCRIBED);
try {
VirtualMachines support = provider.getComputeServices().getVirtualMachineSupport();
return support.isSubscribed();
}
finally {
APITrace.end();
}
}
示例8: remove
import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Override
public void remove(@Nonnull String providerImageId, boolean checkState) throws CloudException, InternalException {
APITrace.begin(getProvider(), "Image.remove");
try {
DigitalOceanModelFactory.performAction(getProvider(), new Destroy(), providerImageId);
}
finally {
APITrace.end();
}
}
示例9: 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();
}
示例10: searchPublicImages
import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Nonnull
@Override
public Iterable<MachineImage> searchPublicImages(@Nonnull ImageFilterOptions options) throws CloudException, InternalException {
APITrace.begin(getProvider(), SEARCH_PUBLIC_IMAGES);
try {
VirtustreamMethod method = new VirtustreamMethod(getProvider());
List<MachineImage> list = new ArrayList<MachineImage>();
JSONArray json;
String obj = method.getString("VirtualMachine?$filter=IsGlobalTemplate eq true and IsRemoved eq false", SEARCH_PUBLIC_IMAGES);
if (obj != null && obj.length() > 0) {
try {
json = new JSONArray(obj);
for (int i = 0; i<json.length(); i++) {
MachineImage img = toImage(json.getJSONObject(i));
if (img != null && (options == null || options.matches(img))) {
list.add(img);
}
}
}
catch (JSONException e) {
logger.error(e);
throw new InternalException("Unable to parse JSON "+e.getMessage());
}
}
return list;
}
finally {
APITrace.end();
}
}
示例11: waitForAllDropletEventsToComplete
import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
/**
* Wait for specified number of minutes for all pending droplet events to complete
* @param instanceId Id of the droplet
* @param timeout Time in minutes to wait for events to complete
* @throws InternalException
* @throws CloudException
*/
void waitForAllDropletEventsToComplete(@Nonnull String instanceId, int timeout) throws InternalException, CloudException {
APITrace.begin(getProvider(), "listVirtualMachineStatus");
try {
// allow maximum five minutes for events to complete
long wait = System.currentTimeMillis() + timeout * 60 * 1000;
boolean eventsPending = false;
while( System.currentTimeMillis() < wait ) {
Actions actions = DigitalOceanModelFactory.getDropletEvents(getProvider(), instanceId);
for( Action action : actions.getActions() ) {
if( "in-progress".equalsIgnoreCase(action.getStatus()) ) {
eventsPending = true;
}
}
if( !eventsPending ) {
break;
}
try {
// must be careful here not to cause rate limits
Thread.sleep(30000);
}
catch( InterruptedException e ) {
break;
}
}
// if events are still pending the cloud will fail the next operation anyway
}
finally {
APITrace.end();
}
}
示例12: renameBucket
import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Nonnull
@Override
public String renameBucket(@Nonnull String oldName, @Nonnull String newName, boolean findFreeName) throws CloudException, InternalException {
APITrace.begin(getProvider(), RENAME_BUCKET);
try {
try {
VirtustreamMethod method = new VirtustreamMethod(getProvider());
if (oldName.indexOf("/") >=0) {
// can only rename the top level storage not lower folders
throw new OperationNotSupportedException("Virtustream does not support rename of folders");
}
findStorageObjectForName(oldName);
JSONObject json = new JSONObject();
json.put("StorageID", storageId);
json.put("CustomerDefinedName", newName);
String obj = method.postString("/Storage/RenameStorage", json.toString(), RENAME_BUCKET);
if (obj != null && obj.length() > 0) {
JSONObject response = new JSONObject(obj);
if (getProvider().parseTaskId(response) == null) {
logger.warn("No confirmation of RenameBucket task completion but no error either");
}
}
return newName;
}
catch (JSONException e) {
logger.error(e);
throw new InternalException("Unable to parse JSONObject "+e.getMessage());
}
}
finally {
APITrace.end();
}
}
示例13: removeObject
import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Override
public void removeObject(@Nullable String bucket, @Nonnull String object) throws CloudException, InternalException {
APITrace.begin(getProvider(), REMOVE_OBJECT);
try {
try {
VirtustreamMethod method = new VirtustreamMethod(getProvider());
String storageName = bucket;
String path = "/";
if (bucket.indexOf("/") >=0) {
storageName = bucket.substring(0, bucket.indexOf("/"));
path = bucket.substring(bucket.indexOf("/"));
}
findStorageObjectForName(storageName);
JSONObject json = new JSONObject();
json.put("StorageID", storageId);
json.put("FilePath", path+"/"+object);
String obj = method.postString("/Storage/DeleteFile", json.toString(), REMOVE_OBJECT);
if (obj != null && obj.length() > 0) {
JSONObject response = new JSONObject(obj);
if (getProvider().parseTaskId(response) == null) {
logger.warn("No confirmation of RemoveObject task completion but no error either");
}
}
}
catch (JSONException e) {
logger.error(e);
throw new InternalException("Unable to parse JSONObject "+e.getMessage());
}
}
finally {
APITrace.end();
}
}
示例14: 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();
}
}
示例15: terminate
import org.dasein.cloud.util.APITrace; //导入方法依赖的package包/类
@Override
public void terminate(@Nonnull String instanceId, @Nullable String explanation) throws InternalException, CloudException {
APITrace.begin(getProvider(), "terminateVM");
try {
if( getVirtualMachine(instanceId) == null ) {
throw new CloudException("No such instance found: " + instanceId);
}
DigitalOceanModelFactory.performAction(getProvider(), new Destroy(), instanceId);
} finally {
APITrace.end();
}
}