mirror of https://github.com/apache/jclouds.git
Issue 112: change task to be id and not uri based
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2449 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
a9e00bab79
commit
8c5f3bec4a
|
@ -29,7 +29,6 @@ import static org.jclouds.vcloud.VCloudMediaType.TASK_XML;
|
|||
import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.VDC_XML;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
|
@ -158,12 +157,15 @@ public interface VCloudAsyncClient {
|
|||
|
||||
@GET
|
||||
@Consumes(TASK_XML)
|
||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||
@Path("/task/{taskId}")
|
||||
@XMLResponseParser(TaskHandler.class)
|
||||
Future<? extends Task> getTask(@Endpoint URI task);
|
||||
Future<? extends Task> getTask(@PathParam("taskId") String taskId);
|
||||
|
||||
@POST
|
||||
@Path("/action/cancel")
|
||||
Future<Void> cancelTask(@Endpoint URI task);
|
||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||
@Path("/task/{taskId}/action/cancel")
|
||||
Future<Void> cancelTask(@PathParam("taskId") String taskId);
|
||||
|
||||
@GET
|
||||
@Consumes(VAPP_XML)
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
*/
|
||||
package org.jclouds.vcloud;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
|
@ -81,9 +80,9 @@ public interface VCloudClient {
|
|||
*/
|
||||
Task suspendVApp(String vAppId);
|
||||
|
||||
Task getTask(URI task);
|
||||
Task getTask(String taskId);
|
||||
|
||||
void cancelTask(URI task);
|
||||
void cancelTask(String taskId);
|
||||
|
||||
VApp getVApp(String appId);
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.domain;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
|
||||
import org.jclouds.rest.domain.Link;
|
||||
import org.jclouds.rest.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.internal.TaskImpl;
|
||||
|
||||
|
@ -35,15 +35,18 @@ import com.google.inject.ImplementedBy;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@ImplementedBy(TaskImpl.class)
|
||||
public interface Task extends Link, Comparable<Task> {
|
||||
public interface Task extends Comparable<Task> {
|
||||
String getId();
|
||||
|
||||
TaskStatus getStatus();
|
||||
URI getLocation();
|
||||
|
||||
Date getStartTime();
|
||||
TaskStatus getStatus();
|
||||
|
||||
Date getEndTime();
|
||||
Date getStartTime();
|
||||
|
||||
NamedResource getOwner();
|
||||
Date getEndTime();
|
||||
|
||||
NamedResource getResult();
|
||||
NamedResource getOwner();
|
||||
|
||||
NamedResource getResult();
|
||||
}
|
|
@ -29,7 +29,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
public enum TaskStatus {
|
||||
SUCCESS, FAILED, RUNNING, QUEUED, ERROR, CANCELLED;
|
||||
SUCCESS, FAILED, RUNNING, QUEUED, ERROR, CANCELLED, COMPLETED;
|
||||
public String value() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
|
|
|
@ -29,8 +29,6 @@ import java.net.URI;
|
|||
import java.util.Date;
|
||||
|
||||
import org.jclouds.rest.domain.NamedResource;
|
||||
import org.jclouds.rest.domain.internal.LinkImpl;
|
||||
import org.jclouds.vcloud.VCloudMediaType;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.TaskStatus;
|
||||
|
||||
|
@ -42,102 +40,130 @@ import com.google.inject.internal.Nullable;
|
|||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
public class TaskImpl extends LinkImpl implements Task {
|
||||
private final TaskStatus status;
|
||||
private final Date startTime;
|
||||
@Nullable
|
||||
private final Date endTime;
|
||||
private final NamedResource owner;
|
||||
@Nullable
|
||||
private final NamedResource result;
|
||||
public class TaskImpl implements Task {
|
||||
private final String id;
|
||||
private final URI location;
|
||||
private final TaskStatus status;
|
||||
private final Date startTime;
|
||||
@Nullable
|
||||
private final Date endTime;
|
||||
private final NamedResource owner;
|
||||
@Nullable
|
||||
private final NamedResource result;
|
||||
|
||||
public TaskImpl(URI location, TaskStatus status, Date startTime, @Nullable Date endTime,
|
||||
NamedResource owner, @Nullable NamedResource result) {
|
||||
super(VCloudMediaType.TASK_XML, location);
|
||||
this.status = checkNotNull(status, "status");
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
this.owner = owner;
|
||||
this.result = result;
|
||||
}
|
||||
public TaskImpl(String id, URI location, TaskStatus status, Date startTime,
|
||||
@Nullable Date endTime, NamedResource owner,
|
||||
@Nullable NamedResource result) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.location = checkNotNull(location, "location");
|
||||
this.status = checkNotNull(status, "status");
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
this.owner = owner;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public TaskStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
public TaskStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public Date getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
public Date getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public NamedResource getOwner() {
|
||||
return owner;
|
||||
}
|
||||
public NamedResource getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public NamedResource getResult() {
|
||||
return result;
|
||||
}
|
||||
public NamedResource getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public Date getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
public Date getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public int compareTo(Task o) {
|
||||
return (this == o) ? 0 : getStartTime().compareTo(o.getStartTime());
|
||||
}
|
||||
public int compareTo(Task o) {
|
||||
return (this == o) ? 0 : getId().compareTo(o.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + ((endTime == null) ? 0 : endTime.hashCode());
|
||||
result = prime * result + ((owner == null) ? 0 : owner.hashCode());
|
||||
result = prime * result + ((this.result == null) ? 0 : this.result.hashCode());
|
||||
result = prime * result + ((startTime == null) ? 0 : startTime.hashCode());
|
||||
result = prime * result + ((status == null) ? 0 : status.hashCode());
|
||||
return result;
|
||||
}
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!super.equals(obj))
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
TaskImpl other = (TaskImpl) obj;
|
||||
if (endTime == null) {
|
||||
if (other.endTime != null)
|
||||
return false;
|
||||
} else if (!endTime.equals(other.endTime))
|
||||
return false;
|
||||
if (owner == null) {
|
||||
if (other.owner != null)
|
||||
return false;
|
||||
} else if (!owner.equals(other.owner))
|
||||
return false;
|
||||
if (result == null) {
|
||||
if (other.result != null)
|
||||
return false;
|
||||
} else if (!result.equals(other.result))
|
||||
return false;
|
||||
if (startTime == null) {
|
||||
if (other.startTime != null)
|
||||
return false;
|
||||
} else if (!startTime.equals(other.startTime))
|
||||
return false;
|
||||
if (status == null) {
|
||||
if (other.status != null)
|
||||
return false;
|
||||
} else if (!status.equals(other.status))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
public URI getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TaskImpl [endTime=" + endTime + ", owner=" + owner + ", result=" + result
|
||||
+ ", startTime=" + startTime + ", status=" + status + "]";
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((endTime == null) ? 0 : endTime.hashCode());
|
||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||
result = prime * result
|
||||
+ ((location == null) ? 0 : location.hashCode());
|
||||
result = prime * result + ((owner == null) ? 0 : owner.hashCode());
|
||||
result = prime * result
|
||||
+ ((this.result == null) ? 0 : this.result.hashCode());
|
||||
result = prime * result
|
||||
+ ((startTime == null) ? 0 : startTime.hashCode());
|
||||
result = prime * result + ((status == null) ? 0 : status.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
TaskImpl other = (TaskImpl) obj;
|
||||
if (endTime == null) {
|
||||
if (other.endTime != null)
|
||||
return false;
|
||||
} else if (!endTime.equals(other.endTime))
|
||||
return false;
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
if (location == null) {
|
||||
if (other.location != null)
|
||||
return false;
|
||||
} else if (!location.equals(other.location))
|
||||
return false;
|
||||
if (owner == null) {
|
||||
if (other.owner != null)
|
||||
return false;
|
||||
} else if (!owner.equals(other.owner))
|
||||
return false;
|
||||
if (result == null) {
|
||||
if (other.result != null)
|
||||
return false;
|
||||
} else if (!result.equals(other.result))
|
||||
return false;
|
||||
if (startTime == null) {
|
||||
if (other.startTime != null)
|
||||
return false;
|
||||
} else if (!startTime.equals(other.startTime))
|
||||
return false;
|
||||
if (status == null) {
|
||||
if (other.status != null)
|
||||
return false;
|
||||
} else if (!status.equals(other.status))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TaskImpl [endTime=" + endTime + ", id=" + id + ", location="
|
||||
+ location + ", owner=" + owner + ", result=" + result
|
||||
+ ", startTime=" + startTime + ", status=" + status + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -23,17 +23,11 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.predicates;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.vcloud.VCloudAsyncClient;
|
||||
import org.jclouds.vcloud.VCloudClient;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.TaskStatus;
|
||||
|
||||
|
@ -47,40 +41,25 @@ import com.google.inject.Inject;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class TaskSuccess implements Predicate<URI> {
|
||||
public class TaskSuccess implements Predicate<String> {
|
||||
|
||||
private final VCloudAsyncClient client;
|
||||
private final VCloudClient client;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named("org.jclouds.vcloud.timeout")
|
||||
private long taskTimeout = 30000;
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
@Inject
|
||||
public TaskSuccess(VCloudClient client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public TaskSuccess(VCloudAsyncClient client) {
|
||||
this.client = client;
|
||||
}
|
||||
public boolean apply(String taskId) {
|
||||
logger.trace("looking for status on task %s", taskId);
|
||||
|
||||
public boolean apply(URI taskUri) {
|
||||
logger.trace("looking for status on task %s", taskUri);
|
||||
|
||||
Task task;
|
||||
try {
|
||||
task = client.getTask(taskUri).get(taskTimeout, TimeUnit.MILLISECONDS);
|
||||
logger.trace("%s: looking for status %s: currently: %s", task, TaskStatus.SUCCESS, task
|
||||
.getStatus());
|
||||
return task.getStatus() == TaskStatus.SUCCESS;
|
||||
} catch (InterruptedException e) {
|
||||
logger.warn(e, "%s interrupted, returning false", taskUri);
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e.getCause());
|
||||
} catch (TimeoutException e) {
|
||||
logger.warn(e, "%s timeout, returning false", taskUri);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
Task task = client.getTask(taskId);
|
||||
logger.trace("%s: looking for status %s: currently: %s", task,
|
||||
TaskStatus.SUCCESS, task.getStatus());
|
||||
return task.getStatus() == TaskStatus.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ import javax.inject.Inject;
|
|||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.rest.domain.Link;
|
||||
import org.jclouds.rest.domain.NamedResource;
|
||||
import org.jclouds.rest.util.Utils;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
|
@ -47,7 +46,7 @@ import org.xml.sax.SAXException;
|
|||
public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
|
||||
protected final DateService dateService;
|
||||
|
||||
private Link taskLink;
|
||||
private NamedResource taskLink;
|
||||
private NamedResource owner;
|
||||
private NamedResource result;
|
||||
private TaskStatus status;
|
||||
|
@ -72,7 +71,7 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
|
|||
throws SAXException {
|
||||
if (qName.equalsIgnoreCase("Task")) {
|
||||
if (attributes.getIndex("href") != -1)// queued tasks may not have an href yet
|
||||
taskLink = Utils.newLink(attributes);
|
||||
taskLink = Utils.newNamedResource(attributes);
|
||||
status = TaskStatus.fromValue(attributes.getValue(attributes.getIndex("status")));
|
||||
if (attributes.getIndex("startTime") != -1)
|
||||
startTime = parseDate(attributes, "startTime");
|
||||
|
@ -83,7 +82,7 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
|
|||
owner = Utils.newNamedResource(attributes);
|
||||
} else if (qName.equals("Link") && attributes.getIndex("rel") != -1
|
||||
&& attributes.getValue(attributes.getIndex("rel")).equals("self")) {
|
||||
taskLink = Utils.newNamedLink(attributes);
|
||||
taskLink = Utils.newNamedResource(attributes);
|
||||
} else if (qName.equals("Result")) {
|
||||
result = Utils.newNamedResource(attributes);
|
||||
}
|
||||
|
@ -111,7 +110,7 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
|
|||
@Override
|
||||
public void endElement(String uri, String localName, String qName) throws SAXException {
|
||||
if (qName.equalsIgnoreCase("Task")) {
|
||||
this.task = new TaskImpl(taskLink.getLocation(), status, startTime, endTime, owner, result);
|
||||
this.task = new TaskImpl(taskLink.getId(), taskLink.getLocation(), status, startTime, endTime, owner, result);
|
||||
taskLink = null;
|
||||
status = null;
|
||||
startTime = null;
|
||||
|
|
|
@ -250,9 +250,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
}
|
||||
|
||||
public void testGetTask() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getTask", URI.class);
|
||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, URI
|
||||
.create("http://vcloud/task/1"));
|
||||
Method method = VCloudAsyncClient.class.getMethod("getTask", String.class);
|
||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "1");
|
||||
|
||||
assertRequestLineEquals(httpMethod, "GET http://vcloud/task/1 HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
|
@ -266,9 +265,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
}
|
||||
|
||||
public void testCancelTask() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("cancelTask", URI.class);
|
||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, URI
|
||||
.create("http://vcloud/task/1"));
|
||||
Method method = VCloudAsyncClient.class.getMethod("cancelTask", String.class);
|
||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "1");
|
||||
|
||||
assertRequestLineEquals(httpMethod, "POST http://vcloud/task/1/action/cancel HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod, "");
|
||||
|
|
|
@ -83,7 +83,7 @@ public class VCloudClientLiveTest {
|
|||
assertNotNull(response.getLocation());
|
||||
assertNotNull(response.getTasks());
|
||||
for (Task t : response.getTasks()) {
|
||||
assertEquals(connection.getTask(t.getLocation()).getLocation(), t.getLocation());
|
||||
assertEquals(connection.getTask(t.getId()).getLocation(), t.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -179,8 +179,8 @@ public class VCloudComputeClientLiveTest {
|
|||
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
private Predicate<URI> successTester(TaskSuccess success) {
|
||||
return new RetryablePredicate<URI>(success, 300, 10, TimeUnit.SECONDS);
|
||||
private Predicate<String> successTester(TaskSuccess success) {
|
||||
return new RetryablePredicate<String>(success, 300, 10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
}).buildInjector();
|
||||
|
|
|
@ -60,7 +60,7 @@ public class TaskHandlerTest extends BaseHandlerTest {
|
|||
|
||||
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
||||
|
||||
Task expects = new TaskImpl(URI
|
||||
Task expects = new TaskImpl("3299", URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"),
|
||||
TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"),
|
||||
dateService.iso8601DateParse("2009-08-24T21:29:44.65Z"), new NamedResourceImpl("1",
|
||||
|
@ -81,7 +81,7 @@ public class TaskHandlerTest extends BaseHandlerTest {
|
|||
|
||||
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
||||
|
||||
Task expects = new TaskImpl(URI
|
||||
Task expects = new TaskImpl("d188849-78", URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-78"),
|
||||
TaskStatus.QUEUED, null, null, null, null
|
||||
);
|
||||
|
@ -94,7 +94,7 @@ public class TaskHandlerTest extends BaseHandlerTest {
|
|||
|
||||
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
||||
|
||||
Task expects = new TaskImpl(URI
|
||||
Task expects = new TaskImpl("d188849-72", URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-72"),
|
||||
TaskStatus.RUNNING, dateService.iso8601SecondsDateParse("2001-01-01T05:00:00Z"),
|
||||
null, new NamedResourceImpl("188849", "188849", VCloudMediaType.VDC_XML, URI
|
||||
|
|
|
@ -65,7 +65,7 @@ public class TasksListHandlerTest extends BaseHandlerTest {
|
|||
TasksList result = factory.create(injector.getInstance(TasksListHandler.class)).parse(is);
|
||||
assertEquals(result.getLocation(), URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/1"));
|
||||
Task task1 = new TaskImpl(URI
|
||||
Task task1 = new TaskImpl("3300", URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3300"),
|
||||
TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:30:19.587Z"),
|
||||
dateService.iso8601DateParse("2009-08-24T21:30:32.63Z"), new NamedResourceImpl("1",
|
||||
|
@ -73,7 +73,7 @@ public class TasksListHandlerTest extends BaseHandlerTest {
|
|||
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
|
||||
new NamedResourceImpl("4012", "Server1", VCloudMediaType.VAPP_XML, URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")));
|
||||
Task task2 = new TaskImpl(URI
|
||||
Task task2 = new TaskImpl("3299", URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"),
|
||||
TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"),
|
||||
dateService.iso8601DateParse("2009-08-24T21:29:44.65Z"), new NamedResourceImpl("1",
|
||||
|
|
|
@ -26,7 +26,6 @@ package org.jclouds.vcloud.hostingdotcom.compute;
|
|||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
@ -53,12 +52,12 @@ public class HostingDotComVCloudComputeClient {
|
|||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
private final Predicate<URI> taskTester;
|
||||
private final Predicate<String> taskTester;
|
||||
private final HostingDotComVCloudClient tmClient;
|
||||
|
||||
@Inject
|
||||
public HostingDotComVCloudComputeClient(HostingDotComVCloudClient tmClient,
|
||||
Predicate<URI> successTester) {
|
||||
Predicate<String> successTester) {
|
||||
this.tmClient = tmClient;
|
||||
this.taskTester = successTester;
|
||||
}
|
||||
|
@ -127,7 +126,7 @@ public class HostingDotComVCloudComputeClient {
|
|||
|
||||
private VApp blockUntilVAppStatusOrThrowException(VApp vApp, Task deployTask, String taskType,
|
||||
VAppStatus expectedStatus) {
|
||||
if (!taskTester.apply(deployTask.getLocation())) {
|
||||
if (!taskTester.apply(deployTask.getId())) {
|
||||
throw new TaskException(taskType, vApp, deployTask);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,8 +69,8 @@ public class HostingDotComVCloudRestClientModule extends VCloudRestClientModule
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Predicate<URI> successTester(TaskSuccess success) {
|
||||
return new RetryablePredicate<URI>(success, 600, 10, TimeUnit.SECONDS);
|
||||
protected Predicate<String> successTester(TaskSuccess success) {
|
||||
return new RetryablePredicate<String>(success, 600, 10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
|
@ -28,7 +28,6 @@ import static org.jclouds.vcloud.terremark.options.AddInternetServiceOptions.Bui
|
|||
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
@ -62,11 +61,11 @@ public class TerremarkVCloudComputeClient {
|
|||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
private final Predicate<URI> taskTester;
|
||||
private final Predicate<String> taskTester;
|
||||
private final TerremarkVCloudClient tmClient;
|
||||
|
||||
@Inject
|
||||
public TerremarkVCloudComputeClient(TerremarkVCloudClient tmClient, Predicate<URI> successTester) {
|
||||
public TerremarkVCloudComputeClient(TerremarkVCloudClient tmClient, Predicate<String> successTester) {
|
||||
this.tmClient = tmClient;
|
||||
this.taskTester = successTester;
|
||||
}
|
||||
|
@ -218,7 +217,7 @@ public class TerremarkVCloudComputeClient {
|
|||
|
||||
private TerremarkVApp blockUntilVAppStatusOrThrowException(TerremarkVApp vApp, Task deployTask,
|
||||
String taskType, VAppStatus expectedStatus) {
|
||||
if (!taskTester.apply(deployTask.getLocation())) {
|
||||
if (!taskTester.apply(deployTask.getId())) {
|
||||
throw new TaskException(taskType, vApp, deployTask);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
@ -76,8 +75,8 @@ public class TerremarkVCloudRestClientModule extends VCloudRestClientModule {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Predicate<URI> successTester(TaskSuccess success) {
|
||||
return new RetryablePredicate<URI>(success, 600, 10, TimeUnit.SECONDS);
|
||||
protected Predicate<String> successTester(TaskSuccess success) {
|
||||
return new RetryablePredicate<String>(success, 600, 10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
|
@ -31,7 +31,6 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
@ -80,7 +79,7 @@ public class TerremarkVCloudClientLiveTest extends VCloudClientLiveTest {
|
|||
|
||||
private RetryablePredicate<InetSocketAddress> socketTester;
|
||||
|
||||
private RetryablePredicate<URI> successTester;
|
||||
private RetryablePredicate<String> successTester;
|
||||
|
||||
public static final String PREFIX = System.getProperty("user.name") + "-terremark";
|
||||
|
||||
|
@ -134,12 +133,12 @@ public class TerremarkVCloudClientLiveTest extends VCloudClientLiveTest {
|
|||
assertEquals(vApp.getStatus(), VAppStatus.CREATING);
|
||||
|
||||
try {// per docs, this is not supported
|
||||
tmClient.cancelTask(deployTask.getLocation());
|
||||
tmClient.cancelTask(deployTask.getId());
|
||||
} catch (HttpResponseException e) {
|
||||
assertEquals(e.getResponse().getStatusCode(), 501);
|
||||
}
|
||||
|
||||
assert successTester.apply(deployTask.getLocation());
|
||||
assert successTester.apply(deployTask.getId());
|
||||
System.out.printf("%d: done deploying vApp%n", System.currentTimeMillis());
|
||||
|
||||
vApp = tmClient.getVApp(vApp.getId());
|
||||
|
@ -150,7 +149,7 @@ public class TerremarkVCloudClientLiveTest extends VCloudClientLiveTest {
|
|||
verifyConfigurationOfVApp(vApp, serverName, expectedOs, processorCount, memory, hardDisk);
|
||||
assertEquals(vApp.getStatus(), VAppStatus.OFF);
|
||||
|
||||
assert successTester.apply(tmClient.powerOnVApp(vApp.getId()).getLocation());
|
||||
assert successTester.apply(tmClient.powerOnVApp(vApp.getId()).getId());
|
||||
System.out.printf("%d: done powering on vApp%n", System.currentTimeMillis());
|
||||
|
||||
vApp = tmClient.getVApp(vApp.getId());
|
||||
|
@ -190,7 +189,7 @@ public class TerremarkVCloudClientLiveTest extends VCloudClientLiveTest {
|
|||
assertEquals(e.getResponse().getStatusCode(), 501);
|
||||
}
|
||||
|
||||
assert successTester.apply(tmClient.resetVApp(vApp.getId()).getLocation());
|
||||
assert successTester.apply(tmClient.resetVApp(vApp.getId()).getId());
|
||||
|
||||
vApp = tmClient.getVApp(vApp.getId());
|
||||
|
||||
|
@ -201,7 +200,7 @@ public class TerremarkVCloudClientLiveTest extends VCloudClientLiveTest {
|
|||
// vApp = tmClient.getVApp(vApp.getId());
|
||||
// assertEquals(vApp.getStatus(), VAppStatus.ON);
|
||||
|
||||
assert successTester.apply(tmClient.powerOffVApp(vApp.getId()).getLocation());
|
||||
assert successTester.apply(tmClient.powerOffVApp(vApp.getId()).getId());
|
||||
|
||||
vApp = tmClient.getVApp(vApp.getId());
|
||||
assertEquals(vApp.getStatus(), VAppStatus.OFF);
|
||||
|
@ -252,7 +251,7 @@ public class TerremarkVCloudClientLiveTest extends VCloudClientLiveTest {
|
|||
tmClient.deleteInternetService(is.getId());
|
||||
if (vApp != null) {
|
||||
try {
|
||||
successTester.apply(tmClient.powerOffVApp(vApp.getId()).getLocation());
|
||||
successTester.apply(tmClient.powerOffVApp(vApp.getId()).getId());
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
@ -276,7 +275,7 @@ public class TerremarkVCloudClientLiveTest extends VCloudClientLiveTest {
|
|||
.getInstance(SocketOpen.class), 130, 10, TimeUnit.SECONDS);// make it longer then
|
||||
// default internet
|
||||
// service timeout
|
||||
successTester = new RetryablePredicate<URI>(injector.getInstance(TaskSuccess.class), 300, 10,
|
||||
successTester = new RetryablePredicate<String>(injector.getInstance(TaskSuccess.class), 300, 10,
|
||||
TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue