You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/12/03 05:55:09 UTC

[GitHub] [ignite] zstan commented on a change in pull request #8516: IGNITE-13775 checkpointRWLock wrapper refactoring.

zstan commented on a change in pull request #8516:
URL: https://github.com/apache/ignite/pull/8516#discussion_r534697499



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/util/ReentrantReadWriteLockWithTracking.java
##########
@@ -0,0 +1,330 @@
+/*
+ * 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.util;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.util.typedef.T2;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.internal.util.IgniteUtils.nl;
+
+/** */
+public class ReentrantReadWriteLockWithTracking implements ReadWriteLock {
+    /** Lock hold message. */
+    public static final String LOCK_HOLD_MESSAGE = "ReadLock held the lock more than ";
+
+    /** Lock print threshold. */
+    private long readLockThreshold;
+
+    /** Delegate instance. */
+    private final ReentrantReadWriteLock delegate = new ReentrantReadWriteLock();
+
+    /** Read lock holder. */
+    private ReentrantReadWriteLockWithTracking.ReadLock readLock;
+
+    /** Write lock holder. */
+    private ReentrantReadWriteLockWithTracking.WriteLock writeLock = new ReentrantReadWriteLockWithTracking.WriteLock(delegate);
+
+    /**
+     * ReentrantRWLock wrapper, provides additional trace info on {@link ReadLockWithTracking#unlock()} method, if someone
+     * holds the lock more than {@code readLockThreshold}.
+     *
+     * @param log Ignite logger.
+     * @param readLockThreshold ReadLock threshold timeout.
+     */
+    public ReentrantReadWriteLockWithTracking(IgniteLogger log, long readLockThreshold) {
+        readLock = new ReadLockWithTracking(delegate, log, readLockThreshold);
+
+        this.readLockThreshold = readLockThreshold;
+    }
+
+    /** Delegator implementation. */
+    public ReentrantReadWriteLockWithTracking() {
+        readLock = new ReentrantReadWriteLockWithTracking.ReadLock(delegate);
+    }
+
+    /** {@inheritDoc} */
+    @Override public ReentrantReadWriteLockWithTracking.ReadLock readLock() {
+        return readLock;
+    }
+
+    /** {@inheritDoc} */
+    @Override public ReentrantReadWriteLockWithTracking.WriteLock writeLock() {

Review comment:
       I can`t ... cause: protected java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock#WriteLock




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org