You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/03/09 20:23:42 UTC

[GitHub] [ignite-3] agura opened a new pull request #64: IGNITE-14198 Meta storage client interface

agura opened a new pull request #64:
URL: https://github.com/apache/ignite-3/pull/64


   Initial definition of client interface for meta storage access.


----------------------------------------------------------------
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r603676332



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/Operation.java
##########
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+/**
+ * Defines operation for meta storage conditional update (invoke).
+ */
+public final class Operation {
+    /** Actual operation implementation. */
+    @SuppressWarnings({"FieldCanBeLocal", "unused"})
+    private final InnerOp upd;
+
+    /**
+     * Constructs an operation which wraps the actual operation implementation.
+     *
+     * @param upd The actual operation implementation.
+     */
+    Operation(InnerOp upd) {
+        this.upd = upd;
+    }
+
+    /**
+     * Represents operation of type <i>remove</i>.
+     */
+    public static final class RemoveOp implements InnerOp {
+        /**
+         * Default no-op constructor.
+         */
+        RemoveOp() {
+            // No-op.
+        }
+    }
+
+    /**
+     * Represents operation of type <i>put</i>.
+     */
+    public static final class PutOp implements InnerOp {
+        /** Value. */
+        private final byte[] val;
+
+        /**
+         * Constructs operation of type <i>put</i>.
+         *
+         * @param val The value to which the entry should be updated.
+         */
+        PutOp(byte[] val) {
+            this.val = val;
+        }
+    }
+
+    /**
+     * Represents operation of type <i>no-op</i>.
+     */
+    public static final class NoOp implements InnerOp {
+        /**
+         * Default no-op constructor.
+         */
+        NoOp() {
+            // No-op.
+        }
+    }
+
+    /**
+     * Defines operation interface.
+     */
+    private interface InnerOp {
+        // Marker interface.
+    }
+}

Review comment:
       It's strange that checkstyle and PMD check don't fail build.
   
   Thx! Fixed.




-- 
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592463983



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);

Review comment:
       Actually @Berkof is right. For meta storage order doesn't matter. The only problem is possible confusion about order of returned entries for `getAndPutAll` method. I'll fix it and add a note which will stress that the order of returned entries depends on map traversal order.
   




----------------------------------------------------------------
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592482427



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/Condition.java
##########
@@ -0,0 +1,357 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+import java.util.Arrays;
+
+/**
+ * Represents a condition for conditional update.
+ */
+public final class Condition {
+    /** Actual condition implementation. */
+    private final InnerCondition cond;
+
+    /**
+     * Constructs a condition which wraps the actual condition implementation.
+     *
+     * @param cond The actual condition implementation.
+     */
+    Condition(InnerCondition cond) {
+        this.cond = cond;
+    }
+
+    /**
+     * Tests the given entry on satisfaction of the condition.
+     *
+     * @param e Entry.
+     * @return The result of condition test. {@code true} - if the entry satisfies to the condition,
+     * otherwise - {@code false}.
+     */
+    public boolean test(Entry e) {
+        return cond.test(e);
+    }
+
+    /**
+     * Represents condition on entry revision. Only one type of condition could be applied to
+     * the one instance of condition. Subsequent invocations of any method which produces condition will throw
+     * {@link IllegalStateException}.
+     */
+    public static final class RevisionCondition implements InnerCondition {
+        /**
+         * The type of condition.
+         *
+         * @see Type
+         */
+        private Type type;
+
+        /**
+         * The revision as the condition argument.
+         */
+        private long rev;
+
+        /**
+         * Default no-op constructor.
+         */
+        RevisionCondition() {
+            // No-op.
+        }
+
+        // TODO: eq, ne, lt, le, gt, ge
+        /**
+         * Produces the condition of type {@link Type#EQUAL}. This condition tests the given revision on equality with
+         * target entry revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#EQUAL}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition eq(long rev) {
+            validate(type);
+
+            this.type = Type.EQUAL;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#NOT_EQUAL}. This condition tests the given revision on inequality
+         * with target entry revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#NOT_EQUAL}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition ne(long rev) {
+            validate(type);
+
+            this.type = Type.NOT_EQUAL;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#GREATER}. This condition tests that the target entry revision
+         * is greater than given revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#GREATER}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition gt(long rev) {
+            validate(type);
+
+            this.type = Type.GREATER;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#GREATER_OR_EQUAL}. This condition tests that the target entry
+         * revision is greater than or equal to given revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#GREATER_OR_EQUAL}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition ge(long rev) {
+            validate(type);
+
+            this.type = Type.GREATER_OR_EQUAL;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#LESS}. This condition tests that target entry revision
+         * is less than the given revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#LESS}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition lt(long rev) {
+            validate(type);
+
+            this.type = Type.LESS;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#LESS_OR_EQUAL}. This condition tests that target entry revision
+         * is less than or equal to the given revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#LESS_OR_EQUAL}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition le(long rev) {
+            validate(type);
+
+            this.type = Type.LESS_OR_EQUAL;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean test(Entry e) {
+            int res = Long.compare(e.revision(), rev);
+
+            return type.test(res);
+        }
+
+        /**
+         * Defines possible condition types which can be applied to the revision.
+         */
+        enum Type {
+            /** Equality condition type. */
+            EQUAL {
+                @Override public boolean test(long res) {
+                    return res == 0;
+                }
+            },
+
+            /** Inequality condition type. */
+            NOT_EQUAL {
+                @Override public boolean test(long res) {
+                    return res != 0;
+                }
+            },
+
+            /** Greater than condition type. */
+            GREATER {
+                @Override public boolean test(long res) {
+                    return res > 0;
+                }
+            },
+
+            /** Less than condition type. */
+            LESS {
+                @Override public boolean test(long res) {
+                    return res < 0;
+                }
+            },
+
+            /** Less than or equal to condition type. */
+            LESS_OR_EQUAL {
+                @Override public boolean test(long res) {
+                    return res <= 0;
+                }
+            },
+
+            /** Greater than or equal to condition type. */
+            GREATER_OR_EQUAL {
+                @Override public boolean test(long res) {
+                    return res >= 0;
+                }
+            };
+
+            /**
+             * Interprets comparison result.
+             *
+             * @param res The result of comparison.
+             * @return The interpretation of the comparison result.
+             */
+            public abstract boolean test(long res);

Review comment:
       `eval` assumes that any type of result could be returned, while `test` is the common name for predicate-like methods. See for example `java.util.function.Predicate` interface.




----------------------------------------------------------------
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592475939



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A list of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndRemoveAll(@NotNull Collection<byte[]> key);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull byte[] key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull byte[] key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(byte[], byte[], long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@Nullable byte[] keyFrom, @Nullable byte[] keyTo,
+                                  long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for the given key.
+     *
+     * @param key The target key. Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).

Review comment:
       @Berkof I don't see any problems here.
   
   @AMashenkov It will lead to big number of methods. About `0`: all revisions accordingly to javadoc.




----------------------------------------------------------------
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



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592428181



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/Operation.java
##########
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+/**
+ * Defines operation for meta storage conditional update (invoke).
+ */
+public final class Operation {
+    /** Actual operation implementation. */
+    @SuppressWarnings({"FieldCanBeLocal", "unused"})
+    private final InnerOp upd;
+
+    /**
+     * Constructs an operation which wraps the actual operation implementation.
+     *
+     * @param upd The actual operation implementation.
+     */
+    Operation(InnerOp upd) {
+        this.upd = upd;
+    }
+
+    /**
+     * Represents operation of type <i>remove</i>.
+     */
+    public static final class RemoveOp implements InnerOp {

Review comment:
       Looks like RemoveOp and NoOp instances can be singletones.




----------------------------------------------------------------
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



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592384297



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);

Review comment:
       In code above, putAll operation accepts a List<byte[]>, which is ordered.
   But remove accepts an unordered Collection. 
   Does the order matter for bulk operations?




----------------------------------------------------------------
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



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592405064



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A list of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndRemoveAll(@NotNull Collection<byte[]> key);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull byte[] key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull byte[] key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(byte[], byte[], long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@Nullable byte[] keyFrom, @Nullable byte[] keyTo,
+                                  long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for the given key.
+     *
+     * @param key The target key. Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@NotNull byte[] key, long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for given keys.
+     *
+     * @param keys Collection of target keys. Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@NotNull Collection<byte[]> keys, long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Cancels subscription for the given identifier.
+     *
+     * @param id Subscription identifier.
+     * @return Completed future in case of operation success. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<Void> stopWatch(@NotNull UUID id);
+
+    /**
+     * Compacts meta storage (removes all tombstone entries and old entries except of entries with latest revision).
+     *
+     * @return Completed future. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     */
+    CompletableFuture<Void> compact();

Review comment:
       ```suggestion
       @NotNull
       CompletableFuture<Void> compact();
   ```




----------------------------------------------------------------
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



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592417345



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/Condition.java
##########
@@ -0,0 +1,357 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+import java.util.Arrays;
+
+/**
+ * Represents a condition for conditional update.
+ */
+public final class Condition {
+    /** Actual condition implementation. */
+    private final InnerCondition cond;
+
+    /**
+     * Constructs a condition which wraps the actual condition implementation.
+     *
+     * @param cond The actual condition implementation.
+     */
+    Condition(InnerCondition cond) {
+        this.cond = cond;
+    }
+
+    /**
+     * Tests the given entry on satisfaction of the condition.
+     *
+     * @param e Entry.
+     * @return The result of condition test. {@code true} - if the entry satisfies to the condition,
+     * otherwise - {@code false}.
+     */
+    public boolean test(Entry e) {
+        return cond.test(e);
+    }
+
+    /**
+     * Represents condition on entry revision. Only one type of condition could be applied to
+     * the one instance of condition. Subsequent invocations of any method which produces condition will throw
+     * {@link IllegalStateException}.
+     */
+    public static final class RevisionCondition implements InnerCondition {
+        /**
+         * The type of condition.
+         *
+         * @see Type
+         */
+        private Type type;
+
+        /**
+         * The revision as the condition argument.
+         */
+        private long rev;
+
+        /**
+         * Default no-op constructor.
+         */
+        RevisionCondition() {
+            // No-op.
+        }
+
+        // TODO: eq, ne, lt, le, gt, ge
+        /**
+         * Produces the condition of type {@link Type#EQUAL}. This condition tests the given revision on equality with
+         * target entry revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#EQUAL}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition eq(long rev) {
+            validate(type);
+
+            this.type = Type.EQUAL;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#NOT_EQUAL}. This condition tests the given revision on inequality
+         * with target entry revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#NOT_EQUAL}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition ne(long rev) {
+            validate(type);
+
+            this.type = Type.NOT_EQUAL;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#GREATER}. This condition tests that the target entry revision
+         * is greater than given revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#GREATER}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition gt(long rev) {
+            validate(type);
+
+            this.type = Type.GREATER;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#GREATER_OR_EQUAL}. This condition tests that the target entry
+         * revision is greater than or equal to given revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#GREATER_OR_EQUAL}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition ge(long rev) {
+            validate(type);
+
+            this.type = Type.GREATER_OR_EQUAL;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#LESS}. This condition tests that target entry revision
+         * is less than the given revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#LESS}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition lt(long rev) {
+            validate(type);
+
+            this.type = Type.LESS;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#LESS_OR_EQUAL}. This condition tests that target entry revision
+         * is less than or equal to the given revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#LESS_OR_EQUAL}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition le(long rev) {
+            validate(type);
+
+            this.type = Type.LESS_OR_EQUAL;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean test(Entry e) {
+            int res = Long.compare(e.revision(), rev);
+
+            return type.test(res);
+        }
+
+        /**
+         * Defines possible condition types which can be applied to the revision.
+         */
+        enum Type {
+            /** Equality condition type. */
+            EQUAL {
+                @Override public boolean test(long res) {
+                    return res == 0;
+                }
+            },
+
+            /** Inequality condition type. */
+            NOT_EQUAL {
+                @Override public boolean test(long res) {
+                    return res != 0;
+                }
+            },
+
+            /** Greater than condition type. */
+            GREATER {
+                @Override public boolean test(long res) {
+                    return res > 0;
+                }
+            },
+
+            /** Less than condition type. */
+            LESS {
+                @Override public boolean test(long res) {
+                    return res < 0;
+                }
+            },
+
+            /** Less than or equal to condition type. */
+            LESS_OR_EQUAL {
+                @Override public boolean test(long res) {
+                    return res <= 0;
+                }
+            },
+
+            /** Greater than or equal to condition type. */
+            GREATER_OR_EQUAL {
+                @Override public boolean test(long res) {
+                    return res >= 0;
+                }
+            };
+
+            /**
+             * Interprets comparison result.
+             *
+             * @param res The result of comparison.
+             * @return The interpretation of the comparison result.
+             */
+            public abstract boolean test(long res);
+        }
+    }
+
+    /**
+     * Represents condition on entry value. Only one type of condition could be applied to
+     * the one instance of condition. Subsequent invocations of any method which produces condition will throw
+     * {@link IllegalStateException}.
+     */
+    public static final class ValueCondition implements InnerCondition {
+        /**
+         * The type of condition.
+         *
+         * @see Type
+         */
+        private Type type;
+
+        /**
+         * The value as the condition argument.
+         */
+        private byte[] val;
+
+        /**
+         * Default no-op constructor.
+         */
+        ValueCondition() {
+            // No-op.
+        }
+
+        /**
+         * Produces the condition of type {@link Type#EQUAL}. This condition tests the given value on equality with
+         * target entry value.
+         *
+         * @param val The value.
+         * @return The condition of type {@link Type#EQUAL}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition eq(byte[] val) {
+            validate(type);
+
+            this.type = Type.EQUAL;
+            this.val = val;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#NOT_EQUAL}. This condition tests the given мфдгу on inequality
+         * with target entry мфдгу.

Review comment:
       ```suggestion
            * Produces the condition of type {@link Type#NOT_EQUAL}. This condition tests the given value on inequality
            * with target entry value.
   ```




----------------------------------------------------------------
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592478388



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A list of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndRemoveAll(@NotNull Collection<byte[]> key);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull byte[] key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull byte[] key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(byte[], byte[], long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@Nullable byte[] keyFrom, @Nullable byte[] keyTo,
+                                  long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for the given key.
+     *
+     * @param key The target key. Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@NotNull byte[] key, long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for given keys.
+     *
+     * @param keys Collection of target keys. Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@NotNull Collection<byte[]> keys, long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Cancels subscription for the given identifier.
+     *
+     * @param id Subscription identifier.
+     * @return Completed future in case of operation success. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<Void> stopWatch(@NotNull UUID id);

Review comment:
       I don't see use case for it. Will add when it will be actual.




----------------------------------------------------------------
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



[GitHub] [ignite-3] Berkof commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
Berkof commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592090933



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);

Review comment:
       Why not use a Map?

##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);

Review comment:
       How to corellate result Entries with keys? I suppose it should have Map parameter and Map result future type

##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A list of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndRemoveAll(@NotNull Collection<byte[]> key);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull byte[] key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull byte[] key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(byte[], byte[], long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@Nullable byte[] keyFrom, @Nullable byte[] keyTo,
+                                  long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for the given key.
+     *
+     * @param key The target key. Could be {@code null}.

Review comment:
       Not it can't. Because of @NotNull annotation. Let's remove it and write something like: "if {@code null} - watch for the all key changes"

##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A list of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndRemoveAll(@NotNull Collection<byte[]> key);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull byte[] key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull byte[] key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(byte[], byte[], long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@Nullable byte[] keyFrom, @Nullable byte[] keyTo,
+                                  long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for the given key.
+     *
+     * @param key The target key. Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).

Review comment:
       Why we need magic number here? Why not using Long revision and null value instead?

##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/CompactedException.java
##########
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+/**
+ * Thrown when a requested operation on meta storage could not be performed because target revisions were removed
+ * from storage due to a compaction procedure. In such case the operation should be retried with actual revision.
+ */
+public class CompactedException extends RuntimeException {

Review comment:
       Why it extends RuntimeException, not some kind of IgniteRuntimeException?

##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A list of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndRemoveAll(@NotNull Collection<byte[]> key);

Review comment:
       Map result type again.

##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A list of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndRemoveAll(@NotNull Collection<byte[]> key);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull byte[] key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull byte[] key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(byte[], byte[], long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@Nullable byte[] keyFrom, @Nullable byte[] keyTo,
+                                  long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for the given key.
+     *
+     * @param key The target key. Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@NotNull byte[] key, long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for given keys.
+     *
+     * @param keys Collection of target keys. Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@NotNull Collection<byte[]> keys, long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Cancels subscription for the given identifier.
+     *
+     * @param id Subscription identifier.
+     * @return Completed future in case of operation success. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<Void> stopWatch(@NotNull UUID id);

Review comment:
       What about a group method like shotWatchAll(Collection<UUID> uuids)

##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A list of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndRemoveAll(@NotNull Collection<byte[]> key);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull byte[] key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull byte[] key, @NotNull Condition condition,

Review comment:
       So we need invokeAndGet? To get an actual value after some operation applied. Or should we always be able to run condition on it, guess if it was success and run the corresponding operation locally?

##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A list of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndRemoveAll(@NotNull Collection<byte[]> key);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull byte[] key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull byte[] key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(byte[], byte[], long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@Nullable byte[] keyFrom, @Nullable byte[] keyTo,
+                                  long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for the given key.
+     *
+     * @param key The target key. Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@NotNull byte[] key, long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for given keys.
+     *
+     * @param keys Collection of target keys. Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@NotNull Collection<byte[]> keys, long revision, @NotNull WatchListener lsnr);

Review comment:
       Why we need some future here? Can I get UUID right after the watch function colled? I mean - why not to generate it locally and simplify the interface a little bit?




----------------------------------------------------------------
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



[GitHub] [ignite-3] agoncharuk commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agoncharuk commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r595322476



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/WatchListener.java
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * The listener which receives and handles watch updates.
+ */
+public interface WatchListener {
+    /**
+     * The method will be called on each meta storage update.
+     *
+     * @param events A single event or batch.
+     * @return {@code True} if listener must continue event handling. If returns {@code false} then the listener and
+     * corresponding watch will be unregistered.
+     */
+    boolean onUpdate(@NotNull Iterable<WatchEvent> events);

Review comment:
       Additionally, what thread will this be executed? Are all invocations of onUpdate serialized (essentially, single-threaded?). Does one WatchListener execution affect other listeners?




----------------------------------------------------------------
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



[GitHub] [ignite-3] dgarus commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
dgarus commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r598303398



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);

Review comment:
       Could we use` List<Entry>` as the input parameter?
   A single list of entries looks more convenient than two separate lists for keys and values.




-- 
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592479941



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);

Review comment:
       Because order doesn't matter for remove, while put requires ordered keys and values. But I'll fix `putAll` so it will get Map.




----------------------------------------------------------------
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r600004863



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/WatchListener.java
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * The listener which receives and handles watch updates.
+ */
+public interface WatchListener {
+    /**
+     * The method will be called on each meta storage update.
+     *
+     * @param events A single event or batch.
+     * @return {@code True} if listener must continue event handling. If returns {@code false} then the listener and
+     * corresponding watch will be unregistered.
+     */
+    boolean onUpdate(@NotNull Iterable<WatchEvent> events);

Review comment:
       @agoncharuk 
    
   > Additionally, what thread will this be executed? Are all invocations of onUpdate serialized (essentially, single-threaded?). Does one WatchListener execution affect other listeners?
   
   It isn't defined by interface yet. What do you mean when talk that `WatchListener` execution affects other listeners?




-- 
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r594179988



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);

Review comment:
       Stop! :) Map isn't good idea due to byte[] key.




----------------------------------------------------------------
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r599989095



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);

Review comment:
       @dgarus `Entry` is immutable and intentionally can't be created by user. Entry has more fields which couldn't be inited by user. So, answer to your question is no. But it is still arguable. In Ignite 2.x there is no such methods at all. Do we really need such methods? 




-- 
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



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592386413



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A list of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndRemoveAll(@NotNull Collection<byte[]> key);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull byte[] key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull byte[] key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(byte[], byte[], long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@Nullable byte[] keyFrom, @Nullable byte[] keyTo,
+                                  long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for the given key.
+     *
+     * @param key The target key. Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).

Review comment:
       I'd prefer a shortcut method with no revision parameter instead of magic "-1".
   What does "0" magic means? any revision or all revisions? Seems there is a typo.




----------------------------------------------------------------
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r599994922



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A list of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndRemoveAll(@NotNull Collection<byte[]> key);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull byte[] key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull byte[] key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(byte[], byte[], long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@Nullable byte[] keyFrom, @Nullable byte[] keyTo,

Review comment:
       @agoncharuk 
   > Probably, we should generate the watch ID on the client side and return the ID immediately?
   
   IMHO, we still need return `CompletableFuture` because this operation is remote by nature. We can try to guarantee that the subscription will be destroyed correctly because the `UUID`, in fact, will be generated on the client side. Moreover, where possible exceptions (like OperationTimeoutException) should be handled in case of immediate return?
   
   




-- 
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592482863



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/Cursor.java
##########
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+/**
+ * Closeable cursor.
+ *
+ * @param <T>
+ */
+//TODO: Should be replaced by common entity from org.ignite.lang or org.ignite.core package.
+public interface Cursor<T> extends Iterable<T>, AutoCloseable {

Review comment:
       Will be revised under addition `ignite-core` module.




----------------------------------------------------------------
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r599998761



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/Condition.java
##########
@@ -0,0 +1,357 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+import java.util.Arrays;
+
+/**
+ * Represents a condition for conditional update.
+ */
+public final class Condition {
+    /** Actual condition implementation. */
+    private final InnerCondition cond;
+
+    /**
+     * Constructs a condition which wraps the actual condition implementation.
+     *
+     * @param cond The actual condition implementation.
+     */
+    Condition(InnerCondition cond) {
+        this.cond = cond;
+    }
+
+    /**
+     * Tests the given entry on satisfaction of the condition.
+     *
+     * @param e Entry.
+     * @return The result of condition test. {@code true} - if the entry satisfies to the condition,
+     * otherwise - {@code false}.
+     */
+    public boolean test(Entry e) {
+        return cond.test(e);
+    }
+
+    /**
+     * Represents condition on entry revision. Only one type of condition could be applied to
+     * the one instance of condition. Subsequent invocations of any method which produces condition will throw
+     * {@link IllegalStateException}.
+     */
+    public static final class RevisionCondition implements InnerCondition {
+        /**
+         * The type of condition.
+         *
+         * @see Type
+         */
+        private Type type;
+
+        /**
+         * The revision as the condition argument.
+         */
+        private long rev;
+
+        /**
+         * Default no-op constructor.
+         */
+        RevisionCondition() {
+            // No-op.
+        }
+
+        // TODO: eq, ne, lt, le, gt, ge

Review comment:
       Thx!




-- 
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



[GitHub] [ignite-3] dgarus commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
dgarus commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r598303398



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);

Review comment:
       Could we use List<Entry> as the input parameter?
   A single list of entries looks more convenient than two separate lists for keys and values.




-- 
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r601849833



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);

Review comment:
       `byte[]` replaced by `Key`




-- 
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



[GitHub] [ignite-3] dgarus commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
dgarus commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r601391171



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/Entry.java
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Represents a storage unit as entry with key, value and revision, where
+ * <ul>
+ *     <li>key - an unique entry's key represented by an array of bytes. Keys are comparable in lexicographic manner.</li>
+ *     <ul>value - a data which is associated with a key and represented as an array of bytes.</ul>
+ *     <ul>revision - a number which denotes a version of whole meta storage. Each change increments the revision.</ul>
+ * </ul>
+ */
+public interface Entry {

Review comment:
       `Entry` is immutable and intentionally can't be created by a user.
   So it should be the final class with package private construcor instead of the interface.




-- 
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



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592414348



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/Condition.java
##########
@@ -0,0 +1,357 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+import java.util.Arrays;
+
+/**
+ * Represents a condition for conditional update.
+ */
+public final class Condition {
+    /** Actual condition implementation. */
+    private final InnerCondition cond;
+
+    /**
+     * Constructs a condition which wraps the actual condition implementation.
+     *
+     * @param cond The actual condition implementation.
+     */
+    Condition(InnerCondition cond) {
+        this.cond = cond;
+    }
+
+    /**
+     * Tests the given entry on satisfaction of the condition.
+     *
+     * @param e Entry.
+     * @return The result of condition test. {@code true} - if the entry satisfies to the condition,
+     * otherwise - {@code false}.
+     */
+    public boolean test(Entry e) {
+        return cond.test(e);
+    }
+
+    /**
+     * Represents condition on entry revision. Only one type of condition could be applied to
+     * the one instance of condition. Subsequent invocations of any method which produces condition will throw
+     * {@link IllegalStateException}.
+     */
+    public static final class RevisionCondition implements InnerCondition {
+        /**
+         * The type of condition.
+         *
+         * @see Type
+         */
+        private Type type;
+
+        /**
+         * The revision as the condition argument.
+         */
+        private long rev;
+
+        /**
+         * Default no-op constructor.
+         */
+        RevisionCondition() {
+            // No-op.
+        }
+
+        // TODO: eq, ne, lt, le, gt, ge
+        /**
+         * Produces the condition of type {@link Type#EQUAL}. This condition tests the given revision on equality with
+         * target entry revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#EQUAL}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition eq(long rev) {
+            validate(type);
+
+            this.type = Type.EQUAL;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#NOT_EQUAL}. This condition tests the given revision on inequality
+         * with target entry revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#NOT_EQUAL}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition ne(long rev) {
+            validate(type);
+
+            this.type = Type.NOT_EQUAL;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#GREATER}. This condition tests that the target entry revision
+         * is greater than given revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#GREATER}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition gt(long rev) {
+            validate(type);
+
+            this.type = Type.GREATER;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#GREATER_OR_EQUAL}. This condition tests that the target entry
+         * revision is greater than or equal to given revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#GREATER_OR_EQUAL}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition ge(long rev) {
+            validate(type);
+
+            this.type = Type.GREATER_OR_EQUAL;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#LESS}. This condition tests that target entry revision
+         * is less than the given revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#LESS}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition lt(long rev) {
+            validate(type);
+
+            this.type = Type.LESS;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#LESS_OR_EQUAL}. This condition tests that target entry revision
+         * is less than or equal to the given revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#LESS_OR_EQUAL}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition le(long rev) {
+            validate(type);
+
+            this.type = Type.LESS_OR_EQUAL;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean test(Entry e) {
+            int res = Long.compare(e.revision(), rev);
+
+            return type.test(res);
+        }
+
+        /**
+         * Defines possible condition types which can be applied to the revision.
+         */
+        enum Type {
+            /** Equality condition type. */
+            EQUAL {
+                @Override public boolean test(long res) {
+                    return res == 0;
+                }
+            },
+
+            /** Inequality condition type. */
+            NOT_EQUAL {
+                @Override public boolean test(long res) {
+                    return res != 0;
+                }
+            },
+
+            /** Greater than condition type. */
+            GREATER {
+                @Override public boolean test(long res) {
+                    return res > 0;
+                }
+            },
+
+            /** Less than condition type. */
+            LESS {
+                @Override public boolean test(long res) {
+                    return res < 0;
+                }
+            },
+
+            /** Less than or equal to condition type. */
+            LESS_OR_EQUAL {
+                @Override public boolean test(long res) {
+                    return res <= 0;
+                }
+            },
+
+            /** Greater than or equal to condition type. */
+            GREATER_OR_EQUAL {
+                @Override public boolean test(long res) {
+                    return res >= 0;
+                }
+            };
+
+            /**
+             * Interprets comparison result.
+             *
+             * @param res The result of comparison.
+             * @return The interpretation of the comparison result.
+             */
+            public abstract boolean test(long res);

Review comment:
       Will be 'eval' more suitable method name?




----------------------------------------------------------------
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592478883



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/CompactedException.java
##########
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+/**
+ * Thrown when a requested operation on meta storage could not be performed because target revisions were removed
+ * from storage due to a compaction procedure. In such case the operation should be retried with actual revision.
+ */
+public class CompactedException extends RuntimeException {

Review comment:
       Because there is no IgniteRuntimeException yet.




----------------------------------------------------------------
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



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592386413



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A list of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndRemoveAll(@NotNull Collection<byte[]> key);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull byte[] key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull byte[] key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(byte[], byte[], long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@Nullable byte[] keyFrom, @Nullable byte[] keyTo,
+                                  long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for the given key.
+     *
+     * @param key The target key. Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).

Review comment:
       I'd prefer a shortcut method with no revision parameter instead of magic "-1" or null.
   What does "0" magic means? any revision or all revisions? Seems there is a typo.
   
   If having magic constants is preferable, then let's move them to static final fields with proper description,




----------------------------------------------------------------
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



[GitHub] [ignite-3] agoncharuk commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agoncharuk commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r599366988



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A list of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndRemoveAll(@NotNull Collection<byte[]> key);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull byte[] key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull byte[] key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(byte[], byte[], long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@Nullable byte[] keyFrom, @Nullable byte[] keyTo,

Review comment:
       Or we should properly handle future.cancel() call, but this will be harder to handle from the outside because the external code should either work with future, or with watch ID.




-- 
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r599997827



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A list of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndRemoveAll(@NotNull Collection<byte[]> key);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull byte[] key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull byte[] key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(byte[], byte[], long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@Nullable byte[] keyFrom, @Nullable byte[] keyTo,
+                                  long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for the given key.
+     *
+     * @param key The target key. Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@NotNull byte[] key, long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for given keys.
+     *
+     * @param keys Collection of target keys. Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@NotNull Collection<byte[]> keys, long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Cancels subscription for the given identifier.
+     *
+     * @param id Subscription identifier.
+     * @return Completed future in case of operation success. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<Void> stopWatch(@NotNull UUID id);
+
+    /**
+     * Compacts meta storage (removes all tombstone entries and old entries except of entries with latest revision).
+     *
+     * @return Completed future. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     */
+    CompletableFuture<Void> compact();

Review comment:
       Thx!




-- 
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592477957



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A list of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndRemoveAll(@NotNull Collection<byte[]> key);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull byte[] key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull byte[] key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(byte[], byte[], long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@Nullable byte[] keyFrom, @Nullable byte[] keyTo,
+                                  long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for the given key.
+     *
+     * @param key The target key. Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@NotNull byte[] key, long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for given keys.
+     *
+     * @param keys Collection of target keys. Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@NotNull Collection<byte[]> keys, long revision, @NotNull WatchListener lsnr);

Review comment:
       UUID wil lbe generated locally, but the operation itself is remote, so the future allows to you wait for the operation completion.




----------------------------------------------------------------
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r603674282



##########
File path: modules/core/src/main/java/org/apache/ignite/util/LexicographicComparator.java
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.util;
+
+import java.util.Comparator;
+
+/**
+ * Byte array lexicographic comparator.
+ */
+public class LexicographicComparator implements Comparator<byte[]> {

Review comment:
       Thx! Fixed.




-- 
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



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592380988



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);

Review comment:
       Map entries order is undefined in a general case.
   I'd suggest a SortedMap, however LinkedHashMap and Map.of(...) are ordered, but do not implemet SortedMap.
   Does the order matter? 




----------------------------------------------------------------
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592471241



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A list of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndRemoveAll(@NotNull Collection<byte[]> key);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull byte[] key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull byte[] key, @NotNull Condition condition,

Review comment:
       @Berkof See `TODO`. Conditional updates will be reworked significantly.




----------------------------------------------------------------
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592473169



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A list of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndRemoveAll(@NotNull Collection<byte[]> key);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull byte[] key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull byte[] key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(byte[], byte[], long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@Nullable byte[] keyFrom, @Nullable byte[] keyTo,
+                                  long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for the given key.
+     *
+     * @param key The target key. Could be {@code null}.

Review comment:
       @Berkof Thx! Will fix.




----------------------------------------------------------------
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r601849216



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);

Review comment:
       After some thinking I'm sure now that such methods are mandatory. Approach is revised: introduced `Key` entity instead of `byte[]` for keys.




-- 
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r600003825



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/WatchListener.java
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * The listener which receives and handles watch updates.
+ */
+public interface WatchListener {
+    /**
+     * The method will be called on each meta storage update.
+     *
+     * @param events A single event or batch.
+     * @return {@code True} if listener must continue event handling. If returns {@code false} then the listener and
+     * corresponding watch will be unregistered.
+     */
+    boolean onUpdate(@NotNull Iterable<WatchEvent> events);

Review comment:
       @agoncharuk 
   > Is it guaranteed that the batch will contain only updates from a single multi-update or multiple updates can be passed to this method? We need to state this clearly in the javadoc.
   
   Thanks for spotting this. Added to the `events` parameter javadoc:
   
   > The batch always contains updates for specific revision.




-- 
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



[GitHub] [ignite-3] dgarus commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
dgarus commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r601391171



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/Entry.java
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Represents a storage unit as entry with key, value and revision, where
+ * <ul>
+ *     <li>key - an unique entry's key represented by an array of bytes. Keys are comparable in lexicographic manner.</li>
+ *     <ul>value - a data which is associated with a key and represented as an array of bytes.</ul>
+ *     <ul>revision - a number which denotes a version of whole meta storage. Each change increments the revision.</ul>
+ * </ul>
+ */
+public interface Entry {

Review comment:
       `Entry` is immutable and intentionally can't be created by a user.
   So it should be the final class with a package-private constructor instead of the interface.




-- 
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



[GitHub] [ignite-3] dgarus commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
dgarus commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r601397443



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);

Review comment:
       I think that if there are doubts, then the best solution is not to introduce these methods. 
   We can easily add them in the future.




-- 
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r603675111



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,349 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Key;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull Key key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull Key key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A map of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Map<Key, Entry>> getAll(Collection<Key> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A map of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Map<Key, Entry>> getAll(Collection<Key> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull Key key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull Key key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     *
+     * @param vals The map of keys and corresponding values. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull Map<Key, byte[]> vals);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     *
+     * @param vals The map of keys and corresponding values. Couldn't be {@code null} or empty.
+     * @return A map of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Map<Key, Entry>> getAndPutAll(@NotNull Map<Key, byte[]> vals);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull Key key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndRemove(@NotNull Key key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param keys The keys collection. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<Key> keys);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param keys The keys collection. Couldn't be {@code null}.
+     * @return A map of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Map<Key, Entry>> getAndRemoveAll(@NotNull Collection<Key> keys);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull Key key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull Key key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull Key keyFrom, @Nullable Key keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(Key, Key, long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull Key keyFrom, @Nullable Key keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revisions,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.

Review comment:
       Thx! Fixed here and everywhere.




-- 
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



[GitHub] [ignite-3] agoncharuk commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agoncharuk commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r595319060



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/WatchListener.java
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * The listener which receives and handles watch updates.
+ */
+public interface WatchListener {
+    /**
+     * The method will be called on each meta storage update.
+     *
+     * @param events A single event or batch.
+     * @return {@code True} if listener must continue event handling. If returns {@code false} then the listener and
+     * corresponding watch will be unregistered.
+     */
+    boolean onUpdate(@NotNull Iterable<WatchEvent> events);

Review comment:
       Is it guaranteed that the batch will contain only updates from a single multi-update or multiple updates can be passed to this method? We need to state this clearly in the javadoc.




----------------------------------------------------------------
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r601849718



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A list of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndRemoveAll(@NotNull Collection<byte[]> key);

Review comment:
       Eventually replaced by `Map` :)




-- 
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r599999348



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/Condition.java
##########
@@ -0,0 +1,357 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+import java.util.Arrays;
+
+/**
+ * Represents a condition for conditional update.
+ */
+public final class Condition {
+    /** Actual condition implementation. */
+    private final InnerCondition cond;
+
+    /**
+     * Constructs a condition which wraps the actual condition implementation.
+     *
+     * @param cond The actual condition implementation.
+     */
+    Condition(InnerCondition cond) {
+        this.cond = cond;
+    }
+
+    /**
+     * Tests the given entry on satisfaction of the condition.
+     *
+     * @param e Entry.
+     * @return The result of condition test. {@code true} - if the entry satisfies to the condition,
+     * otherwise - {@code false}.
+     */
+    public boolean test(Entry e) {
+        return cond.test(e);
+    }
+
+    /**
+     * Represents condition on entry revision. Only one type of condition could be applied to
+     * the one instance of condition. Subsequent invocations of any method which produces condition will throw
+     * {@link IllegalStateException}.
+     */
+    public static final class RevisionCondition implements InnerCondition {
+        /**
+         * The type of condition.
+         *
+         * @see Type
+         */
+        private Type type;
+
+        /**
+         * The revision as the condition argument.
+         */
+        private long rev;
+
+        /**
+         * Default no-op constructor.
+         */
+        RevisionCondition() {
+            // No-op.
+        }
+
+        // TODO: eq, ne, lt, le, gt, ge
+        /**
+         * Produces the condition of type {@link Type#EQUAL}. This condition tests the given revision on equality with
+         * target entry revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#EQUAL}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition eq(long rev) {
+            validate(type);
+
+            this.type = Type.EQUAL;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#NOT_EQUAL}. This condition tests the given revision on inequality
+         * with target entry revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#NOT_EQUAL}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition ne(long rev) {
+            validate(type);
+
+            this.type = Type.NOT_EQUAL;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#GREATER}. This condition tests that the target entry revision
+         * is greater than given revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#GREATER}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition gt(long rev) {
+            validate(type);
+
+            this.type = Type.GREATER;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#GREATER_OR_EQUAL}. This condition tests that the target entry
+         * revision is greater than or equal to given revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#GREATER_OR_EQUAL}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition ge(long rev) {
+            validate(type);
+
+            this.type = Type.GREATER_OR_EQUAL;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#LESS}. This condition tests that target entry revision
+         * is less than the given revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#LESS}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition lt(long rev) {
+            validate(type);
+
+            this.type = Type.LESS;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#LESS_OR_EQUAL}. This condition tests that target entry revision
+         * is less than or equal to the given revision.
+         *
+         * @param rev The revision.
+         * @return The condition of type {@link Type#LESS_OR_EQUAL}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition le(long rev) {
+            validate(type);
+
+            this.type = Type.LESS_OR_EQUAL;
+            this.rev = rev;
+
+            return new Condition(this);
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean test(Entry e) {
+            int res = Long.compare(e.revision(), rev);
+
+            return type.test(res);
+        }
+
+        /**
+         * Defines possible condition types which can be applied to the revision.
+         */
+        enum Type {
+            /** Equality condition type. */
+            EQUAL {
+                @Override public boolean test(long res) {
+                    return res == 0;
+                }
+            },
+
+            /** Inequality condition type. */
+            NOT_EQUAL {
+                @Override public boolean test(long res) {
+                    return res != 0;
+                }
+            },
+
+            /** Greater than condition type. */
+            GREATER {
+                @Override public boolean test(long res) {
+                    return res > 0;
+                }
+            },
+
+            /** Less than condition type. */
+            LESS {
+                @Override public boolean test(long res) {
+                    return res < 0;
+                }
+            },
+
+            /** Less than or equal to condition type. */
+            LESS_OR_EQUAL {
+                @Override public boolean test(long res) {
+                    return res <= 0;
+                }
+            },
+
+            /** Greater than or equal to condition type. */
+            GREATER_OR_EQUAL {
+                @Override public boolean test(long res) {
+                    return res >= 0;
+                }
+            };
+
+            /**
+             * Interprets comparison result.
+             *
+             * @param res The result of comparison.
+             * @return The interpretation of the comparison result.
+             */
+            public abstract boolean test(long res);
+        }
+    }
+
+    /**
+     * Represents condition on entry value. Only one type of condition could be applied to
+     * the one instance of condition. Subsequent invocations of any method which produces condition will throw
+     * {@link IllegalStateException}.
+     */
+    public static final class ValueCondition implements InnerCondition {
+        /**
+         * The type of condition.
+         *
+         * @see Type
+         */
+        private Type type;
+
+        /**
+         * The value as the condition argument.
+         */
+        private byte[] val;
+
+        /**
+         * Default no-op constructor.
+         */
+        ValueCondition() {
+            // No-op.
+        }
+
+        /**
+         * Produces the condition of type {@link Type#EQUAL}. This condition tests the given value on equality with
+         * target entry value.
+         *
+         * @param val The value.
+         * @return The condition of type {@link Type#EQUAL}.
+         * @throws IllegalStateException In case when the condition is already defined.
+         */
+        public Condition eq(byte[] val) {
+            validate(type);
+
+            this.type = Type.EQUAL;
+            this.val = val;
+
+            return new Condition(this);
+        }
+
+        /**
+         * Produces the condition of type {@link Type#NOT_EQUAL}. This condition tests the given мфдгу on inequality
+         * with target entry мфдгу.

Review comment:
       Thx!




-- 
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r599997221



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A list of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndRemoveAll(@NotNull Collection<byte[]> key);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull byte[] key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull byte[] key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(byte[], byte[], long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@Nullable byte[] keyFrom, @Nullable byte[] keyTo,

Review comment:
       @agoncharuk 
   
   > Or we should properly handle future.cancel() call, but this will be harder to handle from the outside because the external code should either work with future, or with watch ID.
   
   Agree. I think we can postpone final solution to the implementation. Both approaches have disadvantages. In this situation I can't foresee all possible problems. 
   
   




-- 
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592466139



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);

Review comment:
       @Berkof `Entry` has additional properties which could be useful for an user. But may be it is good idea to return `Map<byte[] /* key */, Entry>` because it will simplify result processing.




----------------------------------------------------------------
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r603675952



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/OperationTimeoutException.java
##########
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+/**
+ * Thrown when an operation is not executed within a specified time period. Usually in such cases the operation
+ * should be retried.
+ */
+public class OperationTimeoutException extends RuntimeException {

Review comment:
       It is definitely different exceptions.
   
   `java.util.concurrent.TimeoutException` will be thrown on timed waiting on, for example, `future.get(timeout)` operation, while this `timeout` is not related with service timeout yet.




-- 
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592484781



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/Operation.java
##########
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+/**
+ * Defines operation for meta storage conditional update (invoke).
+ */
+public final class Operation {
+    /** Actual operation implementation. */
+    @SuppressWarnings({"FieldCanBeLocal", "unused"})
+    private final InnerOp upd;
+
+    /**
+     * Constructs an operation which wraps the actual operation implementation.
+     *
+     * @param upd The actual operation implementation.
+     */
+    Operation(InnerOp upd) {
+        this.upd = upd;
+    }
+
+    /**
+     * Represents operation of type <i>remove</i>.
+     */
+    public static final class RemoveOp implements InnerOp {

Review comment:
       It is good idea for `NoOp`. `RemoveOp` will requires key after IGNITE-14269. But work is still in progress so I'll take it into account. Thx!




----------------------------------------------------------------
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



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592412162



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/Condition.java
##########
@@ -0,0 +1,357 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+import java.util.Arrays;
+
+/**
+ * Represents a condition for conditional update.
+ */
+public final class Condition {
+    /** Actual condition implementation. */
+    private final InnerCondition cond;
+
+    /**
+     * Constructs a condition which wraps the actual condition implementation.
+     *
+     * @param cond The actual condition implementation.
+     */
+    Condition(InnerCondition cond) {
+        this.cond = cond;
+    }
+
+    /**
+     * Tests the given entry on satisfaction of the condition.
+     *
+     * @param e Entry.
+     * @return The result of condition test. {@code true} - if the entry satisfies to the condition,
+     * otherwise - {@code false}.
+     */
+    public boolean test(Entry e) {
+        return cond.test(e);
+    }
+
+    /**
+     * Represents condition on entry revision. Only one type of condition could be applied to
+     * the one instance of condition. Subsequent invocations of any method which produces condition will throw
+     * {@link IllegalStateException}.
+     */
+    public static final class RevisionCondition implements InnerCondition {
+        /**
+         * The type of condition.
+         *
+         * @see Type
+         */
+        private Type type;
+
+        /**
+         * The revision as the condition argument.
+         */
+        private long rev;
+
+        /**
+         * Default no-op constructor.
+         */
+        RevisionCondition() {
+            // No-op.
+        }
+
+        // TODO: eq, ne, lt, le, gt, ge

Review comment:
       ```suggestion
   ```




----------------------------------------------------------------
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



[GitHub] [ignite-3] dgarus commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
dgarus commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r601391171



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/Entry.java
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Represents a storage unit as entry with key, value and revision, where
+ * <ul>
+ *     <li>key - an unique entry's key represented by an array of bytes. Keys are comparable in lexicographic manner.</li>
+ *     <ul>value - a data which is associated with a key and represented as an array of bytes.</ul>
+ *     <ul>revision - a number which denotes a version of whole meta storage. Each change increments the revision.</ul>
+ * </ul>
+ */
+public interface Entry {

Review comment:
       `Entry` is immutable and intentionally can't be created by a user.
   So it should be the final class instead of the interface.




-- 
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



[GitHub] [ignite-3] agoncharuk commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agoncharuk commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r595321073



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull byte[] key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> getAndRemove(@NotNull byte[] key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<byte[]> key);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A list of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndRemoveAll(@NotNull Collection<byte[]> key);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull byte[] key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull byte[] key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(byte[], byte[], long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull byte[] keyFrom, @Nullable byte[] keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<UUID> watch(@Nullable byte[] keyFrom, @Nullable byte[] keyTo,

Review comment:
       There is a time window between the moment this method returns and the moment the result future obtains a watch ID. Within this window it is impossible to cancel the watch and do the cleanup.
   Probably, we should generate the watch ID on the client side and return the ID immediately?




----------------------------------------------------------------
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



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592421334



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/Cursor.java
##########
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+/**
+ * Closeable cursor.
+ *
+ * @param <T>
+ */
+//TODO: Should be replaced by common entity from org.ignite.lang or org.ignite.core package.
+public interface Cursor<T> extends Iterable<T>, AutoCloseable {

Review comment:
       Do you mean Cursor inherits Iterator?
   
   For now, it is unclear what if one calls Cursor.iterator() twice? Will it same iterator or not?




----------------------------------------------------------------
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r592485916



##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull byte[] key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A list of entries for given keys. The order of entries in the result list corresponds to
+     * the traversal order of {@code keys} collection. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A list of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAll(Collection<byte[]> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull byte[] key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     * Size of {@code keys} and {@code values} must be the same.
+     *
+     * @param keys The list of keys. Couldn't be {@code null} or empty.
+     * @param values The list of values corresponding to the list of keys. Couldn't be {@code null} or empty.
+     * @return A list of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<List<Entry>> getAndPutAll(@NotNull List<byte[]> keys, @NotNull List<byte[]> values);

Review comment:
       Stop! :) Map isn't good idea due to `byte[]` key.




----------------------------------------------------------------
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



[GitHub] [ignite-3] asfgit closed pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #64:
URL: https://github.com/apache/ignite-3/pull/64


   


-- 
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



[GitHub] [ignite-3] alievmirza commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
alievmirza commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r603076036



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/Operation.java
##########
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+/**
+ * Defines operation for meta storage conditional update (invoke).
+ */
+public final class Operation {
+    /** Actual operation implementation. */
+    @SuppressWarnings({"FieldCanBeLocal", "unused"})
+    private final InnerOp upd;
+
+    /**
+     * Constructs an operation which wraps the actual operation implementation.
+     *
+     * @param upd The actual operation implementation.
+     */
+    Operation(InnerOp upd) {
+        this.upd = upd;
+    }
+
+    /**
+     * Represents operation of type <i>remove</i>.
+     */
+    public static final class RemoveOp implements InnerOp {
+        /**
+         * Default no-op constructor.
+         */
+        RemoveOp() {
+            // No-op.
+        }
+    }
+
+    /**
+     * Represents operation of type <i>put</i>.
+     */
+    public static final class PutOp implements InnerOp {
+        /** Value. */
+        private final byte[] val;
+
+        /**
+         * Constructs operation of type <i>put</i>.
+         *
+         * @param val The value to which the entry should be updated.
+         */
+        PutOp(byte[] val) {
+            this.val = val;
+        }
+    }
+
+    /**
+     * Represents operation of type <i>no-op</i>.
+     */
+    public static final class NoOp implements InnerOp {
+        /**
+         * Default no-op constructor.
+         */
+        NoOp() {
+            // No-op.
+        }
+    }
+
+    /**
+     * Defines operation interface.
+     */
+    private interface InnerOp {
+        // Marker interface.
+    }
+}

Review comment:
       Please add a new line 




-- 
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



[GitHub] [ignite-3] ascherbakoff commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
ascherbakoff commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r602159639



##########
File path: modules/core/src/main/java/org/apache/ignite/util/LexicographicComparator.java
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.util;
+
+import java.util.Comparator;
+
+/**
+ * Byte array lexicographic comparator.
+ */
+public class LexicographicComparator implements Comparator<byte[]> {

Review comment:
       Why do we need this class ? java.util.Arrays#compare(byte[], byte[]) method reference can be used as a comparator:
   Comparator<byte[]> cmp = Arrays::compare;

##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,349 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Key;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull Key key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull Key key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A map of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Map<Key, Entry>> getAll(Collection<Key> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A map of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Map<Key, Entry>> getAll(Collection<Key> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull Key key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull Key key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     *
+     * @param vals The map of keys and corresponding values. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull Map<Key, byte[]> vals);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     *
+     * @param vals The map of keys and corresponding values. Couldn't be {@code null} or empty.
+     * @return A map of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Map<Key, Entry>> getAndPutAll(@NotNull Map<Key, byte[]> vals);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull Key key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndRemove(@NotNull Key key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param keys The keys collection. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<Key> keys);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param keys The keys collection. Couldn't be {@code null}.
+     * @return A map of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Map<Key, Entry>> getAndRemoveAll(@NotNull Collection<Key> keys);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull Key key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull Key key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull Key keyFrom, @Nullable Key keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(Key, Key, long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull Key keyFrom, @Nullable Key keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revisions,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.

Review comment:
       TODO can be removed.

##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/OperationTimeoutException.java
##########
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+/**
+ * Thrown when an operation is not executed within a specified time period. Usually in such cases the operation
+ * should be retried.
+ */
+public class OperationTimeoutException extends RuntimeException {

Review comment:
       I suggest to get rid of this exception.
   We already have well known java.util.concurrent.TimeoutException for this purpose.

##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,349 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Key;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull Key key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull Key key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A map of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Map<Key, Entry>> getAll(Collection<Key> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A map of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Map<Key, Entry>> getAll(Collection<Key> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull Key key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull Key key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     *
+     * @param vals The map of keys and corresponding values. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull Map<Key, byte[]> vals);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     *
+     * @param vals The map of keys and corresponding values. Couldn't be {@code null} or empty.
+     * @return A map of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Map<Key, Entry>> getAndPutAll(@NotNull Map<Key, byte[]> vals);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull Key key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndRemove(@NotNull Key key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param keys The keys collection. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<Key> keys);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param keys The keys collection. Couldn't be {@code null}.
+     * @return A map of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Map<Key, Entry>> getAndRemoveAll(@NotNull Collection<Key> keys);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull Key key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull Key key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull Key keyFrom, @Nullable Key keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(Key, Key, long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull Key keyFrom, @Nullable Key keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revisions,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<IgniteUuid> watch(@Nullable Key keyFrom, @Nullable Key keyTo,
+                                  long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for the given key.
+     *
+     * @param key The target key. Couldn't be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revisions,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.

Review comment:
       TODO can be removed.

##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,349 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Key;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull Key key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull Key key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A map of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Map<Key, Entry>> getAll(Collection<Key> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A map of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Map<Key, Entry>> getAll(Collection<Key> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull Key key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull Key key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     *
+     * @param vals The map of keys and corresponding values. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull Map<Key, byte[]> vals);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     *
+     * @param vals The map of keys and corresponding values. Couldn't be {@code null} or empty.
+     * @return A map of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Map<Key, Entry>> getAndPutAll(@NotNull Map<Key, byte[]> vals);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull Key key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndRemove(@NotNull Key key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param keys The keys collection. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<Key> keys);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param keys The keys collection. Couldn't be {@code null}.
+     * @return A map of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Map<Key, Entry>> getAndRemoveAll(@NotNull Collection<Key> keys);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull Key key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull Key key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull Key keyFrom, @Nullable Key keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(Key, Key, long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull Key keyFrom, @Nullable Key keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revisions,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<IgniteUuid> watch(@Nullable Key keyFrom, @Nullable Key keyTo,
+                                  long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for the given key.
+     *
+     * @param key The target key. Couldn't be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revisions,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<IgniteUuid> watch(@NotNull Key key, long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for given keys.
+     *
+     * @param keys Collection of target keys. Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.

Review comment:
       TODO can be removed.

##########
File path: modules/metastorage-client/src/main/java/org/apache/ignite/metastorage/client/MetaStorageService.java
##########
@@ -0,0 +1,349 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.client;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.metastorage.common.CompactedException;
+import org.apache.ignite.metastorage.common.Condition;
+import org.apache.ignite.metastorage.common.Cursor;
+import org.apache.ignite.metastorage.common.Entry;
+import org.apache.ignite.metastorage.common.Key;
+import org.apache.ignite.metastorage.common.Operation;
+import org.apache.ignite.metastorage.common.OperationTimeoutException;
+import org.apache.ignite.metastorage.common.WatchListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Defines interface for access to a meta storage service.
+ */
+public interface MetaStorageService {
+    /**
+     * Retrieves an entry for the given key.
+     *
+     * @param key Key. Couldn't be {@code null}.
+     * @return An entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull Key key);
+
+    /**
+     * Retrieves an entry for the given key and the revision upper bound.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return An entry for the given key and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> get(@NotNull Key key, long revUpperBound);
+
+    /**
+     * Retrieves entries for given keys.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @return A map of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Map<Key, Entry>> getAll(Collection<Key> keys);
+
+    /**
+     * Retrieves entries for given keys and the revision upper bound.
+     *
+     * @param keys The collection of keys. Couldn't be {@code null} or empty.
+     *             Collection elements couldn't be {@code null}.
+     * @param revUpperBound  The upper bound for entry revisions. Must be positive.
+     * @return A map of entries for given keys and maximum revision limited by {@code revUpperBound}.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Map<Key, Entry>> getAll(Collection<Key> keys, long revUpperBound);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> put(@NotNull Key key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates an entry with the given key and the given value and
+     * retrieves a previous entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param value The value.Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndPut(@NotNull Key key, @NotNull byte[] value);
+
+    /**
+     * Inserts or updates entries with given keys and given values.
+     *
+     * @param vals The map of keys and corresponding values. Couldn't be {@code null} or empty.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> putAll(@NotNull Map<Key, byte[]> vals);
+
+    /**
+     * Inserts or updates entries with given keys and given values and
+     * retrieves a previous entries for given keys.
+     *
+     * @param vals The map of keys and corresponding values. Couldn't be {@code null} or empty.
+     * @return A map of entries for given keys. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Map<Key, Entry>> getAndPutAll(@NotNull Map<Key, byte[]> vals);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> remove(@NotNull Key key);
+
+    /**
+     * Removes an entry for the given key.
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @return A previous entry for the given key. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Entry> getAndRemove(@NotNull Key key);
+
+    /**
+     * Removes entries for given keys.
+     *
+     * @param keys The keys collection. Couldn't be {@code null}.
+     * @return Completed future.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Void> removeAll(@NotNull Collection<Key> keys);
+
+    /**
+     * Removes entries for given keys and retrieves previous entries.
+     *
+     * @param keys The keys collection. Couldn't be {@code null}.
+     * @return A map of previous entries for given keys..
+     * The order of entries in the result list corresponds to the traversal order of {@code keys} collection.
+     * Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    CompletableFuture<Map<Key, Entry>> getAndRemoveAll(@NotNull Collection<Key> keys);
+
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return Future result {@code true} if {@code success} update was applied, otherwise {@code false}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Boolean> invoke(@NotNull Key key, @NotNull Condition condition,
+                                      @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Updates an entry for the given key conditionally.
+     *
+     * <p>Conditional update could be treated as <i>if(condition)-then(success)-else(failure)</i> expression.</p>
+     *
+     * @param key The key. Couldn't be {@code null}.
+     * @param condition The condition.
+     * @param success The update which will be applied in case of condition evaluation yields {@code true}.
+     * @param failure The update which will be applied in case of condition evaluation yields {@code false}.
+     * @return A previous entry for the given key.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     * @see Condition
+     * @see Operation
+     */
+    //TODO: https://issues.apache.org/jira/browse/IGNITE-14269: will be replaced by conditional multi update.
+    @NotNull
+    CompletableFuture<Entry> getAndInvoke(@NotNull Key key, @NotNull Condition condition,
+                                          @NotNull Operation success, @NotNull Operation failure);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Entries will be filtered out by upper bound
+     * of given revision number.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revUpperBound  The upper bound for entry revision. {@code -1} means latest revision.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull Key keyFrom, @Nullable Key keyTo, long revUpperBound);
+
+    /**
+     * Retrieves entries for the given key range in lexicographic order. Short cut for
+     * {@link #range(Key, Key, long)} where {@code revUpperBound == -1}.
+     *
+     * @param keyFrom Start key of range (inclusive). Couldn't be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @return Cursor built upon entries corresponding to the given range and revision.
+     * @throws OperationTimeoutException If the operation is timed out.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    Cursor<Entry> range(@NotNull Key keyFrom, @Nullable Key keyTo);
+
+    /**
+     * Subscribes on meta storage updates matching the parameters.
+     *
+     * @param keyFrom Start key of range (inclusive). Could be {@code null}.
+     * @param keyTo End key of range (exclusive). Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revisions,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<IgniteUuid> watch(@Nullable Key keyFrom, @Nullable Key keyTo,
+                                  long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for the given key.
+     *
+     * @param key The target key. Couldn't be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revisions,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<IgniteUuid> watch(@NotNull Key key, long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Subscribes on meta storage updates for given keys.
+     *
+     * @param keys Collection of target keys. Could be {@code null}.
+     * @param revision Start revision inclusive. {@code 0} - all revision,
+     * {@code -1} - latest revision (accordingly to current meta storage state).
+     * @param lsnr Listener which will be notified for each update.
+     * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     * @throws CompactedException If the desired revisions are removed from the storage due to a compaction.
+     * Will be thrown on getting future result.
+     * @see Key
+     * @see Entry
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.
+    CompletableFuture<IgniteUuid> watch(@NotNull Collection<Key> keys, long revision, @NotNull WatchListener lsnr);
+
+    /**
+     * Cancels subscription for the given identifier.
+     *
+     * @param id Subscription identifier.
+     * @return Completed future in case of operation success. Couldn't be {@code null}.
+     * @throws OperationTimeoutException If the operation is timed out. Will be thrown on getting future result.
+     */
+    @NotNull
+    //TODO: UUID Should be replaced by IgniteUUID when it will be introduced.

Review comment:
       TODO can be removed.




-- 
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



[GitHub] [ignite-3] agura commented on a change in pull request #64: IGNITE-14198 Meta storage client interface

Posted by GitBox <gi...@apache.org>.
agura commented on a change in pull request #64:
URL: https://github.com/apache/ignite-3/pull/64#discussion_r601851072



##########
File path: modules/metastorage-common/src/main/java/org/apache/ignite/metastorage/common/Entry.java
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.metastorage.common;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Represents a storage unit as entry with key, value and revision, where
+ * <ul>
+ *     <li>key - an unique entry's key represented by an array of bytes. Keys are comparable in lexicographic manner.</li>
+ *     <ul>value - a data which is associated with a key and represented as an array of bytes.</ul>
+ *     <ul>revision - a number which denotes a version of whole meta storage. Each change increments the revision.</ul>
+ * </ul>
+ */
+public interface Entry {

Review comment:
       @dgarus
   
   See original JIRA issue where intention is explained. So main goal is provide interfaces. Implementation will take into account all this moments.




-- 
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