tkalkirill commented on code in PR #3415:
URL: https://github.com/apache/ignite-3/pull/3415#discussion_r1525801246


##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/StorageDestroyedException.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * 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.storage;
+
+import org.apache.ignite.lang.ErrorGroups.Storage;
+
+/**
+ * Exception that is be thrown when trying to access a storage that is being 
destroyed or is already destroyed.
+ */
+public class StorageDestroyedException extends StorageException {
+    private static final long serialVersionUID = -7988332521347221109L;
+
+    /**
+     * Default constructor.
+     */
+    public StorageDestroyedException() {
+        this("Storage is already destroyed");
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param message Error message.
+     */
+    public StorageDestroyedException(String message) {
+        super(Storage.ALREADY_CLOSED_ERR, message);

Review Comment:
   Maybe we need a new code for the error, otherwise it's a little strange?



##########
modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/Index.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.storage.rocksdb;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import org.apache.ignite.internal.storage.StorageException;
+import 
org.apache.ignite.internal.storage.rocksdb.index.AbstractRocksDbIndexStorage;
+import org.apache.ignite.internal.storage.util.StorageState;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.rocksdb.RocksDBException;
+import org.rocksdb.WriteBatch;
+
+/**
+ * Represents an index for all its partitions.
+ */
+abstract class Index<S extends AbstractRocksDbIndexStorage> {
+    protected final ConcurrentMap<Integer, S> storages = new 
ConcurrentHashMap<>();

Review Comment:
   Lets rename to `storageByPartitionId`.



##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/StorageStates.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.storage;
+
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.ignite.internal.storage.util.StorageState;
+
+/**
+ * Utilities to work with storage states.
+ */
+public class StorageStates {
+    /**
+     * If not already in a terminal state, transitions to the supplied state 
and returns {@code true}, otherwise just returns {@code false}.
+     */
+    public static boolean transitionToTerminalState(StorageState targetState, 
AtomicReference<StorageState> stateRef) {

Review Comment:
   Lets move method to `org.apache.ignite.internal.storage.util.StorageUtils`.



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/PersistentPageMemoryTableStorage.java:
##########
@@ -364,7 +364,10 @@ private GcQueue createGcQueue(
     CompletableFuture<Void> 
destroyMvPartitionStorage(AbstractPageMemoryMvPartitionStorage 
mvPartitionStorage) {
         // It is enough for us to close the partition storage and its indexes 
(do not destroy). Prepare the data region, checkpointer, and
         // compactor to remove the partition, and then simply delete the 
partition file and its delta files.
-        mvPartitionStorage.close();
+        boolean transitioned = mvPartitionStorage.transitionToDestroyedState();

Review Comment:
   Variable is not needed right?



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/VolatilePageMemoryTableStorage.java:
##########
@@ -182,9 +182,14 @@ CompletableFuture<Void> 
clearStorageAndUpdateDataStructures(AbstractPageMemoryMv
     CompletableFuture<Void> 
destroyMvPartitionStorage(AbstractPageMemoryMvPartitionStorage 
mvPartitionStorage) {
         VolatilePageMemoryMvPartitionStorage volatilePartitionStorage = 
(VolatilePageMemoryMvPartitionStorage) mvPartitionStorage;
 
-        volatilePartitionStorage.transitionToDestroyingState();
+        boolean transitioned = 
volatilePartitionStorage.transitionToDestroyedState();

Review Comment:
   Variable is not needed right?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to