|
129 | 129 | import com.google.protobuf.ExtensionRegistry;
|
130 | 130 | import com.google.protobuf.Message;
|
131 | 131 | import io.grpc.Status.Code;
|
132 |
| -import io.reactivex.rxjava3.annotations.NonNull; |
133 | 132 | import io.reactivex.rxjava3.core.Scheduler;
|
134 | 133 | import io.reactivex.rxjava3.core.Single;
|
135 |
| -import io.reactivex.rxjava3.core.SingleObserver; |
136 |
| -import io.reactivex.rxjava3.disposables.Disposable; |
137 | 134 | import io.reactivex.rxjava3.schedulers.Schedulers;
|
138 | 135 | import java.io.FileNotFoundException;
|
139 | 136 | import java.io.IOException;
|
|
160 | 157 | import java.util.concurrent.Phaser;
|
161 | 158 | import java.util.concurrent.Semaphore;
|
162 | 159 | import java.util.concurrent.atomic.AtomicBoolean;
|
| 160 | +import java.util.concurrent.atomic.AtomicLong; |
163 | 161 | import java.util.concurrent.atomic.AtomicReference;
|
164 | 162 | import java.util.stream.Stream;
|
165 | 163 | import javax.annotation.Nullable;
|
@@ -1794,45 +1792,33 @@ public void uploadOutputs(RemoteAction action, SpawnResult spawnResult, Runnable
|
1794 | 1792 |
|
1795 | 1793 | if (remoteOptions.remoteCacheAsync
|
1796 | 1794 | && !action.getSpawn().getResourceOwner().mayModifySpawnOutputsAfterExecution()) {
|
1797 |
| - Single.using( |
1798 |
| - combinedCache::retain, |
1799 |
| - combinedCache -> |
1800 |
| - buildUploadManifestAsync(action, spawnResult) |
1801 |
| - .flatMap( |
1802 |
| - manifest -> |
1803 |
| - manifest.uploadAsync( |
1804 |
| - action.getRemoteActionExecutionContext(), |
1805 |
| - combinedCache, |
1806 |
| - reporter)), |
1807 |
| - CombinedCache::release) |
1808 |
| - .subscribeOn(scheduler) |
1809 |
| - .subscribe( |
1810 |
| - new SingleObserver<ActionResult>() { |
1811 |
| - long startTime = 0; |
1812 |
| - |
1813 |
| - @Override |
1814 |
| - public void onSubscribe(@NonNull Disposable d) { |
1815 |
| - backgroundTaskPhaser.register(); |
1816 |
| - startTime = Profiler.nanoTimeMaybe(); |
1817 |
| - } |
1818 |
| - |
1819 |
| - @Override |
1820 |
| - public void onSuccess(@NonNull ActionResult actionResult) { |
1821 |
| - Profiler.instance() |
1822 |
| - .completeTask(startTime, ProfilerTask.UPLOAD_TIME, "upload outputs"); |
1823 |
| - backgroundTaskPhaser.arriveAndDeregister(); |
1824 |
| - onUploadComplete.run(); |
1825 |
| - } |
1826 |
| - |
1827 |
| - @Override |
1828 |
| - public void onError(@NonNull Throwable e) { |
1829 |
| - Profiler.instance() |
1830 |
| - .completeTask(startTime, ProfilerTask.UPLOAD_TIME, "upload outputs"); |
1831 |
| - backgroundTaskPhaser.arriveAndDeregister(); |
1832 |
| - reportUploadError(e); |
1833 |
| - onUploadComplete.run(); |
1834 |
| - } |
1835 |
| - }); |
| 1795 | + AtomicLong startTime = new AtomicLong(); |
| 1796 | + var unused = |
| 1797 | + Single.using( |
| 1798 | + () -> { |
| 1799 | + backgroundTaskPhaser.register(); |
| 1800 | + CombinedCache cache = combinedCache.retain(); |
| 1801 | + startTime.set(Profiler.nanoTimeMaybe()); |
| 1802 | + return cache; |
| 1803 | + }, |
| 1804 | + combinedCache -> |
| 1805 | + buildUploadManifestAsync(action, spawnResult) |
| 1806 | + .flatMap( |
| 1807 | + manifest -> |
| 1808 | + manifest.uploadAsync( |
| 1809 | + action.getRemoteActionExecutionContext(), |
| 1810 | + combinedCache, |
| 1811 | + reporter)), |
| 1812 | + cacheResource -> { |
| 1813 | + Profiler.instance() |
| 1814 | + .completeTask(startTime.get(), ProfilerTask.UPLOAD_TIME, "upload outputs"); |
| 1815 | + backgroundTaskPhaser.arriveAndDeregister(); |
| 1816 | + onUploadComplete.run(); |
| 1817 | + cacheResource.release(); |
| 1818 | + }, |
| 1819 | + /* eager= */ false) |
| 1820 | + .subscribeOn(scheduler) |
| 1821 | + .subscribe(result -> {}, this::reportUploadError); |
1836 | 1822 | } else {
|
1837 | 1823 | try (SilentCloseable c =
|
1838 | 1824 | Profiler.instance().profile(ProfilerTask.UPLOAD_TIME, "upload outputs")) {
|
|
0 commit comments