Skip to content

Commit

Permalink
Refactor controller client methods
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanBorislavovDimitrov committed Oct 2, 2024
1 parent e4e413d commit 5d8606a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -661,12 +661,8 @@ Optional<String> unbindServiceInstance(String applicationName, String serviceIns

void updateServiceSyslogDrainUrl(String serviceName, String syslogDrainUrl);

CloudPackage asyncUploadApplicationWithExponentialBackoff(String applicationName, Path file, Duration uploadTimeout);

CloudPackage asyncUploadApplicationWithExponentialBackoff(String applicationName, Path file, UploadStatusCallback callback,
Duration uploadTimeout);

CloudPackage asyncUploadApplicationWithExponentialBackoff(String applicationName, Path file, UploadStatusCallback callback);
Duration overrideTimeout);

Upload getUploadStatus(UUID packageGuid);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,18 +561,9 @@ public void updateServiceSyslogDrainUrl(String serviceName, String syslogDrainUr
}

@Override
public CloudPackage asyncUploadApplicationWithExponentialBackoff(String applicationName, Path file, Duration uploadTimeout) {
return handleExceptions(() -> delegate.asyncUploadApplication(applicationName, file, null, uploadTimeout));
}

@Override
public CloudPackage asyncUploadApplicationWithExponentialBackoff(String applicationName, Path file, UploadStatusCallback callback, Duration uploadTimeout) {
return handleExceptions(() -> delegate.asyncUploadApplication(applicationName, file, callback, uploadTimeout));
}

@Override
public CloudPackage asyncUploadApplicationWithExponentialBackoff(String applicationName, Path file, UploadStatusCallback callback) {
throw new UnsupportedOperationException("This method must not be used, as the timeout must be provided as a resilience");
public CloudPackage asyncUploadApplicationWithExponentialBackoff(String applicationName, Path file, UploadStatusCallback callback,
Duration overrideTimeout) {
return handleExceptions(() -> delegate.asyncUploadApplication(applicationName, file, callback, overrideTimeout));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2390,9 +2390,6 @@ private void processAsyncUploadInBackground(CloudPackage cloudPackage, UploadSta
}

private void processAsyncUpload(CloudPackage cloudPackage, UploadStatusCallback callback) {
if (callback == null) {
callback = UploadStatusCallback.NONE;
}
while (true) {
Upload upload = getUploadStatus(cloudPackage.getGuid());
Status uploadStatus = upload.getStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public class ApplicationUtil {

public static CloudPackage uploadApplication(CloudControllerClient client, String applicationName, Path pathToFile)
throws InterruptedException {
CloudPackage cloudPackage = client.asyncUploadApplicationWithExponentialBackoff(applicationName, pathToFile, UPLOAD_TIMEOUT);
CloudPackage cloudPackage = client.asyncUploadApplicationWithExponentialBackoff(applicationName, pathToFile,
UploadStatusCallback.NONE, UPLOAD_TIMEOUT);
while (cloudPackage.getStatus() != Status.READY && !hasUploadFailed(cloudPackage.getStatus())) {
Thread.sleep(TimeUnit.SECONDS.toMillis(1));
cloudPackage = client.getPackage(cloudPackage.getGuid());
Expand Down

0 comments on commit 5d8606a

Please sign in to comment.