vdmitrienko commented on code in PR #7064: URL: https://github.com/apache/ignite-3/pull/7064#discussion_r2560816940
########## modules/index/src/main/java/org/apache/ignite/internal/index/IndexBuildTaskStatisticsLoggingListener.java: ########## @@ -0,0 +1,180 @@ +/* + * 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.index; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; +import org.apache.ignite.internal.logger.IgniteLogger; +import org.apache.ignite.internal.logger.Loggers; +import org.apache.ignite.internal.tx.TxState; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; + +/** + * Listener that collects {@link IndexBuildTask} statistics during execution and logs the aggregated results when the index build + * completes. + */ +class IndexBuildTaskStatisticsLoggingListener implements IndexBuildTaskListener { + private static final IgniteLogger LOG = Loggers.forClass(IndexBuildTaskStatisticsLoggingListener.class); + + private final IndexBuildTaskId taskId; + + private final boolean afterDisasterRecovery; + + private final AtomicLong startTime = new AtomicLong(); + + private final AtomicInteger successfulRaftCallCount = new AtomicInteger(0); + + private final AtomicInteger failedRaftCallCount = new AtomicInteger(0); + + private final AtomicLong rowIndexedCount = new AtomicLong(0); Review Comment: I chose atomics because they guarantee atomicity for increment operations, unlike volatile primitives. This is not the case of `startTime`, which uses an `AtomicLong` only for consistency with the other fields. After thinking more about this, I realized that increment operations are not expected to happen concurrently. They may be executed by different threads, but not at the same time. -- 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]
