Search in sources :

Example 1 with ConditionInfo

use of org.apache.ignite.internal.metastorage.common.command.ConditionInfo 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 ConditionInfo

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

the class MetaStorageServiceImpl method toConditionInfo.

private static ConditionInfo toConditionInfo(@NotNull Condition condition) {
    ConditionInfo cnd = null;
    if (condition instanceof SimpleCondition) {
        Object obj = ((SimpleCondition) condition).inner();
        if (obj instanceof SimpleCondition.ExistenceCondition) {
            SimpleCondition.ExistenceCondition inner = (SimpleCondition.ExistenceCondition) obj;
            cnd = new SimpleConditionInfo(inner.key(), inner.type(), null, 0);
        } else if (obj instanceof SimpleCondition.TombstoneCondition) {
            SimpleCondition.TombstoneCondition inner = (SimpleCondition.TombstoneCondition) obj;
            cnd = new SimpleConditionInfo(inner.key(), inner.type(), null, 0);
        } else if (obj instanceof SimpleCondition.RevisionCondition) {
            SimpleCondition.RevisionCondition inner = (SimpleCondition.RevisionCondition) obj;
            cnd = new SimpleConditionInfo(inner.key(), inner.type(), null, inner.revision());
        } else if (obj instanceof SimpleCondition.ValueCondition) {
            SimpleCondition.ValueCondition inner = (SimpleCondition.ValueCondition) obj;
            cnd = new SimpleConditionInfo(inner.key(), inner.type(), inner.value(), 0);
        } else {
            assert false : "Unknown condition type: " + obj.getClass().getSimpleName();
        }
    } else if (condition instanceof CompoundCondition) {
        CompoundCondition cond = (CompoundCondition) condition;
        cnd = new CompoundConditionInfo(toConditionInfo(cond.leftCondition()), toConditionInfo(cond.rightCondition()), cond.compoundConditionType());
    } else {
        assert false : "Unknown condition type: " + condition.getClass().getSimpleName();
    }
    return cnd;
}
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) SimpleConditionInfo(org.apache.ignite.internal.metastorage.common.command.SimpleConditionInfo) CompoundConditionInfo(org.apache.ignite.internal.metastorage.common.command.CompoundConditionInfo)

Aggregations

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