当前位置: 首页>>代码示例>>Java>>正文


Java Modification类代码示例

本文整理汇总了Java中org.opendaylight.controller.cluster.datastore.modification.Modification的典型用法代码示例。如果您正苦于以下问题:Java Modification类的具体用法?Java Modification怎么用?Java Modification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Modification类属于org.opendaylight.controller.cluster.datastore.modification包,在下文中一共展示了Modification类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: commitNextBatch

import org.opendaylight.controller.cluster.datastore.modification.Modification; //导入依赖的package包/类
void commitNextBatch(EntityOwnershipShard shard) {
    if (inflightCommit != null || pendingModifications.isEmpty() || !shard.hasLeader()) {
        return;
    }

    inflightCommit = newBatchedModifications();
    Iterator<Modification> iter = pendingModifications.iterator();
    while (iter.hasNext()) {
        inflightCommit.addModification(iter.next());
        iter.remove();
        if (inflightCommit.getModifications().size()
                >= shard.getDatastoreContext().getShardBatchedModificationCount()) {
            break;
        }
    }

    log.debug("Committing next BatchedModifications {}, size {}", inflightCommit.getTransactionId(),
            inflightCommit.getModifications().size());

    shard.tryCommitModifications(inflightCommit);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:22,代码来源:EntityOwnershipShardCommitCoordinator.java

示例2: commitModifications

import org.opendaylight.controller.cluster.datastore.modification.Modification; //导入依赖的package包/类
void commitModifications(List<Modification> modifications, EntityOwnershipShard shard) {
    if (modifications.isEmpty()) {
        return;
    }

    boolean hasLeader = shard.hasLeader();
    if (inflightCommit != null || !hasLeader) {
        if (log.isDebugEnabled()) {
            log.debug("{} - adding modifications to pending",
                    inflightCommit != null ? "A commit is inflight" : "No shard leader");
        }

        pendingModifications.addAll(modifications);
    } else {
        inflightCommit = newBatchedModifications();
        inflightCommit.addModifications(modifications);
        shard.tryCommitModifications(inflightCommit);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:20,代码来源:EntityOwnershipShardCommitCoordinator.java

示例3: canForwardModificationToNewLeader

import org.opendaylight.controller.cluster.datastore.modification.Modification; //导入依赖的package包/类
private boolean canForwardModificationToNewLeader(Modification mod) {
    // If this is a WRITE of entity owner we don't want to forward it to a new leader since the criteria used
    // to determine the new owner might be stale.
    if (mod instanceof WriteModification) {
        WriteModification writeMod = (WriteModification)mod;
        boolean canForward = !writeMod.getPath().getLastPathArgument().getNodeType().equals(ENTITY_OWNER_QNAME);

        if (!canForward) {
            log.debug("Not forwarding WRITE modification for {} to new leader", writeMod.getPath());
        }

        return canForward;
    }

    return true;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:EntityOwnershipShardCommitCoordinator.java

示例4: selectNewOwnerForEntitiesOwnedBy

import org.opendaylight.controller.cluster.datastore.modification.Modification; //导入依赖的package包/类
private void selectNewOwnerForEntitiesOwnedBy(final Set<String> ownedBy) {
    final List<Modification> modifications = new ArrayList<>();
    searchForEntitiesOwnedBy(ownedBy, (entityTypeNode, entityNode) -> {
        YangInstanceIdentifier entityPath = YangInstanceIdentifier.builder(ENTITY_TYPES_PATH)
                .node(entityTypeNode.getIdentifier()).node(ENTITY_NODE_ID).node(entityNode.getIdentifier())
                .node(ENTITY_OWNER_NODE_ID).build();
        String newOwner = newOwner(getCurrentOwner(entityPath), getCandidateNames(entityNode),
                getEntityOwnerElectionStrategy(entityPath));

        if (!newOwner.isEmpty()) {
            LOG.debug("{}: Found entity {}, writing new owner {}", persistenceId(), entityPath, newOwner);

            modifications.add(new WriteModification(entityPath,
                ImmutableNodes.leafNode(ENTITY_OWNER_NODE_ID, newOwner)));

        } else {
            LOG.debug("{}: Found entity {} but no other candidates - not clearing owner", persistenceId(),
                    entityPath, newOwner);
        }
    });

    commitCoordinator.commitModifications(modifications, this);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:EntityOwnershipShard.java

示例5: removeCandidateFromEntities

import org.opendaylight.controller.cluster.datastore.modification.Modification; //导入依赖的package包/类
private void removeCandidateFromEntities(final MemberName member) {
    final List<Modification> modifications = new ArrayList<>();
    searchForEntities((entityTypeNode, entityNode) -> {
        if (hasCandidate(entityNode, member)) {
            YangInstanceIdentifier entityId =
                    (YangInstanceIdentifier) entityNode.getIdentifier().getKeyValues().get(ENTITY_ID_QNAME);
            YangInstanceIdentifier candidatePath = candidatePath(
                    entityTypeNode.getIdentifier().getKeyValues().get(ENTITY_TYPE_QNAME).toString(),
                    entityId, member.getName());

            LOG.info("{}: Found entity {}, removing candidate {}, path {}", persistenceId(), entityId,
                    member, candidatePath);

            modifications.add(new DeleteModification(candidatePath));
        }
    });

    commitCoordinator.commitModifications(modifications, this);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:20,代码来源:EntityOwnershipShard.java

示例6: verifyBatchedModifications

import org.opendaylight.controller.cluster.datastore.modification.Modification; //导入依赖的package包/类
protected void verifyBatchedModifications(final Object message, final boolean expIsReady,
        final boolean expIsDoCommitOnReady, final Modification... expected) {
    assertEquals("Message type", BatchedModifications.class, message.getClass());
    BatchedModifications batchedModifications = (BatchedModifications)message;
    assertEquals("BatchedModifications size", expected.length, batchedModifications.getModifications().size());
    assertEquals("isReady", expIsReady, batchedModifications.isReady());
    assertEquals("isDoCommitOnReady", expIsDoCommitOnReady, batchedModifications.isDoCommitOnReady());
    for (int i = 0; i < batchedModifications.getModifications().size(); i++) {
        Modification actual = batchedModifications.getModifications().get(i);
        assertEquals("Modification type", expected[i].getClass(), actual.getClass());
        assertEquals("getPath", ((AbstractModification)expected[i]).getPath(),
                ((AbstractModification)actual).getPath());
        if (actual instanceof WriteModification) {
            assertEquals("getData", ((WriteModification)expected[i]).getData(),
                    ((WriteModification)actual).getData());
        }
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:19,代码来源:AbstractTransactionProxyTest.java

示例7: batchedModifications

import org.opendaylight.controller.cluster.datastore.modification.Modification; //导入依赖的package包/类
@SuppressWarnings("checkstyle:IllegalCatch")
private void batchedModifications(BatchedModifications batched) {
    if (checkClosed()) {
        if (batched.isReady()) {
            getSelf().tell(PoisonPill.getInstance(), getSelf());
        }
        return;
    }

    try {
        for (Modification modification: batched.getModifications()) {
            modification.apply(transaction.getSnapshot());
        }

        totalBatchedModificationsReceived++;
        if (batched.isReady()) {
            if (lastBatchedModificationsException != null) {
                throw lastBatchedModificationsException;
            }

            if (totalBatchedModificationsReceived != batched.getTotalMessagesSent()) {
                throw new IllegalStateException(String.format(
                        "The total number of batched messages received %d does not match the number sent %d",
                        totalBatchedModificationsReceived, batched.getTotalMessagesSent()));
            }

            readyTransaction(false, batched.isDoCommitOnReady(), batched.getVersion());
        } else {
            getSender().tell(new BatchedModificationsReply(batched.getModifications().size()), getSelf());
        }
    } catch (Exception e) {
        lastBatchedModificationsException = e;
        getSender().tell(new akka.actor.Status.Failure(e), getSelf());

        if (batched.isReady()) {
            getSelf().tell(PoisonPill.getInstance(), getSelf());
        }
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:40,代码来源:ShardWriteTransaction.java

示例8: batchModification

import org.opendaylight.controller.cluster.datastore.modification.Modification; //导入依赖的package包/类
private void batchModification(Modification modification) {
    incrementModificationCount();
    if (batchedModifications == null) {
        batchedModifications = newBatchedModifications();
    }

    batchedModifications.addModification(modification);

    if (batchedModifications.getModifications().size()
            >= actorContext.getDatastoreContext().getShardBatchedModificationCount()) {
        sendBatchedModifications();
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:14,代码来源:RemoteTransactionContext.java

示例9: applyModifications

import org.opendaylight.controller.cluster.datastore.modification.Modification; //导入依赖的package包/类
@SuppressWarnings("checkstyle:IllegalCatch")
void applyModifications(final Iterable<Modification> modifications) {
    totalBatchedModificationsReceived++;
    if (lastBatchedModificationsException == null) {
        for (Modification modification : modifications) {
            try {
                modification.apply(transaction.getSnapshot());
            } catch (RuntimeException e) {
                lastBatchedModificationsException = e;
                throw e;
            }
        }
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:15,代码来源:CohortEntry.java

示例10: possiblyPrunePendingCommits

import org.opendaylight.controller.cluster.datastore.modification.Modification; //导入依赖的package包/类
private void possiblyPrunePendingCommits(EntityOwnershipShard shard, boolean isLeader) {
    // If we were the leader and transitioned to follower, we'll try to forward pending commits to the new leader.
    // However certain commits, e.g. entity owner changes, should only be committed by a valid leader as the
    // criteria used to determine the commit may be stale. Since we're no longer a valid leader, we should not
    // forward such commits thus we prune the pending modifications. We still should forward local candidate change
    // commits.
    if (shard.hasLeader() && !isLeader) {
        // We may have already submitted a transaction for replication and commit. We don't need the base Shard to
        // forward it since we also have it stored in the inflightCommit and handle retries. So we just clear
        // pending transactions and drop them.
        shard.convertPendingTransactionsToMessages();

        // Prune the inflightCommit.
        if (inflightCommit != null) {
            inflightCommit = pruneModifications(inflightCommit);
        }

        // Prune the subsequent pending modifications.
        Iterator<Modification> iter = pendingModifications.iterator();
        while (iter.hasNext()) {
            Modification mod = iter.next();
            if (!canForwardModificationToNewLeader(mod)) {
                iter.remove();
            }
        }
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:28,代码来源:EntityOwnershipShardCommitCoordinator.java

示例11: pruneModifications

import org.opendaylight.controller.cluster.datastore.modification.Modification; //导入依赖的package包/类
@Nullable
private BatchedModifications pruneModifications(BatchedModifications toPrune) {
    BatchedModifications prunedModifications = new BatchedModifications(toPrune.getTransactionId(),
            toPrune.getVersion());
    prunedModifications.setDoCommitOnReady(toPrune.isDoCommitOnReady());
    prunedModifications.setReady(toPrune.isReady());
    prunedModifications.setTotalMessagesSent(toPrune.getTotalMessagesSent());
    for (Modification mod: toPrune.getModifications()) {
        if (canForwardModificationToNewLeader(mod)) {
            prunedModifications.addModification(mod);
        }
    }

    return !prunedModifications.getModifications().isEmpty() ? prunedModifications : null;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:16,代码来源:EntityOwnershipShardCommitCoordinator.java

示例12: testToAndFromBinary

import org.opendaylight.controller.cluster.datastore.modification.Modification; //导入依赖的package包/类
@Test
public void testToAndFromBinary() {
    TipProducingDataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
    dataTree.setSchemaContext(TestModel.createTestContext());
    DataTreeModification modification = dataTree.takeSnapshot().newModification();

    ContainerNode writeData = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
    new WriteModification(TestModel.TEST_PATH, writeData).apply(modification);
    MapNode mergeData = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build();
    new MergeModification(TestModel.OUTER_LIST_PATH, mergeData).apply(modification);

    TransactionIdentifier txId = nextTransactionId();
    ReadyLocalTransaction readyMessage = new ReadyLocalTransaction(txId, modification, true);

    ReadyLocalTransactionSerializer serializer = new ReadyLocalTransactionSerializer();

    byte[] bytes = serializer.toBinary(readyMessage);

    Object deserialized = serializer.fromBinary(bytes, ReadyLocalTransaction.class);

    assertNotNull("fromBinary returned null", deserialized);
    assertEquals("fromBinary return type", BatchedModifications.class, deserialized.getClass());
    BatchedModifications batched = (BatchedModifications)deserialized;
    assertEquals("getTransactionID", txId, batched.getTransactionId());
    assertEquals("getVersion", DataStoreVersions.CURRENT_VERSION, batched.getVersion());

    List<Modification> batchedMods = batched.getModifications();
    assertEquals("getModifications size", 2, batchedMods.size());

    Modification mod = batchedMods.get(0);
    assertEquals("Modification type", WriteModification.class, mod.getClass());
    assertEquals("Modification getPath", TestModel.TEST_PATH, ((WriteModification)mod).getPath());
    assertEquals("Modification getData", writeData, ((WriteModification)mod).getData());

    mod = batchedMods.get(1);
    assertEquals("Modification type", MergeModification.class, mod.getClass());
    assertEquals("Modification getPath", TestModel.OUTER_LIST_PATH, ((MergeModification)mod).getPath());
    assertEquals("Modification getData", mergeData, ((MergeModification)mod).getData());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:40,代码来源:ReadyLocalTransactionSerializerTest.java

示例13: verifyOneBatchedModification

import org.opendaylight.controller.cluster.datastore.modification.Modification; //导入依赖的package包/类
protected void verifyOneBatchedModification(final ActorRef actorRef, final Modification expected,
        final boolean expIsReady) {
    List<BatchedModifications> batchedModifications = captureBatchedModifications(actorRef);
    assertEquals("Captured BatchedModifications count", 1, batchedModifications.size());

    verifyBatchedModifications(batchedModifications.get(0), expIsReady, expIsReady, expected);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:8,代码来源:AbstractTransactionProxyTest.java

示例14: commitModification

import org.opendaylight.controller.cluster.datastore.modification.Modification; //导入依赖的package包/类
void commitModification(Modification modification, EntityOwnershipShard shard) {
    commitModifications(ImmutableList.of(modification), shard);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:4,代码来源:EntityOwnershipShardCommitCoordinator.java


注:本文中的org.opendaylight.controller.cluster.datastore.modification.Modification类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。