Search in sources :

Example 1 with OperationInfo

use of org.apache.ignite.internal.metastorage.common.command.OperationInfo in project ignite-3 by apache.

the class MetaStorageServiceImpl method invoke.

/**
 * {@inheritDoc}
 */
@Override
@NotNull
public CompletableFuture<Boolean> invoke(@NotNull Condition condition, @NotNull Collection<Operation> success, @NotNull Collection<Operation> failure) {
    ConditionInfo cond = toConditionInfo(condition);
    List<OperationInfo> successOps = toOperationInfos(success);
    List<OperationInfo> failureOps = toOperationInfos(failure);
    return metaStorageRaftGrpSvc.run(new InvokeCommand(cond, successOps, failureOps));
}
Also used : ConditionInfo(org.apache.ignite.internal.metastorage.common.command.ConditionInfo) SimpleConditionInfo(org.apache.ignite.internal.metastorage.common.command.SimpleConditionInfo) CompoundConditionInfo(org.apache.ignite.internal.metastorage.common.command.CompoundConditionInfo) OperationInfo(org.apache.ignite.internal.metastorage.common.command.OperationInfo) InvokeCommand(org.apache.ignite.internal.metastorage.common.command.InvokeCommand) MultiInvokeCommand(org.apache.ignite.internal.metastorage.common.command.MultiInvokeCommand) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with OperationInfo

use of org.apache.ignite.internal.metastorage.common.command.OperationInfo in project ignite-3 by apache.

the class MetaStorageServiceImpl method toOperationInfos.

private static List<OperationInfo> toOperationInfos(Collection<Operation> ops) {
    List<OperationInfo> res = new ArrayList<>(ops.size());
    for (Operation op : ops) {
        OperationInfo info = null;
        if (op.type() == OperationType.NO_OP) {
            info = new OperationInfo(null, null, OperationType.NO_OP);
        } else if (op.type() == OperationType.REMOVE) {
            info = new OperationInfo(((Operation.RemoveOp) op.inner()).key(), null, OperationType.REMOVE);
        } else if (op.type() == OperationType.PUT) {
            Operation.PutOp inner = (Operation.PutOp) op.inner();
            info = new OperationInfo(inner.key(), inner.value(), OperationType.PUT);
        } else {
            assert false : "Unknown operation type " + op.type();
        }
        res.add(info);
    }
    return res;
}
Also used : OperationInfo(org.apache.ignite.internal.metastorage.common.command.OperationInfo) ArrayList(java.util.ArrayList)

Aggregations

OperationInfo (org.apache.ignite.internal.metastorage.common.command.OperationInfo)2 ArrayList (java.util.ArrayList)1 CompoundConditionInfo (org.apache.ignite.internal.metastorage.common.command.CompoundConditionInfo)1 ConditionInfo (org.apache.ignite.internal.metastorage.common.command.ConditionInfo)1 InvokeCommand (org.apache.ignite.internal.metastorage.common.command.InvokeCommand)1 MultiInvokeCommand (org.apache.ignite.internal.metastorage.common.command.MultiInvokeCommand)1 SimpleConditionInfo (org.apache.ignite.internal.metastorage.common.command.SimpleConditionInfo)1 NotNull (org.jetbrains.annotations.NotNull)1