From ede85e28f562c11e77a03b63a7a2708579389337 Mon Sep 17 00:00:00 2001 From: Alasdair Hodge Date: Wed, 21 Dec 2011 11:22:08 +0000 Subject: [PATCH] Drive domain object (and subclasses) refer to tags, and not explicitly to affinity --- .../cloudsigma/domain/CreateDriveRequest.java | 6 +-- .../org/jclouds/cloudsigma/domain/Drive.java | 50 ++++++++----------- .../jclouds/cloudsigma/domain/DriveData.java | 6 +-- .../jclouds/cloudsigma/domain/DriveInfo.java | 6 +-- 4 files changed, 30 insertions(+), 38 deletions(-) diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java index 4e8a507af4..30db029c76 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java @@ -89,7 +89,7 @@ public class CreateDriveRequest extends Drive { } public CreateDriveRequest build() { - return new CreateDriveRequest(name, size, claimType, affinity, readers, use, encryptionCipher, avoid); + return new CreateDriveRequest(name, size, claimType, tags, readers, use, encryptionCipher, avoid); } } @@ -97,9 +97,9 @@ public class CreateDriveRequest extends Drive { @Nullable private final String encryptionCipher; - public CreateDriveRequest(String name, long size, @Nullable ClaimType claimType, AffinityType affinity, + public CreateDriveRequest(String name, long size, @Nullable ClaimType claimType, Iterable tags, Iterable readers, Iterable use, @Nullable String encryptionCipher, Iterable avoid) { - super(null, name, size, claimType, affinity, readers, use); + super(null, name, size, claimType, tags, readers, use); this.encryptionCipher = encryptionCipher; this.avoid = ImmutableSet.copyOf(checkNotNull(avoid, "avoid")); } diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java index aadf281dba..5adcce61ca 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java @@ -24,6 +24,7 @@ import java.util.Set; import org.jclouds.javax.annotation.Nullable; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; /** @@ -34,7 +35,7 @@ public class Drive extends Item { public static class Builder extends Item.Builder { protected long size; protected ClaimType claimType = ClaimType.EXCLUSIVE; - protected AffinityType affinity = AffinityType.HDD; + protected Set tags = ImmutableSet.of(); protected Set readers = ImmutableSet.of(); public Builder claimType(ClaimType claimType) { @@ -42,8 +43,8 @@ public class Drive extends Item { return this; } - public Builder affinity(AffinityType affinity) { - this.affinity = affinity; + public Builder tags(Iterable tags) { + this.tags = ImmutableSet.copyOf(checkNotNull(tags, "tags")); return this; } @@ -82,7 +83,7 @@ public class Drive extends Item { } public Drive build() { - return new Drive(uuid, name, size, claimType, affinity, readers, use); + return new Drive(uuid, name, size, claimType, tags, readers, use); } @Override @@ -90,7 +91,7 @@ public class Drive extends Item { final int prime = 31; int result = super.hashCode(); result = prime * result + ((claimType == null) ? 0 : claimType.hashCode()); - result = prime * result + ((affinity == null) ? 0 : affinity.hashCode()); + result = prime * result + ((tags == null) ? 0 : tags.hashCode()); result = prime * result + ((readers == null) ? 0 : readers.hashCode()); result = prime * result + (int) (size ^ (size >>> 32)); return result; @@ -107,13 +108,10 @@ public class Drive extends Item { Builder other = (Builder) obj; if (claimType != other.claimType) return false; - if (affinity != other.affinity) + if (!Objects.equal(tags, other.tags)) + return false; + if (!Objects.equal(readers, other.readers)) return false; - if (readers == null) { - if (other.readers != null) - return false; - } else if (!readers.equals(other.readers)) - return false; if (size != other.size) return false; return true; @@ -122,15 +120,15 @@ public class Drive extends Item { protected final long size; protected final ClaimType claimType; - protected final AffinityType affinity; + protected final Set tags; protected final Set readers; public Drive(@Nullable String uuid, String name, long size, @Nullable ClaimType claimType, - AffinityType affinity, Iterable readers, Iterable use) { + Iterable tags, Iterable readers, Iterable use) { super(uuid, name, use); this.size = size; this.claimType = checkNotNull(claimType, "set claimType to exclusive, not null"); - this.affinity = checkNotNull(affinity, "affinity"); + this.tags = ImmutableSet.copyOf(checkNotNull(tags, "tags")); this.readers = ImmutableSet.copyOf(checkNotNull(readers, "readers")); } @@ -145,10 +143,10 @@ public class Drive extends Item { } /** - * @return either 'HDD' (the default) or 'SSD' (for solid-state drives) + * @return all tags associated with this drive, both user-specified and "system" tags (e.g. "affinity:ssd") */ - public AffinityType getAffinity() { - return affinity; + public Set getTags() { + return tags; } /** @@ -173,7 +171,7 @@ public class Drive extends Item { final int prime = 31; int result = 1; result = prime * result + ((claimType == null) ? 0 : claimType.hashCode()); - result = prime * result + ((affinity == null) ? 0 : affinity.hashCode()); + result = prime * result + ((tags == null) ? 0 : tags.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((readers == null) ? 0 : readers.hashCode()); result = prime * result + (int) (size ^ (size >>> 32)); @@ -192,18 +190,12 @@ public class Drive extends Item { Drive other = (Drive) obj; if (claimType != other.claimType) return false; - if (affinity != other.affinity) + if (!Objects.equal(tags, other.tags)) + return false; + if (!Objects.equal(name, other.name)) + return false; + if (!Objects.equal(readers, other.readers)) return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (readers == null) { - if (other.readers != null) - return false; - } else if (!readers.equals(other.readers)) - return false; if (size != other.size) return false; if (use == null) { diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java index 7a8e96d651..7d0a561195 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java @@ -68,12 +68,12 @@ public class DriveData extends Drive { } public DriveData build() { - return new DriveData(uuid, name, size, claimType, affinity, readers, use); + return new DriveData(uuid, name, size, claimType, tags, readers, use); } } public DriveData(@Nullable String uuid, String name, long size, @Nullable ClaimType claimType, - AffinityType affinity, Iterable readers, Iterable use) { - super(uuid, name, size, claimType, affinity, readers, use); + Iterable tags, Iterable readers, Iterable use) { + super(uuid, name, size, claimType, tags, readers, use); } } \ No newline at end of file diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java index 5c4b72fad7..0738d86727 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java @@ -195,7 +195,7 @@ public class DriveInfo extends Drive { */ @Override public DriveInfo build() { - return new DriveInfo(uuid, name, size, claimType, affinity, readers, use, status, user, claimed, encryptionCipher, + return new DriveInfo(uuid, name, size, claimType, tags, readers, use, status, user, claimed, encryptionCipher, imaging, metrics, autoexpanding, bits, description, driveType, encryptionKey, free, installNotes, os, type, url); } @@ -221,12 +221,12 @@ public class DriveInfo extends Drive { private final DriveType type; private final URI url; - public DriveInfo(String uuid, String name, long size, ClaimType claimType, AffinityType affinity, Iterable readers, + public DriveInfo(String uuid, String name, long size, ClaimType claimType, Iterable tags, Iterable readers, Iterable use, DriveStatus status, String user, Set claimed, String encryptionCipher, String imaging, DriveMetrics metrics, Boolean autoexpanding, Integer bits, String description, Iterable driveType, String encryptionKey, Boolean free, String installNotes, String os, DriveType type, URI url) { - super(uuid, name, size, claimType, affinity, readers, use); + super(uuid, name, size, claimType, tags, readers, use); this.status = status; this.user = user; this.claimed = ImmutableSet.copyOf(checkNotNull(claimed, "claimed"));