|
116 | 116 | import org.cloudfoundry.client.v3.applications.GetApplicationResponse; |
117 | 117 | import org.cloudfoundry.client.v3.applications.GetApplicationSshEnabledRequest; |
118 | 118 | import org.cloudfoundry.client.v3.applications.GetApplicationSshEnabledResponse; |
119 | | -import org.cloudfoundry.client.v3.applications.ListApplicationProcessesRequest; |
120 | 119 | import org.cloudfoundry.client.v3.applications.ListApplicationRoutesRequest; |
121 | 120 | import org.cloudfoundry.client.v3.applications.ListApplicationsRequest; |
122 | 121 | import org.cloudfoundry.client.v3.applications.SetApplicationCurrentDropletRequest; |
|
136 | 135 | import org.cloudfoundry.client.v3.packages.PackageState; |
137 | 136 | import org.cloudfoundry.client.v3.packages.PackageType; |
138 | 137 | import org.cloudfoundry.client.v3.packages.UploadPackageRequest; |
139 | | -import org.cloudfoundry.client.v3.processes.GetProcessStatisticsRequest; |
140 | | -import org.cloudfoundry.client.v3.processes.GetProcessStatisticsResponse; |
141 | 138 | import org.cloudfoundry.client.v3.processes.ProcessState; |
142 | 139 | import org.cloudfoundry.client.v3.processes.ProcessStatisticsResource; |
143 | 140 | import org.cloudfoundry.client.v3.resourcematch.MatchedResource; |
@@ -2655,61 +2652,7 @@ private Mono<Void> waitForRunning( |
2655 | 2652 |
|
2656 | 2653 | private Mono<Void> waitForRunningV3( |
2657 | 2654 | String applicationName, String applicationId, Duration startupTimeout) { |
2658 | | - Duration timeout = Optional.ofNullable(startupTimeout).orElse(Duration.ofMinutes(5)); |
2659 | | - |
2660 | | - return PaginationUtils.requestClientV3Resources( |
2661 | | - page -> |
2662 | | - this.cloudFoundryClient |
2663 | | - .applicationsV3() |
2664 | | - .listProcesses( |
2665 | | - ListApplicationProcessesRequest.builder() |
2666 | | - .applicationId(applicationId) |
2667 | | - .page(page) |
2668 | | - .build())) |
2669 | | - .filter(p -> p.getInstances() != 0) |
2670 | | - .flatMap( |
2671 | | - process -> |
2672 | | - this.cloudFoundryClient |
2673 | | - .processes() |
2674 | | - .getStatistics( |
2675 | | - GetProcessStatisticsRequest.builder() |
2676 | | - .processId(process.getId()) |
2677 | | - .build()) |
2678 | | - .flatMapIterable(GetProcessStatisticsResponse::getResources) |
2679 | | - .map(ProcessStatisticsResource::getState) |
2680 | | - .filter( |
2681 | | - state -> |
2682 | | - EnumSet.of( |
2683 | | - ProcessState.RUNNING, |
2684 | | - ProcessState.CRASHED) |
2685 | | - .contains(state)) |
2686 | | - .reduce( |
2687 | | - (totalState, instanceState) -> |
2688 | | - totalState.ordinal() |
2689 | | - < instanceState.ordinal() |
2690 | | - ? totalState |
2691 | | - : instanceState) // CRASHED takes |
2692 | | - // precedence over |
2693 | | - // RUNNING |
2694 | | - .repeatWhenEmpty( |
2695 | | - exponentialBackOff( |
2696 | | - Duration.ofSeconds(1), |
2697 | | - Duration.ofSeconds(15), |
2698 | | - timeout)) |
2699 | | - .filter(state -> state == ProcessState.RUNNING) |
2700 | | - .switchIfEmpty( |
2701 | | - ExceptionUtils.illegalState( |
2702 | | - "Process %s of Application %s failed during" |
2703 | | - + " start", |
2704 | | - process.getId(), applicationName)) |
2705 | | - .onErrorResume( |
2706 | | - DelayTimeoutException.class, |
2707 | | - t -> |
2708 | | - ExceptionUtils.illegalState( |
2709 | | - "Process %s of Application %s timed" |
2710 | | - + " out during start", |
2711 | | - process.getId(), applicationName))) |
2712 | | - .then(); |
| 2655 | + return waitForRunning(applicationName, applicationId, startupTimeout); |
2713 | 2656 | } |
2714 | 2657 |
|
2715 | 2658 | private Mono<Void> waitForStaging( |
|
0 commit comments