Skip to content

Commit f14289f

Browse files
committed
docs: write javadoc
1 parent 0ab926a commit f14289f

8 files changed

Lines changed: 137 additions & 4 deletions

File tree

src/main/java/io/weaviate/client6/v1/api/backup/Backup.java

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,27 @@
1313
import io.weaviate.client6.v1.internal.ObjectBuilder;
1414

1515
public record Backup(
16+
/** Backup ID. */
1617
@SerializedName("id") String id,
18+
/** Path to backup in the backend storage. */
1719
@SerializedName("path") String path,
20+
/** Backup storage backend. */
1821
@SerializedName("backend") String backend,
22+
/** Collections included in the backup. */
1923
@SerializedName("classes") List<String> includesCollections,
24+
/** Backup creation / restoration status. */
2025
@SerializedName("status") BackupStatus status,
26+
/** Backup creation / restoration error. */
2127
@SerializedName("error") String error,
28+
/**
29+
* This value indicates if a backup is being created or restored from.
30+
* For operations like LIST this value is null.
31+
*/
32+
// We set a bogus SerializedName to make sure we do not pick up this
33+
// value from the JSON by accident, but always set it ourselves.
2234
@SerializedName("__operation__") Operation operation) {
2335

36+
/** Set operation associated with this backup. */
2437
public Backup withOperation(Operation operation) {
2538
return new Backup(id, path, backend, includesCollections, status, error, operation);
2639
}
@@ -29,19 +42,71 @@ public enum Operation {
2942
CREATE, RESTORE;
3043
}
3144

45+
/**
46+
* Block until the backup has been created / restored successfully.
47+
*
48+
* @param client Weaviate client. Make sure {@link WeaviateClient#close} is not
49+
* called before this method returns.
50+
* @throws IllegalStateException if {@link #operation} is not set (null).
51+
* @throws TimeoutException in case the wait times out without reaching
52+
* BackupStatus.SUCCESS.
53+
* @throws IOException in case the request was not sent successfully
54+
* due to a malformed request, a networking error
55+
* or the server being unavailable.
56+
*/
3257
public Backup waitForCompletion(WeaviateClient client) throws IOException, TimeoutException {
3358
return waitForStatus(client, BackupStatus.SUCCESS);
3459
}
3560

61+
/**
62+
* Block until the backup has been created / restored successfully.
63+
*
64+
* @param client Weaviate client. Make sure {@link WeaviateClient#close} is not
65+
* called before this method returns.
66+
* @param fn Lambda expression for optional parameters.
67+
* @throws IllegalStateException if {@link #operation} is not set (null).
68+
* @throws TimeoutException in case the wait times out without reaching
69+
* BackupStatus.SUCCESS.
70+
* @throws IOException in case the request was not sent successfully
71+
* due to a malformed request, a networking error
72+
* or the server being unavailable.
73+
*/
3674
public Backup waitForCompletion(WeaviateClient client, Function<WaitOptions.Builder, ObjectBuilder<WaitOptions>> fn)
3775
throws IOException, TimeoutException {
3876
return waitForStatus(client, BackupStatus.SUCCESS, fn);
3977
}
4078

79+
/**
80+
* Block until the backup operation reaches a certain status.
81+
*
82+
* @param client Weaviate client. Make sure {@link WeaviateClient#close} is not
83+
* called before this method returns.
84+
* @param status Target status.
85+
* @throws IllegalStateException if {@link #operation} is not set (null).
86+
* @throws TimeoutException in case the wait times out without reaching
87+
* the target status.
88+
* @throws IOException in case the request was not sent successfully
89+
* due to a malformed request, a networking error
90+
* or the server being unavailable.
91+
*/
4192
public Backup waitForStatus(WeaviateClient client, BackupStatus status) throws IOException, TimeoutException {
4293
return waitForStatus(client, status, ObjectBuilder.identity());
4394
}
4495

96+
/**
97+
* Block until the backup operation reaches a certain status.
98+
*
99+
* @param client Weaviate client. Make sure {@link WeaviateClient#close} is not
100+
* called before this method returns.
101+
* @param status Target status.
102+
* @param fn Lambda expression for optional parameters.
103+
* @throws IllegalStateException if {@link #operation} is not set (null).
104+
* @throws TimeoutException in case the wait times out without reaching
105+
* the target status.
106+
* @throws IOException in case the request was not sent successfully
107+
* due to a malformed request, a networking error
108+
* or the server being unavailable.
109+
*/
45110
public Backup waitForStatus(WeaviateClient client, BackupStatus status,
46111
Function<WaitOptions.Builder, ObjectBuilder<WaitOptions>> fn) throws IOException, TimeoutException {
47112
if (operation == null) {
@@ -55,10 +120,19 @@ public Backup waitForStatus(WeaviateClient client, BackupStatus status,
55120
return new Waiter(this, poll, options).waitForStatus(status);
56121
}
57122

123+
/**
124+
* Cancel backup creation.
125+
*
126+
* <p>
127+
* This method cannot be called cancel backup restore.
128+
*
129+
* @param client Weaviate client. Make sure {@link WeaviateClient#close} is not
130+
* called before this method returns.
131+
* @throws IOException in case the request was not sent successfully
132+
* due to a malformed request, a networking error
133+
* or the server being unavailable.
134+
*/
58135
public void cancel(WeaviateClient client) throws IOException {
59-
if (operation == Operation.RESTORE) {
60-
throw new IllegalStateException("backup restore cannot be canceled");
61-
}
62136
client.backup.cancel(id(), backend());
63137
}
64138
}

src/main/java/io/weaviate/client6/v1/api/backup/BackupStatus.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,22 @@
33
import com.google.gson.annotations.SerializedName;
44

55
public enum BackupStatus {
6+
/** Backup creation / restoration has begun. */
67
@SerializedName("STARTED")
78
STARTED,
9+
/** Backup in progress, data is being transferred. */
810
@SerializedName("TRANSFERRING")
911
TRANSFERRING,
12+
/** Backup creation / restoration completed successfully. */
1013
@SerializedName("SUCCESS")
1114
SUCCESS,
15+
/** Backup creation / restoration failed. */
1216
@SerializedName("FAILED")
1317
FAILED,
18+
/**
19+
* Backup creation canceled.
20+
* This status is never returned for backup restorations.
21+
*/
1422
@SerializedName("CANCELED")
1523
CANCELED;
1624
}

src/main/java/io/weaviate/client6/v1/api/backup/CompressionLevel.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
import com.google.gson.annotations.SerializedName;
44

55
public enum CompressionLevel {
6+
/** Use default compression algorithm (gzip). */
67
@SerializedName("DefaultCompression")
78
DEFAULT,
9+
/** Use compression algorithm that prioritizes speed. */
810
@SerializedName("BestSpeed")
911
BEST_SPEED,
12+
/** Use compression algorithm that prioritizes compression quality. */
1013
@SerializedName("BestCompression")
1114
BEST_COMPRESSION;
1215
}

src/main/java/io/weaviate/client6/v1/api/backup/CreateBackupRequest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,44 +72,64 @@ public Builder(String backupId) {
7272
this.backupId = backupId;
7373
}
7474

75+
/** Collection that should be included in the backup. */
7576
public Builder includeCollections(String... includeCollections) {
7677
return includeCollections(Arrays.asList(includeCollections));
7778
}
7879

80+
/** Collection that should be included in the backup. */
7981
public Builder includeCollections(List<String> includeCollections) {
8082
this.includeCollections.addAll(includeCollections);
8183
return this;
8284
}
8385

86+
/** Collection that should be excluded from the backup. */
8487
public Builder excludeCollections(String... excludeCollections) {
8588
return excludeCollections(Arrays.asList(excludeCollections));
8689
}
8790

91+
/** Collection that should be excluded from the backup. */
8892
public Builder excludeCollections(List<String> excludeCollections) {
8993
this.excludeCollections.addAll(excludeCollections);
9094
return this;
9195
}
9296

97+
/**
98+
* Set the desired CPU core utilization.
99+
*
100+
* @param cpuPercentage Percent value of the target CPU utilization (1% to 80%).
101+
*/
93102
public Builder cpuPercentage(int cpuPercentage) {
94103
this.cpuPercentage = cpuPercentage;
95104
return this;
96105
}
97106

107+
/**
108+
* Set the desired chunk size. Defaults to 128MB.
109+
*
110+
* @param chunkSize Chunk size in MB (2MB to 512 MB).
111+
*/
98112
public Builder chunkSize(int chunkSize) {
99113
this.chunkSize = chunkSize;
100114
return this;
101115
}
102116

117+
/** Adjust the parameters of the selected compression algorithm. */
103118
public Builder compressionLevel(CompressionLevel compressionLevel) {
104119
this.compressionLevel = compressionLevel;
105120
return this;
106121
}
107122

123+
/**
124+
* Set the bucket where backups are stored.
125+
* Applicable for cloud storage backends.
126+
*/
108127
public Builder bucket(String bucket) {
109128
this.bucket = bucket;
110129
return this;
111130
}
112131

132+
/** Override default backup location. */
113133
public Builder path(String path) {
114134
this.path = path;
115135
return this;

src/main/java/io/weaviate/client6/v1/api/backup/RbacRestoreOption.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
import com.google.gson.annotations.SerializedName;
44

5+
/** Controls which RBAC objects (users, roles) get restored. */
56
public enum RbacRestoreOption {
7+
/** Do not restore any objects. */
68
@SerializedName("noRestore")
79
NONE,
10+
/** Restore all objects. */
811
@SerializedName("all")
912
ALL;
1013
}

src/main/java/io/weaviate/client6/v1/api/backup/RestoreBackupRequest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,49 +68,69 @@ public static class Builder implements ObjectBuilder<BackupRestore> {
6868
private final List<String> includeCollections = new ArrayList<>();
6969
private final List<String> excludeCollections = new ArrayList<>();
7070

71+
/** Collection that should be restored. */
7172
public Builder includeCollections(String... includeCollections) {
7273
return includeCollections(Arrays.asList(includeCollections));
7374
}
7475

76+
/** Collection that should be restored. */
7577
public Builder includeCollections(List<String> includeCollections) {
7678
this.includeCollections.addAll(includeCollections);
7779
return this;
7880
}
7981

82+
/** Collection that should be not be restored. */
8083
public Builder excludeCollections(String... excludeCollections) {
8184
return excludeCollections(Arrays.asList(excludeCollections));
8285
}
8386

87+
/** Collection that should be not be restored. */
8488
public Builder excludeCollections(List<String> excludeCollections) {
8589
this.excludeCollections.addAll(excludeCollections);
8690
return this;
8791
}
8892

93+
/**
94+
* Set the desired CPU core utilization.
95+
*
96+
* @param cpuPercentage Percent value of the target CPU utilization (1% to 80%).
97+
*/
8998
public Builder cpuPercentage(int cpuPercentage) {
9099
this.cpuPercentage = cpuPercentage;
91100
return this;
92101
}
93102

103+
/**
104+
* Set the bucket where backups are stored.
105+
* Applicable for cloud storage backends.
106+
*/
94107
public Builder bucket(String bucket) {
95108
this.bucket = bucket;
96109
return this;
97110
}
98111

112+
/** Override default backup location. */
99113
public Builder path(String path) {
100114
this.path = path;
101115
return this;
102116
}
103117

118+
/**
119+
* Allow restored collection aliases to overwrite existing ones
120+
* in case of conflict.
121+
*/
104122
public Builder overwriteAlias(boolean overwriteAlias) {
105123
this.overwriteAlias = overwriteAlias;
106124
return this;
107125
}
108126

127+
/** Control which RBAC users should be restored. */
109128
public Builder restoreUsers(RbacRestoreOption restoreUsers) {
110129
this.restoreUsers = restoreUsers;
111130
return this;
112131
}
113132

133+
/** Control which RBAC roles should be restored. */
114134
public Builder restoreRoles(RbacRestoreOption restoreRoles) {
115135
this.restoreRoles = restoreRoles;
116136
return this;

src/main/java/io/weaviate/client6/v1/api/backup/Waiter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ Backup waitForStatus(BackupStatus wantStatus) throws IOException, TimeoutExcepti
5353
try {
5454
Thread.sleep(wait.interval());
5555
} catch (InterruptedException e) {
56-
System.out.println("Interrupted");
56+
// TODO: the interrupted state will be cleared on the next while() check
57+
// and then we will simply return the latest state. An absence of an exception
58+
// might be misleading here. What should we do?
5759
Thread.currentThread().interrupt();
5860
}
5961
}

src/main/java/io/weaviate/client6/v1/api/backup/WeaviateBackupClient.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ public List<Backup> list(String backend) throws IOException {
163163
/**
164164
* Cancel in-progress backup.
165165
*
166+
* <p>
167+
* This method cannot be called cancel backup restore.
168+
*
166169
* @param backupId Backup ID.
167170
* @param backend Backup storage backend.
168171
* @throws WeaviateApiException in case the server returned with an

0 commit comments

Comments
 (0)