Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import com.netflix.spinnaker.gate.services.internal.OrcaServiceSelector;
import com.netflix.spinnaker.security.AuthenticatedRequest;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import lombok.Data;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -37,6 +40,8 @@ public class TaskService {
private ClouddriverServiceSelector clouddriverServiceSelector;
private TaskServiceProperties taskServiceProperties;

@Autowired ExecutorService executorService;

@Autowired
public TaskService(
OrcaServiceSelector orcaServiceSelector,
Expand Down Expand Up @@ -132,10 +137,25 @@ public Map createAndWaitForCompletion(Map body, int maxPolls) {
}

public Map createAndWaitForCompletion(Map body) {
return createAndWaitForCompletion(
body,
taskServiceProperties.getMaxNumberOfPolls(),
taskServiceProperties.getDefaultIntervalBetweenPolls());
CompletableFuture<Map> future =
CompletableFuture.supplyAsync(
() -> {
return createAndWaitForCompletion(
body,
taskServiceProperties.getMaxNumberOfPolls(),
taskServiceProperties.getDefaultIntervalBetweenPolls());
},
executorService)
.thenApply(
result -> {
return result;
});

try {
return future.get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}

/** @deprecated This pipeline operation does not belong here. */
Expand Down