Search in sources :

Example 1 with TxVerboseId

use of org.apache.ignite.internal.visor.tx.TxVerboseId in project ignite by apache.

the class TxCommands method transactionInfo.

/**
 * Executes --tx --info command.
 *
 * @param client Client.
 */
private Object transactionInfo(GridClient client, GridClientConfiguration conf) throws GridClientException {
    checkFeatureSupportedByCluster(client, IgniteFeatures.TX_INFO_COMMAND, true, true);
    GridCacheVersion nearXidVer = executeTask(client, FetchNearXidVersionTask.class, args.txInfoArgument(), conf);
    boolean histMode = false;
    if (nearXidVer != null) {
        logger.info("Resolved transaction near XID version: " + nearXidVer);
        args.txInfoArgument(new TxVerboseId(null, nearXidVer));
    } else {
        logger.info("Active transactions not found.");
        if (args.txInfoArgument().gridCacheVersion() != null) {
            logger.info("Will try to peek history to find out whether transaction was committed / rolled back.");
            histMode = true;
        } else {
            logger.info("You can specify transaction in GridCacheVersion format in order to peek history " + "to find out whether transaction was committed / rolled back.");
            return null;
        }
    }
    Map<ClusterNode, VisorTxTaskResult> res = executeTask(client, VisorTxTask.class, args, conf);
    if (histMode)
        printTxInfoHistoricalResult(res);
    else
        printTxInfoResult(res);
    return res;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) TxVerboseId(org.apache.ignite.internal.visor.tx.TxVerboseId) VisorTxTaskResult(org.apache.ignite.internal.visor.tx.VisorTxTaskResult)

Example 2 with TxVerboseId

use of org.apache.ignite.internal.visor.tx.TxVerboseId 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);
}
Also used : TxVerboseId(org.apache.ignite.internal.visor.tx.TxVerboseId) VisorTxTaskArg(org.apache.ignite.internal.visor.tx.VisorTxTaskArg) VisorTxProjection(org.apache.ignite.internal.visor.tx.VisorTxProjection) VisorTxOperation(org.apache.ignite.internal.visor.tx.VisorTxOperation) VisorTxSortOrder(org.apache.ignite.internal.visor.tx.VisorTxSortOrder) PatternSyntaxException(java.util.regex.PatternSyntaxException)

Aggregations

TxVerboseId (org.apache.ignite.internal.visor.tx.TxVerboseId)2 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 GridCacheVersion (org.apache.ignite.internal.processors.cache.version.GridCacheVersion)1 VisorTxOperation (org.apache.ignite.internal.visor.tx.VisorTxOperation)1 VisorTxProjection (org.apache.ignite.internal.visor.tx.VisorTxProjection)1 VisorTxSortOrder (org.apache.ignite.internal.visor.tx.VisorTxSortOrder)1 VisorTxTaskArg (org.apache.ignite.internal.visor.tx.VisorTxTaskArg)1 VisorTxTaskResult (org.apache.ignite.internal.visor.tx.VisorTxTaskResult)1