You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2021/02/23 14:24:06 UTC
[GitHub] [zookeeper] eolivelli commented on a change in pull request #1559: ZOOKEEPER-4026: Complete support for Stat objects (and create2) in multi requests
eolivelli commented on a change in pull request #1559:
URL: https://github.com/apache/zookeeper/pull/1559#discussion_r581074879
##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/Op.java
##########
@@ -253,6 +254,142 @@ void validate() throws KeeperException {
PathUtils.validatePath(path);
}
+ /**
+ * "Fluent builder" for {@link Create} operations.
+ */
+ public static class CreateBuilder {
+ private String path;
+ private byte[] data;
+ private List<ACL> acl;
+ private Integer createModeFlag;
+ private CreateMode createMode;
+ private boolean returnStat = false;
+ private Long ttl;
+
+ /**
+ * Sets the path for the node. Must be set before calling
+ * {@link #build()}.
+ *
+ * @param path the path for the node
+ * @return the builder, for chaining.
+ */
+ public CreateBuilder setPath(String path) {
+ this.path = path;
+ return this;
+ }
+
+ /**
+ * Sets the initial data for the node, or {@code null}.
+ *
+ * @param data the initial data for the node
+ * @return the builder, for chaining.
+ */
+ @SuppressFBWarnings({"EI_EXPOSE_REP", "EI_EXPOSE_REP2"})
+ public CreateBuilder setData(byte[] data) {
+ this.data = data;
+ return this;
+ }
+
+ /**
+ * Sets the acl for the node. Must be set before calling
+ * {@link #build()}.
+ *
+ * @param acl the acl for the node
+ * @return the builder, for chaining.
+ */
+ public CreateBuilder setACL(List<ACL> acl) {
+ this.acl = acl;
+ return this;
+ }
+
+ /**
+ * Specifyies whether the node to be created is ephemeral,
+ * sequential, etc. using the integer encoding. Either this
+ * or {@link #setCreateMode} must be used before calling
+ * {@link #build()}.
+ *
+ * @param createModeFlag the create mode encoded as an integer
+ * @return the builder, for chaining.
+ */
+ public CreateBuilder setCreateModeFlag(Integer createModeFlag) {
Review comment:
why "Integer" ?
is it expected to pass "null" ?
I am fine with having `Integer` as internal value, but maybe here in this point we should have only `int`
##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/Op.java
##########
@@ -253,6 +254,142 @@ void validate() throws KeeperException {
PathUtils.validatePath(path);
}
+ /**
+ * "Fluent builder" for {@link Create} operations.
+ */
+ public static class CreateBuilder {
+ private String path;
+ private byte[] data;
+ private List<ACL> acl;
+ private Integer createModeFlag;
+ private CreateMode createMode;
+ private boolean returnStat = false;
+ private Long ttl;
+
+ /**
+ * Sets the path for the node. Must be set before calling
+ * {@link #build()}.
+ *
+ * @param path the path for the node
+ * @return the builder, for chaining.
+ */
+ public CreateBuilder setPath(String path) {
+ this.path = path;
+ return this;
+ }
+
+ /**
+ * Sets the initial data for the node, or {@code null}.
+ *
+ * @param data the initial data for the node
+ * @return the builder, for chaining.
+ */
+ @SuppressFBWarnings({"EI_EXPOSE_REP", "EI_EXPOSE_REP2"})
+ public CreateBuilder setData(byte[] data) {
+ this.data = data;
+ return this;
+ }
+
+ /**
+ * Sets the acl for the node. Must be set before calling
+ * {@link #build()}.
+ *
+ * @param acl the acl for the node
+ * @return the builder, for chaining.
+ */
+ public CreateBuilder setACL(List<ACL> acl) {
+ this.acl = acl;
+ return this;
+ }
+
+ /**
+ * Specifyies whether the node to be created is ephemeral,
+ * sequential, etc. using the integer encoding. Either this
+ * or {@link #setCreateMode} must be used before calling
+ * {@link #build()}.
+ *
+ * @param createModeFlag the create mode encoded as an integer
+ * @return the builder, for chaining.
+ */
+ public CreateBuilder setCreateModeFlag(Integer createModeFlag) {
+ this.createModeFlag = createModeFlag;
+ return this;
+ }
+
+ /**
+ * Specifyies whether the node to be created is ephemeral,
+ * sequential, etc. Either this or {@link #setCreateModeFlag}
+ * must be used before calling {@link #build()}.
+ *
+ * @param createMode the create mode as an enum value
+ * @return the builder, for chaining.
+ */
+ public CreateBuilder setCreateMode(CreateMode createMode) {
+ this.createMode = createMode;
+ return this;
+ }
+
+ /**
+ * Configures whether to include a {@code Stat} object in the
+ * response. Defaults to {@code false}.
+ *
+ * <p>Note that this flag has no effect for TTL or container
+ * nodes, as those always include a {@code Stat} at the
+ * protocol level.
+ *
+ * @param returnStat whether node creation should produce a
+ * {@code Stat} object
+ * @return the builder, for chaining.
+ */
+ public CreateBuilder setReturnStat(boolean returnStat) {
+ this.returnStat = returnStat;
+ return this;
+ }
+
+ /**
+ * Sets the TTL for the node. Must be set before calling
+ * {@link #build()} when creating TTL nodes.
+ *
+ * @param ttl the TTL for the node
+ * @return the builder, for chaining.
+ */
+ public CreateBuilder setTTL(Long ttl) {
Review comment:
the same here, we should have `long`
##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/Op.java
##########
@@ -253,6 +254,142 @@ void validate() throws KeeperException {
PathUtils.validatePath(path);
}
+ /**
+ * "Fluent builder" for {@link Create} operations.
+ */
+ public static class CreateBuilder {
+ private String path;
+ private byte[] data;
+ private List<ACL> acl;
+ private Integer createModeFlag;
+ private CreateMode createMode;
+ private boolean returnStat = false;
+ private Long ttl;
+
+ /**
+ * Sets the path for the node. Must be set before calling
+ * {@link #build()}.
+ *
+ * @param path the path for the node
+ * @return the builder, for chaining.
+ */
+ public CreateBuilder setPath(String path) {
+ this.path = path;
+ return this;
+ }
+
+ /**
+ * Sets the initial data for the node, or {@code null}.
+ *
+ * @param data the initial data for the node
+ * @return the builder, for chaining.
+ */
+ @SuppressFBWarnings({"EI_EXPOSE_REP", "EI_EXPOSE_REP2"})
+ public CreateBuilder setData(byte[] data) {
+ this.data = data;
+ return this;
+ }
+
+ /**
+ * Sets the acl for the node. Must be set before calling
+ * {@link #build()}.
+ *
+ * @param acl the acl for the node
+ * @return the builder, for chaining.
+ */
+ public CreateBuilder setACL(List<ACL> acl) {
+ this.acl = acl;
Review comment:
are we allowing a `null` value here ?
##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/Op.java
##########
@@ -253,6 +254,142 @@ void validate() throws KeeperException {
PathUtils.validatePath(path);
}
+ /**
+ * "Fluent builder" for {@link Create} operations.
+ */
+ public static class CreateBuilder {
+ private String path;
+ private byte[] data;
+ private List<ACL> acl;
+ private Integer createModeFlag;
+ private CreateMode createMode;
+ private boolean returnStat = false;
+ private Long ttl;
+
+ /**
+ * Sets the path for the node. Must be set before calling
+ * {@link #build()}.
+ *
+ * @param path the path for the node
+ * @return the builder, for chaining.
+ */
+ public CreateBuilder setPath(String path) {
+ this.path = path;
+ return this;
+ }
+
+ /**
+ * Sets the initial data for the node, or {@code null}.
+ *
+ * @param data the initial data for the node
+ * @return the builder, for chaining.
+ */
+ @SuppressFBWarnings({"EI_EXPOSE_REP", "EI_EXPOSE_REP2"})
+ public CreateBuilder setData(byte[] data) {
+ this.data = data;
Review comment:
are we allowing a `null` value here ?
##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/Op.java
##########
@@ -253,6 +254,142 @@ void validate() throws KeeperException {
PathUtils.validatePath(path);
}
+ /**
+ * "Fluent builder" for {@link Create} operations.
+ */
+ public static class CreateBuilder {
+ private String path;
+ private byte[] data;
+ private List<ACL> acl;
+ private Integer createModeFlag;
+ private CreateMode createMode;
+ private boolean returnStat = false;
+ private Long ttl;
+
+ /**
+ * Sets the path for the node. Must be set before calling
+ * {@link #build()}.
+ *
+ * @param path the path for the node
+ * @return the builder, for chaining.
+ */
+ public CreateBuilder setPath(String path) {
+ this.path = path;
+ return this;
+ }
+
+ /**
+ * Sets the initial data for the node, or {@code null}.
+ *
+ * @param data the initial data for the node
+ * @return the builder, for chaining.
+ */
+ @SuppressFBWarnings({"EI_EXPOSE_REP", "EI_EXPOSE_REP2"})
+ public CreateBuilder setData(byte[] data) {
+ this.data = data;
+ return this;
+ }
+
+ /**
+ * Sets the acl for the node. Must be set before calling
+ * {@link #build()}.
+ *
+ * @param acl the acl for the node
+ * @return the builder, for chaining.
+ */
+ public CreateBuilder setACL(List<ACL> acl) {
+ this.acl = acl;
+ return this;
+ }
+
+ /**
+ * Specifyies whether the node to be created is ephemeral,
+ * sequential, etc. using the integer encoding. Either this
+ * or {@link #setCreateMode} must be used before calling
+ * {@link #build()}.
+ *
+ * @param createModeFlag the create mode encoded as an integer
+ * @return the builder, for chaining.
+ */
+ public CreateBuilder setCreateModeFlag(Integer createModeFlag) {
+ this.createModeFlag = createModeFlag;
+ return this;
+ }
+
+ /**
+ * Specifyies whether the node to be created is ephemeral,
+ * sequential, etc. Either this or {@link #setCreateModeFlag}
+ * must be used before calling {@link #build()}.
+ *
+ * @param createMode the create mode as an enum value
+ * @return the builder, for chaining.
+ */
+ public CreateBuilder setCreateMode(CreateMode createMode) {
+ this.createMode = createMode;
Review comment:
are we allowing a `null` value here ?
##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/Op.java
##########
@@ -253,6 +254,142 @@ void validate() throws KeeperException {
PathUtils.validatePath(path);
}
+ /**
+ * "Fluent builder" for {@link Create} operations.
+ */
+ public static class CreateBuilder {
+ private String path;
+ private byte[] data;
+ private List<ACL> acl;
+ private Integer createModeFlag;
+ private CreateMode createMode;
+ private boolean returnStat = false;
+ private Long ttl;
+
+ /**
+ * Sets the path for the node. Must be set before calling
+ * {@link #build()}.
+ *
+ * @param path the path for the node
+ * @return the builder, for chaining.
+ */
+ public CreateBuilder setPath(String path) {
+ this.path = path;
Review comment:
are we allowing a `null` value here ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org