Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
add polling start and end events
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanbrainard committed Jun 28, 2012
1 parent 7cbde55 commit 7f8e8c9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Expand Up @@ -190,6 +190,7 @@ protected ClientResponse upload(DeployRequest deployRequest) throws DeploymentEx
}

protected Map<String, String> poll(DeployRequest deployRequest, ClientResponse uploadResponse) {
deployRequest.getEventSubscription().announce(POLL_START);
final List<String> locationHeaders = uploadResponse.getHeaders().get("Location");
if (locationHeaders == null || locationHeaders.get(0) == null) {
throw new DeploymentException("Location header not found");
Expand All @@ -201,7 +202,7 @@ protected Map<String, String> poll(DeployRequest deployRequest, ClientResponse u
long pollingInterval = deployRequest.getPollingIntervalInit();
final long startTime = System.currentTimeMillis();
while (STATUS_IN_PROCESS.equals(response.get(STATUS))) {
deployRequest.getEventSubscription().announce(POLL);
deployRequest.getEventSubscription().announce(POLLING);
response = stringify(pollingRequest.get(Map.class));

if (System.currentTimeMillis() - startTime > deployRequest.getPollingTimeout()) {
Expand All @@ -220,6 +221,7 @@ protected Map<String, String> poll(DeployRequest deployRequest, ClientResponse u
throw new DeploymentException(unsuccessfulMsg, response.toString());
}

deployRequest.getEventSubscription().announce(POLL_END);
return response;
}

Expand Down
Expand Up @@ -13,7 +13,9 @@ public static enum Event {
DEPLOY_START,
UPLOAD_START,
UPLOAD_END,
POLL,
POLL_START,
POLLING,
POLL_END,
DEPLOY_END
}

Expand Down
Expand Up @@ -36,7 +36,7 @@ public void handle(Event event) {
@Test
public void testDeploy() throws Exception {
assertEquals(STATUS_SUCCESS, client.deploy(new DeployRequest(WAR_PIPELINE, appName, warBundle).setEventSubscription(subscription)).get(STATUS));
assertEquals(EnumSet.of(DEPLOY_START, UPLOAD_START, UPLOAD_END, POLL, DEPLOY_END), recordedEvents);
assertEquals(EnumSet.of(DEPLOY_START, UPLOAD_START, UPLOAD_END, POLL_START, POLLING, POLL_END, DEPLOY_END), recordedEvents);
}

@Test
Expand Down

0 comments on commit 7f8e8c9

Please sign in to comment.