You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sk...@apache.org on 2021/06/15 09:04:14 UTC
[ignite-3] branch main updated: IGNITE-14709 Changed readAll in
DistributedConfigurationStorage to take configuration keys stored in the
vault. Fixes #160
This is an automated email from the ASF dual-hosted git repository.
sk0x50 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new 3cd6981 IGNITE-14709 Changed readAll in DistributedConfigurationStorage to take configuration keys stored in the vault. Fixes #160
3cd6981 is described below
commit 3cd69819ae5c02d4cc73d18bbeb06f5c068f06f7
Author: Mirza Aliev <al...@gmail.com>
AuthorDate: Tue Jun 15 12:03:36 2021 +0300
IGNITE-14709 Changed readAll in DistributedConfigurationStorage to take configuration keys stored in the vault. Fixes #160
Signed-off-by: Slava Koptilin <sl...@gmail.com>
---
.../org/apache/ignite/internal/manager/Event.java | 2 +-
.../org/apache/ignite/internal/util/ByteUtils.java | 11 ++
.../internal/metastorage/MetaStorageManager.java | 54 +++++++-
.../ignite/internal/runner/app/IgnitionTest.java | 2 -
.../apache/ignite/internal/app/IgnitionImpl.java | 10 +-
.../storage/DistributedConfigurationStorage.java | 69 +++++-----
.../internal/table/distributed/TableManager.java | 2 +-
.../apache/ignite/internal/vault/VaultManager.java | 74 +++-------
.../internal/vault/common/VaultListener.java | 43 ------
.../ignite/internal/vault/common/VaultWatch.java | 85 ------------
.../ignite/internal/vault/common/Watcher.java | 50 -------
.../ignite/internal/vault/common/WatcherImpl.java | 151 ---------------------
.../internal/vault/impl/VaultServiceImpl.java | 25 ----
.../internal/vault/service/VaultService.java | 17 ---
.../vault/impl/VaultBaseContractsTest.java | 99 ++++++--------
15 files changed, 159 insertions(+), 535 deletions(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/manager/Event.java b/modules/core/src/main/java/org/apache/ignite/internal/manager/Event.java
index 39d0bbf..4c37586 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/manager/Event.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/manager/Event.java
@@ -18,7 +18,7 @@
package org.apache.ignite.internal.manager;
/**
- * The event cas whcih is produced by event producer component.
+ * The event cas which is produced by event producer component.
* @see Producer#onEvent(Event, EventParameters, Throwable)
*/
public interface Event {
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/ByteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/ByteUtils.java
index aefd419..6412df4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/ByteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/ByteUtils.java
@@ -57,6 +57,17 @@ public class ByteUtils {
}
/**
+ * Constructs {@code long} from byte array with offset equals 0.
+ *
+ * @see #bytesToLong(byte[], int)
+ * @param bytes Array of bytes.
+ * @return Long value.
+ */
+ public static long bytesToLong(byte[] bytes) {
+ return bytesToLong(bytes, 0);
+ }
+
+ /**
* Converts primitive {@code long} type to byte array.
*
* @param l Long value.
diff --git a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/MetaStorageManager.java b/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/MetaStorageManager.java
index ff0d3c8..5a2d789 100644
--- a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/MetaStorageManager.java
+++ b/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/MetaStorageManager.java
@@ -43,6 +43,7 @@ import org.apache.ignite.internal.metastorage.watch.AggregatedWatch;
import org.apache.ignite.internal.metastorage.watch.KeyCriterion;
import org.apache.ignite.internal.metastorage.watch.WatchAggregator;
import org.apache.ignite.internal.raft.Loza;
+import org.apache.ignite.internal.util.ByteUtils;
import org.apache.ignite.internal.util.Cursor;
import org.apache.ignite.internal.vault.VaultManager;
import org.apache.ignite.lang.ByteArray;
@@ -69,6 +70,15 @@ public class MetaStorageManager {
/** Meta storage raft group name. */
private static final String METASTORAGE_RAFT_GROUP_NAME = "metastorage_raft_group";
+ /** Prefix added to configuration keys to distinguish them in the meta storage. Must end with a dot. */
+ public static final String DISTRIBUTED_PREFIX = "dst-cfg.";
+
+ /**
+ * Special key for the vault where the applied revision for {@link MetaStorageManager#storeEntries(Collection, long)}
+ * operation is stored. This mechanism is needed for committing processed watches to {@link VaultManager}.
+ */
+ public static final ByteArray APPLIED_REV = ByteArray.fromString(DISTRIBUTED_PREFIX + "applied_revision");
+
/** Vault manager in order to commit processed watches with corresponding applied revision. */
private final VaultManager vaultMgr;
@@ -103,6 +113,9 @@ public class MetaStorageManager {
*/
private boolean deployed;
+ /** Flag indicates if meta storage nodes were set on start */
+ private boolean metaStorageNodesOnStart;
+
/**
* The constructor.
*
@@ -129,6 +142,8 @@ public class MetaStorageManager {
clusterNode -> Arrays.asList(metastorageNodes).contains(clusterNode.name());
if (metastorageNodes.length > 0) {
+ metaStorageNodesOnStart = true;
+
this.metaStorageSvcFut = CompletableFuture.completedFuture(new MetaStorageServiceImpl(
raftMgr.startRaftGroup(
METASTORAGE_RAFT_GROUP_NAME,
@@ -161,14 +176,22 @@ public class MetaStorageManager {
public synchronized void deployWatches() {
try {
var watch = watchAggregator.watch(
- vaultMgr.appliedRevision() + 1,
+ appliedRevision() + 1,
this::storeEntries
);
if (watch.isEmpty())
deployFut.complete(Optional.empty());
- else
- dispatchAppropriateMetaStorageWatch(watch.get()).thenAccept(id -> deployFut.complete(Optional.of(id))).join();
+ else {
+ CompletableFuture<Void> fut =
+ dispatchAppropriateMetaStorageWatch(watch.get()).thenAccept(id -> deployFut.complete(Optional.of(id)));
+
+ if (metaStorageNodesOnStart)
+ fut.join();
+ else {
+ // TODO: need to wait for this future in init phase https://issues.apache.org/jira/browse/IGNITE-14414
+ }
+ }
}
catch (IgniteInternalCheckedException e) {
throw new IgniteInternalException("Couldn't receive applied revision during deploy watches", e);
@@ -388,7 +411,7 @@ public class MetaStorageManager {
metaStorageSvcFut,
metaStorageSvcFut.thenApply(svc -> {
try {
- return svc.range(keyFrom, keyTo, vaultMgr.appliedRevision());
+ return svc.range(keyFrom, keyTo, appliedRevision());
}
catch (IgniteInternalCheckedException e) {
throw new IgniteInternalException(e);
@@ -415,14 +438,31 @@ public class MetaStorageManager {
}
/**
+ * @return Applied revision for {@link VaultManager#putAll(Map, ByteArray, long)} operation.
+ * @throws IgniteInternalCheckedException If couldn't get applied revision from vault.
+ */
+ private long appliedRevision() throws IgniteInternalCheckedException {
+ byte[] appliedRevision;
+
+ try {
+ appliedRevision = vaultMgr.get(APPLIED_REV).get().value();
+ }
+ catch (InterruptedException | ExecutionException e) {
+ throw new IgniteInternalCheckedException("Error occurred when getting applied revision", e);
+ }
+
+ return appliedRevision == null ? 0L : ByteUtils.bytesToLong(appliedRevision);
+ }
+
+ /**
* Stop current batch of consolidated watches and register new one from current {@link WatchAggregator}.
*
* @return Ignite UUID of new consolidated watch.
*/
private CompletableFuture<Optional<IgniteUuid>> updateWatches() {
- Long revision;
+ long revision;
try {
- revision = vaultMgr.appliedRevision() + 1;
+ revision = appliedRevision() + 1;
}
catch (IgniteInternalCheckedException e) {
throw new IgniteInternalException("Couldn't receive applied revision during watch redeploy", e);
@@ -455,7 +495,7 @@ public class MetaStorageManager {
private CompletableFuture<Void> storeEntries(Collection<IgniteBiTuple<ByteArray, byte[]>> entries, long revision) {
try {
return vaultMgr.putAll(entries.stream().collect(
- Collectors.toMap(e -> e.getKey(), IgniteBiTuple::getValue)), revision);
+ Collectors.toMap(IgniteBiTuple::getKey, IgniteBiTuple::getValue)), APPLIED_REV, revision);
}
catch (IgniteInternalCheckedException e) {
throw new IgniteInternalException("Couldn't put entries with considered revision.", e);
diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/IgnitionTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/IgnitionTest.java
index e5a25a8..113ada5 100644
--- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/IgnitionTest.java
+++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/IgnitionTest.java
@@ -24,7 +24,6 @@ import java.util.Map;
import org.apache.ignite.app.Ignite;
import org.apache.ignite.app.IgnitionManager;
import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
@@ -83,7 +82,6 @@ class IgnitionTest {
* Check that Ignition.start() with bootstrap configuration returns Ignite instance.
*/
@Test
- @Disabled("https://issues.apache.org/jira/browse/IGNITE-14709")
void testNodeStartWithoutBootstrapConfiguration() {
Ignite ignite = IgnitionManager.start("node0", null);
diff --git a/modules/runner/src/main/java/org/apache/ignite/internal/app/IgnitionImpl.java b/modules/runner/src/main/java/org/apache/ignite/internal/app/IgnitionImpl.java
index fbf8f37..7ac6120 100644
--- a/modules/runner/src/main/java/org/apache/ignite/internal/app/IgnitionImpl.java
+++ b/modules/runner/src/main/java/org/apache/ignite/internal/app/IgnitionImpl.java
@@ -17,11 +17,11 @@
package org.apache.ignite.internal.app;
+import io.netty.util.internal.StringUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import io.netty.util.internal.StringUtil;
import org.apache.ignite.app.Ignite;
import org.apache.ignite.app.Ignition;
import org.apache.ignite.configuration.RootKey;
@@ -100,11 +100,11 @@ public class IgnitionImpl implements Ignition {
TablesConfiguration.KEY
);
- List<ConfigurationStorage> configurationStorages =
+ List<ConfigurationStorage> cfgStorages =
new ArrayList<>(Collections.singletonList(new LocalConfigurationStorage(vaultMgr)));
// Bootstrap local configuration manager.
- ConfigurationManager locConfigurationMgr = new ConfigurationManager(rootKeys, configurationStorages);
+ ConfigurationManager locConfigurationMgr = new ConfigurationManager(rootKeys, cfgStorages);
if (!cfgBootstrappedFromPds && jsonStrBootstrapCfg != null)
try {
@@ -147,10 +147,10 @@ public class IgnitionImpl implements Ignition {
);
// TODO IGNITE-14578 Bootstrap configuration manager with distributed configuration.
- configurationStorages.add(new DistributedConfigurationStorage(metaStorageMgr));
+ cfgStorages.add(new DistributedConfigurationStorage(metaStorageMgr, vaultMgr));
// Start configuration manager.
- ConfigurationManager configurationMgr = new ConfigurationManager(rootKeys, configurationStorages);
+ ConfigurationManager configurationMgr = new ConfigurationManager(rootKeys, cfgStorages);
// Baseline manager startup.
BaselineManager baselineMgr = new BaselineManager(configurationMgr, metaStorageMgr, clusterNetSvc);
diff --git a/modules/runner/src/main/java/org/apache/ignite/internal/storage/DistributedConfigurationStorage.java b/modules/runner/src/main/java/org/apache/ignite/internal/storage/DistributedConfigurationStorage.java
index d19057d..fd2c286 100644
--- a/modules/runner/src/main/java/org/apache/ignite/internal/storage/DistributedConfigurationStorage.java
+++ b/modules/runner/src/main/java/org/apache/ignite/internal/storage/DistributedConfigurationStorage.java
@@ -23,6 +23,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.ignite.configuration.storage.ConfigurationStorage;
@@ -31,10 +32,6 @@ import org.apache.ignite.configuration.storage.ConfigurationType;
import org.apache.ignite.configuration.storage.Data;
import org.apache.ignite.configuration.storage.StorageException;
import org.apache.ignite.internal.metastorage.MetaStorageManager;
-import org.apache.ignite.internal.util.ByteUtils;
-import org.apache.ignite.internal.util.Cursor;
-import org.apache.ignite.lang.ByteArray;
-import org.apache.ignite.lang.IgniteLogger;
import org.apache.ignite.internal.metastorage.client.Conditions;
import org.apache.ignite.internal.metastorage.client.Entry;
import org.apache.ignite.internal.metastorage.client.EntryEvent;
@@ -42,15 +39,18 @@ import org.apache.ignite.internal.metastorage.client.Operation;
import org.apache.ignite.internal.metastorage.client.Operations;
import org.apache.ignite.internal.metastorage.client.WatchEvent;
import org.apache.ignite.internal.metastorage.client.WatchListener;
+import org.apache.ignite.internal.util.ByteUtils;
+import org.apache.ignite.internal.vault.VaultManager;
+import org.apache.ignite.lang.ByteArray;
+import org.apache.ignite.lang.IgniteLogger;
import org.jetbrains.annotations.NotNull;
+import static org.apache.ignite.internal.metastorage.MetaStorageManager.DISTRIBUTED_PREFIX;
+
/**
* Distributed configuration storage.
*/
public class DistributedConfigurationStorage implements ConfigurationStorage {
- /** Prefix that we add to configuration keys to distinguish them in meta storage. Must end with dot. */
- private static final String DISTRIBUTED_PREFIX = "dst-cfg.";
-
/** Logger. */
private static final IgniteLogger LOG = IgniteLogger.forClass(DistributedConfigurationStorage.class);
@@ -63,14 +63,17 @@ public class DistributedConfigurationStorage implements ConfigurationStorage {
/**
* This key is expected to be the last key in lexicographical order of distributed configuration keys. It is
* possible because keys are in lexicographical order in meta storage and adding {@code (char)('.' + 1)} to the end
- * will produce all keys with prefix {@link DistributedConfigurationStorage#DISTRIBUTED_PREFIX}
+ * will produce all keys with prefix {@link MetaStorageManager#DISTRIBUTED_PREFIX}
*/
private static final ByteArray DST_KEYS_END_RANGE =
new ByteArray(DISTRIBUTED_PREFIX.substring(0, DISTRIBUTED_PREFIX.length() - 1) + (char)('.' + 1));
- /** MetaStorage manager */
+ /** Meta storage manager. */
private final MetaStorageManager metaStorageMgr;
+ /** Vault manager. */
+ private final VaultManager vaultMgr;
+
/** Configuration changes listener. */
private ConfigurationStorageListener lsnr;
@@ -80,45 +83,45 @@ public class DistributedConfigurationStorage implements ConfigurationStorage {
/**
* Constructor.
*
- * @param metaStorageMgr MetaStorage Manager.
+ * @param metaStorageMgr Meta storage manager.
+ * @param vaultMgr Vault manager.
*/
- public DistributedConfigurationStorage(MetaStorageManager metaStorageMgr) {
+ public DistributedConfigurationStorage(MetaStorageManager metaStorageMgr, VaultManager vaultMgr) {
this.metaStorageMgr = metaStorageMgr;
+
+ this.vaultMgr = vaultMgr;
}
/** {@inheritDoc} */
@Override public synchronized Data readAll() throws StorageException {
HashMap<String, Serializable> data = new HashMap<>();
- Iterator<Entry> entries = allDistributedConfigKeys().iterator();
+ Iterator<org.apache.ignite.internal.vault.common.Entry> entries = storedDistributedConfigKeys();
- long maxRevision = 0L;
+ long appliedRevision = 0L;
if (!entries.hasNext())
return new Data(data, ver.get());
- Entry entryForMasterKey = entries.next();
-
- // First key must be the masterKey because it's supposed to be the first in lexicographical order
- assert entryForMasterKey.key().equals(MASTER_KEY);
-
while (entries.hasNext()) {
- Entry entry = entries.next();
+ var entry = entries.next();
- data.put(entry.key().toString().substring((DISTRIBUTED_PREFIX).length()), (Serializable)ByteUtils.fromBytes(entry.value()));
+ if (entry.key().equals(MetaStorageManager.APPLIED_REV)) {
+ appliedRevision = ByteUtils.bytesToLong(Objects.requireNonNull(entry.value()));
- // Move to stream
- if (maxRevision < entry.revision())
- maxRevision = entry.revision();
+ continue;
+ }
+ data.put(entry.key().toString().substring((DISTRIBUTED_PREFIX).length()), (Serializable)ByteUtils.fromBytes(entry.value()));
}
if (!data.isEmpty()) {
- assert maxRevision == entryForMasterKey.revision();
+ assert appliedRevision > 0;
- assert maxRevision >= ver.get();
+ assert appliedRevision >= ver.get() : "Applied revision cannot be less than storage version " +
+ "that is applied to configuration manager.";
- return new Data(data, maxRevision);
+ return new Data(data, appliedRevision);
}
return new Data(data, ver.get());
@@ -235,17 +238,17 @@ public class DistributedConfigurationStorage implements ConfigurationStorage {
}
/**
- * Method that returns all distributed configuration keys from meta storage filtered out by the current applied
- * revision as an upper bound. Applied revision is a revision of the last successful vault update.
+ * Method that returns all distributed configuration keys from the meta storage that were stored in the vault filtered out by the
+ * current applied revision as an upper bound. Applied revision is a revision of the last successful vault update.
* <p>
- * This is possible to distinguish cfg keys from meta storage because we add special prefix {@link
- * DistributedConfigurationStorage#DISTRIBUTED_PREFIX} to all configuration keys that we put to meta storage.
+ * This is possible to distinguish cfg keys from meta storage because we add a special prefix {@link
+ * MetaStorageManager#DISTRIBUTED_PREFIX} to all configuration keys that we put to the meta storage.
*
- * @return Cursor built upon all distributed configuration entries.
+ * @return Iterator built upon all distributed configuration entries stored in vault.
*/
- private Cursor<Entry> allDistributedConfigKeys() {
+ private @NotNull Iterator<org.apache.ignite.internal.vault.common.Entry> storedDistributedConfigKeys() {
// TODO: rangeWithAppliedRevision could throw OperationTimeoutException and CompactedException and we should
// TODO: properly handle such cases https://issues.apache.org/jira/browse/IGNITE-14604
- return metaStorageMgr.rangeWithAppliedRevision(MASTER_KEY, DST_KEYS_END_RANGE);
+ return vaultMgr.range(MASTER_KEY, DST_KEYS_END_RANGE);
}
}
diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
index a26873d..eeb29c4 100644
--- a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
+++ b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
@@ -185,7 +185,7 @@ public class TableManager extends Producer<TableEvent, TableEventParameters> imp
* Compounds a RAFT group unique name.
*
* @param tableId Table identifier.
- * @param partition Muber of table partition.
+ * @param partition Number of table partitions.
* @return A RAFT group name.
*/
@NotNull private String raftGroupName(UUID tableId, int partition) {
diff --git a/modules/vault/src/main/java/org/apache/ignite/internal/vault/VaultManager.java b/modules/vault/src/main/java/org/apache/ignite/internal/vault/VaultManager.java
index 2686772..fbeb7cc 100644
--- a/modules/vault/src/main/java/org/apache/ignite/internal/vault/VaultManager.java
+++ b/modules/vault/src/main/java/org/apache/ignite/internal/vault/VaultManager.java
@@ -25,7 +25,6 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import org.apache.ignite.internal.util.ByteUtils;
import org.apache.ignite.internal.vault.common.Entry;
-import org.apache.ignite.internal.vault.common.VaultWatch;
import org.apache.ignite.internal.vault.service.VaultService;
import org.apache.ignite.lang.ByteArray;
import org.apache.ignite.lang.IgniteInternalCheckedException;
@@ -37,9 +36,6 @@ import org.jetbrains.annotations.Nullable;
* and providing interface for managing local keys.
*/
public class VaultManager {
- /** Special key for vault where applied revision for {@code putAll} operation is stored. */
- private static ByteArray APPLIED_REV = ByteArray.fromString("applied_revision");
-
/** Special key, which reserved for storing the name of the current node. */
private static final ByteArray NODE_NAME = ByteArray.fromString("node_name");
@@ -47,14 +43,14 @@ public class VaultManager {
private final Object mux = new Object();
/** Instance of vault */
- private VaultService vaultService;
+ private VaultService vaultSvc;
/** Default constructor.
*
- * @param vaultService Instance of vault.
+ * @param vaultSvc Instance of vault.
*/
- public VaultManager(VaultService vaultService) {
- this.vaultService = vaultService;
+ public VaultManager(VaultService vaultSvc) {
+ this.vaultSvc = vaultSvc;
}
/**
@@ -75,7 +71,7 @@ public class VaultManager {
* then {@code Entry} with value that equals to {@code null} will be returned.
*/
@NotNull public CompletableFuture<Entry> get(@NotNull ByteArray key) {
- return vaultService.get(key);
+ return vaultSvc.get(key);
}
/**
@@ -86,7 +82,7 @@ public class VaultManager {
* @return Future representing pending completion of the operation. Couldn't be {@code null}.
*/
@NotNull public CompletableFuture<Void> put(@NotNull ByteArray key, @NotNull byte[] val) {
- return vaultService.put(key, val);
+ return vaultSvc.put(key, val);
}
/**
@@ -96,7 +92,7 @@ public class VaultManager {
* @return Future representing pending completion of the operation. Couldn't be {@code null}.
*/
@NotNull public CompletableFuture<Void> remove(@NotNull ByteArray key) {
- return vaultService.remove(key);
+ return vaultSvc.remove(key);
}
/**
@@ -107,7 +103,7 @@ public class VaultManager {
* @return Iterator built upon entries corresponding to the given range.
*/
@NotNull public Iterator<Entry> range(@NotNull ByteArray fromKey, @NotNull ByteArray toKey) {
- return vaultService.range(fromKey, toKey);
+ return vaultSvc.range(fromKey, toKey);
}
/**
@@ -119,7 +115,7 @@ public class VaultManager {
*/
@NotNull public CompletableFuture<Void> putAll(@NotNull Map<ByteArray, byte[]> vals) {
synchronized (mux) {
- return vaultService.putAll(vals);
+ return vaultSvc.putAll(vals);
}
}
@@ -133,46 +129,27 @@ public class VaultManager {
* @throws IgniteInternalCheckedException If revision is inconsistent with applied revision from vault or if
* couldn't get applied revision from vault.
*/
- public CompletableFuture<Void> putAll(@NotNull Map<ByteArray, byte[]> vals, long revision) throws IgniteInternalCheckedException {
+ public CompletableFuture<Void> putAll(@NotNull Map<ByteArray, byte[]> vals, ByteArray appliedRevKey, long revision) throws IgniteInternalCheckedException {
synchronized (mux) {
byte[] appliedRevBytes;
try {
- appliedRevBytes = vaultService.get(APPLIED_REV).get().value();
+ appliedRevBytes = vaultSvc.get(appliedRevKey).get().value();
}
catch (InterruptedException | ExecutionException e) {
throw new IgniteInternalCheckedException("Error occurred when getting applied revision", e);
}
- long appliedRevision = appliedRevBytes != null ? ByteUtils.bytesToLong(appliedRevBytes, 0) : 0L;
+ long appliedRevision = appliedRevBytes != null ? ByteUtils.bytesToLong(appliedRevBytes) : 0L;
if (revision < appliedRevision)
throw new IgniteInternalCheckedException("Inconsistency between applied revision from vault and the current revision");
HashMap<ByteArray, byte[]> mergedMap = new HashMap<>(vals);
- mergedMap.put(APPLIED_REV, ByteUtils.longToBytes(revision));
-
- return vaultService.putAll(mergedMap);
- }
- }
-
- /**
- * @return Applied revision for {@link VaultManager#putAll(Map, long)} operation.
- * @throws IgniteInternalCheckedException If couldn't get applied revision from vault.
- */
- @NotNull public Long appliedRevision() throws IgniteInternalCheckedException {
- byte[] appliedRevision;
-
- synchronized (mux) {
- try {
- appliedRevision = vaultService.get(APPLIED_REV).get().value();
- }
- catch (InterruptedException | ExecutionException e) {
- throw new IgniteInternalCheckedException("Error occurred when getting applied revision", e);
- }
+ mergedMap.put(appliedRevKey, ByteUtils.longToBytes(revision));
- return appliedRevision == null ? 0L : ByteUtils.bytesToLong(appliedRevision, 0);
+ return vaultSvc.putAll(mergedMap);
}
}
@@ -193,7 +170,8 @@ public class VaultManager {
@Nullable public String name() throws IgniteInternalCheckedException {
synchronized (mux) {
try {
- byte[] nodeName = vaultService.get(NODE_NAME).get().value();
+ byte[] nodeName = vaultSvc.get(NODE_NAME).get().value();
+
if (nodeName != null)
return new String(nodeName, StandardCharsets.UTF_8);
else
@@ -204,24 +182,4 @@ public class VaultManager {
}
}
}
-
- /**
- * See {@link VaultService#watch(VaultWatch)}
- *
- * @param vaultWatch Watch which will notify for each update.
- * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
- */
- @NotNull public CompletableFuture<Long> watch(@NotNull VaultWatch vaultWatch) {
- return vaultService.watch(vaultWatch);
- }
-
- /**
- * See {@link VaultService#stopWatch(Long)}
- *
- * @param id Subscription identifier.
- * @return Completed future in case of operation success. Couldn't be {@code null}.
- */
- @NotNull public CompletableFuture<Void> stopWatch(@NotNull Long id) {
- return vaultService.stopWatch(id);
- }
}
diff --git a/modules/vault/src/main/java/org/apache/ignite/internal/vault/common/VaultListener.java b/modules/vault/src/main/java/org/apache/ignite/internal/vault/common/VaultListener.java
deleted file mode 100644
index 1938a9e..0000000
--- a/modules/vault/src/main/java/org/apache/ignite/internal/vault/common/VaultListener.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.internal.vault.common;
-
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Vault storage listener for changes.
- */
-//TODO: need to generify with metastorage WatchListener https://issues.apache.org/jira/browse/IGNITE-14653
-public interface VaultListener {
- /**
- * The method will be called on each vault update.
- *
- * @param entries A single entry or a 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<Entry> entries);
-
- /**
- * The method will be called in case of an error occurred. The listener and corresponding watch will be
- * unregistered.
- *
- * @param e Exception.
- */
- void onError(@NotNull Throwable e);
-}
diff --git a/modules/vault/src/main/java/org/apache/ignite/internal/vault/common/VaultWatch.java b/modules/vault/src/main/java/org/apache/ignite/internal/vault/common/VaultWatch.java
deleted file mode 100644
index 51b2ca8..0000000
--- a/modules/vault/src/main/java/org/apache/ignite/internal/vault/common/VaultWatch.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.internal.vault.common;
-
-import java.util.Collections;
-import java.util.Comparator;
-import org.apache.ignite.lang.ByteArray;
-
-/**
- * Watch for vault entries.
- * Could be specified by range of keys.
- * If value of key in range is changed, then corresponding listener will be triggered.
- */
-public final class VaultWatch {
- /** Comparator for {@code ByteArray} values. */
- private static final Comparator<ByteArray> CMP = ByteArray::compare;
-
- /**
- * Start key of range (inclusive).
- * If value of key in range is changed, then corresponding listener will be triggered.
- */
- private final ByteArray startKey;
-
- /**
- * End key of range (exclusive).
- * If value of key in range is changed, then corresponding listener will be triggered.
- */
- private final ByteArray endKey;
-
- /** Listener for vault's values updates. */
- private VaultListener listener;
-
- /**
- * @param startKey Start key of range (inclusive).
- * @param endkey End key of range (exclusive).
- * @param listener Listener.
- */
- public VaultWatch(ByteArray startKey, ByteArray endkey, VaultListener listener) {
- this.startKey = startKey;
- this.endKey = endkey;
- this.listener = listener;
- }
-
- /**
- * Notifies specified listener if {@code val} of key in range was changed.
- *
- * @param val Vault entry.
- * @return {@code True} if watch must continue event handling according to corresponding listener logic. If returns
- * {@code false} then the listener and corresponding watch will be unregistered.
- */
- public boolean notify(Entry val) {
- if (startKey != null && CMP.compare(val.key(), startKey) < 0)
- return true;
-
- if (endKey != null && CMP.compare(val.key(), endKey) >= 0)
- return true;
-
- return listener.onUpdate(Collections.singleton(val));
- }
-
- /**
- * The method will be called in case of an error occurred. The watch and corresponding listener will be
- * unregistered.
- *
- * @param e Exception.
- */
- public void onError(Throwable e) {
- listener.onError(e);
- }
-}
diff --git a/modules/vault/src/main/java/org/apache/ignite/internal/vault/common/Watcher.java b/modules/vault/src/main/java/org/apache/ignite/internal/vault/common/Watcher.java
deleted file mode 100644
index a5623c0..0000000
--- a/modules/vault/src/main/java/org/apache/ignite/internal/vault/common/Watcher.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.internal.vault.common;
-
-import java.util.concurrent.CompletableFuture;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Vault watcher.
- *
- * Watches for vault entries updates.
- */
-public interface Watcher {
- /**
- * Registers watch for vault entries updates.
- *
- * @param vaultWatch Vault watch.
- * @return Id of registered watch.
- */
- CompletableFuture<Long> register(@NotNull VaultWatch vaultWatch);
-
- /**
- * Notifies watcher that vault entry {@code val} was changed.
- *
- * @param val Vault entry.
- */
- void notify(@NotNull Entry val);
-
- /**
- * Cancels watch with specified {@code id}.
- *
- * @param id Id of watch.
- */
- void cancel(@NotNull Long id);
-}
diff --git a/modules/vault/src/main/java/org/apache/ignite/internal/vault/common/WatcherImpl.java b/modules/vault/src/main/java/org/apache/ignite/internal/vault/common/WatcherImpl.java
deleted file mode 100644
index 90187b3..0000000
--- a/modules/vault/src/main/java/org/apache/ignite/internal/vault/common/WatcherImpl.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * 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.internal.vault.common;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-import org.apache.ignite.lang.IgniteInternalCheckedException;
-import org.apache.ignite.lang.IgniteLogger;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Implementation of vault {@link Watcher}.
- */
-public class WatcherImpl implements Watcher {
- /** Logger. */
- private static final IgniteLogger LOG = IgniteLogger.forClass(WatcherImpl.class);
-
- /** Queue for changed vault entries. */
- private final BlockingQueue<Entry> queue = new LinkedBlockingQueue<>();
-
- /** Registered vault watches. */
- private final Map<Long, VaultWatch> watches = new HashMap<>();
-
- /** Flag for indicating if watcher is stopped. */
- private volatile boolean stop;
-
- /** Counter for generating ids for watches. */
- private AtomicLong watchIds;
-
- /** Mutex. */
- private final Object mux = new Object();
-
- /** Execution service which runs thread for processing changed vault entries. */
- private final ExecutorService exec;
-
- /**
- * Default constructor.
- */
- public WatcherImpl() {
- watchIds = new AtomicLong(0);
-
- exec = Executors.newFixedThreadPool(1);
-
- exec.execute(new WatcherWorker());
- }
-
- /** {@inheritDoc} */
- @Override public CompletableFuture<Long> register(@NotNull VaultWatch vaultWatch) {
- synchronized (mux) {
- Long key = watchIds.incrementAndGet();
-
- watches.put(key, vaultWatch);
-
- return CompletableFuture.completedFuture(key);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void notify(@NotNull Entry val) {
- queue.offer(val);
- }
-
- /** {@inheritDoc} */
- @Override public void cancel(@NotNull Long id) {
- synchronized (mux) {
- watches.remove(id);
- }
- }
-
- /**
- * Shutdowns watcher.
- */
- public void shutdown() {
- stop = true;
-
- if (exec != null) {
- List<Runnable> tasks = exec.shutdownNow();
-
- if (!tasks.isEmpty())
- LOG.warn("Runnable tasks outlived thread pool executor service");
-
- try {
- exec.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
- }
- catch (InterruptedException ignored) {
- LOG.warn("Got interrupted while waiting for executor service to stop.");
-
- exec.shutdownNow();
-
- // Preserve interrupt status.
- Thread.currentThread().interrupt();
- }
- }
- }
-
- /**
- * Worker that polls changed vault entries from queue and notifies registered watches.
- */
- private class WatcherWorker implements Runnable {
- /** {@inheritDoc} */
- @Override public void run() {
- while (!stop) {
- try {
- Entry val = queue.take();
-
- synchronized (mux) {
- watches.forEach((k, w) -> {
- if (!w.notify(val))
- cancel(k);
- });
- }
- }
- catch (InterruptedException interruptedException) {
- synchronized (mux) {
- watches.forEach((k, w) -> {
- w.onError(
- new IgniteInternalCheckedException(
- "Error occurred during watches handling ",
- interruptedException.getCause()));
-
- cancel(k);
- });
- }
- }
- }
- }
- }
-}
diff --git a/modules/vault/src/main/java/org/apache/ignite/internal/vault/impl/VaultServiceImpl.java b/modules/vault/src/main/java/org/apache/ignite/internal/vault/impl/VaultServiceImpl.java
index 3814d91..f5be5cb 100644
--- a/modules/vault/src/main/java/org/apache/ignite/internal/vault/impl/VaultServiceImpl.java
+++ b/modules/vault/src/main/java/org/apache/ignite/internal/vault/impl/VaultServiceImpl.java
@@ -25,8 +25,6 @@ import java.util.TreeMap;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import org.apache.ignite.internal.vault.common.Entry;
-import org.apache.ignite.internal.vault.common.VaultWatch;
-import org.apache.ignite.internal.vault.common.WatcherImpl;
import org.apache.ignite.internal.vault.service.VaultService;
import org.apache.ignite.lang.ByteArray;
import org.jetbrains.annotations.NotNull;
@@ -41,13 +39,10 @@ public class VaultServiceImpl implements VaultService {
/** Mutex. */
private final Object mux = new Object();
- private final WatcherImpl watcher;
-
/**
* Default constructor.
*/
public VaultServiceImpl() {
- this.watcher = new WatcherImpl();
this.storage = new TreeMap<>();
}
@@ -63,8 +58,6 @@ public class VaultServiceImpl implements VaultService {
synchronized (mux) {
storage.put(key, val);
- watcher.notify(new Entry(key, val));
-
return CompletableFuture.allOf();
}
}
@@ -74,8 +67,6 @@ public class VaultServiceImpl implements VaultService {
synchronized (mux) {
storage.remove(key);
- watcher.notify(new Entry(key, null));
-
return CompletableFuture.allOf();
}
}
@@ -94,22 +85,6 @@ public class VaultServiceImpl implements VaultService {
}
/** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Long> watch(@NotNull VaultWatch vaultWatch) {
- synchronized (mux) {
- return watcher.register(vaultWatch);
- }
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull CompletableFuture<Void> stopWatch(@NotNull Long id) {
- synchronized (mux) {
- watcher.cancel(id);
-
- return CompletableFuture.allOf();
- }
- }
-
- /** {@inheritDoc} */
@Override public @NotNull CompletableFuture<Void> putAll(@NotNull Map<ByteArray, byte[]> vals) {
synchronized (mux) {
vals.forEach((k, v) -> {
diff --git a/modules/vault/src/main/java/org/apache/ignite/internal/vault/service/VaultService.java b/modules/vault/src/main/java/org/apache/ignite/internal/vault/service/VaultService.java
index 45bc884..831e4f7 100644
--- a/modules/vault/src/main/java/org/apache/ignite/internal/vault/service/VaultService.java
+++ b/modules/vault/src/main/java/org/apache/ignite/internal/vault/service/VaultService.java
@@ -21,7 +21,6 @@ import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import org.apache.ignite.internal.vault.common.Entry;
-import org.apache.ignite.internal.vault.common.VaultWatch;
import org.apache.ignite.lang.ByteArray;
import org.jetbrains.annotations.NotNull;
@@ -67,22 +66,6 @@ public interface VaultService {
@NotNull Iterator<Entry> range(@NotNull ByteArray fromKey, @NotNull ByteArray toKey);
/**
- * Subscribes on vault storage updates for the given key.
- *
- * @param vaultWatch Watch which will notify for each update.
- * @return Subscription identifier. Could be used in {@link #stopWatch} method in order to cancel subscription.
- */
- @NotNull CompletableFuture<Long> watch(@NotNull VaultWatch vaultWatch);
-
- /**
- * Cancels subscription for the given identifier.
- *
- * @param id Subscription identifier.
- * @return Future representing pending completion of the operation. Couldn't be {@code null}.
- */
- @NotNull CompletableFuture<Void> stopWatch(@NotNull Long id);
-
- /**
* Inserts or updates entries with given keys and given values. If the given value in {@code vals} is null,
* then corresponding value with key will be deleted if there was any mapping.
*
diff --git a/modules/vault/src/test/java/org/apache/ignite/internal/vault/impl/VaultBaseContractsTest.java b/modules/vault/src/test/java/org/apache/ignite/internal/vault/impl/VaultBaseContractsTest.java
index 3d5aee8..d753e0a 100644
--- a/modules/vault/src/test/java/org/apache/ignite/internal/vault/impl/VaultBaseContractsTest.java
+++ b/modules/vault/src/test/java/org/apache/ignite/internal/vault/impl/VaultBaseContractsTest.java
@@ -22,16 +22,12 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
+import org.apache.ignite.internal.util.ByteUtils;
import org.apache.ignite.internal.vault.VaultManager;
import org.apache.ignite.internal.vault.common.Entry;
-import org.apache.ignite.internal.vault.common.VaultListener;
-import org.apache.ignite.internal.vault.common.VaultWatch;
import org.apache.ignite.lang.ByteArray;
import org.apache.ignite.lang.IgniteInternalCheckedException;
-import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -39,21 +35,20 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test for base vault manager contracts.
*/
public class VaultBaseContractsTest {
/** Vault. */
- private VaultManager vaultManager;
+ private VaultManager vaultMgr;
/**
* Instantiate vault.
*/
@BeforeEach
public void setUp() {
- vaultManager = new VaultManager(new VaultServiceImpl());
+ vaultMgr = new VaultManager(new VaultServiceImpl());
}
/**
@@ -64,18 +59,18 @@ public class VaultBaseContractsTest {
ByteArray key = getKey(1);
byte[] val = getValue(key, 1);
- assertNull(vaultManager.get(key).get().value());
+ assertNull(vaultMgr.get(key).get().value());
- vaultManager.put(key, val);
+ vaultMgr.put(key, val);
- Entry v = vaultManager.get(key).get();
+ Entry v = vaultMgr.get(key).get();
assertFalse(v.empty());
assertEquals(val, v.value());
- vaultManager.put(key, val);
+ vaultMgr.put(key, val);
- v = vaultManager.get(key).get();
+ v = vaultMgr.get(key).get();
assertFalse(v.empty());
assertEquals(val, v.value());
@@ -89,24 +84,24 @@ public class VaultBaseContractsTest {
ByteArray key = getKey(1);
byte[] val = getValue(key, 1);
- assertNull(vaultManager.get(key).get().value());
+ assertNull(vaultMgr.get(key).get().value());
// Remove non-existent value.
- vaultManager.remove(key);
+ vaultMgr.remove(key);
- assertNull(vaultManager.get(key).get().value());
+ assertNull(vaultMgr.get(key).get().value());
- vaultManager.put(key, val);
+ vaultMgr.put(key, val);
- Entry v = vaultManager.get(key).get();
+ Entry v = vaultMgr.get(key).get();
assertFalse(v.empty());
assertEquals(val, v.value());
// Remove existent value.
- vaultManager.remove(key);
+ vaultMgr.remove(key);
- v = vaultManager.get(key).get();
+ v = vaultMgr.get(key).get();
assertNull(v.value());
}
@@ -125,15 +120,15 @@ public class VaultBaseContractsTest {
values.put(key, getValue(key, i));
- assertNull(vaultManager.get(key).get().value());
+ assertNull(vaultMgr.get(key).get().value());
}
- values.forEach((k, v) -> vaultManager.put(k, v));
+ values.forEach((k, v) -> vaultMgr.put(k, v));
for (Map.Entry<ByteArray, byte[]> entry : values.entrySet())
- assertEquals(entry.getValue(), vaultManager.get(entry.getKey()).get().value());
+ assertEquals(entry.getValue(), vaultMgr.get(entry.getKey()).get().value());
- Iterator<Entry> it = vaultManager.range(getKey(3), getKey(7));
+ Iterator<Entry> it = vaultMgr.range(getKey(3), getKey(7));
List<Entry> rangeRes = new ArrayList<>();
@@ -147,52 +142,44 @@ public class VaultBaseContractsTest {
}
/**
- * watch contract.
+ * putAll with applied revision contract.
*/
@Test
- public void watch() throws ExecutionException, InterruptedException {
- ByteArray key;
-
- Map<ByteArray, byte[]> values = new HashMap<>();
-
- for (int i = 0; i < 10; i++) {
- key = getKey(i);
+ public void putAllAndRevision() throws ExecutionException, InterruptedException, IgniteInternalCheckedException {
+ Map<ByteArray, byte[]> entries = new HashMap<>();
- values.put(key, getValue(key, i));
- }
+ int entriesNum = 100;
- values.forEach((k, v) -> vaultManager.put(k, v));
+ ByteArray appRevKey = ByteArray.fromString("test_applied_revision");
- for (Map.Entry<ByteArray, byte[]> entry : values.entrySet())
- assertEquals(entry.getValue(), vaultManager.get(entry.getKey()).get().value());
+ for (int i = 0; i < entriesNum; i++) {
+ ByteArray key = getKey(i);
- CountDownLatch counter = new CountDownLatch(4);
+ entries.put(key, getValue(key, i));
+ }
- VaultWatch vaultWatch = new VaultWatch(getKey(3), getKey(7), new VaultListener() {
- @Override public boolean onUpdate(@NotNull Iterable<Entry> entries) {
- counter.countDown();
+ for (int i = 0; i < entriesNum; i++) {
+ ByteArray key = getKey(i);
- return true;
- }
+ assertNull(vaultMgr.get(key).get().value());
+ }
- @Override public void onError(@NotNull Throwable e) {
- // no-op
- }
- });
+ vaultMgr.putAll(entries, appRevKey, 1L);
- vaultManager.watch(vaultWatch);
+ for (int i = 0; i < entriesNum; i++) {
+ ByteArray key = getKey(i);
- for (int i = 3; i < 7; i++)
- vaultManager.put(getKey(i), ("new" + i).getBytes());
+ assertArrayEquals(entries.get(key), vaultMgr.get(key).get().value());
+ }
- assertTrue(counter.await(1, TimeUnit.SECONDS));
+ assertEquals(1L, ByteUtils.bytesToLong(vaultMgr.get(appRevKey).get().value()));
}
/**
* putAll contract.
*/
@Test
- public void putAllAndRevision() throws ExecutionException, InterruptedException, IgniteInternalCheckedException {
+ public void putAll() throws ExecutionException, InterruptedException {
Map<ByteArray, byte[]> entries = new HashMap<>();
int entriesNum = 100;
@@ -206,18 +193,16 @@ public class VaultBaseContractsTest {
for (int i = 0; i < entriesNum; i++) {
ByteArray key = getKey(i);
- assertNull(vaultManager.get(key).get().value());
+ assertNull(vaultMgr.get(key).get().value());
}
- vaultManager.putAll(entries, 1L);
+ vaultMgr.putAll(entries);
for (int i = 0; i < entriesNum; i++) {
ByteArray key = getKey(i);
- assertEquals(entries.get(key), vaultManager.get(key).get().value());
+ assertArrayEquals(entries.get(key), vaultMgr.get(key).get().value());
}
-
- assertEquals(1L, vaultManager.appliedRevision());
}
/**