-
Notifications
You must be signed in to change notification settings - Fork 152
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] consistent validation and version comparison fix #823
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,7 @@ | |
import java.time.Duration; | ||
|
||
import static io.nats.client.support.NatsObjectStoreUtil.*; | ||
import static io.nats.client.support.Validator.validateBucketName; | ||
import static io.nats.client.support.Validator.validateMaxBucketBytes; | ||
import static io.nats.client.support.Validator.*; | ||
|
||
/** | ||
* The ObjectStoreStatus class contains information about an object store. | ||
|
@@ -54,20 +53,27 @@ public String toString() { | |
'}'; | ||
} | ||
|
||
/** | ||
* Creates a builder for the Object Store Configuration. | ||
* @return an ObjectStoreConfiguration Builder | ||
*/ | ||
public static ObjectStoreConfiguration.Builder builder() { | ||
return new ObjectStoreConfiguration.Builder((ObjectStoreConfiguration)null); | ||
} | ||
|
||
/** | ||
* Creates a builder for the Object Store Configuration. | ||
* @param name the name of the object store bucket | ||
* @return an Object Store configuration builder | ||
* @return an ObjectStoreConfiguration Builder | ||
*/ | ||
public static ObjectStoreConfiguration.Builder builder(String name) { | ||
return new ObjectStoreConfiguration.Builder().name(name); | ||
return new ObjectStoreConfiguration.Builder(name); | ||
} | ||
|
||
/** | ||
* Creates a builder to copy the Object Store configuration. | ||
* @param osc an existing ObjectStoreConfiguration | ||
* @return an ObjectStoreConfiguration builder | ||
* @return an ObjectStoreConfiguration Builder | ||
*/ | ||
public static ObjectStoreConfiguration.Builder builder(ObjectStoreConfiguration osc) { | ||
return new ObjectStoreConfiguration.Builder(osc); | ||
|
@@ -81,15 +87,23 @@ public static ObjectStoreConfiguration.Builder builder(ObjectStoreConfiguration | |
* | ||
*/ | ||
public static class Builder { | ||
|
||
String name; | ||
StreamConfiguration.Builder scBuilder; | ||
|
||
/** | ||
* Default Builder | ||
*/ | ||
public Builder() { | ||
this(null); | ||
this((ObjectStoreConfiguration)null); | ||
} | ||
|
||
/** | ||
* Builder accepting the object store bucket name. | ||
* @param name name of the store. | ||
*/ | ||
public Builder(String name) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment |
||
this((ObjectStoreConfiguration)null); | ||
name(name); | ||
} | ||
|
||
/** | ||
|
@@ -112,7 +126,7 @@ public Builder(ObjectStoreConfiguration osc) { | |
* @param name name of the store. | ||
* @return the builder | ||
*/ | ||
public ObjectStoreConfiguration.Builder name(String name) { | ||
public Builder name(String name) { | ||
this.name = validateBucketName(name, true); | ||
return this; | ||
} | ||
|
@@ -122,7 +136,7 @@ public ObjectStoreConfiguration.Builder name(String name) { | |
* @param description description of the store. | ||
* @return the builder | ||
*/ | ||
public ObjectStoreConfiguration.Builder description(String description) { | ||
public Builder description(String description) { | ||
scBuilder.description(description); | ||
return this; | ||
} | ||
|
@@ -132,7 +146,7 @@ public ObjectStoreConfiguration.Builder description(String description) { | |
* @param maxBucketSize the maximum number of bytes | ||
* @return Builder | ||
*/ | ||
public ObjectStoreConfiguration.Builder maxBucketSize(long maxBucketSize) { | ||
public Builder maxBucketSize(long maxBucketSize) { | ||
scBuilder.maxBytes(validateMaxBucketBytes(maxBucketSize)); | ||
return this; | ||
} | ||
|
@@ -142,7 +156,7 @@ public ObjectStoreConfiguration.Builder maxBucketSize(long maxBucketSize) { | |
* @param ttl the maximum age | ||
* @return Builder | ||
*/ | ||
public ObjectStoreConfiguration.Builder ttl(Duration ttl) { | ||
public Builder ttl(Duration ttl) { | ||
scBuilder.maxAge(ttl); | ||
return this; | ||
} | ||
|
@@ -152,7 +166,7 @@ public ObjectStoreConfiguration.Builder ttl(Duration ttl) { | |
* @param storageType the storage type | ||
* @return Builder | ||
*/ | ||
public ObjectStoreConfiguration.Builder storageType(StorageType storageType) { | ||
public Builder storageType(StorageType storageType) { | ||
scBuilder.storageType(storageType); | ||
return this; | ||
} | ||
|
@@ -162,8 +176,8 @@ public ObjectStoreConfiguration.Builder storageType(StorageType storageType) { | |
* @param replicas the number of replicas | ||
* @return Builder | ||
*/ | ||
public ObjectStoreConfiguration.Builder replicas(int replicas) { | ||
scBuilder.replicas(Math.max(replicas, 1)); | ||
public Builder replicas(int replicas) { | ||
scBuilder.replicas(replicas); | ||
return this; | ||
} | ||
|
||
|
@@ -172,7 +186,7 @@ public ObjectStoreConfiguration.Builder replicas(int replicas) { | |
* @param placement the placement directive object | ||
* @return Builder | ||
*/ | ||
public ObjectStoreConfiguration.Builder placement(Placement placement) { | ||
public Builder placement(Placement placement) { | ||
scBuilder.placement(placement); | ||
return this; | ||
} | ||
|
@@ -182,7 +196,7 @@ public ObjectStoreConfiguration.Builder placement(Placement placement) { | |
* @return the ObjectStoreConfiguration. | ||
*/ | ||
public ObjectStoreConfiguration build() { | ||
name = validateBucketName(name, true); | ||
name = required(name, "name"); | ||
scBuilder.name(toStreamName(name)) | ||
.subjects(toMetaStreamSubject(name), toChunkStreamSubject(name)) | ||
.allowRollup(true) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix comments