本文整理汇总了Java中org.opendaylight.yangtools.yang.binding.InstanceIdentifier类的典型用法代码示例。如果您正苦于以下问题:Java InstanceIdentifier类的具体用法?Java InstanceIdentifier怎么用?Java InstanceIdentifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InstanceIdentifier类属于org.opendaylight.yangtools.yang.binding包,在下文中一共展示了InstanceIdentifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ouputChanges
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; //导入依赖的package包/类
private static void ouputChanges(final DataTreeModification<Cars> change) {
final DataObjectModification<Cars> rootNode = change.getRootNode();
final ModificationType modificationType = rootNode.getModificationType();
final InstanceIdentifier<Cars> rootIdentifier = change.getRootPath().getRootIdentifier();
switch (modificationType) {
case WRITE:
case SUBTREE_MODIFIED: {
final Cars dataBefore = rootNode.getDataBefore();
final Cars dataAfter = rootNode.getDataAfter();
LOG.trace("onDataTreeChanged - Cars config with path {} was added or changed from {} to {}",
rootIdentifier, dataBefore, dataAfter);
break;
}
case DELETE: {
LOG.trace("onDataTreeChanged - Cars config with path {} was deleted", rootIdentifier);
break;
}
default: {
LOG.trace("onDataTreeChanged called with unknown modificationType: {}", modificationType);
break;
}
}
}
示例2: writeTopWithListItemAugmentedListenAugmentSubtreeWildcarded
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; //导入依赖的package包/类
@Test
public void writeTopWithListItemAugmentedListenAugmentSubtreeWildcarded() {
TestListener listener = createListener(CONFIGURATION,AUGMENT_WILDCARD, DataChangeScope.SUBTREE, false);
writeTopWithListItem(CONFIGURATION);
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
/*
* Event should not contain parent nodes
*/
assertNotContains(event.getCreatedData(), TOP_PATH, path(TOP_FOO_KEY));
assertContains(event.getCreatedData(), path(TOP_FOO_KEY, TreeComplexUsesAugment.class));
assertContains(event.getCreatedData(), path(TOP_FOO_KEY, USES_ONE_KEY));
assertContains(event.getCreatedData(), path(TOP_FOO_KEY, USES_TWO_KEY));
assertEmpty(event.getUpdatedData());
assertEmpty(event.getRemovedPaths());
}
示例3: registerListeners
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; //导入依赖的package包/类
@Override
public void registerListeners() {
super.registerListeners();
String defaultTenant = FpcProvider.getInstance().getConfig().getDefaultTenantId();
FpcIdentity defaultIdentity = (defaultTenant == null) ? new FpcIdentity(0L) : new FpcIdentity(defaultTenant);
groupsDataTreeChangeListenerRegistration = this.db
.registerDataTreeChangeListener(
new DataTreeIdentifier<DpnGroups>(LogicalDatastoreType.CONFIGURATION,
InstanceIdentifier.builder(Tenants.class)
.child(Tenant.class, new TenantKey( defaultIdentity ))
.child(FpcTopology.class)
.child(DpnGroups.class).build() ),
new DpnGroupChangeManager() );
LOG.info("DpnManager Registered");
}
示例4: load
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; //导入依赖的package包/类
/**
* Loads the Connection Information from the data store
*/
private void load() {
ReadOnlyTransaction rtrans = dataBroker.newReadOnlyTransaction();
try {
Optional<ConnectionInfo> connInfo = rtrans.read(LogicalDatastoreType.OPERATIONAL,
InstanceIdentifier.create(ConnectionInfo.class)).get();
if (connInfo.isPresent()) {
for (Connections conn : (connInfo.get().getConnections() == null) ?
Collections.<Connections>emptyList() : connInfo.get().getConnections()) {
connections.put(conn.getAssignedInfo().getClientId().toString(), conn);
}
}
} catch (Exception exc) {
ErrorLog.logError("FpcServiceImpl - Error in loading Connection information from the datastore\n" + exc.getMessage(), exc.getStackTrace());
}
}
示例5: addPrefixShardReplica
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; //导入依赖的package包/类
private void addPrefixShardReplica(final MemberNode memberNode,
final InstanceIdentifier<?> identifier,
final BindingNormalizedNodeSerializer serializer,
final String shardName,
final String... peerMemberNames) throws Exception {
final AddPrefixShardReplicaInput input = new AddPrefixShardReplicaInputBuilder()
.setShardPrefix(identifier)
.setDataStoreType(DataStoreType.Config).build();
final ClusterAdminRpcService service =
new ClusterAdminRpcService(memberNode.configDataStore(), memberNode.operDataStore(), serializer);
final RpcResult<Void> rpcResult = service.addPrefixShardReplica(input).get(10, TimeUnit.SECONDS);
verifySuccessfulRpcResult(rpcResult);
verifyRaftPeersPresent(memberNode.configDataStore(), shardName, peerMemberNames);
Optional<ActorRef> optional = memberNode.configDataStore().getActorContext().findLocalShard(shardName);
assertTrue("Replica shard not present", optional.isPresent());
}
示例6: complexAugmentationCreatedTest
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; //导入依赖的package包/类
@Test
public void complexAugmentationCreatedTest() {
TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT,
AsyncDataBroker.DataChangeScope.SUBTREE, false);
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP, top());
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
writeTx.put(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT, complexUsesAugment(LIST_VIA_USES_KEY));
assertCommit(writeTx.submit());
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
assertContains(event.getCreatedData(), COMPLEX_AUGMENT);
assertContains(event.getCreatedData(), COMPLEX_AUGMENT.child(ListViaUses.class, LIST_VIA_USES_KEY));
assertEmpty(event.getUpdatedData());
assertEmpty(event.getOriginalData());
assertEmpty(event.getRemovedPaths());
}
示例7: testDataChangeListener
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testDataChangeListener() throws Exception {
DataChangeListener listener = mock(DataChangeListener.class);
InstanceIdentifier<ListItem> wildCard = InstanceIdentifier.builder(ListenerTest.class)
.child(ListItem.class).build();
ListenerRegistration<DataChangeListener> reg = getDataBroker().registerDataChangeListener(
LogicalDatastoreType.OPERATIONAL, wildCard, listener, AsyncDataBroker.DataChangeScope.SUBTREE);
final ListItem item = writeListItem();
ArgumentCaptor<AsyncDataChangeEvent> captor = ArgumentCaptor.forClass(AsyncDataChangeEvent.class);
verify(listener, timeout(100)).onDataChanged(captor.capture());
AsyncDataChangeEvent event = captor.getValue();
assertEquals("createdData", 1, event.getCreatedData().size());
assertEquals("ListItem", item, event.getCreatedData().values().iterator().next());
}
示例8: deleteChildListenParent
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; //导入依赖的package包/类
@Test
public void deleteChildListenParent() throws InterruptedException, ExecutionException, TimeoutException {
DataBroker dataBroker = testContext.getDataBroker();
final WriteTransaction initTx = dataBroker.newWriteOnlyTransaction();
initTx.put(LogicalDatastoreType.OPERATIONAL, LIST11_PATH, createList11(), true);
initTx.submit().get(5, TimeUnit.SECONDS);
final SettableFuture<AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject>> event = SettableFuture.create();
dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, LIST11_PATH,
change -> event.set(change), DataChangeScope.SUBTREE);
final WriteTransaction deleteTx = dataBroker.newWriteOnlyTransaction();
deleteTx.delete(LogicalDatastoreType.OPERATIONAL, LIST11_PATH.augmentation(List11SimpleAugment.class));
deleteTx.submit().get(5, TimeUnit.SECONDS);
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> receivedEvent = event.get();
assertFalse(receivedEvent.getRemovedPaths().contains(TLL_COMPLEX_AUGMENT_PATH));
}
示例9: putData
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; //导入依赖的package包/类
private <T extends DataObject> void putData(final LogicalDatastoreType store,
final InstanceIdentifier<T> path,
final T data){
final WriteTransaction tx = getDataBroker().newWriteOnlyTransaction();
tx.put(store, path, data, true);
Futures.addCallback( tx.submit(), new FutureCallback<Void>(){
@Override
public void onSuccess(final Void result) {
LOG.trace("Data has put into datastore {} {}", store, path);
}
@Override
public void onFailure(final Throwable t) {
LOG.error("Can not put data into datastore [store: {}] [path: {}] [exception: {}]",store,path, t);
}
});
}
示例10: deleteAugmentChildListenAugmentSubtreeWildcarded
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; //导入依赖的package包/类
@Test
public void deleteAugmentChildListenAugmentSubtreeWildcarded() {
writeTopWithListItem(CONFIGURATION);
TestListener listener = createListener(CONFIGURATION, AUGMENT_WILDCARD, DataChangeScope.SUBTREE, false);
InstanceIdentifier<?> deletePath = path(TOP_FOO_KEY,USES_ONE_KEY);
deleteItem(CONFIGURATION,deletePath);
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
assertEmpty(event.getCreatedData());
assertContains(event.getUpdatedData(), path(TOP_FOO_KEY, TreeComplexUsesAugment.class));
/*
* Event should not contain parent nodes
*/
assertNotContains(event.getUpdatedData(), TOP_PATH, path(TOP_FOO_KEY));
assertContains(event.getRemovedPaths(), deletePath);
}
示例11: writeTopWithListItemAugmentedListenTopSubtree
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; //导入依赖的package包/类
@Test
public void writeTopWithListItemAugmentedListenTopSubtree() {
TestListener listener = createListener(CONFIGURATION,TOP_PATH, DataChangeScope.SUBTREE, false);
writeTopWithListItem(CONFIGURATION);
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
assertContains(event.getCreatedData(), TOP_PATH);
assertContains(event.getCreatedData(), path(TOP_FOO_KEY));
assertContains(event.getCreatedData(), path(TOP_FOO_KEY, TreeComplexUsesAugment.class));
assertContains(event.getCreatedData(), path(TOP_FOO_KEY, USES_ONE_KEY));
assertContains(event.getCreatedData(), path(TOP_FOO_KEY, USES_TWO_KEY));
assertEmpty(event.getUpdatedData());
assertEmpty(event.getRemovedPaths());
}
示例12: leafOnlyAugmentationUpdatedTest
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; //导入依赖的package包/类
@Test
public void leafOnlyAugmentationUpdatedTest() {
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP, top());
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
writeTx.put(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugment("test leaf"));
assertCommit(writeTx.submit());
TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT,
AsyncDataBroker.DataChangeScope.SUBTREE);
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugment("test leaf changed"));
assertCommit(writeTx.submit());
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
assertContains(event.getUpdatedData(), SIMPLE_AUGMENT);
assertContains(event.getOriginalData(), SIMPLE_AUGMENT);
assertEmpty(event.getCreatedData());
assertEmpty(event.getRemovedPaths());
}
示例13: ensureParentsByMerge
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; //导入依赖的package包/类
@Override
protected void ensureParentsByMerge(final LogicalDatastoreType store,
final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalizedPath, final InstanceIdentifier<?> path) {
List<PathArgument> currentArguments = new ArrayList<>();
DataNormalizationOperation<?> currentOp = getCodec().getDataNormalizer().getRootOperation();
for (PathArgument currentArg : normalizedPath.getPathArguments()) {
try {
currentOp = currentOp.getChild(currentArg);
} catch (DataNormalizationException e) {
throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e);
}
currentArguments.add(currentArg);
YangInstanceIdentifier currentPath = YangInstanceIdentifier.create(
currentArguments);
getDelegate().merge(store, currentPath, currentOp.createDefault(currentArg));
}
}
示例14: registerNew
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; //导入依赖的package包/类
public static DOMRpcImplementationRegistration<RoutedGetConstantService> registerNew(
final BindingNormalizedNodeSerializer codec, final DOMRpcProviderService rpcProviderService,
final String constant, final InstanceIdentifier<?> context) {
LOG.debug("Registering get-contexted-constant on context: {}, with value: {}", context, constant);
final YangInstanceIdentifier yid = codec.toYangInstanceIdentifier(context);
final DOMRpcIdentifier id = DOMRpcIdentifier.create(SchemaPath.create(true, GET_CONTEXTED_CONSTANT), yid);
return rpcProviderService.registerRpcImplementation(new RoutedGetConstantService(constant), id);
}
示例15: validateGreetingRegistry
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; //导入依赖的package包/类
private void validateGreetingRegistry(String name) {
InstanceIdentifier<GreetingRegistryEntry> iid = InstanceIdentifier.create(GreetingRegistry.class)
.child(GreetingRegistryEntry.class, new GreetingRegistryEntryKey(name));
DataBroker db = getSession().getSALService(DataBroker.class);
ReadOnlyTransaction transaction = db.newReadOnlyTransaction();
CheckedFuture<Optional<GreetingRegistryEntry>, ReadFailedException> future =
transaction.read(LogicalDatastoreType.OPERATIONAL, iid);
Optional<GreetingRegistryEntry> optional = Optional.absent();
try {
optional = future.checkedGet();
} catch (ReadFailedException e) {
LOG.warn("Reading greeting failed:",e);
}
Assert.assertTrue(name + " not recorded in greeting registry",optional.isPresent());
}