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

Support dynamic backup location #341

Merged
merged 8 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -8,7 +8,9 @@
import io.weaviate.client.v1.auth.provider.AccessTokenProvider;
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
import org.apache.hc.core5.concurrent.FutureCallback;
import org.apache.hc.core5.net.URIBuilder;

import java.net.URISyntaxException;
import java.util.concurrent.Future;

/**
Expand All @@ -22,13 +24,14 @@ public class BackupCanceler extends AsyncBaseClient<Void>

private String backend;
private String backupId;
private String bucket;
private String path;


public BackupCanceler(CloseableHttpAsyncClient client, Config config, AccessTokenProvider tokenProvider) {
super(client, config, tokenProvider);
}


public BackupCanceler withBackend(String backend) {
this.backend = backend;
return this;
Expand All @@ -39,10 +42,27 @@ public BackupCanceler withBackupId(String backupId) {
return this;
}

public BackupCanceler withBucket(String bucket) {
this.bucket = bucket;
return this;
}

public BackupCanceler withPath(String path) {
this.path = path;
return this;
}


@Override
public Future<Result<Void>> run(FutureCallback<Result<Void>> callback) {
String path = String.format("/backups/%s/%s", UrlEncoder.encodePathParam(backend), UrlEncoder.encodePathParam(backupId));
try {
path = new URIBuilder(path)
.addParameter("bucket", bucket)
.addParameter("path", this.path)
.toString();
} catch (URISyntaxException e) {
}
return sendDeleteRequest(path, null, Void.class, callback);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
package io.weaviate.client.v1.async.backup.api;

import java.net.URISyntaxException;
import java.util.concurrent.Future;

import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
import org.apache.hc.core5.concurrent.FutureCallback;
import org.apache.hc.core5.net.URIBuilder;

import io.weaviate.client.Config;
import io.weaviate.client.base.AsyncBaseClient;
import io.weaviate.client.base.AsyncClientResult;
import io.weaviate.client.base.Result;
import io.weaviate.client.base.util.UrlEncoder;
import io.weaviate.client.v1.auth.provider.AccessTokenProvider;
import io.weaviate.client.v1.backup.model.BackupCreateStatusResponse;
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
import org.apache.hc.core5.concurrent.FutureCallback;

import java.util.concurrent.Future;

public class BackupCreateStatusGetter extends AsyncBaseClient<BackupCreateStatusResponse>
implements AsyncClientResult<BackupCreateStatusResponse> {

private String backend;
private String backupId;

private String bucket;
private String path;

public BackupCreateStatusGetter(CloseableHttpAsyncClient client, Config config, AccessTokenProvider tokenProvider) {
super(client, config, tokenProvider);
Expand All @@ -34,9 +38,26 @@ public BackupCreateStatusGetter withBackupId(String backupId) {
return this;
}

public BackupCreateStatusGetter withBucket(String bucket) {
this.bucket = bucket;
return this;
}

public BackupCreateStatusGetter withPath(String path) {
this.path = path;
return this;
}

@Override
public Future<Result<BackupCreateStatusResponse>> run(FutureCallback<Result<BackupCreateStatusResponse>> callback) {
String path = String.format("/backups/%s/%s", UrlEncoder.encodePathParam(backend), UrlEncoder.encodePathParam(backupId));
try {
path = new URIBuilder(path)
.addParameter("bucket", bucket)
.addParameter("path", this.path)
.toString();
} catch (URISyntaxException e) {
}
return sendGetRequest(path, BackupCreateStatusResponse.class, callback);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ public static class BackupCreateConfig {
Integer chunkSize;
@SerializedName("CompressionLevel")
String compressionLevel;
@SerializedName("Bucket")
String bucket;
@SerializedName("Path")
String path;
}

public interface BackupCompression {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
import io.weaviate.client.v1.backup.model.BackupRestoreStatusResponse;
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
import org.apache.hc.core5.concurrent.FutureCallback;
import org.apache.hc.core5.net.URIBuilder;

import java.net.URISyntaxException;
import java.util.concurrent.Future;

public class BackupRestoreStatusGetter extends AsyncBaseClient<BackupRestoreStatusResponse>
implements AsyncClientResult<BackupRestoreStatusResponse> {

private String backend;
private String backupId;

private String bucket;
private String path;

public BackupRestoreStatusGetter(CloseableHttpAsyncClient client, Config config, AccessTokenProvider tokenProvider) {
super(client, config, tokenProvider);
Expand All @@ -34,10 +37,26 @@ public BackupRestoreStatusGetter withBackupId(String backupId) {
return this;
}

public BackupRestoreStatusGetter withBucket(String bucket) {
this.bucket = bucket;
return this;
}

public BackupRestoreStatusGetter withPath(String path) {
this.path = path;
return this;
}

@Override
public Future<Result<BackupRestoreStatusResponse>> run(FutureCallback<Result<BackupRestoreStatusResponse>> callback) {
String path = String.format("/backups/%s/%s/restore", UrlEncoder.encodePathParam(backend), UrlEncoder.encodePathParam(backupId));
try {
path = new URIBuilder(path)
.addParameter("bucket", bucket)
.addParameter("path", this.path)
.toString();
} catch (URISyntaxException e) {
}
return sendGetRequest(path, BackupRestoreStatusResponse.class, callback);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -237,5 +237,9 @@ private static class BackupRestore {
public static class BackupRestoreConfig {
@SerializedName("CPUPercentage")
Integer cpuPercentage;
@SerializedName("Bucket")
String bucket;
@SerializedName("Path")
String path;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package io.weaviate.client.v1.backup.api;

import java.net.URISyntaxException;

import org.apache.hc.core5.net.URIBuilder;

import io.weaviate.client.Config;
import io.weaviate.client.base.BaseClient;
import io.weaviate.client.base.ClientResult;
Expand All @@ -16,6 +20,8 @@
public class BackupCanceler extends BaseClient<Void> implements ClientResult<Void> {
private String backend;
private String backupId;
private String bucket;
private String path;

public BackupCanceler(HttpClient client, Config config) {
super(client, config);
Expand All @@ -26,6 +32,16 @@ public BackupCanceler withBackend(String backend) {
return this;
}

public BackupCanceler withBucket(String bucket) {
this.bucket = bucket;
return this;
}

public BackupCanceler withPath(String path) {
this.path = path;
return this;
}

public BackupCanceler withBackupId(String backupId) {
this.backupId = backupId;
return this;
Expand All @@ -38,7 +54,15 @@ public Result<Void> run() {
}

private String path() {
return String.format("/backups/%s/%s", backend, backupId);
String base = String.format("/backups/%s/%s", backend, backupId);
try {
return new URIBuilder(base)
.addParameter("bucket", bucket)
.addParameter("path", path)
.toString();
} catch (URISyntaxException e) {
return base;
}
}
}

Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
package io.weaviate.client.v1.backup.api;

import io.weaviate.client.v1.backup.model.BackupCreateStatusResponse;
import java.net.URISyntaxException;

import org.apache.hc.core5.net.URIBuilder;

import io.weaviate.client.Config;
import io.weaviate.client.base.BaseClient;
import io.weaviate.client.base.ClientResult;
import io.weaviate.client.base.Response;
import io.weaviate.client.base.Result;
import io.weaviate.client.base.http.HttpClient;
import io.weaviate.client.v1.backup.model.BackupCreateStatusResponse;

public class BackupCreateStatusGetter extends BaseClient<BackupCreateStatusResponse> implements ClientResult<BackupCreateStatusResponse> {

private String backend;
private String backupId;
private String bucket;
private String path;

public BackupCreateStatusGetter(HttpClient httpClient, Config config) {
super(httpClient, config);
Expand All @@ -27,6 +33,16 @@ public BackupCreateStatusGetter withBackupId(String backupId) {
return this;
}

public BackupCreateStatusGetter withBucket(String bucket) {
this.bucket = bucket;
return this;
}

public BackupCreateStatusGetter withPath(String path) {
this.path = path;
return this;
}

@Override
public Result<BackupCreateStatusResponse> run() {
return new Result<>(statusCreate());
Expand All @@ -37,6 +53,14 @@ Response<BackupCreateStatusResponse> statusCreate() {
}

private String path() {
return String.format("/backups/%s/%s", backend, backupId);
String base = String.format("/backups/%s/%s", backend, backupId);
try {
return new URIBuilder(base)
.addParameter("bucket", bucket)
.addParameter("path", path)
.toString();
} catch (URISyntaxException e) {
return base;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ public static class BackupCreateConfig {
Integer chunkSize;
@SerializedName("CompressionLevel")
String compressionLevel;
@SerializedName("Bucket")
String bucket;
@SerializedName("Path")
String path;
}

public interface BackupCompression {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
package io.weaviate.client.v1.backup.api;

import io.weaviate.client.v1.backup.model.BackupRestoreStatusResponse;
import java.net.URISyntaxException;

import org.apache.hc.core5.net.URIBuilder;

import io.weaviate.client.Config;
import io.weaviate.client.base.BaseClient;
import io.weaviate.client.base.ClientResult;
import io.weaviate.client.base.Response;
import io.weaviate.client.base.Result;
import io.weaviate.client.base.http.HttpClient;
import io.weaviate.client.v1.backup.model.BackupRestoreStatusResponse;

public class BackupRestoreStatusGetter extends BaseClient<BackupRestoreStatusResponse> implements ClientResult<BackupRestoreStatusResponse> {

private String backend;
private String backupId;
private String bucket;
private String path;

public BackupRestoreStatusGetter(HttpClient httpClient, Config config) {
super(httpClient, config);
Expand All @@ -27,6 +33,16 @@ public BackupRestoreStatusGetter withBackupId(String backupId) {
return this;
}

public BackupRestoreStatusGetter withBucket(String bucket) {
this.bucket = bucket;
return this;
}

public BackupRestoreStatusGetter withPath(String path) {
this.path = path;
return this;
}

@Override
public Result<BackupRestoreStatusResponse> run() {
return new Result<>(statusRestore());
Expand All @@ -37,6 +53,14 @@ Response<BackupRestoreStatusResponse> statusRestore() {
}

private String path() {
return String.format("/backups/%s/%s/restore", backend, backupId);
String base = String.format("/backups/%s/%s/restore", backend, backupId);
try {
return new URIBuilder(base)
.addParameter("bucket", bucket)
.addParameter("path", path)
.toString();
} catch (URISyntaxException e) {
return base;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,9 @@ private static class BackupRestore {
public static class BackupRestoreConfig {
@SerializedName("CPUPercentage")
Integer cpuPercentage;
@SerializedName("Bucket")
String bucket;
@SerializedName("Path")
String path;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
public class WeaviateVersion {

// docker image version
public static final String WEAVIATE_IMAGE = "1.27.0";
public static final String WEAVIATE_IMAGE = "stable-v1.28-ac93b01";

// to be set according to weaviate docker image
public static final String EXPECTED_WEAVIATE_VERSION = "1.27.0";
public static final String EXPECTED_WEAVIATE_VERSION = "1.28.0";
// to be set according to weaviate docker image
public static final String EXPECTED_WEAVIATE_GIT_HASH = "6c571ff";
public static final String EXPECTED_WEAVIATE_GIT_HASH = "ac93b01";

private WeaviateVersion() {
}
Expand Down
Loading
Loading