This is an automated email from the ASF dual-hosted git repository.
sanpwc 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 bca08752e6 IGNITE-22113 Remove unused MetaStorageManagerImpl getAnd<>
methods (#3670)
bca08752e6 is described below
commit bca08752e6d04093586d47185b45196984d540ae
Author: Cyrill <[email protected]>
AuthorDate: Fri Apr 26 13:42:10 2024 +0300
IGNITE-22113 Remove unused MetaStorageManagerImpl getAnd<> methods (#3670)
---
.../metastorage/impl/ItMetaStorageServiceTest.java | 117 -----
.../metastorage/command/GetAndPutAllCommand.java | 38 --
.../metastorage/command/GetAndPutCommand.java | 37 --
.../command/GetAndRemoveAllCommand.java | 32 --
.../metastorage/command/GetAndRemoveCommand.java | 32 --
.../command/MetastorageCommandsMessageGroup.java | 12 -
.../metastorage/impl/MetaStorageManagerImpl.java | 68 ---
.../metastorage/impl/MetaStorageService.java | 46 --
.../metastorage/impl/MetaStorageServiceImpl.java | 84 ----
.../metastorage/server/KeyValueStorage.java | 38 --
.../server/persistence/RocksDbKeyValueStorage.java | 114 -----
.../server/raft/MetaStorageWriteHandler.java | 31 --
.../server/BasicOperationsKeyValueStorageTest.java | 493 +--------------------
.../server/SimpleInMemoryKeyValueStorage.java | 77 ----
14 files changed, 1 insertion(+), 1218 deletions(-)
diff --git
a/modules/metastorage/src/integrationTest/java/org/apache/ignite/internal/metastorage/impl/ItMetaStorageServiceTest.java
b/modules/metastorage/src/integrationTest/java/org/apache/ignite/internal/metastorage/impl/ItMetaStorageServiceTest.java
index 37c4a8177b..03b50f98f2 100644
---
a/modules/metastorage/src/integrationTest/java/org/apache/ignite/internal/metastorage/impl/ItMetaStorageServiceTest.java
+++
b/modules/metastorage/src/integrationTest/java/org/apache/ignite/internal/metastorage/impl/ItMetaStorageServiceTest.java
@@ -382,25 +382,6 @@ public class ItMetaStorageServiceTest extends
BaseIgniteAbstractTest {
node.metaStorageService.put(expKey, expVal).get();
}
- /**
- * Tests {@link MetaStorageService#getAndPut(ByteArray, byte[])}.
- *
- * @throws Exception If failed.
- */
- @Test
- public void testGetAndPut() throws Exception {
- Node node = startNodes(1).get(0);
-
- byte[] expVal = {2};
-
- when(node.mockStorage.getAndPut(eq(EXPECTED_RESULT_ENTRY.key()),
eq(expVal), any())).thenReturn(EXPECTED_RESULT_ENTRY);
-
- assertEquals(
- EXPECTED_RESULT_ENTRY,
- node.metaStorageService.getAndPut(new
ByteArray(EXPECTED_RESULT_ENTRY.key()), expVal).get()
- );
- }
-
/**
* Tests {@link MetaStorageService#putAll(Map)}.
*
@@ -444,53 +425,6 @@ public class ItMetaStorageServiceTest extends
BaseIgniteAbstractTest {
}
}
- /**
- * Tests {@link MetaStorageService#getAndPutAll(Map)}.
- *
- * @throws Exception If failed.
- */
- @Test
- public void testGetAndPutAll() throws Exception {
- Node node = startNodes(1).get(0);
-
- when(node.mockStorage.getAndPutAll(anyList(), anyList(),
any())).thenReturn(EXPECTED_SRV_RESULT_COLL);
-
- Map<ByteArray, Entry> gotRes = node.metaStorageService.getAndPutAll(
- EXPECTED_RESULT_MAP.entrySet().stream()
- .collect(Collectors.toMap(
- Map.Entry::getKey,
- e -> e.getValue().value())
- )
- ).get();
-
- assertEquals(EXPECTED_RESULT_MAP, gotRes);
-
- ArgumentCaptor<List<byte[]>> keysCaptor =
ArgumentCaptor.forClass(List.class);
- ArgumentCaptor<List<byte[]>> valuesCaptor =
ArgumentCaptor.forClass(List.class);
-
- verify(node.mockStorage).getAndPutAll(keysCaptor.capture(),
valuesCaptor.capture(), any());
-
- // Assert keys equality.
- assertEquals(EXPECTED_RESULT_MAP.keySet().size(),
keysCaptor.getValue().size());
-
- List<byte[]> expKeys = EXPECTED_RESULT_MAP.keySet().stream()
- .map(ByteArray::bytes).collect(toList());
-
- for (int i = 0; i < expKeys.size(); i++) {
- assertArrayEquals(expKeys.get(i), keysCaptor.getValue().get(i));
- }
-
- // Assert values equality.
- assertEquals(EXPECTED_RESULT_MAP.values().size(),
valuesCaptor.getValue().size());
-
- List<byte[]> expVals = EXPECTED_RESULT_MAP.values().stream()
- .map(Entry::value).collect(toList());
-
- for (int i = 0; i < expKeys.size(); i++) {
- assertArrayEquals(expVals.get(i), valuesCaptor.getValue().get(i));
- }
- }
-
/**
* Tests {@link MetaStorageService#remove(ByteArray)}.
*
@@ -507,27 +441,6 @@ public class ItMetaStorageServiceTest extends
BaseIgniteAbstractTest {
node.metaStorageService.remove(expKey).get();
}
- /**
- * Tests {@link MetaStorageService#getAndRemove(ByteArray)}.
- *
- * @throws Exception If failed.
- */
- @Test
- public void testGetAndRemove() throws Exception {
- Node node = startNodes(1).get(0);
-
- Entry expRes = new EntryImpl(
- new byte[]{1},
- new byte[]{3},
- 10,
- 2
- );
-
- when(node.mockStorage.getAndRemove(eq(expRes.key()),
any())).thenReturn(expRes);
-
- assertEquals(expRes, node.metaStorageService.getAndRemove(new
ByteArray(expRes.key())).get());
- }
-
/**
* Tests {@link MetaStorageService#removeAll(Set)}.
*
@@ -553,36 +466,6 @@ public class ItMetaStorageServiceTest extends
BaseIgniteAbstractTest {
}
}
- /**
- * Tests {@link MetaStorageService#getAndRemoveAll(Set)}.
- *
- * @throws Exception If failed.
- */
- @Test
- public void testGetAndRemoveAll() throws Exception {
- Node node = startNodes(1).get(0);
-
- when(node.mockStorage.getAndRemoveAll(anyList(),
any())).thenReturn(EXPECTED_SRV_RESULT_COLL);
-
- Map<ByteArray, Entry> gotRes =
node.metaStorageService.getAndRemoveAll(EXPECTED_RESULT_MAP.keySet()).get();
-
- assertEquals(EXPECTED_RESULT_MAP, gotRes);
-
- ArgumentCaptor<List<byte[]>> keysCaptor =
ArgumentCaptor.forClass(List.class);
-
- verify(node.mockStorage).getAndRemoveAll(keysCaptor.capture(), any());
-
- // Assert keys equality.
- assertEquals(EXPECTED_RESULT_MAP.keySet().size(),
keysCaptor.getValue().size());
-
- List<byte[]> expKeys = EXPECTED_RESULT_MAP.keySet().stream()
- .map(ByteArray::bytes).collect(toList());
-
- for (int i = 0; i < expKeys.size(); i++) {
- assertArrayEquals(expKeys.get(i), keysCaptor.getValue().get(i));
- }
- }
-
/**
* Tests {@link MetaStorageService#range(ByteArray, ByteArray, long)}}
with not null keyTo and explicit revUpperBound.
*/
diff --git
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/command/GetAndPutAllCommand.java
b/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/command/GetAndPutAllCommand.java
deleted file mode 100644
index b477bf8aaf..0000000000
---
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/command/GetAndPutAllCommand.java
+++ /dev/null
@@ -1,38 +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.metastorage.command;
-
-import java.util.List;
-import org.apache.ignite.internal.network.annotations.Transferable;
-
-/**
- * Get and put all command for MetaStorageCommandListener that inserts or
updates entries with given keys and given values and retrieves a
- * previous entries for given keys.
- */
-@Transferable(MetastorageCommandsMessageGroup.GET_AND_PUT_ALL)
-public interface GetAndPutAllCommand extends MetaStorageWriteCommand {
- /**
- * Returns keys.
- */
- List<byte[]> keys();
-
- /**
- * Returns values.
- */
- List<byte[]> values();
-}
diff --git
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/command/GetAndPutCommand.java
b/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/command/GetAndPutCommand.java
deleted file mode 100644
index 79c8531458..0000000000
---
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/command/GetAndPutCommand.java
+++ /dev/null
@@ -1,37 +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.metastorage.command;
-
-import org.apache.ignite.internal.network.annotations.Transferable;
-
-/**
- * Get and put command for MetaStorageCommandListener that inserts or updates
an entry with the given key and the given value and retrieves
- * a previous entry for the given key.
- */
-@Transferable(MetastorageCommandsMessageGroup.GET_AND_PUT)
-public interface GetAndPutCommand extends MetaStorageWriteCommand {
- /**
- * Returns the key. Couldn't be {@code null}.
- */
- byte[] key();
-
- /**
- * Returns the value. Couldn't be {@code null}.
- */
- byte[] value();
-}
diff --git
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/command/GetAndRemoveAllCommand.java
b/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/command/GetAndRemoveAllCommand.java
deleted file mode 100644
index 473e2992f5..0000000000
---
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/command/GetAndRemoveAllCommand.java
+++ /dev/null
@@ -1,32 +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.metastorage.command;
-
-import java.util.List;
-import org.apache.ignite.internal.network.annotations.Transferable;
-
-/**
- * Get and remove all command for MetaStorageCommandListener that removes
entries for given keys and retrieves previous entries.
- */
-@Transferable(MetastorageCommandsMessageGroup.GET_AND_REMOVE_ALL)
-public interface GetAndRemoveAllCommand extends MetaStorageWriteCommand {
- /**
- * Returns the keys collection. Couldn't be {@code null}.
- */
- List<byte[]> keys();
-}
diff --git
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/command/GetAndRemoveCommand.java
b/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/command/GetAndRemoveCommand.java
deleted file mode 100644
index 3d1ac4a4d4..0000000000
---
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/command/GetAndRemoveCommand.java
+++ /dev/null
@@ -1,32 +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.metastorage.command;
-
-import org.apache.ignite.internal.network.annotations.Transferable;
-
-/**
- * Get and remove command for MetaStorageCommandListener that removes an entry
for the given key and retrieves a previous entry for the
- * given key.
- */
-@Transferable(MetastorageCommandsMessageGroup.GET_AND_REMOVE)
-public interface GetAndRemoveCommand extends MetaStorageWriteCommand {
- /**
- * Returns the key. Couldn't be {@code null}.
- */
- byte[] key();
-}
diff --git
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/command/MetastorageCommandsMessageGroup.java
b/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/command/MetastorageCommandsMessageGroup.java
index 039771f3ca..0967b84d5c 100644
---
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/command/MetastorageCommandsMessageGroup.java
+++
b/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/command/MetastorageCommandsMessageGroup.java
@@ -35,21 +35,9 @@ public interface MetastorageCommandsMessageGroup {
/** Message type for {@link GetCommand}. */
short GET = 20;
- /** Message type for {@link GetAndPutCommand}. */
- short GET_AND_PUT = 21;
-
- /** Message type for {@link GetAndRemoveCommand}. */
- short GET_AND_REMOVE = 22;
-
/** Message type for {@link GetAllCommand}. */
short GET_ALL = 30;
- /** Message type for {@link GetAndPutAllCommand}. */
- short GET_AND_PUT_ALL = 31;
-
- /** Message type for {@link GetAndRemoveAllCommand}. */
- short GET_AND_REMOVE_ALL = 32;
-
/** Message type for {@link GetCurrentRevisionCommand}. */
short GET_CURRENT_REVISION = 33;
diff --git
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageManagerImpl.java
b/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageManagerImpl.java
index 1a3d82ee5e..ff19fa1313 100644
---
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageManagerImpl.java
+++
b/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageManagerImpl.java
@@ -571,23 +571,6 @@ public class MetaStorageManagerImpl implements
MetaStorageManager {
}
}
- /**
- * Inserts or updates an entry with the given key and the given value and
retrieves a previous entry for the given key.
- *
- * @see MetaStorageService#getAndPut(ByteArray, byte[])
- */
- public CompletableFuture<Entry> getAndPut(ByteArray key, byte[] val) {
- if (!busyLock.enterBusy()) {
- return CompletableFuture.failedFuture(new NodeStoppingException());
- }
-
- try {
- return metaStorageSvcFut.thenCompose(svc -> svc.getAndPut(key,
val));
- } finally {
- busyLock.leaveBusy();
- }
- }
-
/**
* Inserts or updates entries with given keys and given values.
*
@@ -606,23 +589,6 @@ public class MetaStorageManagerImpl implements
MetaStorageManager {
}
}
- /**
- * Inserts or updates entries with given keys and given values and
retrieves a previous entries for given keys.
- *
- * @see MetaStorageService#getAndPutAll(Map)
- */
- public CompletableFuture<Map<ByteArray, Entry>>
getAndPutAll(Map<ByteArray, byte[]> vals) {
- if (!busyLock.enterBusy()) {
- return CompletableFuture.failedFuture(new NodeStoppingException());
- }
-
- try {
- return metaStorageSvcFut.thenCompose(svc ->
svc.getAndPutAll(vals));
- } finally {
- busyLock.leaveBusy();
- }
- }
-
/**
* Removes an entry for the given key.
*
@@ -641,23 +607,6 @@ public class MetaStorageManagerImpl implements
MetaStorageManager {
}
}
- /**
- * Removes an entry for the given key.
- *
- * @see MetaStorageService#getAndRemove(ByteArray)
- */
- public CompletableFuture<Entry> getAndRemove(ByteArray key) {
- if (!busyLock.enterBusy()) {
- return CompletableFuture.failedFuture(new NodeStoppingException());
- }
-
- try {
- return metaStorageSvcFut.thenCompose(svc -> svc.getAndRemove(key));
- } finally {
- busyLock.leaveBusy();
- }
- }
-
/**
* Removes entries for given keys.
*
@@ -676,23 +625,6 @@ public class MetaStorageManagerImpl implements
MetaStorageManager {
}
}
- /**
- * Removes entries for given keys and retrieves previous entries.
- *
- * @see MetaStorageService#getAndRemoveAll(Set)
- */
- public CompletableFuture<Map<ByteArray, Entry>>
getAndRemoveAll(Set<ByteArray> keys) {
- if (!busyLock.enterBusy()) {
- return CompletableFuture.failedFuture(new NodeStoppingException());
- }
-
- try {
- return metaStorageSvcFut.thenCompose(svc ->
svc.getAndRemoveAll(keys));
- } finally {
- busyLock.leaveBusy();
- }
- }
-
@Override
public CompletableFuture<Boolean> invoke(Condition cond, Operation
success, Operation failure) {
if (!busyLock.enterBusy()) {
diff --git
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageService.java
b/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageService.java
index 37af1c5450..66bb7c57ab 100644
---
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageService.java
+++
b/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageService.java
@@ -99,18 +99,6 @@ public interface MetaStorageService extends
ManuallyCloseable {
*/
CompletableFuture<Void> put(ByteArray key, 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 ByteArray
- * @see Entry
- */
- CompletableFuture<Entry> getAndPut(ByteArray key, byte[] value);
-
/**
* Inserts or updates entries with given keys and given values.
*
@@ -122,17 +110,6 @@ public interface MetaStorageService extends
ManuallyCloseable {
*/
CompletableFuture<Void> putAll(Map<ByteArray, 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 ByteArray
- * @see Entry
- */
- CompletableFuture<Map<ByteArray, Entry>> getAndPutAll(Map<ByteArray,
byte[]> vals);
-
/**
* Removes an entry for the given key.
*
@@ -144,17 +121,6 @@ public interface MetaStorageService extends
ManuallyCloseable {
*/
CompletableFuture<Void> remove(ByteArray 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 ByteArray
- * @see Entry
- */
- CompletableFuture<Entry> getAndRemove(ByteArray key);
-
/**
* Removes entries for given keys.
*
@@ -166,18 +132,6 @@ public interface MetaStorageService extends
ManuallyCloseable {
*/
CompletableFuture<Void> removeAll(Set<ByteArray> 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 ByteArray
- * @see Entry
- */
- CompletableFuture<Map<ByteArray, Entry>> getAndRemoveAll(Set<ByteArray>
keys);
-
/**
* Updates an entry for the given key conditionally.
*
diff --git
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageServiceImpl.java
b/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageServiceImpl.java
index 9206cf779f..b1f94fc8d7 100644
---
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageServiceImpl.java
+++
b/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageServiceImpl.java
@@ -35,10 +35,6 @@ import org.apache.ignite.internal.logger.Loggers;
import org.apache.ignite.internal.metastorage.Entry;
import org.apache.ignite.internal.metastorage.MetaStorageManager;
import org.apache.ignite.internal.metastorage.command.GetAllCommand;
-import org.apache.ignite.internal.metastorage.command.GetAndPutAllCommand;
-import org.apache.ignite.internal.metastorage.command.GetAndPutCommand;
-import org.apache.ignite.internal.metastorage.command.GetAndRemoveAllCommand;
-import org.apache.ignite.internal.metastorage.command.GetAndRemoveCommand;
import org.apache.ignite.internal.metastorage.command.GetCommand;
import
org.apache.ignite.internal.metastorage.command.GetCurrentRevisionCommand;
import org.apache.ignite.internal.metastorage.command.InvokeCommand;
@@ -136,17 +132,6 @@ public class MetaStorageServiceImpl implements
MetaStorageService {
return context.raftService().run(putCommand);
}
- @Override
- public CompletableFuture<Entry> getAndPut(ByteArray key, byte[] value) {
- GetAndPutCommand getAndPutCommand =
context.commandsFactory().getAndPutCommand()
- .key(key.bytes())
- .value(value)
- .initiatorTimeLong(clusterTime.nowLong())
- .build();
-
- return context.raftService().run(getAndPutCommand);
- }
-
@Override
public CompletableFuture<Void> putAll(Map<ByteArray, byte[]> vals) {
PutAllCommand putAllCommand = putAllCommand(context.commandsFactory(),
vals, clusterTime.now());
@@ -154,14 +139,6 @@ public class MetaStorageServiceImpl implements
MetaStorageService {
return context.raftService().run(putAllCommand);
}
- @Override
- public CompletableFuture<Map<ByteArray, Entry>>
getAndPutAll(Map<ByteArray, byte[]> vals) {
- GetAndPutAllCommand getAndPutAllCommand =
getAndPutAllCommand(context.commandsFactory(), vals, clusterTime.now());
-
- return context.raftService().<List<Entry>>run(getAndPutAllCommand)
- .thenApply(MetaStorageServiceImpl::multipleEntryResult);
- }
-
@Override
public CompletableFuture<Void> remove(ByteArray key) {
RemoveCommand removeCommand =
context.commandsFactory().removeCommand().key(key.bytes())
@@ -170,14 +147,6 @@ public class MetaStorageServiceImpl implements
MetaStorageService {
return context.raftService().run(removeCommand);
}
- @Override
- public CompletableFuture<Entry> getAndRemove(ByteArray key) {
- GetAndRemoveCommand getAndRemoveCommand =
context.commandsFactory().getAndRemoveCommand().key(key.bytes())
- .initiatorTimeLong(clusterTime.nowLong()).build();
-
- return context.raftService().run(getAndRemoveCommand);
- }
-
@Override
public CompletableFuture<Void> removeAll(Set<ByteArray> keys) {
RemoveAllCommand removeAllCommand =
removeAllCommand(context.commandsFactory(), keys, clusterTime.now());
@@ -185,14 +154,6 @@ public class MetaStorageServiceImpl implements
MetaStorageService {
return context.raftService().run(removeAllCommand);
}
- @Override
- public CompletableFuture<Map<ByteArray, Entry>>
getAndRemoveAll(Set<ByteArray> keys) {
- GetAndRemoveAllCommand getAndRemoveAllCommand =
getAndRemoveAllCommand(context.commandsFactory(), keys, clusterTime.now());
-
- return context.raftService().<List<Entry>>run(getAndRemoveAllCommand)
- .thenApply(MetaStorageServiceImpl::multipleEntryResult);
- }
-
@Override
public CompletableFuture<Boolean> invoke(Condition condition, Operation
success, Operation failure) {
return invoke(condition, List.of(success), List.of(failure));
@@ -350,51 +311,6 @@ public class MetaStorageServiceImpl implements
MetaStorageService {
.build();
}
- /**
- * Creates get and put all command.
- *
- * @param commandsFactory Commands factory.
- * @param map Values.
- * @param ts Local time.
- */
- private GetAndPutAllCommand getAndPutAllCommand(MetaStorageCommandsFactory
commandsFactory, Map<ByteArray, byte[]> map,
- HybridTimestamp ts) {
- int size = map.size();
-
- List<byte[]> keys = new ArrayList<>(size);
- List<byte[]> values = new ArrayList<>(size);
-
- for (Map.Entry<ByteArray, byte[]> e : map.entrySet()) {
- keys.add(e.getKey().bytes());
-
- values.add(e.getValue());
- }
-
- return commandsFactory.getAndPutAllCommand()
- .keys(keys)
- .values(values)
- .initiatorTimeLong(ts.longValue())
- .build();
- }
-
- /**
- * Creates get and remove all command.
- *
- * @param commandsFactory Commands factory.
- * @param keys The keys collection. Couldn't be {@code null}.
- * @param ts Local time.
- */
- private GetAndRemoveAllCommand
getAndRemoveAllCommand(MetaStorageCommandsFactory commandsFactory,
Set<ByteArray> keys,
- HybridTimestamp ts) {
- List<byte[]> keysList = new ArrayList<>(keys.size());
-
- for (ByteArray key : keys) {
- keysList.add(key.bytes());
- }
-
- return
commandsFactory.getAndRemoveAllCommand().keys(keysList).initiatorTimeLong(ts.longValue()).build();
- }
-
/**
* Creates remove all command.
*
diff --git
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/KeyValueStorage.java
b/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/KeyValueStorage.java
index de625f477e..414aabc03c 100644
---
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/KeyValueStorage.java
+++
b/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/KeyValueStorage.java
@@ -110,16 +110,6 @@ public interface KeyValueStorage extends ManuallyCloseable
{
*/
void put(byte[] key, byte[] value, HybridTimestamp opTs);
- /**
- * Inserts an entry with the given key and given value and returns
previous entry.
- *
- * @param key The key.
- * @param value The value.
- * @param opTs Operation's timestamp.
- * @return Previous entry corresponding to the given key.
- */
- Entry getAndPut(byte[] key, byte[] value, HybridTimestamp opTs);
-
/**
* Inserts entries with given keys and given values.
*
@@ -129,16 +119,6 @@ public interface KeyValueStorage extends ManuallyCloseable
{
*/
void putAll(List<byte[]> keys, List<byte[]> values, HybridTimestamp opTs);
- /**
- * Inserts entries with given keys and given values and returns previous
entries.
- *
- * @param keys The key list.
- * @param values The values list.
- * @param opTs Operation's timestamp.
- * @return Collection of previous entries corresponding to given keys.
- */
- Collection<Entry> getAndPutAll(List<byte[]> keys, List<byte[]> values,
HybridTimestamp opTs);
-
/**
* Removes an entry with the given key.
*
@@ -147,15 +127,6 @@ public interface KeyValueStorage extends ManuallyCloseable
{
*/
void remove(byte[] key, HybridTimestamp opTs);
- /**
- * Removes an entry with the given key and returns previous entry.
- *
- * @param key The key.
- * @param opTs Operation's timestamp.
- * @return Previous entry.
- */
- Entry getAndRemove(byte[] key, HybridTimestamp opTs);
-
/**
* Remove all entries corresponding to given keys.
*
@@ -164,15 +135,6 @@ public interface KeyValueStorage extends ManuallyCloseable
{
*/
void removeAll(List<byte[]> keys, HybridTimestamp opTs);
- /**
- * Remove all entries corresponding to given keys and returns previous
entries.
- *
- * @param keys The keys list.
- * @param opTs Operation's timestamp.
- * @return Previous entries.
- */
- Collection<Entry> getAndRemoveAll(List<byte[]> keys, HybridTimestamp opTs);
-
/**
* Performs {@code success} operation if condition is {@code true},
otherwise performs {@code failure} operations.
*
diff --git
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/persistence/RocksDbKeyValueStorage.java
b/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/persistence/RocksDbKeyValueStorage.java
index f82c7c1836..b96dcd5520 100644
---
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/persistence/RocksDbKeyValueStorage.java
+++
b/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/persistence/RocksDbKeyValueStorage.java
@@ -498,33 +498,6 @@ public class RocksDbKeyValueStorage implements
KeyValueStorage {
: new EntryImpl(key, value.bytes(), revision,
value.updateCounter());
}
- @Override
- public Entry getAndPut(byte[] key, byte[] value, HybridTimestamp opTs) {
- rwLock.writeLock().lock();
-
- try (WriteBatch batch = new WriteBatch()) {
- long curRev = rev + 1;
- long cntr = updCntr + 1;
-
- long[] revs = getRevisions(key);
-
- long lastRev = revs.length == 0 ? 0 : lastRevision(revs);
-
- addDataToBatch(batch, key, value, curRev, cntr);
-
- updateKeysIndex(batch, key, curRev);
-
- fillAndWriteBatch(batch, curRev, cntr, opTs);
-
- // Return previous value.
- return doGetValue(key, lastRev);
- } catch (RocksDBException e) {
- throw new MetaStorageException(OP_EXECUTION_ERR, e);
- } finally {
- rwLock.writeLock().unlock();
- }
- }
-
@Override
public void putAll(List<byte[]> keys, List<byte[]> values, HybridTimestamp
opTs) {
rwLock.writeLock().lock();
@@ -546,33 +519,6 @@ public class RocksDbKeyValueStorage implements
KeyValueStorage {
}
}
- @Override
- public Collection<Entry> getAndPutAll(List<byte[]> keys, List<byte[]>
values, HybridTimestamp opTs) {
- Collection<Entry> res;
-
- rwLock.writeLock().lock();
-
- try (WriteBatch batch = new WriteBatch()) {
- long curRev = rev + 1;
-
- res = doGetAll(keys, curRev);
-
- long counter = addAllToBatch(batch, keys, values, curRev);
-
- for (byte[] key : keys) {
- updateKeysIndex(batch, key, curRev);
- }
-
- fillAndWriteBatch(batch, curRev, counter, opTs);
- } catch (RocksDBException e) {
- throw new MetaStorageException(OP_EXECUTION_ERR, e);
- } finally {
- rwLock.writeLock().unlock();
- }
-
- return res;
- }
-
@Override
public Entry get(byte[] key) {
rwLock.readLock().lock();
@@ -648,23 +594,6 @@ public class RocksDbKeyValueStorage implements
KeyValueStorage {
}
}
- @Override
- public Entry getAndRemove(byte[] key, HybridTimestamp opTs) {
- rwLock.writeLock().lock();
-
- try {
- Entry e = doGet(key, rev);
-
- if (e.empty() || e.tombstone()) {
- return e;
- }
-
- return getAndPut(key, TOMBSTONE, opTs);
- } finally {
- rwLock.writeLock().unlock();
- }
- }
-
@Override
public void removeAll(List<byte[]> keys, HybridTimestamp opTs) {
rwLock.writeLock().lock();
@@ -696,49 +625,6 @@ public class RocksDbKeyValueStorage implements
KeyValueStorage {
}
}
- @Override
- public Collection<Entry> getAndRemoveAll(List<byte[]> keys,
HybridTimestamp opTs) {
- Collection<Entry> res = new ArrayList<>(keys.size());
-
- rwLock.writeLock().lock();
-
- try (WriteBatch batch = new WriteBatch()) {
- long curRev = rev + 1;
-
- List<byte[]> existingKeys = new ArrayList<>(keys.size());
-
- List<byte[]> vals = new ArrayList<>(keys.size());
-
- for (byte[] key : keys) {
- Entry e = doGet(key, curRev);
-
- res.add(e);
-
- if (e.empty() || e.tombstone()) {
- continue;
- }
-
- existingKeys.add(key);
-
- vals.add(TOMBSTONE);
- }
-
- long counter = addAllToBatch(batch, existingKeys, vals, curRev);
-
- for (byte[] key : existingKeys) {
- updateKeysIndex(batch, key, curRev);
- }
-
- fillAndWriteBatch(batch, curRev, counter, opTs);
- } catch (RocksDBException e) {
- throw new MetaStorageException(OP_EXECUTION_ERR, e);
- } finally {
- rwLock.writeLock().unlock();
- }
-
- return res;
- }
-
@Override
public boolean invoke(Condition condition, Collection<Operation> success,
Collection<Operation> failure, HybridTimestamp opTs) {
rwLock.writeLock().lock();
diff --git
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/raft/MetaStorageWriteHandler.java
b/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/raft/MetaStorageWriteHandler.java
index 3648d86827..f0bb116a50 100644
---
a/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/raft/MetaStorageWriteHandler.java
+++
b/modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/raft/MetaStorageWriteHandler.java
@@ -17,18 +17,11 @@
package org.apache.ignite.internal.metastorage.server.raft;
-import java.io.Serializable;
-import java.util.Collection;
import java.util.concurrent.CompletionException;
import org.apache.ignite.internal.hlc.HybridTimestamp;
import org.apache.ignite.internal.lang.IgniteInternalException;
import org.apache.ignite.internal.logger.IgniteLogger;
import org.apache.ignite.internal.logger.Loggers;
-import org.apache.ignite.internal.metastorage.Entry;
-import org.apache.ignite.internal.metastorage.command.GetAndPutAllCommand;
-import org.apache.ignite.internal.metastorage.command.GetAndPutCommand;
-import org.apache.ignite.internal.metastorage.command.GetAndRemoveAllCommand;
-import org.apache.ignite.internal.metastorage.command.GetAndRemoveCommand;
import org.apache.ignite.internal.metastorage.command.InvokeCommand;
import org.apache.ignite.internal.metastorage.command.MetaStorageWriteCommand;
import org.apache.ignite.internal.metastorage.command.MultiInvokeCommand;
@@ -128,48 +121,24 @@ public class MetaStorageWriteHandler {
storage.put(putCmd.key(), putCmd.value(), opTime);
clo.result(null);
- } else if (command instanceof GetAndPutCommand) {
- GetAndPutCommand getAndPutCmd = (GetAndPutCommand) command;
-
- Entry e = storage.getAndPut(getAndPutCmd.key(),
getAndPutCmd.value(), opTime);
-
- clo.result(e);
} else if (command instanceof PutAllCommand) {
PutAllCommand putAllCmd = (PutAllCommand) command;
storage.putAll(putAllCmd.keys(), putAllCmd.values(), opTime);
clo.result(null);
- } else if (command instanceof GetAndPutAllCommand) {
- GetAndPutAllCommand getAndPutAllCmd = (GetAndPutAllCommand)
command;
-
- Collection<Entry> entries =
storage.getAndPutAll(getAndPutAllCmd.keys(), getAndPutAllCmd.values(), opTime);
-
- clo.result((Serializable) entries);
} else if (command instanceof RemoveCommand) {
RemoveCommand rmvCmd = (RemoveCommand) command;
storage.remove(rmvCmd.key(), opTime);
clo.result(null);
- } else if (command instanceof GetAndRemoveCommand) {
- GetAndRemoveCommand getAndRmvCmd = (GetAndRemoveCommand) command;
-
- Entry e = storage.getAndRemove(getAndRmvCmd.key(), opTime);
-
- clo.result(e);
} else if (command instanceof RemoveAllCommand) {
RemoveAllCommand rmvAllCmd = (RemoveAllCommand) command;
storage.removeAll(rmvAllCmd.keys(), opTime);
clo.result(null);
- } else if (command instanceof GetAndRemoveAllCommand) {
- GetAndRemoveAllCommand getAndRmvAllCmd = (GetAndRemoveAllCommand)
command;
-
- Collection<Entry> entries =
storage.getAndRemoveAll(getAndRmvAllCmd.keys(), opTime);
-
- clo.result((Serializable) entries);
} else if (command instanceof InvokeCommand) {
InvokeCommand cmd = (InvokeCommand) command;
diff --git
a/modules/metastorage/src/test/java/org/apache/ignite/internal/metastorage/server/BasicOperationsKeyValueStorageTest.java
b/modules/metastorage/src/test/java/org/apache/ignite/internal/metastorage/server/BasicOperationsKeyValueStorageTest.java
index 80742d1677..4c53d34fbc 100644
---
a/modules/metastorage/src/test/java/org/apache/ignite/internal/metastorage/server/BasicOperationsKeyValueStorageTest.java
+++
b/modules/metastorage/src/test/java/org/apache/ignite/internal/metastorage/server/BasicOperationsKeyValueStorageTest.java
@@ -460,34 +460,6 @@ public abstract class BasicOperationsKeyValueStorageTest
extends AbstractKeyValu
assertTrue(e4.empty());
}
- @Test
- public void getAndPut() {
- byte[] key = key(1);
- byte[] val = keyValue(1, 1);
-
- assertEquals(0, storage.revision());
- assertEquals(0, storage.updateCounter());
- assertTrue(storage.get(key).empty());
-
- Entry e = getAndPutToMs(key, val);
-
- assertEquals(1, storage.revision());
- assertEquals(1, storage.updateCounter());
- assertTrue(e.empty());
- assertFalse(e.tombstone());
- assertEquals(0, e.revision());
- assertEquals(0, e.updateCounter());
-
- e = getAndPutToMs(key, val);
-
- assertEquals(2, storage.revision());
- assertEquals(2, storage.updateCounter());
- assertFalse(e.empty());
- assertFalse(e.tombstone());
- assertEquals(1, e.revision());
- assertEquals(1, e.updateCounter());
- }
-
@Test
public void putAll() {
byte[] key1 = key(1);
@@ -564,115 +536,6 @@ public abstract class BasicOperationsKeyValueStorageTest
extends AbstractKeyValu
assertTrue(e4.empty());
}
- @Test
- public void getAndPutAll() {
- byte[] key1 = key(1);
- byte[] val1 = keyValue(1, 1);
-
- byte[] key2 = key(2);
- byte[] val21 = keyValue(2, 21);
- byte[] val22 = keyValue(2, 22);
-
- byte[] key3 = key(3);
- byte[] val31 = keyValue(3, 31);
- byte[] val32 = keyValue(3, 32);
-
- byte[] key4 = key(4);
-
- assertEquals(0, storage.revision());
- assertEquals(0, storage.updateCounter());
-
- // Must be rewritten.
- putToMs(key2, val21);
-
- // Remove. Tombstone must be replaced by new value.
- putToMs(key3, val31);
- removeFromMs(key3);
-
- assertEquals(3, storage.revision());
- assertEquals(3, storage.updateCounter());
-
- Collection<Entry> entries = getAndPutAllToMs(List.of(key1, key2,
key3), List.of(val1, val22, val32));
-
- assertEquals(4, storage.revision());
- assertEquals(6, storage.updateCounter());
-
- assertEquals(3, entries.size());
-
- Map<ByteArray, Entry> map =
entries.stream().collect(Collectors.toMap(e -> new ByteArray(e.key()),
identity()));
-
- // Test regular put value.
- Entry e1 = map.get(new ByteArray(key1));
-
- assertNotNull(e1);
- assertEquals(0, e1.revision());
- assertEquals(0, e1.updateCounter());
- assertFalse(e1.tombstone());
- assertTrue(e1.empty());
-
- // Test rewritten value.
- Entry e2 = map.get(new ByteArray(key2));
-
- assertNotNull(e2);
- assertEquals(1, e2.revision());
- assertEquals(1, e2.updateCounter());
- assertFalse(e2.tombstone());
- assertFalse(e2.empty());
- assertArrayEquals(val21, e2.value());
-
- // Test removed value.
- Entry e3 = map.get(new ByteArray(key3));
-
- assertNotNull(e3);
- assertEquals(3, e3.revision());
- assertEquals(3, e3.updateCounter());
- assertTrue(e3.tombstone());
- assertFalse(e3.empty());
-
- // Test state after putAll.
- entries = storage.getAll(List.of(key1, key2, key3, key4));
-
- assertEquals(4, entries.size());
-
- map = entries.stream().collect(Collectors.toMap(e -> new
ByteArray(e.key()), identity()));
-
- // Test regular put value.
- e1 = map.get(new ByteArray(key1));
-
- assertNotNull(e1);
- assertEquals(4, e1.revision());
- assertEquals(4, e1.updateCounter());
- assertFalse(e1.tombstone());
- assertFalse(e1.empty());
- assertArrayEquals(val1, e1.value());
-
- // Test rewritten value.
- e2 = map.get(new ByteArray(key2));
-
- assertNotNull(e2);
- assertEquals(4, e2.revision());
- assertEquals(5, e2.updateCounter());
- assertFalse(e2.tombstone());
- assertFalse(e2.empty());
- assertArrayEquals(val22, e2.value());
-
- // Test removed value.
- e3 = map.get(new ByteArray(key3));
-
- assertNotNull(e3);
- assertEquals(4, e3.revision());
- assertEquals(6, e3.updateCounter());
- assertFalse(e3.tombstone());
- assertFalse(e3.empty());
-
- // Test empty value.
- Entry e4 = map.get(new ByteArray(key4));
-
- assertNotNull(e4);
- assertFalse(e4.tombstone());
- assertTrue(e4.empty());
- }
-
@Test
public void testRemove() {
byte[] key = key(1);
@@ -721,63 +584,6 @@ public abstract class BasicOperationsKeyValueStorageTest
extends AbstractKeyValu
assertEquals(2, e.updateCounter());
}
- @Test
- public void getAndRemove() {
- byte[] key = key(1);
- byte[] val = keyValue(1, 1);
-
- assertEquals(0, storage.revision());
- assertEquals(0, storage.updateCounter());
- assertTrue(storage.get(key).empty());
-
- // Remove non-existent entry.
- Entry e = getAndRemoveFromMs(key);
-
- assertTrue(e.empty());
- assertEquals(0, storage.revision());
- assertEquals(0, storage.updateCounter());
- assertTrue(storage.get(key).empty());
-
- putToMs(key, val);
-
- assertEquals(1, storage.revision());
- assertEquals(1, storage.updateCounter());
-
- // Remove existent entry.
- e = getAndRemoveFromMs(key);
-
- assertFalse(e.empty());
- assertFalse(e.tombstone());
- assertEquals(1, e.revision());
- assertEquals(1, e.updateCounter());
- assertEquals(2, storage.revision());
- assertEquals(2, storage.updateCounter());
-
- e = storage.get(key);
-
- assertFalse(e.empty());
- assertTrue(e.tombstone());
- assertEquals(2, e.revision());
- assertEquals(2, e.updateCounter());
-
- // Remove already removed entry (tombstone can't be removed).
- e = getAndRemoveFromMs(key);
-
- assertFalse(e.empty());
- assertTrue(e.tombstone());
- assertEquals(2, e.revision());
- assertEquals(2, e.updateCounter());
- assertEquals(2, storage.revision());
- assertEquals(2, storage.updateCounter());
-
- e = storage.get(key);
-
- assertFalse(e.empty());
- assertTrue(e.tombstone());
- assertEquals(2, e.revision());
- assertEquals(2, e.updateCounter());
- }
-
@Test
public void removeAll() {
byte[] key1 = key(1);
@@ -855,156 +661,6 @@ public abstract class BasicOperationsKeyValueStorageTest
extends AbstractKeyValu
assertTrue(e4.empty());
}
- @Test
- public void getAndRemoveAll() {
- byte[] key1 = key(1);
- byte[] val1 = keyValue(1, 1);
-
- byte[] key2 = key(2);
- byte[] val21 = keyValue(2, 21);
- byte[] val22 = keyValue(2, 22);
-
- byte[] key3 = key(3);
- byte[] val31 = keyValue(3, 31);
-
- byte[] key4 = key(4);
-
- assertEquals(0, storage.revision());
- assertEquals(0, storage.updateCounter());
-
- // Regular put.
- putToMs(key1, val1);
-
- // Rewrite.
- putToMs(key2, val21);
- putToMs(key2, val22);
-
- // Remove. Tombstone must not be removed again.
- putToMs(key3, val31);
- removeFromMs(key3);
-
- assertEquals(5, storage.revision());
- assertEquals(5, storage.updateCounter());
-
- Collection<Entry> entries = getAndRemoveAllFromMs(List.of(key1, key2,
key3, key4));
-
- assertEquals(6, storage.revision());
- assertEquals(7, storage.updateCounter()); // Only two keys are updated.
-
- assertEquals(4, entries.size());
-
- Map<ByteArray, Entry> map =
entries.stream().collect(Collectors.toMap(e -> new ByteArray(e.key()),
identity()));
-
- // Test regular put value.
- Entry e1 = map.get(new ByteArray(key1));
-
- assertNotNull(e1);
- assertEquals(1, e1.revision());
- assertEquals(1, e1.updateCounter());
- assertFalse(e1.tombstone());
- assertFalse(e1.empty());
-
- // Test rewritten value.
- Entry e2 = map.get(new ByteArray(key2));
-
- assertNotNull(e2);
- assertEquals(3, e2.revision());
- assertEquals(3, e2.updateCounter());
- assertFalse(e2.tombstone());
- assertFalse(e2.empty());
-
- // Test removed value.
- Entry e3 = map.get(new ByteArray(key3));
-
- assertNotNull(e3);
- assertEquals(5, e3.revision());
- assertEquals(5, e3.updateCounter());
- assertTrue(e3.tombstone());
- assertFalse(e3.empty());
-
- // Test empty value.
- Entry e4 = map.get(new ByteArray(key4));
-
- assertNotNull(e4);
- assertFalse(e4.tombstone());
- assertTrue(e4.empty());
-
- // Test state after getAndRemoveAll.
- entries = storage.getAll(List.of(key1, key2, key3, key4));
-
- assertEquals(4, entries.size());
-
- map = entries.stream().collect(Collectors.toMap(e -> new
ByteArray(e.key()), identity()));
-
- // Test regular put value.
- e1 = map.get(new ByteArray(key1));
-
- assertNotNull(e1);
- assertEquals(6, e1.revision());
- assertEquals(6, e1.updateCounter());
- assertTrue(e1.tombstone());
- assertFalse(e1.empty());
-
- // Test rewritten value.
- e2 = map.get(new ByteArray(key2));
-
- assertNotNull(e2);
- assertEquals(6, e2.revision());
- assertEquals(7, e2.updateCounter());
- assertTrue(e2.tombstone());
- assertFalse(e2.empty());
-
- // Test removed value.
- e3 = map.get(new ByteArray(key3));
-
- assertNotNull(e3);
- assertEquals(5, e3.revision());
- assertEquals(5, e3.updateCounter());
- assertTrue(e3.tombstone());
- assertFalse(e3.empty());
-
- // Test empty value.
- e4 = map.get(new ByteArray(key4));
-
- assertNotNull(e4);
- assertFalse(e4.tombstone());
- assertTrue(e4.empty());
- }
-
- @Test
- public void getAfterRemove() {
- byte[] key = key(1);
- byte[] val = keyValue(1, 1);
-
- getAndPutToMs(key, val);
-
- getAndRemoveFromMs(key);
-
- Entry e = storage.get(key);
-
- assertEquals(2, storage.revision());
- assertEquals(2, storage.updateCounter());
- assertEquals(2, e.revision());
- assertTrue(e.tombstone());
- }
-
- @Test
- public void getAndPutAfterRemove() {
- byte[] key = key(1);
- byte[] val = keyValue(1, 1);
-
- getAndPutToMs(key, val);
-
- getAndRemoveFromMs(key);
-
- Entry e = getAndPutToMs(key, val);
-
- assertEquals(3, storage.revision());
- assertEquals(3, storage.updateCounter());
- assertEquals(2, e.revision());
- assertTrue(e.tombstone());
- }
-
@Test
public void invokeWithRevisionCondition_successBranch() {
byte[] key1 = key(1);
@@ -2437,137 +2093,6 @@ public abstract class
BasicOperationsKeyValueStorageTest extends AbstractKeyValu
verify(mockCallback, never()).onRevisionApplied(anyLong());
}
- @Test
- public void putGetRemoveCompact() {
- byte[] key1 = key(1);
- byte[] val11 = keyValue(1, 1);
- byte[] val13 = keyValue(1, 3);
-
- byte[] key2 = key(2);
- byte[] val22 = keyValue(2, 2);
-
- assertEquals(0, storage.revision());
- assertEquals(0, storage.updateCounter());
-
- // Previous entry is empty.
- Entry emptyEntry = getAndPutToMs(key1, val11);
-
- assertEquals(1, storage.revision());
- assertEquals(1, storage.updateCounter());
- assertTrue(emptyEntry.empty());
-
- // Entry with rev == 1.
- Entry e11 = storage.get(key1);
-
- assertFalse(e11.empty());
- assertFalse(e11.tombstone());
- assertArrayEquals(key1, e11.key());
- assertArrayEquals(val11, e11.value());
- assertEquals(1, e11.revision());
- assertEquals(1, e11.updateCounter());
- assertEquals(1, storage.revision());
- assertEquals(1, storage.updateCounter());
-
- // Previous entry is empty.
- emptyEntry = getAndPutToMs(key2, val22);
-
- assertEquals(2, storage.revision());
- assertEquals(2, storage.updateCounter());
- assertTrue(emptyEntry.empty());
-
- // Entry with rev == 2.
- Entry e2 = storage.get(key2);
-
- assertFalse(e2.empty());
- assertFalse(e2.tombstone());
- assertArrayEquals(key2, e2.key());
- assertArrayEquals(val22, e2.value());
- assertEquals(2, e2.revision());
- assertEquals(2, e2.updateCounter());
- assertEquals(2, storage.revision());
- assertEquals(2, storage.updateCounter());
-
- // Previous entry is not empty.
- e11 = getAndPutToMs(key1, val13);
-
- assertFalse(e11.empty());
- assertFalse(e11.tombstone());
- assertArrayEquals(key1, e11.key());
- assertArrayEquals(val11, e11.value());
- assertEquals(1, e11.revision());
- assertEquals(1, e11.updateCounter());
- assertEquals(3, storage.revision());
- assertEquals(3, storage.updateCounter());
-
- // Entry with rev == 3.
- Entry e13 = storage.get(key1);
-
- assertFalse(e13.empty());
- assertFalse(e13.tombstone());
- assertArrayEquals(key1, e13.key());
- assertArrayEquals(val13, e13.value());
- assertEquals(3, e13.revision());
- assertEquals(3, e13.updateCounter());
- assertEquals(3, storage.revision());
- assertEquals(3, storage.updateCounter());
-
- // Remove existing entry.
- Entry e22 = getAndRemoveFromMs(key2);
-
- assertFalse(e22.empty());
- assertFalse(e22.tombstone());
- assertArrayEquals(key2, e22.key());
- assertArrayEquals(val22, e22.value());
- assertEquals(2, e22.revision());
- assertEquals(2, e22.updateCounter());
- assertEquals(4, storage.revision()); // Storage revision is changed.
- assertEquals(4, storage.updateCounter());
-
- // Remove already removed entry.
- Entry tombstoneEntry = getAndRemoveFromMs(key2);
-
- assertFalse(tombstoneEntry.empty());
- assertTrue(tombstoneEntry.tombstone());
- assertEquals(4, storage.revision()); // Storage revision is not
changed.
- assertEquals(4, storage.updateCounter());
-
- // Compact and check that tombstones are removed.
- storage.compact(HybridTimestamp.MAX_VALUE);
-
- assertEquals(4, storage.revision());
- assertEquals(4, storage.updateCounter());
- assertTrue(getAndRemoveFromMs(key2).empty());
- assertTrue(storage.get(key2).empty());
-
- // Remove existing entry.
- e13 = getAndRemoveFromMs(key1);
-
- assertFalse(e13.empty());
- assertFalse(e13.tombstone());
- assertArrayEquals(key1, e13.key());
- assertArrayEquals(val13, e13.value());
- assertEquals(3, e13.revision());
- assertEquals(3, e13.updateCounter());
- assertEquals(5, storage.revision()); // Storage revision is changed.
- assertEquals(5, storage.updateCounter());
-
- // Remove already removed entry.
- tombstoneEntry = getAndRemoveFromMs(key1);
-
- assertFalse(tombstoneEntry.empty());
- assertTrue(tombstoneEntry.tombstone());
- assertEquals(5, storage.revision()); // // Storage revision is not
changed.
- assertEquals(5, storage.updateCounter());
-
- // Compact and check that tombstones are removed.
- storage.compact(HybridTimestamp.MAX_VALUE);
-
- assertEquals(5, storage.revision());
- assertEquals(5, storage.updateCounter());
- assertTrue(getAndRemoveFromMs(key1).empty());
- assertTrue(storage.get(key1).empty());
- }
-
private CompletableFuture<Void> watchExact(
byte[] key, long revision, int expectedNumCalls,
BiConsumer<WatchEvent, Integer> testCondition
) {
@@ -2650,22 +2175,6 @@ public abstract class BasicOperationsKeyValueStorageTest
extends AbstractKeyValu
storage.removeAll(keys, HybridTimestamp.MIN_VALUE);
}
- private Entry getAndRemoveFromMs(byte[] key) {
- return storage.getAndRemove(key, HybridTimestamp.MIN_VALUE);
- }
-
- private Entry getAndPutToMs(byte[] key, byte[] value) {
- return storage.getAndPut(key, value, HybridTimestamp.MIN_VALUE);
- }
-
- private Collection<Entry> getAndPutAllToMs(List<byte[]> keys, List<byte[]>
values) {
- return storage.getAndPutAll(keys, values, HybridTimestamp.MIN_VALUE);
- }
-
- private Collection<Entry> getAndRemoveAllFromMs(List<byte[]> keys) {
- return storage.getAndRemoveAll(keys, HybridTimestamp.MIN_VALUE);
- }
-
private boolean invokeOnMs(Condition condition, Collection<Operation>
success, Collection<Operation> failure) {
return storage.invoke(condition, success, failure,
HybridTimestamp.MIN_VALUE);
}
@@ -2673,4 +2182,4 @@ public abstract class BasicOperationsKeyValueStorageTest
extends AbstractKeyValu
private StatementResult invokeOnMs(If iif) {
return storage.invoke(iif, HybridTimestamp.MIN_VALUE);
}
-}
\ No newline at end of file
+}
diff --git
a/modules/metastorage/src/testFixtures/java/org/apache/ignite/internal/metastorage/server/SimpleInMemoryKeyValueStorage.java
b/modules/metastorage/src/testFixtures/java/org/apache/ignite/internal/metastorage/server/SimpleInMemoryKeyValueStorage.java
index e1cc224b4f..f130c60819 100644
---
a/modules/metastorage/src/testFixtures/java/org/apache/ignite/internal/metastorage/server/SimpleInMemoryKeyValueStorage.java
+++
b/modules/metastorage/src/testFixtures/java/org/apache/ignite/internal/metastorage/server/SimpleInMemoryKeyValueStorage.java
@@ -42,8 +42,6 @@ import java.util.function.LongConsumer;
import java.util.function.Predicate;
import org.apache.ignite.internal.failure.NoOpFailureProcessor;
import org.apache.ignite.internal.hlc.HybridTimestamp;
-import org.apache.ignite.internal.logger.IgniteLogger;
-import org.apache.ignite.internal.logger.Loggers;
import org.apache.ignite.internal.metastorage.Entry;
import org.apache.ignite.internal.metastorage.RevisionUpdateListener;
import org.apache.ignite.internal.metastorage.WatchListener;
@@ -59,8 +57,6 @@ import org.jetbrains.annotations.Nullable;
* Simple in-memory key/value storage for tests.
*/
public class SimpleInMemoryKeyValueStorage implements KeyValueStorage {
- private static final IgniteLogger LOG =
Loggers.forClass(SimpleInMemoryKeyValueStorage.class);
-
/** Lexicographical comparator. */
private static final Comparator<byte[]> CMP = Arrays::compareUnsigned;
@@ -153,20 +149,6 @@ public class SimpleInMemoryKeyValueStorage implements
KeyValueStorage {
}
}
- @Override
- public Entry getAndPut(byte[] key, byte[] bytes, HybridTimestamp opTs) {
- synchronized (mux) {
- long curRev = rev + 1;
-
- long lastRev = doPut(key, bytes, curRev);
-
- updateRevision(curRev, opTs);
-
- // Return previous value.
- return doGetValue(key, lastRev);
- }
- }
-
@Override
public void putAll(List<byte[]> keys, List<byte[]> values, HybridTimestamp
opTs) {
synchronized (mux) {
@@ -176,21 +158,6 @@ public class SimpleInMemoryKeyValueStorage implements
KeyValueStorage {
}
}
- @Override
- public Collection<Entry> getAndPutAll(List<byte[]> keys, List<byte[]>
values, HybridTimestamp opTs) {
- Collection<Entry> res;
-
- synchronized (mux) {
- long curRev = rev + 1;
-
- res = doGetAll(keys, curRev);
-
- doPutAll(curRev, keys, values, opTs);
- }
-
- return res;
- }
-
@Override
public Entry get(byte[] key) {
synchronized (mux) {
@@ -238,19 +205,6 @@ public class SimpleInMemoryKeyValueStorage implements
KeyValueStorage {
}
}
- @Override
- public Entry getAndRemove(byte[] key, HybridTimestamp opTs) {
- synchronized (mux) {
- Entry e = doGet(key, rev);
-
- if (e.empty() || e.tombstone()) {
- return e;
- }
-
- return getAndPut(key, TOMBSTONE, opTs);
- }
- }
-
@Override
public void removeAll(List<byte[]> keys, HybridTimestamp opTs) {
synchronized (mux) {
@@ -276,37 +230,6 @@ public class SimpleInMemoryKeyValueStorage implements
KeyValueStorage {
}
}
- @Override
- public Collection<Entry> getAndRemoveAll(List<byte[]> keys,
HybridTimestamp opTs) {
- Collection<Entry> res = new ArrayList<>(keys.size());
-
- synchronized (mux) {
- long curRev = rev + 1;
-
- List<byte[]> existingKeys = new ArrayList<>(keys.size());
-
- List<byte[]> vals = new ArrayList<>(keys.size());
-
- for (byte[] key : keys) {
- Entry e = doGet(key, rev);
-
- res.add(e);
-
- if (e.empty() || e.tombstone()) {
- continue;
- }
-
- existingKeys.add(key);
-
- vals.add(TOMBSTONE);
- }
-
- doPutAll(curRev, existingKeys, vals, opTs);
- }
-
- return res;
- }
-
@Override
public boolean invoke(Condition condition, Collection<Operation> success,
Collection<Operation> failure, HybridTimestamp opTs) {
synchronized (mux) {