ibessonov commented on code in PR #800:
URL: https://github.com/apache/ignite-3/pull/800#discussion_r871477524


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/CheckpointProgressImpl.java:
##########
@@ -0,0 +1,265 @@
+/*
+ * 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.pagememory.persistence.checkpoint;
+
+import static 
org.apache.ignite.internal.pagememory.persistence.checkpoint.CheckpointState.FINISHED;
+import static 
org.apache.ignite.internal.pagememory.persistence.checkpoint.CheckpointState.LOCK_RELEASED;
+import static 
org.apache.ignite.internal.pagememory.persistence.checkpoint.CheckpointState.SCHEDULED;
+
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Data class representing the state of running/scheduled checkpoint.
+ */
+// TODO: IGNITE-16950 Check for a race between futureFor, transitTo and fail
+class CheckpointProgressImpl implements CheckpointProgress {
+    /** Checkpoint id. */
+    private final UUID id = UUID.randomUUID();
+
+    /** Scheduled time of checkpoint. */
+    private volatile long nextCheckpointNanos;
+
+    /** Current checkpoint state. */
+    private volatile AtomicReference<CheckpointState> state = new 
AtomicReference<>(SCHEDULED);
+
+    /** Future which would be finished when corresponds state is set. */
+    private final Map<CheckpointState, CompletableFuture<Void>> stateFutures = 
new ConcurrentHashMap<>();
+
+    /** Wakeup reason. */
+    private volatile String reason;
+
+    /** Number of dirty pages in current checkpoint at the beginning of 
checkpoint. */
+    private volatile int currCheckpointPagesCnt;
+
+    /** Cause of fail, which has happened during the checkpoint or {@code 
null} if checkpoint was successful. */
+    @Nullable
+    private volatile Throwable failCause;
+
+    /** Counter for written checkpoint pages. Not {@link null} only if 
checkpoint is running. */
+    @Nullable
+    private volatile AtomicInteger writtenPagesCntr;

Review Comment:
   I know that it's an old code, but why do these fields have to be volatile? 
And why can't we instantiate them in constructor?



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