Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docs/_docs/monitoring-metrics/system-views.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ Each row in this view represents a transaction object on the node where the view
|ORIGINATING_NODE_ID | UUID | ID of the node that initiated the current transaction object. For a transaction object mapped to a primary partition, this is the transaction initiator node; for a transaction object mapped to a backup partition, this is the node that owns the primary partition
|STATE | string | Current transaction state
|XID | UUID | Unique transaction identifier
|ORIGINATING_XID | UUID | Ttransaction ID on originating node
|LABEL | string | Transaction label
|START_TIME | long | Start time of the transaction on this node
|ISOLATION | string | Transaction isolation level
Expand All @@ -299,6 +300,39 @@ Each row in this view represents a transaction object on the node where the view
|TOP_VER | string | Topology version assigned to the transaction. If not assigned explicitly, it is a topology version of the latest partition exchange.
|===

== CACHE_EXPLICIT_LOCKS

This view exposes information about explicit locks acquired on the current node.
Explicit locks are acquired using the `Cache.lock(key)` API.

[{table_opts}]
|===
|NAME | TYPE | DESCRIPTION
|CACHE_ID | int | Cache ID
|KEY | string | Locked key
|THREAD_ID | long | ID of the thread that acquired the lock
|XID | UUID | Lock ID (unique identifier)
|===

== CACHE_KEY_LOCKS

This view exposes information about all locks (both explicit and transactional) requested for keys hosted on the current node.
This includes locks from remote nodes trying to access primary keys on this node.

[{table_opts}]
|===
|NAME | TYPE | DESCRIPTION
|CACHE_ID | int | Cache ID
|KEY | string | Locked key
|NODE_ID | UUID | ID of the node where the lock is hosted
|ORIGINATING_NODE_ID | UUID | ID of the node that initiated the lock request
|IS_OWNER | boolean | `True` if the lock is currently owned
|IS_TX | boolean | `True` if the lock is part of a transaction
|FLAGS | string | All flags for the lock
|XID | UUID | Current transaction ID (or explicit lock ID)
|ORIGINATING_XID | UUID | Originating transaction ID (or explicit lock ID)
|===

== NODES


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3291,7 +3291,7 @@ public void clearAllListener() {
* @param ver Cache version.
* @return Version represented as {@code IgniteUuid}.
*/
public static IgniteUuid asIgniteUuid(GridCacheVersion ver) {
return new IgniteUuid(new UUID(ver.topologyVersion(), ver.nodeOrderAndDrIdRaw()), ver.order());
public static @Nullable IgniteUuid asIgniteUuid(@Nullable GridCacheVersion ver) {
return ver == null ? null : new IgniteUuid(new UUID(ver.topologyVersion(), ver.nodeOrderAndDrIdRaw()), ver.order());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
import org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectEnum;
import org.apache.ignite.internal.management.SystemViewCommand;
import org.apache.ignite.internal.management.SystemViewTask;
import org.apache.ignite.internal.metric.SystemViewSelfTest.TestPredicate;
import org.apache.ignite.internal.metric.SystemViewSelfTest.TestRunnable;
import org.apache.ignite.internal.metric.SystemViewSelfTest.TestTransformer;
import org.apache.ignite.internal.metric.SystemViewExecutorsTest.TestRunnable;
import org.apache.ignite.internal.metric.SystemViewQueriesTest.TestPredicate;
import org.apache.ignite.internal.metric.SystemViewQueriesTest.TestTransformer;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState;
import org.apache.ignite.internal.processors.cache.metric.SqlViewExporterSpiTest.TestAffinityFunction;
Expand Down Expand Up @@ -93,8 +93,8 @@
import static org.apache.ignite.internal.management.SystemViewCommand.COLUMN_SEPARATOR;
import static org.apache.ignite.internal.managers.discovery.GridDiscoveryManager.NODES_SYS_VIEW;
import static org.apache.ignite.internal.managers.systemview.ScanQuerySystemView.SCAN_QRY_SYS_VIEW;
import static org.apache.ignite.internal.metric.SystemViewSelfTest.TEST_PREDICATE;
import static org.apache.ignite.internal.metric.SystemViewSelfTest.TEST_TRANSFORMER;
import static org.apache.ignite.internal.metric.SystemViewQueriesTest.TEST_PREDICATE;
import static org.apache.ignite.internal.metric.SystemViewQueriesTest.TEST_TRANSFORMER;
import static org.apache.ignite.internal.processors.cache.ClusterCachesInfo.CACHES_VIEW;
import static org.apache.ignite.internal.processors.cache.ClusterCachesInfo.CACHE_GRPS_VIEW;
import static org.apache.ignite.internal.processors.cache.GridCacheProcessor.CACHE_GRP_PAGE_LIST_VIEW;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.ignite.internal.processors.cache;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
import java.util.HashMap;
import java.util.Iterator;
Expand Down Expand Up @@ -216,6 +218,20 @@ public boolean isEmpty() {
}
}

/**
* @return Lock candidates.
*/
public Collection<GridCacheMvccCandidate> candidates() {
lock();

try {
return new ArrayList<>(F.flatCollections(cands.values()));
}
finally {
unlock();
}
}

/**
* Marks all candidates added for given key as owned.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,22 @@ public IgniteTxKey key() {
return parent0.txKey();
}

/** */
public String enabledFlags() {
SB sb = new SB();

for (Mask m : Mask.MASKS) {
if (m.bit(flags) != 0) {
if (sb.length() != 0)
sb.a(" | ");

sb.a(m.name());
}
}

return sb.toString();
}

/** {@inheritDoc} */
@Override public GridCacheMvccCandidate candidate(int idx) {
assert idx == 0 : idx;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -49,6 +50,8 @@
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.systemview.CacheExplicitLockViewWalker;
import org.apache.ignite.internal.systemview.CacheKeyLockViewWalker;
import org.apache.ignite.internal.util.GridBoundedConcurrentLinkedHashSet;
import org.apache.ignite.internal.util.GridConcurrentFactory;
import org.apache.ignite.internal.util.GridConcurrentHashSet;
Expand All @@ -67,6 +70,8 @@
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.spi.systemview.view.CacheExplicitLockView;
import org.apache.ignite.spi.systemview.view.CacheKeyLockView;
import org.apache.ignite.util.deque.FastSizeDeque;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -94,6 +99,18 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
private static final int MAX_NESTED_LSNR_CALLS =
getInteger(IGNITE_MAX_NESTED_LISTENER_CALLS, DFLT_MAX_NESTED_LISTENER_CALLS);

/** System view name for cache explicit locks. */
public static final String CACHE_EXPLICIT_LOCKS_VIEW = "cacheExplicitLocks";

/** System view description for cache explicit locks. */
public static final String CACHE_EXPLICIT_LOCKS_VIEW_DESC = "Explicit locks on cache keys";

/** System view name for cache locks. */
public static final String CACHE_KEY_LOCKS_VIEW = "cacheKeyLocks";

/** System view description for cache keys locks. */
public static final String CACHE_KEY_LOCKS_VIEW_DESC = "Held and queued locks on cache keys";

/** Pending locks per thread. */
private final ThreadLocal<Deque<GridCacheMvccCandidate>> pending = new ThreadLocal<>();

Expand Down Expand Up @@ -282,6 +299,34 @@ else if (log.isDebugEnabled())
pendingExplicit = GridConcurrentFactory.newMap();

cctx.gridEvents().addLocalEventListener(discoLsnr, EVT_NODE_FAILED, EVT_NODE_LEFT);

cctx.kernalContext().systemView().registerInnerCollectionView(
CACHE_EXPLICIT_LOCKS_VIEW,
CACHE_EXPLICIT_LOCKS_VIEW_DESC,
new CacheExplicitLockViewWalker(),
pendingExplicit.values(),
GridCacheExplicitLockSpan::candidates,
(threadId, lock) -> new CacheExplicitLockView(lock)
);

cctx.kernalContext().systemView().registerInnerCollectionView(
CACHE_KEY_LOCKS_VIEW,
CACHE_KEY_LOCKS_VIEW_DESC,
new CacheKeyLockViewWalker(),
locked.values(),
entry -> {
entry.lockEntry();
try {
GridCacheMvcc mvcc = entry.mvccExtras();
return mvcc != null ? mvcc.localCandidates() : Collections.emptyList();
}
finally {
entry.unlockEntry();
}
},
(entry, cand) -> new CacheKeyLockView(cand)
);

}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* 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.spi.systemview.view;

import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate;
import org.apache.ignite.internal.systemview.Order;
import org.apache.ignite.internal.systemview.SystemViewDescriptor;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.lang.IgniteUuid;

/**
* Cache explicit lock representation for a {@link SystemView}.
* Shows locks acquired on current node (not hosted by current node).
*/
@SystemViewDescriptor
public class CacheExplicitLockView {
/** */
@GridToStringExclude
private final GridCacheMvccCandidate cand;

/**
* @param cand Lock candidate
*/
public CacheExplicitLockView(GridCacheMvccCandidate cand) {
this.cand = cand;
}

/**
* @return Cache ID.
*/
@Order
public int cacheId() {
return cand.key().cacheId();
}

/**
* @return Key.
*/
@Order(1)
public String key() {
return cand.key().key().toString();
}

/**
* @return Thread ID.
*/
@Order(2)
public long threadId() {
return cand.threadId();
}

/**
* @return Version.
*/
@Order(3)
public IgniteUuid xid() {
return BinaryUtils.asIgniteUuid(cand.version());
}
}
Loading
Loading