Skip to content

Commit 110f8d2

Browse files
authored
IGNITE-12209: Transactions system view. (apache#6896)
1 parent 5fee450 commit 110f8d2

File tree

10 files changed

+749
-3
lines changed

10 files changed

+749
-3
lines changed

modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcMetadataSelfTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@ public void testGetAllView() throws Exception {
334334
"TABLES",
335335
"TASKS",
336336
"SERVICES",
337-
"CLIENT_CONNECTIONS"
337+
"CLIENT_CONNECTIONS",
338+
"TRANSACTIONS"
338339
));
339340

340341
Set<String> actViews = new HashSet<>();

modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinMetadataSelfTest.java

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,8 @@ public void testGetAllView() throws Exception {
343343
"SYS.LOCAL_SQL_RUNNING_QUERIES",
344344
"SYS.NODE_ATTRIBUTES",
345345
"SYS.TABLES",
346-
"SYS.CLIENT_CONNECTIONS"
346+
"SYS.CLIENT_CONNECTIONS",
347+
"SYS.TRANSACTIONS"
347348
))
348349
);
349350
}
@@ -761,9 +762,40 @@ public void testGetAllColumns() throws Exception {
761762
"SYS.CLIENT_CONNECTIONS.REMOTE_ADDRESS.null.2147483647",
762763
"SYS.CLIENT_CONNECTIONS.TYPE.null.2147483647",
763764
"SYS.CLIENT_CONNECTIONS.USER.null.2147483647",
764-
"SYS.CLIENT_CONNECTIONS.VERSION.null.2147483647"
765+
"SYS.CLIENT_CONNECTIONS.VERSION.null.2147483647",
766+
"SYS.TASKS.EXEC_NAME.null.2147483647",
767+
"SYS.TRANSACTIONS.LOCAL_NODE_ID.null.2147483647",
768+
"SYS.TRANSACTIONS.STATE.null.2147483647",
769+
"SYS.TRANSACTIONS.XID.null.2147483647",
770+
"SYS.TRANSACTIONS.LABEL.null.2147483647",
771+
"SYS.TRANSACTIONS.START_TIME.null.19",
772+
"SYS.TRANSACTIONS.ISOLATION.null.2147483647",
773+
"SYS.TRANSACTIONS.CONCURRENCY.null.2147483647",
774+
"SYS.TRANSACTIONS.COLOCATED.null.1",
775+
"SYS.TRANSACTIONS.DHT.null.1",
776+
"SYS.TRANSACTIONS.IMPLICIT.null.1",
777+
"SYS.TRANSACTIONS.IMPLICIT_SINGLE.null.1",
778+
"SYS.TRANSACTIONS.INTERNAL.null.1",
779+
"SYS.TRANSACTIONS.LOCAL.null.1",
780+
"SYS.TRANSACTIONS.NEAR.null.1",
781+
"SYS.TRANSACTIONS.ONE_PHASE_COMMIT.null.1",
782+
"SYS.TRANSACTIONS.SUBJECT_ID.null.2147483647",
783+
"SYS.TRANSACTIONS.SYSTEM.null.1",
784+
"SYS.TRANSACTIONS.THREAD_ID.null.19",
785+
"SYS.TRANSACTIONS.TIMEOUT.null.19",
786+
"SYS.TRANSACTIONS.DURATION.null.19",
787+
"SYS.TRANSACTIONS.ORIGINATING_NODE_ID.null.2147483647",
788+
"SYS.TRANSACTIONS.OTHER_NODE_ID.null.2147483647",
789+
"SYS.TRANSACTIONS.TOP_VER.null.2147483647",
790+
"SYS.TRANSACTIONS.KEYS_COUNT.null.10",
791+
"SYS.TRANSACTIONS.CACHE_IDS.null.2147483647"
765792
));
766793

794+
for (String col : actualSystemCols) {
795+
if (!expectedCols.contains(col))
796+
System.out.println(col);
797+
}
798+
767799
Assert.assertEquals(expectedCols, actualSystemCols);
768800
}
769801
}

modules/codegen/src/main/java/org/apache/ignite/codegen/SystemViewRowAttributeWalkerGenerator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.apache.ignite.spi.systemview.view.ComputeTaskView;
4343
import org.apache.ignite.spi.systemview.view.ServiceView;
4444
import org.apache.ignite.spi.systemview.SystemViewLocal;
45+
import org.apache.ignite.spi.systemview.view.TransactionView;
4546

4647
import static org.apache.ignite.codegen.MessageCodeGenerator.DFLT_SRC_DIR;
4748

@@ -75,6 +76,7 @@ public static void main(String[] args) throws Exception {
7576
gen.generateAndWrite(ServiceView.class, DFLT_SRC_DIR);
7677
gen.generateAndWrite(ComputeTaskView.class, DFLT_SRC_DIR);
7778
gen.generateAndWrite(ClientConnectionView.class, DFLT_SRC_DIR);
79+
gen.generateAndWrite(TransactionView.class, DFLT_SRC_DIR);
7880
}
7981

8082
/**

modules/core/src/main/java/org/apache/ignite/internal/managers/systemview/GridSystemViewManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.apache.ignite.internal.managers.systemview.walker.ClientConnectionViewWalker;
3535
import org.apache.ignite.internal.managers.systemview.walker.ComputeTaskViewWalker;
3636
import org.apache.ignite.internal.managers.systemview.walker.ServiceViewWalker;
37+
import org.apache.ignite.internal.managers.systemview.walker.TransactionViewWalker;
3738
import org.apache.ignite.spi.systemview.ReadOnlySystemViewRegistry;
3839
import org.apache.ignite.spi.systemview.SystemViewExporterSpi;
3940
import org.apache.ignite.spi.systemview.view.CacheGroupView;
@@ -43,6 +44,7 @@
4344
import org.apache.ignite.spi.systemview.view.ServiceView;
4445
import org.apache.ignite.spi.systemview.view.SystemView;
4546
import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker;
47+
import org.apache.ignite.spi.systemview.view.TransactionView;
4648
import org.jetbrains.annotations.NotNull;
4749
import org.jetbrains.annotations.Nullable;
4850

@@ -76,6 +78,7 @@ public GridSystemViewManager(GridKernalContext ctx) {
7678
registerWalker(ServiceView.class, new ServiceViewWalker());
7779
registerWalker(ComputeTaskView.class, new ComputeTaskViewWalker());
7880
registerWalker(ClientConnectionView.class, new ClientConnectionViewWalker());
81+
registerWalker(TransactionView.class, new TransactionViewWalker());
7982
}
8083

8184
/** {@inheritDoc} */
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.ignite.internal.managers.systemview.walker;
19+
20+
import java.util.UUID;
21+
import org.apache.ignite.lang.IgniteUuid;
22+
import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker;
23+
import org.apache.ignite.spi.systemview.view.TransactionView;
24+
import org.apache.ignite.transactions.TransactionConcurrency;
25+
import org.apache.ignite.transactions.TransactionIsolation;
26+
import org.apache.ignite.transactions.TransactionState;
27+
28+
/**
29+
* Generated by {@code org.apache.ignite.codegen.SystemViewRowAttributeWalkerGenerator}.
30+
* {@link TransactionView} attributes walker.
31+
*
32+
* @see TransactionView
33+
*/
34+
public class TransactionViewWalker implements SystemViewRowAttributeWalker<TransactionView> {
35+
/** {@inheritDoc} */
36+
@Override public void visitAll(AttributeVisitor v) {
37+
v.accept(0, "originatingNodeId", UUID.class);
38+
v.accept(1, "state", TransactionState.class);
39+
v.accept(2, "xid", IgniteUuid.class);
40+
v.accept(3, "label", String.class);
41+
v.accept(4, "startTime", long.class);
42+
v.accept(5, "isolation", TransactionIsolation.class);
43+
v.accept(6, "concurrency", TransactionConcurrency.class);
44+
v.accept(7, "keysCount", int.class);
45+
v.accept(8, "cacheIds", String.class);
46+
v.accept(9, "colocated", boolean.class);
47+
v.accept(10, "dht", boolean.class);
48+
v.accept(11, "duration", long.class);
49+
v.accept(12, "implicit", boolean.class);
50+
v.accept(13, "implicitSingle", boolean.class);
51+
v.accept(14, "internal", boolean.class);
52+
v.accept(15, "local", boolean.class);
53+
v.accept(16, "localNodeId", UUID.class);
54+
v.accept(17, "near", boolean.class);
55+
v.accept(18, "onePhaseCommit", boolean.class);
56+
v.accept(19, "otherNodeId", UUID.class);
57+
v.accept(20, "subjectId", UUID.class);
58+
v.accept(21, "system", boolean.class);
59+
v.accept(22, "threadId", long.class);
60+
v.accept(23, "timeout", long.class);
61+
v.accept(24, "topVer", String.class);
62+
}
63+
64+
/** {@inheritDoc} */
65+
@Override public void visitAll(TransactionView row, AttributeWithValueVisitor v) {
66+
v.accept(0, "originatingNodeId", UUID.class, row.originatingNodeId());
67+
v.accept(1, "state", TransactionState.class, row.state());
68+
v.accept(2, "xid", IgniteUuid.class, row.xid());
69+
v.accept(3, "label", String.class, row.label());
70+
v.acceptLong(4, "startTime", row.startTime());
71+
v.accept(5, "isolation", TransactionIsolation.class, row.isolation());
72+
v.accept(6, "concurrency", TransactionConcurrency.class, row.concurrency());
73+
v.acceptInt(7, "keysCount", row.keysCount());
74+
v.accept(8, "cacheIds", String.class, row.cacheIds());
75+
v.acceptBoolean(9, "colocated", row.colocated());
76+
v.acceptBoolean(10, "dht", row.dht());
77+
v.acceptLong(11, "duration", row.duration());
78+
v.acceptBoolean(12, "implicit", row.implicit());
79+
v.acceptBoolean(13, "implicitSingle", row.implicitSingle());
80+
v.acceptBoolean(14, "internal", row.internal());
81+
v.acceptBoolean(15, "local", row.local());
82+
v.accept(16, "localNodeId", UUID.class, row.localNodeId());
83+
v.acceptBoolean(17, "near", row.near());
84+
v.acceptBoolean(18, "onePhaseCommit", row.onePhaseCommit());
85+
v.accept(19, "otherNodeId", UUID.class, row.otherNodeId());
86+
v.accept(20, "subjectId", UUID.class, row.subjectId());
87+
v.acceptBoolean(21, "system", row.system());
88+
v.acceptLong(22, "threadId", row.threadId());
89+
v.acceptLong(23, "timeout", row.timeout());
90+
v.accept(24, "topVer", String.class, row.topVer());
91+
}
92+
93+
/** {@inheritDoc} */
94+
@Override public int count() {
95+
return 25;
96+
}
97+
}

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
import org.apache.ignite.internal.processors.cache.transactions.TxDeadlockDetection.TxDeadlockFuture;
7979
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
8080
import org.apache.ignite.internal.processors.cluster.BaselineTopology;
81+
import org.apache.ignite.internal.util.lang.gridfunc.ReadOnlyCollectionView2X;
82+
import org.apache.ignite.spi.systemview.view.TransactionView;
8183
import org.apache.ignite.internal.processors.metric.impl.HitRateMetric;
8284
import org.apache.ignite.internal.processors.timeout.GridTimeoutObjectAdapter;
8385
import org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException;
@@ -142,6 +144,12 @@
142144
* Cache transaction manager.
143145
*/
144146
public class IgniteTxManager extends GridCacheSharedManagerAdapter {
147+
/** */
148+
public static final String TXS_MON_LIST = "transactions";
149+
150+
/** */
151+
public static final String TXS_MON_LIST_DESC = "Running transactions";
152+
145153
/** Default maximum number of transactions that have completed. */
146154
private static final int DFLT_MAX_COMPLETED_TX_CNT = 262144; // 2^18
147155

@@ -343,6 +351,11 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
343351
this.logTxRecords = IgniteSystemProperties.getBoolean(IGNITE_WAL_LOG_TX_RECORDS, false);
344352

345353
cctx.txMetrics().onTxManagerStarted();
354+
355+
cctx.kernalContext().systemView().registerView(TXS_MON_LIST, TXS_MON_LIST_DESC,
356+
TransactionView.class,
357+
new ReadOnlyCollectionView2X<>(idMap.values(), nearIdMap.values()),
358+
TransactionView::new);
346359
}
347360

348361
/** {@inheritDoc} */

0 commit comments

Comments
 (0)