use of org.apache.ignite.internal.visor.tx.VisorTxSortOrder in project ignite by apache.
the class TxCommands method parseArguments.
/**
* @param argIter Argument iterator.
*/
@Override
public void parseArguments(CommandArgIterator argIter) {
VisorTxProjection proj = null;
Integer limit = null;
VisorTxSortOrder sortOrder = null;
Long duration = null;
Integer size = null;
String lbRegex = null;
List<String> consistentIds = null;
VisorTxOperation op = VisorTxOperation.LIST;
String xid = null;
TxVerboseId txVerboseId = null;
while (true) {
String str = argIter.peekNextArg();
if (str == null)
break;
TxCommandArg arg = CommandArgUtils.of(str, TxCommandArg.class);
if (arg == null)
break;
switch(arg) {
case TX_LIMIT:
argIter.nextArg("");
limit = (int) argIter.nextNonNegativeLongArg(TxCommandArg.TX_LIMIT.toString());
break;
case TX_ORDER:
argIter.nextArg("");
sortOrder = VisorTxSortOrder.valueOf(argIter.nextArg(TxCommandArg.TX_ORDER.toString()).toUpperCase());
break;
case TX_SERVERS:
argIter.nextArg("");
proj = VisorTxProjection.SERVER;
break;
case TX_CLIENTS:
argIter.nextArg("");
proj = VisorTxProjection.CLIENT;
break;
case TX_NODES:
argIter.nextArg("");
Set<String> ids = argIter.nextStringSet(TxCommandArg.TX_NODES.toString());
if (ids.isEmpty()) {
throw new IllegalArgumentException("Consistent id list is empty.");
}
consistentIds = new ArrayList<>(ids);
break;
case TX_DURATION:
argIter.nextArg("");
duration = argIter.nextNonNegativeLongArg(TxCommandArg.TX_DURATION.toString()) * 1000L;
break;
case TX_SIZE:
argIter.nextArg("");
size = (int) argIter.nextNonNegativeLongArg(TxCommandArg.TX_SIZE.toString());
break;
case TX_LABEL:
argIter.nextArg("");
lbRegex = argIter.nextArg(TxCommandArg.TX_LABEL.toString());
try {
Pattern.compile(lbRegex);
} catch (PatternSyntaxException ignored) {
throw new IllegalArgumentException("Illegal regex syntax");
}
break;
case TX_XID:
argIter.nextArg("");
xid = argIter.nextArg(TxCommandArg.TX_XID.toString());
break;
case TX_KILL:
argIter.nextArg("");
op = VisorTxOperation.KILL;
break;
case TX_INFO:
argIter.nextArg("");
op = VisorTxOperation.INFO;
txVerboseId = TxVerboseId.fromString(argIter.nextArg(TX_INFO.argName()));
break;
default:
throw new AssertionError();
}
}
if (proj != null && consistentIds != null)
throw new IllegalArgumentException("Projection can't be used together with list of consistent ids.");
this.args = new VisorTxTaskArg(op, limit, duration, size, null, proj, consistentIds, xid, lbRegex, sortOrder, txVerboseId);
}
use of org.apache.ignite.internal.visor.tx.VisorTxSortOrder in project ignite by apache.
the class TransactionsMXBeanImpl method getActiveTransactions.
/**
* {@inheritDoc}
*/
@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());
}
}
Aggregations