TransactionsMXBeanImpl implements TransactionsMXBean { @Override public String getActiveTransactions(Long minDuration, Integer minSize, String prj, String consistentIds, String xid, String lbRegex, Integer limit, String order, boolean detailed, boolean kill) { try { IgniteCompute compute = ctx.cluster().get().compute(); VisorTxProjection proj = null; if (prj != null) { if ("clients".equals(prj)) proj = VisorTxProjection.CLIENT; else if ("servers".equals(prj)) proj = VisorTxProjection.SERVER; } List<String> consIds = null; if (consistentIds != null) consIds = Arrays.stream(consistentIds.split(",")).collect(Collectors.toList()); VisorTxSortOrder sortOrder = null; if (order != null) sortOrder = VisorTxSortOrder.valueOf(order.toUpperCase()); VisorTxTaskArg arg = new VisorTxTaskArg(kill ? VisorTxOperation.KILL : VisorTxOperation.LIST, limit, minDuration == null ? null : minDuration * 1000, minSize, null, proj, consIds, xid, lbRegex, sortOrder, null); Map<ClusterNode, VisorTxTaskResult> res = compute.execute(new VisorTxTask(), new VisorTaskArgument<>(ctx.cluster().get().localNode().id(), arg, false)); if (detailed) { StringWriter sw = new StringWriter(); PrintWriter w = new PrintWriter(sw); for (Map.Entry<ClusterNode, VisorTxTaskResult> entry : res.entrySet()) { if (entry.getValue().getInfos().isEmpty()) continue; ClusterNode key = entry.getKey(); w.println(key.toString()); for (VisorTxInfo info : entry.getValue().getInfos()) w.println(info.toUserString()); } w.flush(); return sw.toString(); } else { int cnt = 0; for (VisorTxTaskResult result : res.values()) cnt += result.getInfos().size(); return Integer.toString(cnt); } } catch (Exception e) { throw new RuntimeException(e.getMessage()); } } TransactionsMXBeanImpl(GridKernalContextImpl ctx); @Override String getActiveTransactions(Long minDuration, Integer minSize, String prj, String consistentIds,
        String xid, String lbRegex, Integer limit, String order, boolean detailed, boolean kill); @Override long getTxTimeoutOnPartitionMapExchange(); @Override void setTxTimeoutOnPartitionMapExchange(long timeout); @Override boolean getTxOwnerDumpRequestsAllowed(); @Override void setTxOwnerDumpRequestsAllowed(boolean allowed); @Override long getLongTransactionTimeDumpThreshold(); @Override void setLongTransactionTimeDumpThreshold(long threshold); @Override double getTransactionTimeDumpSamplesCoefficient(); @Override void setTransactionTimeDumpSamplesCoefficient(double coefficient); @Override int getTransactionTimeDumpSamplesPerSecondLimit(); @Override void setTransactionTimeDumpSamplesPerSecondLimit(int limit); @Override void setLongOperationsDumpTimeout(long timeout); @Override long getLongOperationsDumpTimeout(); @Override void setTxKeyCollisionsInterval(int timeout); @Override int getTxKeyCollisionsInterval(); @Override String toString();  }
@Test public void testBasic() throws Exception { IgniteEx ignite = startGrid(0); TransactionsMXBean bean = txMXBean(0); ignite.transactions().txStart(); ignite.cache(DEFAULT_CACHE_NAME).put(0, 0); String res = bean.getActiveTransactions(null, null, null, null, null, null, null, null, false, false); assertEquals("1", res); res = bean.getActiveTransactions(null, null, null, null, null, null, null, null, true, false); assertTrue(res.indexOf("Tx:") > 0); res = bean.getActiveTransactions(null, null, null, null, null, null, null, null, false, true); assertEquals("1", res); doSleep(500); res = bean.getActiveTransactions(null, null, null, null, null, null, null, null, false, false); assertEquals("0", res); }