Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/template storage rpc #1575

Open
wants to merge 2 commits into
base: nightly
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -352,7 +352,7 @@ CompletableFuture<Boolean> deployDirectoryAsync(
* @throws NullPointerException if the given template is null.
*/
@NonNull
CompletableFuture<InputStream> zipTemplateAsync(@NonNull ServiceTemplate template);
CompletableFuture<@Nullable InputStream> zipTemplateAsync(@NonNull ServiceTemplate template);

/**
* Pulls the data of the given template into a temporary directory and zip it. When the returned input stream is
Expand All @@ -363,7 +363,7 @@ CompletableFuture<Boolean> deployDirectoryAsync(
* @throws NullPointerException if the given template is null.
*/
@NonNull
CompletableFuture<ZipInputStream> openZipInputStreamAsync(@NonNull ServiceTemplate template);
CompletableFuture<@Nullable ZipInputStream> openZipInputStreamAsync(@NonNull ServiceTemplate template);

/**
* Deletes the given template completely from this template storage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void write(
@NonNull Type type,
@NonNull ObjectMapper caller
) {
var pathUri = object.toUri().toString();
var pathUri = object.toAbsolutePath().toUri().toString();
dataBuf.writeString(pathUri);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.nio.file.Path;
import java.util.concurrent.CompletableFuture;
import java.util.function.Predicate;
import java.util.zip.ZipInputStream;
import lombok.NonNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -93,6 +94,19 @@ public boolean deployDirectory(
}
}

@Override
public @NonNull CompletableFuture<Boolean> deployDirectoryAsync(@NonNull ServiceTemplate target,
@NonNull Path directory, @Nullable Predicate<Path> filter) {
return TaskUtil.supplyAsync(() -> this.deployDirectory(target, directory, filter));
}

@Override
public @NonNull CompletableFuture<@Nullable ZipInputStream> openZipInputStreamAsync(
@NonNull ServiceTemplate template) {
return this.zipTemplateAsync(template)
.thenApply(inputStream -> inputStream == null ? null : new ZipInputStream(inputStream));
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -147,6 +161,12 @@ public boolean deploy(@NonNull ServiceTemplate target, @NonNull InputStream inpu
return this.openLocalOutputStream(template, path, FileUtil.createTempFile(), true);
}

@Override
public @NonNull CompletableFuture<OutputStream> appendOutputStreamAsync(@NonNull ServiceTemplate template,
@NonNull String path) {
return TaskUtil.supplyAsync(() -> this.appendOutputStream(template, path));
}

/**
* {@inheritDoc}
*/
Expand All @@ -158,6 +178,12 @@ public boolean deploy(@NonNull ServiceTemplate target, @NonNull InputStream inpu
return this.openLocalOutputStream(template, path, FileUtil.createTempFile(), false);
}

@Override
public @NonNull CompletableFuture<OutputStream> newOutputStreamAsync(@NonNull ServiceTemplate template,
@NonNull String path) {
return TaskUtil.supplyAsync(() -> this.newOutputStream(template, path));
}

/**
* Opens a new output stream to a temporary local file which will be deployed to the remote component once the stream
* was closed.
Expand Down