summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
4cb9924)
Preparatory patch, bulk-removes all trailing whitespace from Java files.
Change-Id: I1fbef5746df7277b3865429d4faa82fc8ba8cbb5
Signed-off-by: Robert Varga <rovarga@cisco.com>
109 files changed:
.setType(etherType);
targetEthMatchBuild.setEthernetType(ethType.build());
}
.setType(etherType);
targetEthMatchBuild.setEthernetType(ethType.build());
}
- if((sourceMatch.getField(DL_SRC) != null && sourceMatch.getField(DL_SRC).getValue() != null) ||
- (sourceMatch.getField(DL_DST) != null && sourceMatch.getField(DL_DST).getValue() != null)||
+ if((sourceMatch.getField(DL_SRC) != null && sourceMatch.getField(DL_SRC).getValue() != null) ||
+ (sourceMatch.getField(DL_DST) != null && sourceMatch.getField(DL_DST).getValue() != null)||
- return targetEthMatchBuild.build();
- }
+ return targetEthMatchBuild.build();
+ }
.toAddrString(inetDestAddress);
layer4MatchBuild
.setIpv4Destination(new Ipv4Prefix(inetDstAddressString));
.toAddrString(inetDestAddress);
layer4MatchBuild
.setIpv4Destination(new Ipv4Prefix(inetDstAddressString));
return layer4MatchBuild.build();
}
return layer4MatchBuild.build();
}
}
if(inetDestAddress != null) {
String inetDstAddressString = InetAddresses
}
if(inetDestAddress != null) {
String inetDstAddressString = InetAddresses
- .toAddrString(inetDestAddress);
+ .toAddrString(inetDestAddress);
layer6MatchBuild
.setIpv6Destination(new Ipv6Prefix(inetDstAddressString));
}
return layer6MatchBuild.build();
}
layer6MatchBuild
.setIpv6Destination(new Ipv6Prefix(inetDstAddressString));
}
return layer6MatchBuild.build();
}
public static boolean flowEquals(Flow statsFlow, Flow storedFlow) {
if (statsFlow.getClass() != storedFlow.getClass()) {
return false;
public static boolean flowEquals(Flow statsFlow, Flow storedFlow) {
if (statsFlow.getClass() != storedFlow.getClass()) {
return false;
public static byte[] bytesFromDpid(long dpid) {
byte[] mac = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
public static byte[] bytesFromDpid(long dpid) {
byte[] mac = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
{(byte) 0x7f, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff},
{(byte) 0x76, (byte) 0x4a, (byte) 0xe9, (byte) 0xac, (byte) 0xe6, (byte) 0x5a}
};
{(byte) 0x7f, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff},
{(byte) 0x76, (byte) 0x4a, (byte) 0xe9, (byte) 0xac, (byte) 0xe6, (byte) 0x5a}
};
Assert.assertEquals(expectedMacs.length, nodeIds.length);
for (int i = 0; i < expectedMacs.length; i++) {
Assert.assertEquals(expectedMacs.length, nodeIds.length);
for (int i = 0; i < expectedMacs.length; i++) {
public void testToSalConversion() throws ConstructionException {
FlowAddedBuilder odNodeFlowBuilder = new FlowAddedBuilder();
odNodeFlowBuilder = prepareOdFlowCommon();
public void testToSalConversion() throws ConstructionException {
FlowAddedBuilder odNodeFlowBuilder = new FlowAddedBuilder();
odNodeFlowBuilder = prepareOdFlowCommon();
Node node = new Node(NodeIDType.OPENFLOW,(long)1);
Node node = new Node(NodeIDType.OPENFLOW,(long)1);
Flow salFlow = ToSalConversionsUtils.toFlow(prepareOdFlow(odNodeFlowBuilder, MtchType.other), node);
checkSalMatch(salFlow.getMatch(), MtchType.other);
Flow salFlow = ToSalConversionsUtils.toFlow(prepareOdFlow(odNodeFlowBuilder, MtchType.other), node);
checkSalMatch(salFlow.getMatch(), MtchType.other);
private void checkSalMatch(org.opendaylight.controller.sal.match.Match match, MtchType mt) {
switch (mt) {
case other:
private void checkSalMatch(org.opendaylight.controller.sal.match.Match match, MtchType mt) {
switch (mt) {
case other:
- /*assertNotNull("DL_DST isn't equal.", "3C:A9:F4:00:E0:C8",
+ /*assertNotNull("DL_DST isn't equal.", "3C:A9:F4:00:E0:C8",
new String((byte[]) match.getField(MatchType.DL_DST).getValue()));
assertEquals("DL_SRC isn't equal.", "24:77:03:7C:C5:F1",
new String((byte[]) match.getField(MatchType.DL_SRC).getValue()));
new String((byte[]) match.getField(MatchType.DL_DST).getValue()));
assertEquals("DL_SRC isn't equal.", "24:77:03:7C:C5:F1",
new String((byte[]) match.getField(MatchType.DL_SRC).getValue()));
odActions.add(new ActionBuilder().setAction(setVlanPcpActionBuilder.build()).build());
odActions.add(new ActionBuilder().setAction(swPathActionBuilder.build()).build());
odActions.add(new ActionBuilder().setAction(setVlanPcpActionBuilder.build()).build());
odActions.add(new ActionBuilder().setAction(swPathActionBuilder.build()).build());
ApplyActionsCase innerInst = new ApplyActionsCaseBuilder().setApplyActions(new ApplyActionsBuilder().setAction(odActions).build()).build();
Instruction applyActions = new InstructionBuilder().setInstruction(innerInst).build();
List<Instruction> instructions = Collections.singletonList(applyActions );
InstructionsBuilder instBuilder = new InstructionsBuilder();
ApplyActionsCase innerInst = new ApplyActionsCaseBuilder().setApplyActions(new ApplyActionsBuilder().setAction(odActions).build()).build();
Instruction applyActions = new InstructionBuilder().setInstruction(innerInst).build();
List<Instruction> instructions = Collections.singletonList(applyActions );
InstructionsBuilder instBuilder = new InstructionsBuilder();
instBuilder.setInstruction(instructions);
instBuilder.setInstruction(instructions);
return instBuilder.build();
}
return instBuilder.build();
}
private void prepareActionSetNwDst(List<Action> odActions) {
// test case for IPv4
private void prepareActionSetNwDst(List<Action> odActions) {
// test case for IPv4
SetNwDstActionBuilder setNwDstActionBuilderIpv4 = new SetNwDstActionBuilder();
setNwDstActionBuilderIpv4.setAddress(prapareIpv4Address("192.168.100.101"));
odActions.add(new ActionBuilder().setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilderIpv4.build()).build()).build());
SetNwDstActionBuilder setNwDstActionBuilderIpv4 = new SetNwDstActionBuilder();
setNwDstActionBuilderIpv4.setAddress(prapareIpv4Address("192.168.100.101"));
odActions.add(new ActionBuilder().setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilderIpv4.build()).build()).build());
/**
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
/**
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
/**
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
/**
* @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
*
*/
* @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
*
*/
public void onDataChanged(DataChangeEvent<InstanceIdentifier<?>, DataObject> changeEvent) {
this.transactionId = this.newTransactionIdentifier().toString();
public void onDataChanged(DataChangeEvent<InstanceIdentifier<?>, DataObject> changeEvent) {
this.transactionId = this.newTransactionIdentifier().toString();
- final Set<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> createdEntries =
+ final Set<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> createdEntries =
changeEvent.getCreatedConfigurationData().entrySet();
changeEvent.getCreatedConfigurationData().entrySet();
- final Set<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> updatedEntries =
+ final Set<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> updatedEntries =
new HashSet<Entry<InstanceIdentifier<? extends DataObject>, DataObject>>();
new HashSet<Entry<InstanceIdentifier<? extends DataObject>, DataObject>>();
- Set<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> updateConfigEntrySet =
+ Set<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> updateConfigEntrySet =
changeEvent.getUpdatedConfigurationData().entrySet();
updatedEntries.addAll(updateConfigEntrySet);
updatedEntries.removeAll(createdEntries);
changeEvent.getUpdatedConfigurationData().entrySet();
updatedEntries.addAll(updateConfigEntrySet);
updatedEntries.removeAll(createdEntries);
- final Set<InstanceIdentifier<? extends DataObject>> removeEntriesInstanceIdentifiers =
+ final Set<InstanceIdentifier<? extends DataObject>> removeEntriesInstanceIdentifiers =
changeEvent.getRemovedConfigurationData();
for (final Entry<InstanceIdentifier<? extends DataObject>, DataObject> createdEntry : createdEntries) {
changeEvent.getRemovedConfigurationData();
for (final Entry<InstanceIdentifier<? extends DataObject>, DataObject> createdEntry : createdEntries) {
}
for (final Entry<InstanceIdentifier<?>, DataObject> updatedEntrie : updatedEntries) {
}
for (final Entry<InstanceIdentifier<?>, DataObject> updatedEntrie : updatedEntries) {
- Map<InstanceIdentifier<? extends DataObject>, DataObject> origConfigData =
+ Map<InstanceIdentifier<? extends DataObject>, DataObject> origConfigData =
changeEvent.getOriginalConfigurationData();
InstanceIdentifier<? extends Object> u_key = updatedEntrie.getKey();
changeEvent.getOriginalConfigurationData();
InstanceIdentifier<? extends Object> u_key = updatedEntrie.getKey();
}
for (final InstanceIdentifier<?> instanceId : removeEntriesInstanceIdentifiers) {
}
for (final InstanceIdentifier<?> instanceId : removeEntriesInstanceIdentifiers) {
- Map<InstanceIdentifier<? extends DataObject>, DataObject> origConfigData =
+ Map<InstanceIdentifier<? extends DataObject>, DataObject> origConfigData =
changeEvent.getOriginalConfigurationData();
final DataObject removeValue = origConfigData.get(instanceId);
changeEvent.getOriginalConfigurationData();
final DataObject removeValue = origConfigData.get(instanceId);
/**
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
/**
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
private final static Logger LOG = LoggerFactory.getLogger(FRMActivator.class);
private final static Logger LOG = LoggerFactory.getLogger(FRMActivator.class);
- private static FlowProvider flowProvider = new FlowProvider();
+ private static FlowProvider flowProvider = new FlowProvider();
private static GroupProvider groupProvider = new GroupProvider();
private static MeterProvider meterProvider = new MeterProvider();
private static GroupProvider groupProvider = new GroupProvider();
private static MeterProvider meterProvider = new MeterProvider();
@Override
public void onSessionInitiated(final ProviderContext session) {
DataProviderService flowSalService = session.<DataProviderService>getSALService(DataProviderService.class);
@Override
public void onSessionInitiated(final ProviderContext session) {
DataProviderService flowSalService = session.<DataProviderService>getSALService(DataProviderService.class);
FRMActivator.meterProvider.setSalMeterService(rpcMeterSalService);
FRMActivator.meterProvider.start();
}
FRMActivator.meterProvider.setSalMeterService(rpcMeterSalService);
FRMActivator.meterProvider.start();
}
@Override
protected void stopImpl(final BundleContext context) {
try {
@Override
protected void stopImpl(final BundleContext context) {
try {
/**
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
/**
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
import org.slf4j.LoggerFactory;
/**
import org.slf4j.LoggerFactory;
/**
* @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
*
*/
* @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
*
*/
public SalFlowService getSalFlowService() {
return this.salFlowService;
}
public SalFlowService getSalFlowService() {
return this.salFlowService;
}
public FlowChangeListener(final SalFlowService manager) {
this.salFlowService = manager;
}
public FlowChangeListener(final SalFlowService manager) {
this.salFlowService = manager;
}
@Override
protected void remove(InstanceIdentifier<? extends DataObject> identifier, DataObject removeDataObj) {
if ((removeDataObj instanceof Flow)) {
@Override
protected void remove(InstanceIdentifier<? extends DataObject> identifier, DataObject removeDataObj) {
if ((removeDataObj instanceof Flow)) {
final Flow flow = ((Flow) removeDataObj);
final InstanceIdentifier<Table> tableInstanceId = identifier.<Table> firstIdentifierOf(Table.class);
final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
final RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(flow);
final Flow flow = ((Flow) removeDataObj);
final InstanceIdentifier<Table> tableInstanceId = identifier.<Table> firstIdentifierOf(Table.class);
final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
final RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(flow);
builder.setFlowRef(new FlowRef(identifier));
builder.setNode(new NodeRef(nodeInstanceId));
builder.setFlowTable(new FlowTableRef(tableInstanceId));
builder.setFlowRef(new FlowRef(identifier));
builder.setNode(new NodeRef(nodeInstanceId));
builder.setFlowTable(new FlowTableRef(tableInstanceId));
Uri uri = new Uri(this.getTransactionId());
builder.setTransactionUri(uri);
this.salFlowService.removeFlow((RemoveFlowInput) builder.build());
Uri uri = new Uri(this.getTransactionId());
builder.setTransactionUri(uri);
this.salFlowService.removeFlow((RemoveFlowInput) builder.build());
@Override
protected void update(InstanceIdentifier<? extends DataObject> identifier, DataObject original, DataObject update) {
if (original instanceof Flow && update instanceof Flow) {
@Override
protected void update(InstanceIdentifier<? extends DataObject> identifier, DataObject original, DataObject update) {
if (original instanceof Flow && update instanceof Flow) {
final Flow originalFlow = ((Flow) original);
final Flow updatedFlow = ((Flow) update);
final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node>firstIdentifierOf(Node.class);
final UpdateFlowInputBuilder builder = new UpdateFlowInputBuilder();
final Flow originalFlow = ((Flow) original);
final Flow updatedFlow = ((Flow) update);
final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node>firstIdentifierOf(Node.class);
final UpdateFlowInputBuilder builder = new UpdateFlowInputBuilder();
builder.setNode(new NodeRef(nodeInstanceId));
builder.setFlowRef(new FlowRef(identifier));
builder.setNode(new NodeRef(nodeInstanceId));
builder.setFlowRef(new FlowRef(identifier));
Uri uri = new Uri(this.getTransactionId());
builder.setTransactionUri(uri);
Uri uri = new Uri(this.getTransactionId());
builder.setTransactionUri(uri);
builder.setUpdatedFlow((UpdatedFlow) (new UpdatedFlowBuilder(updatedFlow)).build());
builder.setOriginalFlow((OriginalFlow) (new OriginalFlowBuilder(originalFlow)).build());
builder.setUpdatedFlow((UpdatedFlow) (new UpdatedFlowBuilder(updatedFlow)).build());
builder.setOriginalFlow((OriginalFlow) (new OriginalFlowBuilder(originalFlow)).build());
this.salFlowService.updateFlow((UpdateFlowInput) builder.build());
LOG.debug("Transaction {} - Update Flow has updated flow {} with {}", new Object[]{uri, original, update});
}
this.salFlowService.updateFlow((UpdateFlowInput) builder.build());
LOG.debug("Transaction {} - Update Flow has updated flow {} with {}", new Object[]{uri, original, update});
}
@Override
protected void add(InstanceIdentifier<? extends DataObject> identifier, DataObject addDataObj) {
if ((addDataObj instanceof Flow)) {
@Override
protected void add(InstanceIdentifier<? extends DataObject> identifier, DataObject addDataObj) {
if ((addDataObj instanceof Flow)) {
final Flow flow = ((Flow) addDataObj);
final InstanceIdentifier<Table> tableInstanceId = identifier.<Table> firstIdentifierOf(Table.class);
final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
final AddFlowInputBuilder builder = new AddFlowInputBuilder(flow);
final Flow flow = ((Flow) addDataObj);
final InstanceIdentifier<Table> tableInstanceId = identifier.<Table> firstIdentifierOf(Table.class);
final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
final AddFlowInputBuilder builder = new AddFlowInputBuilder(flow);
builder.setNode(new NodeRef(nodeInstanceId));
builder.setFlowRef(new FlowRef(identifier));
builder.setFlowTable(new FlowTableRef(tableInstanceId));
builder.setNode(new NodeRef(nodeInstanceId));
builder.setFlowRef(new FlowRef(identifier));
builder.setFlowTable(new FlowTableRef(tableInstanceId));
Uri uri = new Uri(this.getTransactionId());
builder.setTransactionUri(uri);
this.salFlowService.addFlow((AddFlowInput) builder.build());
Uri uri = new Uri(this.getTransactionId());
builder.setTransactionUri(uri);
this.salFlowService.addFlow((AddFlowInput) builder.build());
/**
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
/**
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
InstanceIdentifierBuilder<Table> tableChild = augmentFlowCapNode.<Table> child(Table.class);
InstanceIdentifierBuilder<Flow> flowChild = tableChild.<Flow> child(Flow.class);
final InstanceIdentifier<? extends DataObject> flowDataObjectPath = flowChild.toInstance();
InstanceIdentifierBuilder<Table> tableChild = augmentFlowCapNode.<Table> child(Table.class);
InstanceIdentifierBuilder<Flow> flowChild = tableChild.<Flow> child(Flow.class);
final InstanceIdentifier<? extends DataObject> flowDataObjectPath = flowChild.toInstance();
/* DataChangeListener registration */
this.flowDataChangeListener = new FlowChangeListener(this.salFlowService);
this.flowDataChangeListenerRegistration = this.dataService.registerDataChangeListener(flowDataObjectPath, flowDataChangeListener);
/* DataChangeListener registration */
this.flowDataChangeListener = new FlowChangeListener(this.salFlowService);
this.flowDataChangeListenerRegistration = this.dataService.registerDataChangeListener(flowDataObjectPath, flowDataChangeListener);
/**
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
/**
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
/**
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
/**
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
import org.slf4j.LoggerFactory;
/**
import org.slf4j.LoggerFactory;
/**
* @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
*
*/
* @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
*
*/
public SalGroupService getSalGroupService() {
return this.salGroupService;
}
public SalGroupService getSalGroupService() {
return this.salGroupService;
}
public GroupChangeListener(final SalGroupService manager) {
this.salGroupService = manager;
}
public GroupChangeListener(final SalGroupService manager) {
this.salGroupService = manager;
}
@Override
protected void remove(InstanceIdentifier<? extends DataObject> identifier, DataObject removeDataObj) {
if ((removeDataObj instanceof Group)) {
@Override
protected void remove(InstanceIdentifier<? extends DataObject> identifier, DataObject removeDataObj) {
if ((removeDataObj instanceof Group)) {
final Group group = ((Group) removeDataObj);
final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
final RemoveGroupInputBuilder builder = new RemoveGroupInputBuilder(group);
final Group group = ((Group) removeDataObj);
final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
final RemoveGroupInputBuilder builder = new RemoveGroupInputBuilder(group);
builder.setNode(new NodeRef(nodeInstanceId));
builder.setGroupRef(new GroupRef(identifier));
builder.setNode(new NodeRef(nodeInstanceId));
builder.setGroupRef(new GroupRef(identifier));
Uri uri = new Uri(this.getTransactionId());
builder.setTransactionUri(uri);
this.salGroupService.removeGroup((RemoveGroupInput) builder.build());
Uri uri = new Uri(this.getTransactionId());
builder.setTransactionUri(uri);
this.salGroupService.removeGroup((RemoveGroupInput) builder.build());
@Override
protected void update(InstanceIdentifier<? extends DataObject> identifier, DataObject original, DataObject update) {
if (original instanceof Group && update instanceof Group) {
@Override
protected void update(InstanceIdentifier<? extends DataObject> identifier, DataObject original, DataObject update) {
if (original instanceof Group && update instanceof Group) {
final Group originalGroup = ((Group) original);
final Group updatedGroup = ((Group) update);
final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
final UpdateGroupInputBuilder builder = new UpdateGroupInputBuilder();
final Group originalGroup = ((Group) original);
final Group updatedGroup = ((Group) update);
final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
final UpdateGroupInputBuilder builder = new UpdateGroupInputBuilder();
builder.setNode(new NodeRef(nodeInstanceId));
builder.setGroupRef(new GroupRef(identifier));
builder.setNode(new NodeRef(nodeInstanceId));
builder.setGroupRef(new GroupRef(identifier));
Uri uri = new Uri(this.getTransactionId());
builder.setTransactionUri(uri);
Uri uri = new Uri(this.getTransactionId());
builder.setTransactionUri(uri);
builder.setUpdatedGroup((UpdatedGroup) (new UpdatedGroupBuilder(updatedGroup)).build());
builder.setOriginalGroup((OriginalGroup) (new OriginalGroupBuilder(originalGroup)).build());
builder.setUpdatedGroup((UpdatedGroup) (new UpdatedGroupBuilder(updatedGroup)).build());
builder.setOriginalGroup((OriginalGroup) (new OriginalGroupBuilder(originalGroup)).build());
this.salGroupService.updateGroup((UpdateGroupInput) builder.build());
LOG.debug("Transaction {} - Update Group has updated group {} with group {}", new Object[]{uri, original, update});
}
this.salGroupService.updateGroup((UpdateGroupInput) builder.build());
LOG.debug("Transaction {} - Update Group has updated group {} with group {}", new Object[]{uri, original, update});
}
final Group group = ((Group) addDataObj);
final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
final AddGroupInputBuilder builder = new AddGroupInputBuilder(group);
final Group group = ((Group) addDataObj);
final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
final AddGroupInputBuilder builder = new AddGroupInputBuilder(group);
builder.setNode(new NodeRef(nodeInstanceId));
builder.setGroupRef(new GroupRef(identifier));
builder.setNode(new NodeRef(nodeInstanceId));
builder.setGroupRef(new GroupRef(identifier));
Uri uri = new Uri(this.getTransactionId());
builder.setTransactionUri(uri);
this.salGroupService.addGroup((AddGroupInput) builder.build());
Uri uri = new Uri(this.getTransactionId());
builder.setTransactionUri(uri);
this.salGroupService.addGroup((AddGroupInput) builder.build());
/**
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
/**
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
this.groupDataChangeListenerRegistration = this.dataService.registerDataChangeListener(groupDataObjectPath, groupDataChangeListener);
LOG.info("Group Config Provider started.");
}
this.groupDataChangeListenerRegistration = this.dataService.registerDataChangeListener(groupDataObjectPath, groupDataChangeListener);
LOG.info("Group Config Provider started.");
}
protected DataModificationTransaction startChange() {
return this.dataService.beginTransaction();
}
protected DataModificationTransaction startChange() {
return this.dataService.beginTransaction();
}
public void close() throws Exception {
if(groupDataChangeListenerRegistration != null){
groupDataChangeListenerRegistration.close();
public void close() throws Exception {
if(groupDataChangeListenerRegistration != null){
groupDataChangeListenerRegistration.close();
/**
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
/**
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
import org.slf4j.LoggerFactory;
/**
import org.slf4j.LoggerFactory;
/**
* @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
*
*/
* @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
*
*/
public SalMeterService getSalMeterService() {
return this.salMeterService;
}
public SalMeterService getSalMeterService() {
return this.salMeterService;
}
public MeterChangeListener(final SalMeterService manager) {
this.salMeterService = manager;
}
public MeterChangeListener(final SalMeterService manager) {
this.salMeterService = manager;
}
@Override
protected void remove(InstanceIdentifier<? extends DataObject> identifier, DataObject removeDataObj) {
if ((removeDataObj instanceof Meter)) {
@Override
protected void remove(InstanceIdentifier<? extends DataObject> identifier, DataObject removeDataObj) {
if ((removeDataObj instanceof Meter)) {
final Meter meter = ((Meter) removeDataObj);
final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
final RemoveMeterInputBuilder builder = new RemoveMeterInputBuilder(meter);
final Meter meter = ((Meter) removeDataObj);
final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
final RemoveMeterInputBuilder builder = new RemoveMeterInputBuilder(meter);
builder.setNode(new NodeRef(nodeInstanceId));
builder.setMeterRef(new MeterRef(identifier));
builder.setNode(new NodeRef(nodeInstanceId));
builder.setMeterRef(new MeterRef(identifier));
Uri uri = new Uri(this.getTransactionId());
builder.setTransactionUri(uri);
this.salMeterService.removeMeter((RemoveMeterInput) builder.build());
Uri uri = new Uri(this.getTransactionId());
builder.setTransactionUri(uri);
this.salMeterService.removeMeter((RemoveMeterInput) builder.build());
@Override
protected void update(InstanceIdentifier<? extends DataObject> identifier, DataObject original, DataObject update) {
if (original instanceof Meter && update instanceof Meter) {
@Override
protected void update(InstanceIdentifier<? extends DataObject> identifier, DataObject original, DataObject update) {
if (original instanceof Meter && update instanceof Meter) {
final Meter originalMeter = ((Meter) original);
final Meter updatedMeter = ((Meter) update);
final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
final UpdateMeterInputBuilder builder = new UpdateMeterInputBuilder();
final Meter originalMeter = ((Meter) original);
final Meter updatedMeter = ((Meter) update);
final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
final UpdateMeterInputBuilder builder = new UpdateMeterInputBuilder();
builder.setNode(new NodeRef(nodeInstanceId));
builder.setMeterRef(new MeterRef(identifier));
builder.setNode(new NodeRef(nodeInstanceId));
builder.setMeterRef(new MeterRef(identifier));
Uri uri = new Uri(this.getTransactionId());
builder.setTransactionUri(uri);
Uri uri = new Uri(this.getTransactionId());
builder.setTransactionUri(uri);
builder.setUpdatedMeter((UpdatedMeter) (new UpdatedMeterBuilder(updatedMeter)).build());
builder.setOriginalMeter((OriginalMeter) (new OriginalMeterBuilder(originalMeter)).build());
builder.setUpdatedMeter((UpdatedMeter) (new UpdatedMeterBuilder(updatedMeter)).build());
builder.setOriginalMeter((OriginalMeter) (new OriginalMeterBuilder(originalMeter)).build());
this.salMeterService.updateMeter((UpdateMeterInput) builder.build());
LOG.debug("Transaction {} - Update Meter has updated meter {} with {}", new Object[]{uri, original, update});
}
this.salMeterService.updateMeter((UpdateMeterInput) builder.build());
LOG.debug("Transaction {} - Update Meter has updated meter {} with {}", new Object[]{uri, original, update});
}
@Override
protected void add(InstanceIdentifier<? extends DataObject> identifier, DataObject addDataObj) {
if ((addDataObj instanceof Meter)) {
@Override
protected void add(InstanceIdentifier<? extends DataObject> identifier, DataObject addDataObj) {
if ((addDataObj instanceof Meter)) {
final Meter meter = ((Meter) addDataObj);
final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
final AddMeterInputBuilder builder = new AddMeterInputBuilder(meter);
final Meter meter = ((Meter) addDataObj);
final InstanceIdentifier<Node> nodeInstanceId = identifier.<Node> firstIdentifierOf(Node.class);
final AddMeterInputBuilder builder = new AddMeterInputBuilder(meter);
builder.setNode(new NodeRef(nodeInstanceId));
builder.setMeterRef(new MeterRef(identifier));
builder.setNode(new NodeRef(nodeInstanceId));
builder.setMeterRef(new MeterRef(identifier));
Uri uri = new Uri(this.getTransactionId());
builder.setTransactionUri(uri);
this.salMeterService.addMeter((AddMeterInput) builder.build());
Uri uri = new Uri(this.getTransactionId());
builder.setTransactionUri(uri);
this.salMeterService.addMeter((AddMeterInput) builder.build());
/**
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
/**
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
this.meterDataChangeListenerRegistration = this.dataService.registerDataChangeListener(meterDataObjectPath, meterDataChangeListener);
LOG.info("Meter Config Provider started.");
}
this.meterDataChangeListenerRegistration = this.dataService.registerDataChangeListener(meterDataObjectPath, meterDataChangeListener);
LOG.info("Meter Config Provider started.");
}
protected DataModificationTransaction startChange() {
return this.dataService.beginTransaction();
}
protected DataModificationTransaction startChange() {
return this.dataService.beginTransaction();
}
Future<RpcResult<TransactionStatus>> commitResult = it.commit();
listenOnTransactionState(it.getIdentifier(), commitResult, "node update", ref.getValue());
}
Future<RpcResult<TransactionStatus>> commitResult = it.commit();
listenOnTransactionState(it.getIdentifier(), commitResult, "node update", ref.getValue());
}
/**
* @param txId transaction identificator
* @param future transaction result
/**
* @param txId transaction identificator
* @param future transaction result
private static void listenOnTransactionState(final Object txId, Future<RpcResult<TransactionStatus>> future,
final String action, final InstanceIdentifier<?> nodeConnectorPath) {
Futures.addCallback(JdkFutureAdapters.listenInPoolThread(future),new FutureCallback<RpcResult<TransactionStatus>>() {
private static void listenOnTransactionState(final Object txId, Future<RpcResult<TransactionStatus>> future,
final String action, final InstanceIdentifier<?> nodeConnectorPath) {
Futures.addCallback(JdkFutureAdapters.listenInPoolThread(future),new FutureCallback<RpcResult<TransactionStatus>>() {
@Override
public void onFailure(Throwable t) {
LOG.error("Action {} [{}] failed for Tx:{}", action, nodeConnectorPath, txId, t);
@Override
public void onFailure(Throwable t) {
LOG.error("Action {} [{}] failed for Tx:{}", action, nodeConnectorPath, txId, t);
@Override
public void onSuccess(RpcResult<TransactionStatus> result) {
if(!result.isSuccessful()) {
@Override
public void onSuccess(RpcResult<TransactionStatus> result) {
if(!result.isSuccessful()) {
private ServiceTracker<BindingAwareBroker, BindingAwareBroker> tracker;
private BindingAwareBroker broker;
private ServiceTrackerCustomizer<BindingAwareBroker, BindingAwareBroker> customizer = new ServiceTrackerCustomizer<BindingAwareBroker, BindingAwareBroker>() {
private ServiceTracker<BindingAwareBroker, BindingAwareBroker> tracker;
private BindingAwareBroker broker;
private ServiceTrackerCustomizer<BindingAwareBroker, BindingAwareBroker> customizer = new ServiceTrackerCustomizer<BindingAwareBroker, BindingAwareBroker>() {
@Override
public BindingAwareBroker addingService(ServiceReference<BindingAwareBroker> reference) {
broker = context.getService(reference);
mdActivationPool.execute(new Runnable() {
@Override
public BindingAwareBroker addingService(ServiceReference<BindingAwareBroker> reference) {
broker = context.getService(reference);
mdActivationPool.execute(new Runnable() {
@Override
public void run() {
onBrokerAvailable(broker, context);;
@Override
public void run() {
onBrokerAvailable(broker, context);;
@Override
public void modifiedService(ServiceReference<BindingAwareBroker> reference, BindingAwareBroker service) {
// TODO Auto-generated method stub
@Override
public void modifiedService(ServiceReference<BindingAwareBroker> reference, BindingAwareBroker service) {
// TODO Auto-generated method stub
}
@Override
public void removedService(ServiceReference<BindingAwareBroker> reference, BindingAwareBroker service) {
// TODO Auto-generated method stub
}
@Override
public void removedService(ServiceReference<BindingAwareBroker> reference, BindingAwareBroker service) {
// TODO Auto-generated method stub
@Override
public final void start(BundleContext context) throws Exception {
this.context = context;
startImpl(context);
tracker = new ServiceTracker<>(context, BindingAwareBroker.class, customizer);
tracker.open();
@Override
public final void start(BundleContext context) throws Exception {
this.context = context;
startImpl(context);
tracker = new ServiceTracker<>(context, BindingAwareBroker.class, customizer);
tracker.open();
@Override
public final void stop(BundleContext context) throws Exception {
tracker.close();
stopImpl(context);
}
@Override
public final void stop(BundleContext context) throws Exception {
tracker.close();
stopImpl(context);
}
/**
* Called when this bundle is started (before
* {@link #onSessionInitiated(ProviderContext)} so the Framework can perform
* the bundle-specific activities necessary to start this bundle. This
* method can be used to register services or to allocate any resources that
* this bundle needs.
/**
* Called when this bundle is started (before
* {@link #onSessionInitiated(ProviderContext)} so the Framework can perform
* the bundle-specific activities necessary to start this bundle. This
* method can be used to register services or to allocate any resources that
* this bundle needs.
* <p>
* This method must complete and return to its caller in a timely manner.
* <p>
* This method must complete and return to its caller in a timely manner.
* @param context
* The execution context of the bundle being started.
* @throws Exception
* @param context
* The execution context of the bundle being started.
* @throws Exception
* started. There should be no active threads that were started by this
* bundle when this bundle returns. A stopped bundle must not call any
* Framework objects.
* started. There should be no active threads that were started by this
* bundle when this bundle returns. A stopped bundle must not call any
* Framework objects.
* <p>
* This method must complete and return to its caller in a timely manner.
* <p>
* This method must complete and return to its caller in a timely manner.
* @param context The execution context of the bundle being stopped.
* @throws Exception If this method throws an exception, the bundle is still
* marked as stopped, and the Framework will remove the bundle's
* @param context The execution context of the bundle being stopped.
* @throws Exception If this method throws an exception, the bundle is still
* marked as stopped, and the Framework will remove the bundle's
protected void stopImpl(BundleContext context) {
// NOOP
}
protected void stopImpl(BundleContext context) {
// NOOP
}
protected abstract void onBrokerAvailable(BindingAwareBroker broker, BundleContext context);
protected abstract void onBrokerAvailable(BindingAwareBroker broker, BundleContext context);
protected void onBrokerRemoved(BindingAwareBroker broker, BundleContext context) {
protected void onBrokerRemoved(BindingAwareBroker broker, BundleContext context) {
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
/**
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
/**
* Defines the component of controller and supplies additional metadata. A
* component of the controller or application supplies a concrete implementation
* of this interface.
* Defines the component of controller and supplies additional metadata. A
* component of the controller or application supplies a concrete implementation
* of this interface.
* A user-implemented component (application) which facilitates the SAL and SAL
* services to access infrastructure services or providers' functionality.
* A user-implemented component (application) which facilitates the SAL and SAL
* services to access infrastructure services or providers' functionality.
*/
public interface BindingAwareConsumer {
/**
* Callback signaling initialization of the consumer session to the SAL.
*/
public interface BindingAwareConsumer {
/**
* Callback signaling initialization of the consumer session to the SAL.
* The consumer MUST use the session for all communication with SAL or
* retrieving SAL infrastructure services.
* The consumer MUST use the session for all communication with SAL or
* retrieving SAL infrastructure services.
* This method is invoked by
* {@link BindingAwareBroker#registerConsumer(BindingAwareConsumer)}
* This method is invoked by
* {@link BindingAwareBroker#registerConsumer(BindingAwareConsumer)}
* @param session
* Unique session between consumer and SAL.
*/
* @param session
* Unique session between consumer and SAL.
*/
import org.opendaylight.yangtools.yang.binding.RpcService;
/**
import org.opendaylight.yangtools.yang.binding.RpcService;
/**
* Defines the component of controller and supplies additional metadata. A
* component of the controller or application supplies a concrete implementation
* of this interface.
* Defines the component of controller and supplies additional metadata. A
* component of the controller or application supplies a concrete implementation
* of this interface.
* <p>
* A user-implemented component (application) which facilitates the SAL and SAL
* services to access infrastructure services and to provide functionality to
* {@link Consumer}s and other providers.
* <p>
* A user-implemented component (application) which facilitates the SAL and SAL
* services to access infrastructure services and to provide functionality to
* {@link Consumer}s and other providers.
*/
public interface BindingAwareProvider {
/**
* Returns a set of provided implementations of YANG modules and their rpcs.
*/
public interface BindingAwareProvider {
/**
* Returns a set of provided implementations of YANG modules and their rpcs.
* @return Set of provided implementation of YANG modules and their Rpcs
*/
Collection<? extends RpcService> getImplementations();
* @return Set of provided implementation of YANG modules and their Rpcs
*/
Collection<? extends RpcService> getImplementations();
/**
* Gets a set of implementations of provider functionality to be registered
* into system during the provider registration to the SAL.
/**
* Gets a set of implementations of provider functionality to be registered
* into system during the provider registration to the SAL.
* <p>
* This method is invoked by {@link Broker#registerProvider(Provider)} to
* learn the initial provided functionality
* <p>
* This method is invoked by {@link Broker#registerProvider(Provider)} to
* learn the initial provided functionality
* @return Set of provider's functionality.
*/
Collection<? extends ProviderFunctionality> getFunctionality();
/**
* Functionality provided by the {@link BindingAwareProvider}
* @return Set of provider's functionality.
*/
Collection<? extends ProviderFunctionality> getFunctionality();
/**
* Functionality provided by the {@link BindingAwareProvider}
* <p>
* Marker interface used to mark the interfaces describing specific
* functionality which could be exposed by providers to other components.
* <p>
* Marker interface used to mark the interfaces describing specific
* functionality which could be exposed by providers to other components.
*/
public interface ProviderFunctionality {
*/
public interface ProviderFunctionality {
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
/**
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
/**
* Session-specific instance of the broker functionality.
* Session-specific instance of the broker functionality.
* <p>
* BindingAwareService is marker interface for infrastructure services provided
* by the SAL. These services are session-specific, each
* {@link BindingAwareConsumer} and {@link BindingAwareProvider} usually has own
* instance of the service with it's own context.
* <p>
* BindingAwareService is marker interface for infrastructure services provided
* by the SAL. These services are session-specific, each
* {@link BindingAwareConsumer} and {@link BindingAwareProvider} usually has own
* instance of the service with it's own context.
* <p>
* The consumer's (or provider's) instance of specific service could be obtained
* by invoking {@link ConsumerContext#getSALService(Class)} method on session
* assigned to the consumer.
* <p>
* The consumer's (or provider's) instance of specific service could be obtained
* by invoking {@link ConsumerContext#getSALService(Class)} method on session
* assigned to the consumer.
* <p>
* {@link BindingAwareService} and {@link BindingAwareProvider} may seem
* similar, but provider provides YANG model-based functionality and
* <p>
* {@link BindingAwareService} and {@link BindingAwareProvider} may seem
* similar, but provider provides YANG model-based functionality and
* to implement specific functionality of YANG and to reuse it in the
* development of {@link BindingAwareConsumer}s and {@link BindingAwareProvider}
* s.
* to implement specific functionality of YANG and to reuse it in the
* development of {@link BindingAwareConsumer}s and {@link BindingAwareProvider}
* s.
*/
public interface BindingAwareService {
*/
public interface BindingAwareService {
/**
* Base interface defining contract for retrieving MD-SAL
* version of RpcServices
/**
* Base interface defining contract for retrieving MD-SAL
* version of RpcServices
*/
public interface RpcConsumerRegistry extends BindingAwareService {
/**
* Returns a session specific instance (implementation) of requested
* YANG module implementation / service provided by consumer.
*/
public interface RpcConsumerRegistry extends BindingAwareService {
/**
* Returns a session specific instance (implementation) of requested
* YANG module implementation / service provided by consumer.
* @return Session specific implementation of service
*/
<T extends RpcService> T getRpcService(Class<T> module);
* @return Session specific implementation of service
*/
<T extends RpcService> T getRpcService(Class<T> module);
* Provider's version of Mount Point, this version allows access to MD-SAL
* services specific for this mountpoint and registration / provision of
* interfaces for mount point.
* Provider's version of Mount Point, this version allows access to MD-SAL
* services specific for this mountpoint and registration / provision of
* interfaces for mount point.
*/
public interface MountProviderInstance //
extends //
*/
public interface MountProviderInstance //
extends //
public final Class<? extends RpcService> rpcService;
public final Class<? extends BaseIdentity> routingContext;
public final Class<? extends RpcService> rpcService;
public final Class<? extends BaseIdentity> routingContext;
private RpcContextIdentifier(Class<? extends RpcService> rpcService, Class<? extends BaseIdentity> routingContext) {
super();
this.rpcService = rpcService;
private RpcContextIdentifier(Class<? extends RpcService> rpcService, Class<? extends BaseIdentity> routingContext) {
super();
this.rpcService = rpcService;
public Class<? extends BaseIdentity> getRoutingContext() {
return routingContext;
}
public Class<? extends BaseIdentity> getRoutingContext() {
return routingContext;
}
public static final RpcContextIdentifier contextForGlobalRpc(Class<? extends RpcService> serviceType) {
return new RpcContextIdentifier(serviceType, null);
}
public static final RpcContextIdentifier contextForGlobalRpc(Class<? extends RpcService> serviceType) {
return new RpcContextIdentifier(serviceType, null);
}
public static final RpcContextIdentifier contextFor(Class<? extends RpcService> serviceType,Class<? extends BaseIdentity> routingContext) {
return new RpcContextIdentifier(serviceType, routingContext);
}
public static final RpcContextIdentifier contextFor(Class<? extends RpcService> serviceType,Class<? extends BaseIdentity> routingContext) {
return new RpcContextIdentifier(serviceType, routingContext);
}
/**
* Updates route for particular path to specified instance of
* {@link RpcService}.
/**
* Updates route for particular path to specified instance of
* {@link RpcService}.
* @param path
* Path for which RpcService routing is to be updated
* @param service
* @param path
* Path for which RpcService routing is to be updated
* @param service
/**
* Deletes a route for particular path
/**
* Deletes a route for particular path
* @param path
* Path for which
*/
void removeRoute(InstanceIdentifier<?> path);
/**
* @param path
* Path for which
*/
void removeRoute(InstanceIdentifier<?> path);
/**
*/
S getRoute(InstanceIdentifier<?> nodeInstance);
/**
*/
S getRoute(InstanceIdentifier<?> nodeInstance);
/**
* @return
*/
Map<InstanceIdentifier<?>, S> getRoutes();
* @return
*/
Map<InstanceIdentifier<?>, S> getRoutes();
*/
public class BindingBrokerImplModuleFactory extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplModuleFactory {
*/
public class BindingBrokerImplModuleFactory extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplModuleFactory {
@Override
public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
BindingBrokerImplModule module = (BindingBrokerImplModule) super.createModule(instanceName, dependencyResolver, bundleContext);
module.setBundleContext(bundleContext);
return module;
}
@Override
public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
BindingBrokerImplModule module = (BindingBrokerImplModule) super.createModule(instanceName, dependencyResolver, bundleContext);
module.setBundleContext(bundleContext);
return module;
}
@Override
public Module createModule(String instanceName, DependencyResolver dependencyResolver,
DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
@Override
public Module createModule(String instanceName, DependencyResolver dependencyResolver,
DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
/**
* Returns an instance of provided RpcService type which delegates all calls
* to the delegate.
/**
* Returns an instance of provided RpcService type which delegates all calls
* to the delegate.
* <p>
* Returned instance:
* <ul>
* <p>
* Returned instance:
* <ul>
* all calls are delegated.
* <li>{@link DelegateProxy#setDelegate(Object)} - sets the delegate for
* particular instance
* all calls are delegated.
* <li>{@link DelegateProxy#setDelegate(Object)} - sets the delegate for
* particular instance
* @param serviceType
* - Subclass of RpcService for which direct proxy is to be
* generated.
* @return Instance of RpcService of provided serviceType which implements
* and {@link DelegateProxy}
* @throws IllegalArgumentException
* @param serviceType
* - Subclass of RpcService for which direct proxy is to be
* generated.
* @return Instance of RpcService of provided serviceType which implements
* and {@link DelegateProxy}
* @throws IllegalArgumentException
*/
<T extends RpcService> T getDirectProxyFor(Class<T> serviceType) throws IllegalArgumentException;
/**
* Returns an instance of provided RpcService type which routes all calls to
* other instances selected on particular input field.
*/
<T extends RpcService> T getDirectProxyFor(Class<T> serviceType) throws IllegalArgumentException;
/**
* Returns an instance of provided RpcService type which routes all calls to
* other instances selected on particular input field.
* <p>
* Returned instance:
* <ul>
* <p>
* Returned instance:
* <ul>
* is not present on any field invocation will be delegated to default
* service {@link RpcRouter#getDefaultService()}.
* </ul>
* is not present on any field invocation will be delegated to default
* service {@link RpcRouter#getDefaultService()}.
* </ul>
* @param serviceType
* - Subclass of RpcService for which Router is to be generated.
* @return Instance of RpcService of provided serviceType which implements
* @param serviceType
* - Subclass of RpcService for which Router is to be generated.
* @return Instance of RpcService of provided serviceType which implements
LOG.info("Starting Binding Aware Broker: {}", identifier);
controllerRoot = new RootSalInstance(getRpcProviderRegistry(), getNotificationBroker(), getDataBroker());
LOG.info("Starting Binding Aware Broker: {}", identifier);
controllerRoot = new RootSalInstance(getRpcProviderRegistry(), getNotificationBroker(), getDataBroker());
supportedConsumerServices = ImmutableClassToInstanceMap.<BindingAwareService> builder()
.put(NotificationService.class, getRoot()) //
supportedConsumerServices = ImmutableClassToInstanceMap.<BindingAwareService> builder()
.put(NotificationService.class, getRoot()) //
public void close() throws Exception {
// FIXME: Close all sessions
}
public void close() throws Exception {
// FIXME: Close all sessions
}
@Override
public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> type, T implementation)
throws IllegalStateException {
return getRoot().addRoutedRpcImplementation(type, implementation);
}
@Override
public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> type, T implementation)
throws IllegalStateException {
return getRoot().addRoutedRpcImplementation(type, implementation);
}
@Override
public <T extends RpcService> RpcRegistration<T> addRpcImplementation(Class<T> type, T implementation)
throws IllegalStateException {
return getRoot().addRpcImplementation(type, implementation);
}
@Override
public <T extends RpcService> RpcRegistration<T> addRpcImplementation(Class<T> type, T implementation)
throws IllegalStateException {
return getRoot().addRpcImplementation(type, implementation);
}
@Override
public <T extends RpcService> T getRpcService(Class<T> module) {
return getRoot().getRpcService(module);
@Override
public <T extends RpcService> T getRpcService(Class<T> module) {
return getRoot().getRpcService(module);
L arg0) {
return getRoot().registerRouteChangeListener(arg0);
}
L arg0) {
return getRoot().registerRouteChangeListener(arg0);
}
public class RootSalInstance extends
AbstractBindingSalProviderInstance<DataProviderService, NotificationProviderService, RpcProviderRegistry> {
public class RootSalInstance extends
AbstractBindingSalProviderInstance<DataProviderService, NotificationProviderService, RpcProviderRegistry> {
connector.startDataForwarding();
}
connector.startDataForwarding();
}
- public static void startNotificationForwarding(BindingIndependentConnector connector,
+ public static void startNotificationForwarding(BindingIndependentConnector connector,
NotificationProviderService baService, NotificationPublishService domService) {
if(connector.isNotificationForwarding()) {
return;
NotificationProviderService baService, NotificationPublishService domService) {
if(connector.isNotificationForwarding()) {
return;
DomForwardedBroker forwardedSource = (DomForwardedBroker) source;
DomForwardedBroker forwardedTarget = (DomForwardedBroker) target;
reuseForwardingFrom(forwardedTarget, forwardedSource);
DomForwardedBroker forwardedSource = (DomForwardedBroker) source;
DomForwardedBroker forwardedTarget = (DomForwardedBroker) target;
reuseForwardingFrom(forwardedTarget, forwardedSource);
}
private static void reuseForwardingFrom(DomForwardedBroker target, DomForwardedBroker source) {
}
private static void reuseForwardingFrom(DomForwardedBroker target, DomForwardedBroker source) {
package org.opendaylight.controller.sal.binding.spi;
public interface DelegateProxy<T> {
package org.opendaylight.controller.sal.binding.spi;
public interface DelegateProxy<T> {
void setDelegate(T delegate);
T getDelegate();
}
void setDelegate(T delegate);
T getDelegate();
}
public interface RemoteRpcRouter {
public interface RemoteRpcRouter {
ListenerRegistration<RouteChangeListener> registerRouteChangeListener(RouteChangeListener listener);
ListenerRegistration<RouteChangeListener> registerRouteChangeListener(RouteChangeListener listener);
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
public class UnionSerializationTest extends AbstractDataServiceTest {
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
public class UnionSerializationTest extends AbstractDataServiceTest {
public static final String PREFIX_STRING = "192.168.0.1/32";
public static final String PREFIX_STRING = "192.168.0.1/32";
@Test
public void testPrefixSerialization() throws Exception {
@Test
public void testPrefixSerialization() throws Exception {
Ipv4Prefix ipv4prefix = new Ipv4Prefix(PREFIX_STRING);
IpPrefix ipPrefix = new IpPrefix(ipv4prefix);
Prefix prefix = new PrefixBuilder().setPrefix(ipPrefix).build();
Ipv4Prefix ipv4prefix = new Ipv4Prefix(PREFIX_STRING);
IpPrefix ipPrefix = new IpPrefix(ipv4prefix);
Prefix prefix = new PrefixBuilder().setPrefix(ipPrefix).build();
CompositeNode serialized = testContext.getBindingToDomMappingService().toDataDom(prefix);
assertNotNull(serialized);
assertNotNull(serialized.getFirstSimpleByName(Prefix.QNAME));
assertEquals(PREFIX_STRING, serialized.getFirstSimpleByName(Prefix.QNAME).getValue());
CompositeNode serialized = testContext.getBindingToDomMappingService().toDataDom(prefix);
assertNotNull(serialized);
assertNotNull(serialized.getFirstSimpleByName(Prefix.QNAME));
assertEquals(PREFIX_STRING, serialized.getFirstSimpleByName(Prefix.QNAME).getValue());
Prefix deserialized = (Prefix) testContext.getBindingToDomMappingService().dataObjectFromDataDom(Prefix.class, serialized);
assertNotNull(deserialized);
assertNotNull(deserialized.getPrefix());
Prefix deserialized = (Prefix) testContext.getBindingToDomMappingService().dataObjectFromDataDom(Prefix.class, serialized);
assertNotNull(deserialized);
assertNotNull(deserialized.getPrefix());
public interface BarListener extends NotificationListener {
void onBarUpdate(BarUpdate notification);
public interface BarListener extends NotificationListener {
void onBarUpdate(BarUpdate notification);
void onFlowDelete(FlowDelete notification);
}
void onFlowDelete(FlowDelete notification);
}
public interface FooListener extends NotificationListener {
void onFooUpdate(FooUpdate notification);
public interface FooListener extends NotificationListener {
void onFooUpdate(FooUpdate notification);
import org.opendaylight.yangtools.yang.common.RpcResult;
public interface FooService extends RpcService {
import org.opendaylight.yangtools.yang.common.RpcResult;
public interface FooService extends RpcService {
Future<RpcResult<Void>> foo();
Future<RpcResult<Void>> foo();
Future<RpcResult<Void>> simple(SimpleInput obj);
Future<RpcResult<Void>> simple(SimpleInput obj);
Future<RpcResult<Void>> inheritedContext(InheritedContextInput obj);
}
Future<RpcResult<Void>> inheritedContext(InheritedContextInput obj);
}
public class RpcRegistrationNullPointer {
public class RpcRegistrationNullPointer {
/**
* We create transaction no 2
/**
* We create transaction no 2
*/
DataModificationTransaction removalTransaction = baDataService.beginTransaction();
assertNotNull(transaction);
/**
* We remove node 1
*/
DataModificationTransaction removalTransaction = baDataService.beginTransaction();
assertNotNull(transaction);
/**
* We remove node 1
*/
removalTransaction.removeConfigurationData(node1.getValue());
*/
removalTransaction.removeConfigurationData(node1.getValue());
registration.unregisterPath(context, path);
return this;
}
registration.unregisterPath(context, path);
return this;
}
public static MessageCapturingFlowService create() {
return new MessageCapturingFlowService();
}
public static MessageCapturingFlowService create() {
return new MessageCapturingFlowService();
}
public static MessageCapturingFlowService create(RpcProviderRegistry registry) {
MessageCapturingFlowService ret = new MessageCapturingFlowService();
ret.registerTo(registry);
return ret;
}
public static MessageCapturingFlowService create(RpcProviderRegistry registry) {
MessageCapturingFlowService ret = new MessageCapturingFlowService();
ret.registerTo(registry);
return ret;
}
public interface RegistrationListener<T extends Registration<?>> extends EventListener {
void onRegister(T registration);
public interface RegistrationListener<T extends Registration<?>> extends EventListener {
void onRegister(T registration);
void onUnregister(T registration);
}
void onUnregister(T registration);
}
public interface DataProvisionService<P extends Path<P> , D> {
public Registration<DataCommitHandler<P, D>> registerCommitHandler(P path, DataCommitHandler<P, D> commitHandler);
public interface DataProvisionService<P extends Path<P> , D> {
public Registration<DataCommitHandler<P, D>> registerCommitHandler(P path, DataCommitHandler<P, D> commitHandler);
-
- public ListenerRegistration<RegistrationListener<DataCommitHandlerRegistration<P, D>>>
+
+ public ListenerRegistration<RegistrationListener<DataCommitHandlerRegistration<P, D>>>
registerCommitHandlerListener(RegistrationListener<DataCommitHandlerRegistration<P, D>> commitHandlerListener);
}
registerCommitHandlerListener(RegistrationListener<DataCommitHandlerRegistration<P, D>> commitHandlerListener);
}
public interface NotificationPublishService<N> {
void publish(N notification);
public interface NotificationPublishService<N> {
void publish(N notification);
void publish(N notification,ExecutorService executor);
}
void publish(N notification,ExecutorService executor);
}
import org.opendaylight.yangtools.concepts.Path;
public interface MutableRoutingTable<C, P extends Path<P>, T> extends RoutingTable<C,P,T>, Mutable {
import org.opendaylight.yangtools.concepts.Path;
public interface MutableRoutingTable<C, P extends Path<P>, T> extends RoutingTable<C,P,T>, Mutable {
void setDefaultRoute(T target);
void updateRoute(P path,T target);
void removeRoute(P path);
void setDefaultRoute(T target);
void updateRoute(P path,T target);
void removeRoute(P path);
public interface Route<C,P> extends Immutable {
C getType();
public interface Route<C,P> extends Immutable {
C getType();
public interface RoutingTable<C, P extends Path<P>, T> {
C getIdentifier();
public interface RoutingTable<C, P extends Path<P>, T> {
C getIdentifier();
/**
* Base abstract implementation of DataReadRouter, which performs
* a read operation on multiple data readers and then merges result.
/**
* Base abstract implementation of DataReadRouter, which performs
* a read operation on multiple data readers and then merges result.
* @param <P>
* @param <D>
*/
* @param <P>
* @param <D>
*/
/**
* Merges data readed by reader instances from specified path
/**
* Merges data readed by reader instances from specified path
* @param path Path on which read was performed
* @param data Data which was returned by read operation.
* @return Merged result.
* @param path Path on which read was performed
* @param data Data which was returned by read operation.
* @return Merged result.
/**
* Returns a function which performs configuration read for supplied path
/**
* Returns a function which performs configuration read for supplied path
* @param path
* @return function which performs configuration read for supplied path
*/
* @param path
* @return function which performs configuration read for supplied path
*/
private Function<DataReader<P, D>, D> configurationRead(final P path) {
return new Function<DataReader<P, D>, D>() {
@Override
private Function<DataReader<P, D>, D> configurationRead(final P path) {
return new Function<DataReader<P, D>, D>() {
@Override
/**
* Returns a function which performs operational read for supplied path
/**
* Returns a function which performs operational read for supplied path
* @param path
* @return function which performs operational read for supplied path
*/
* @param path
* @return function which performs operational read for supplied path
*/
/**
* Register's a reader for operational data.
/**
* Register's a reader for operational data.
* @param path Path which is served by this reader
* @param reader Reader instance which is responsible for reading particular subpath.
* @param path Path which is served by this reader
* @param reader Reader instance which is responsible for reading particular subpath.
*/
public Registration<DataReader<P, D>> registerOperationalReader(P path, DataReader<P, D> reader) {
OperationalDataReaderRegistration<P, D> ret = new OperationalDataReaderRegistration<>(path, reader);
*/
public Registration<DataReader<P, D>> registerOperationalReader(P path, DataReader<P, D> reader) {
OperationalDataReaderRegistration<P, D> ret = new OperationalDataReaderRegistration<>(path, reader);
}
private Predicate<? super Entry<P, DataReaderRegistration<P, D>>> affects(final P path) {
}
private Predicate<? super Entry<P, DataReaderRegistration<P, D>>> affects(final P path) {
return new Predicate<Entry<P, DataReaderRegistration<P, D>>>() {
return new Predicate<Entry<P, DataReaderRegistration<P, D>>>() {
@Override
public boolean apply(Entry<P, DataReaderRegistration<P, D>> input) {
final P key = input.getKey();
return key.contains(path) || ((P) path).contains(key);
}
@Override
public boolean apply(Entry<P, DataReaderRegistration<P, D>> input) {
final P key = input.getKey();
return key.contains(path) || ((P) path).contains(key);
}
private final D updatedOperationalSubtree;
private final D updatedConfigurationSubtree;
private final D updatedOperationalSubtree;
private final D updatedConfigurationSubtree;
public DataChangeEventImpl(DataChange<P, D> dataChange, D originalConfigurationSubtree,
D originalOperationalSubtree, D updatedOperationalSubtree, D updatedConfigurationSubtree) {
super();
public DataChangeEventImpl(DataChange<P, D> dataChange, D originalConfigurationSubtree,
D originalOperationalSubtree, D updatedOperationalSubtree, D updatedConfigurationSubtree) {
super();
updatedConfigurationData = Collections.emptyMap();
updatedOperationalData = Collections.emptyMap();
}
updatedConfigurationData = Collections.emptyMap();
updatedOperationalData = Collections.emptyMap();
}
public InitialDataChangeEventImpl(D configTree, D operTree, Map<P, D> updatedCfgData, Map<P, D> updatedOperData) {
updatedConfigurationTree = configTree;
updatedOperationalTree = operTree;
updatedConfigurationData = updatedCfgData;
updatedOperationalData = updatedOperData;
}
public InitialDataChangeEventImpl(D configTree, D operTree, Map<P, D> updatedCfgData, Map<P, D> updatedOperData) {
updatedConfigurationTree = configTree;
updatedOperationalTree = operTree;
updatedConfigurationData = updatedCfgData;
updatedOperationalData = updatedOperData;
}
@Override
public Map<P, D> getCreatedConfigurationData() {
return Collections.emptyMap();
}
@Override
public Map<P, D> getCreatedConfigurationData() {
return Collections.emptyMap();
}
@Override
public Map<P, D> getCreatedOperationalData() {
return Collections.emptyMap();
}
@Override
public Map<P, D> getCreatedOperationalData() {
return Collections.emptyMap();
}
@Override
public Map<P, D> getOriginalConfigurationData() {
return Collections.emptyMap();
@Override
public Map<P, D> getOriginalConfigurationData() {
return Collections.emptyMap();
public Map<P, D> getUpdatedConfigurationData() {
return updatedConfigurationData;
}
public Map<P, D> getUpdatedConfigurationData() {
return updatedConfigurationData;
}
@Override
public D getUpdatedConfigurationSubtree() {
return updatedConfigurationTree;
@Override
public D getUpdatedConfigurationSubtree() {
return updatedConfigurationTree;
public D getUpdatedOperationalSubtree() {
return updatedOperationalTree;
}
public D getUpdatedOperationalSubtree() {
return updatedOperationalTree;
}
@Override
public D getOriginalConfigurationSubtree() {
return updatedConfigurationTree;
}
@Override
public D getOriginalConfigurationSubtree() {
return updatedConfigurationTree;
}
@Override
public D getOriginalOperationalSubtree() {
return updatedOperationalTree;
}
@Override
public D getOriginalOperationalSubtree() {
return updatedOperationalTree;
}
@Override
public Map<P, D> getUpdatedOperationalData() {
return updatedOperationalData;
}
@Override
public Map<P, D> getUpdatedOperationalData() {
return updatedOperationalData;
}
public class CommitHandlerTransactions {
private static class AllwaysSuccessfulTransaction<P extends Path<P>,D> implements DataCommitTransaction<P, D> {
public class CommitHandlerTransactions {
private static class AllwaysSuccessfulTransaction<P extends Path<P>,D> implements DataCommitTransaction<P, D> {
private final DataModification<P, D> modification;
public AllwaysSuccessfulTransaction(DataModification<P, D> modification) {
private final DataModification<P, D> modification;
public AllwaysSuccessfulTransaction(DataModification<P, D> modification) {
public RpcResult<Void> finish() throws IllegalStateException {
return Rpcs.<Void>getRpcResult(true, null, Collections.<RpcError>emptyList());
}
public RpcResult<Void> finish() throws IllegalStateException {
return Rpcs.<Void>getRpcResult(true, null, Collections.<RpcError>emptyList());
}
@Override
public DataModification<P, D> getModification() {
return modification;
}
}
@Override
public DataModification<P, D> getModification() {
return modification;
}
}
public static final <P extends Path<P>,D> AllwaysSuccessfulTransaction<P, D> allwaysSuccessfulTransaction(DataModification<P, D> modification) {
return new AllwaysSuccessfulTransaction<>(modification);
}
public static final <P extends Path<P>,D> AllwaysSuccessfulTransaction<P, D> allwaysSuccessfulTransaction(DataModification<P, D> modification) {
return new AllwaysSuccessfulTransaction<>(modification);
}
*
*/
public class RpcErrors {
*
*/
public class RpcErrors {
/**
* @param applicationTag
* @param tag
* @param info
* @param severity
* @param message
/**
* @param applicationTag
* @param tag
* @param info
* @param severity
* @param message
- * @param errorType
- * @param cause
+ * @param errorType
+ * @param cause
* @return {@link RpcError} implementation
*/
public static RpcError getRpcError(String applicationTag, String tag, String info,
ErrorSeverity severity, String message, ErrorType errorType, Throwable cause) {
* @return {@link RpcError} implementation
*/
public static RpcError getRpcError(String applicationTag, String tag, String info,
ErrorSeverity severity, String message, ErrorType errorType, Throwable cause) {
- RpcErrorTO ret = new RpcErrorTO(applicationTag, tag, info, severity, message,
+ RpcErrorTO ret = new RpcErrorTO(applicationTag, tag, info, severity, message,
errorType, cause);
return ret;
}
errorType, cause);
return ret;
}
public Throwable getCause() {
return cause;
}
public Throwable getCause() {
return cause;
}
@Override
public ErrorType getErrorType() {
return errorType;
@Override
public ErrorType getErrorType() {
return errorType;
public class ToSalPropertyClassUtils {
public static Bandwidth salAdvertisedBandwidthFrom(NodeConnector nodeConnector) {
public class ToSalPropertyClassUtils {
public static Bandwidth salAdvertisedBandwidthFrom(NodeConnector nodeConnector) {
- FlowCapableNodeConnector flowCapNodeConn = nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
+ FlowCapableNodeConnector flowCapNodeConn = nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
PortFeatures portFeatures = flowCapNodeConn.getAdvertisedFeatures();
return new AdvertisedBandwidth(resolveBandwidth(portFeatures));
}
public static Bandwidth salPeerBandwidthFrom(NodeConnector nodeConnector) {
PortFeatures portFeatures = flowCapNodeConn.getAdvertisedFeatures();
return new AdvertisedBandwidth(resolveBandwidth(portFeatures));
}
public static Bandwidth salPeerBandwidthFrom(NodeConnector nodeConnector) {
- FlowCapableNodeConnector flowCapNodeConn = nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
+ FlowCapableNodeConnector flowCapNodeConn = nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
PortFeatures portFeatures = flowCapNodeConn.getPeerFeatures();
return new PeerBandwidth(resolveBandwidth(portFeatures));
}
public static Bandwidth salSupportedBandwidthFrom(NodeConnector nodeConnector) {
PortFeatures portFeatures = flowCapNodeConn.getPeerFeatures();
return new PeerBandwidth(resolveBandwidth(portFeatures));
}
public static Bandwidth salSupportedBandwidthFrom(NodeConnector nodeConnector) {
- FlowCapableNodeConnector flowCapNodeConn = nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
+ FlowCapableNodeConnector flowCapNodeConn = nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
PortFeatures portFeatures = flowCapNodeConn.getSupported();
return new SupportedBandwidth(resolveBandwidth(portFeatures));
}
public static MacAddress salMacAddressFrom(NodeConnector nodeConnector) {
PortFeatures portFeatures = flowCapNodeConn.getSupported();
return new SupportedBandwidth(resolveBandwidth(portFeatures));
}
public static MacAddress salMacAddressFrom(NodeConnector nodeConnector) {
- FlowCapableNodeConnector flowCapNodeConn = nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
+ FlowCapableNodeConnector flowCapNodeConn = nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
String hwAddress = flowCapNodeConn.getHardwareAddress().getValue();
String hwAddress = flowCapNodeConn.getHardwareAddress().getValue();
- return new MacAddress(bytesFrom(hwAddress));
+ return new MacAddress(bytesFrom(hwAddress));
public static Name salNameFrom(NodeConnector nodeConnector) {
public static Name salNameFrom(NodeConnector nodeConnector) {
- FlowCapableNodeConnector flowCapNodeConn = nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
+ FlowCapableNodeConnector flowCapNodeConn = nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
return new Name(flowCapNodeConn.getName());
}
return new Name(flowCapNodeConn.getName());
}
private static byte[] bytesFrom(String hwAddress) {
String[] mac = hwAddress.split(":");
private static byte[] bytesFrom(String hwAddress) {
String[] mac = hwAddress.split(":");
/**
* Java class name of Rpc Context
/**
* Java class name of Rpc Context
*/
@Override
public String getContext() {
*/
@Override
public String getContext() {
/**
* String representation of route e.g. node-id
/**
* String representation of route e.g. node-id
*/
@Override
public String getRoute() {
*/
@Override
public String getRoute() {
/**
* Java class name of Rpc Type e.g org.opendaylight.AddFlowInput
/**
* Java class name of Rpc Type e.g org.opendaylight.AddFlowInput
*/
@Override
public String getType() {
*/
@Override
public String getType() {
public class BindingAwareZeroMqRpcRouter implements BindingAwareRpcRouter {
BindingAwareRpcRouter mdSalRouter;
public class BindingAwareZeroMqRpcRouter implements BindingAwareRpcRouter {
BindingAwareRpcRouter mdSalRouter;
public BindingAwareRpcRouter getMdSalRouter() {
return mdSalRouter;
}
public BindingAwareRpcRouter getMdSalRouter() {
return mdSalRouter;
}
// Write message down to the wire
return null;
}
// Write message down to the wire
return null;
}
// Receiver part - invoked when request is received and deserialized
private Future<RpcReply<byte[]>> receivedRequest(RpcRequest<String, String, String, byte[]> input) {
// Receiver part - invoked when request is received and deserialized
private Future<RpcReply<byte[]>> receivedRequest(RpcRequest<String, String, String, byte[]> input) {
return mdSalRouter.sendRpc(input);
}
return mdSalRouter.sendRpc(input);
}
public interface Connector extends RpcImplementation, NotificationListener {
public interface Connector extends RpcImplementation, NotificationListener {
Set<InstanceIdentifier> getConfigurationPrefixes();
Set<InstanceIdentifier> getRuntimePrefixes();
Set<InstanceIdentifier> getConfigurationPrefixes();
Set<InstanceIdentifier> getRuntimePrefixes();
void registerListener(ConnectorListener listener);
void unregisterListener(ConnectorListener listener);
}
void registerListener(ConnectorListener listener);
void unregisterListener(ConnectorListener listener);
}
import java.util.concurrent.Future;
/**
import java.util.concurrent.Future;
/**
* @author ttkacik
*
* @param <C> Routing Context Identifier
* @author ttkacik
*
* @param <C> Routing Context Identifier
*/
public interface RpcRouter<C,T,R,D> {
*/
public interface RpcRouter<C,T,R,D> {
Future<RpcReply<D>> sendRpc(RpcRequest<C, T, R, D> input);
Future<RpcReply<D>> sendRpc(RpcRequest<C, T, R, D> input);
*
* @param <C> Routing Context Identifier
* @param <R> Route Type
*
* @param <C> Routing Context Identifier
* @param <R> Route Type
RouteIdentifier<C,T,R> getRoutingInformation();
D getPayload();
}
RouteIdentifier<C,T,R> getRoutingInformation();
D getPayload();
}
public interface RouteIdentifier<C,T,R> {
public interface RouteIdentifier<C,T,R> {
C getContext(); // defines a routing table (e.g. NodeContext)
T getType(); // rpc type
R getRoute(); // e.g. (node identity)
}
C getContext(); // defines a routing table (e.g. NodeContext)
T getType(); // rpc type
R getRoute(); // e.g. (node identity)
}
public interface RpcReply<D> {
D getPayload();
}
public interface RpcReply<D> {
D getPayload();
}
public abstract class AbstractConsumer implements Consumer, BundleActivator,ServiceTrackerCustomizer<Broker, Broker> {
public abstract class AbstractConsumer implements Consumer, BundleActivator,ServiceTrackerCustomizer<Broker, Broker> {
private BundleContext context;
private ServiceTracker<Broker, Broker> tracker;
private Broker broker;
private BundleContext context;
private ServiceTracker<Broker, Broker> tracker;
private Broker broker;
return Collections.emptySet();
}
return Collections.emptySet();
}
@Override
public Broker addingService(ServiceReference<Broker> reference) {
if(broker == null) {
@Override
public Broker addingService(ServiceReference<Broker> reference) {
if(broker == null) {
broker.registerConsumer(this, context);
return broker;
}
broker.registerConsumer(this, context);
return broker;
}
@Override
public void modifiedService(ServiceReference<Broker> reference, Broker service) {
// NOOP
}
@Override
public void modifiedService(ServiceReference<Broker> reference, Broker service) {
// NOOP
}
@Override
public void removedService(ServiceReference<Broker> reference, Broker service) {
stopImpl(context);
@Override
public void removedService(ServiceReference<Broker> reference, Broker service) {
stopImpl(context);
import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession;
/**
import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession;
/**
* Session-specific instance of the broker functionality.
* Session-specific instance of the broker functionality.
* <p>
* BrokerService is marker interface for infrastructure services provided by the
* SAL. These services are session-specific, each {@link Provider} and
* {@link Consumer} usually has own instance of the service with it's own
* context.
* <p>
* BrokerService is marker interface for infrastructure services provided by the
* SAL. These services are session-specific, each {@link Provider} and
* {@link Consumer} usually has own instance of the service with it's own
* context.
* <p>
* The consumer's (or provider's) instance of specific service could be obtained
* by invoking {@link ConsumerSession#getService(Class)} method on session
* assigned to the consumer.
* <p>
* The consumer's (or provider's) instance of specific service could be obtained
* by invoking {@link ConsumerSession#getService(Class)} method on session
* assigned to the consumer.
* <p>
* {@link BrokerService} and {@link Provider} may seem similar, but provider
* provides YANG model-based functionality and {@link BrokerService} exposes the
* necessary supporting functionality to implement specific functionality of
* YANG and to reuse it in the development of {@link Consumer}s and
* {@link Provider}s.
* <p>
* {@link BrokerService} and {@link Provider} may seem similar, but provider
* provides YANG model-based functionality and {@link BrokerService} exposes the
* necessary supporting functionality to implement specific functionality of
* YANG and to reuse it in the development of {@link Consumer}s and
* {@link Provider}s.
*/
public interface BrokerService {
*/
public interface BrokerService {
import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession;
/**
import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession;
/**
* Defines the component of controller and supplies additional metadata. A
* component of the controller or application supplies a concrete implementation
* of this interface.
* Defines the component of controller and supplies additional metadata. A
* component of the controller or application supplies a concrete implementation
* of this interface.
* A user-implemented component (application) which facilitates the SAL and SAL
* services to access infrastructure services or providers' functionality.
* A user-implemented component (application) which facilitates the SAL and SAL
* services to access infrastructure services or providers' functionality.
*/
public interface Consumer {
/**
* Callback signaling initialization of the consumer session to the SAL.
*/
public interface Consumer {
/**
* Callback signaling initialization of the consumer session to the SAL.
* The consumer MUST use the session for all communication with SAL or
* retrieving SAL infrastructure services.
* The consumer MUST use the session for all communication with SAL or
* retrieving SAL infrastructure services.
* This method is invoked by {@link Broker#registerConsumer(Consumer)}
* This method is invoked by {@link Broker#registerConsumer(Consumer)}
* @param session
* Unique session between consumer and SAL.
*/
* @param session
* Unique session between consumer and SAL.
*/
/**
* Get a set of implementations of consumer functionality to be registered
* into system during the consumer registration to the SAL.
/**
* Get a set of implementations of consumer functionality to be registered
* into system during the consumer registration to the SAL.
* This method is invoked by {@link Broker#registerConsumer(Consumer)}.
* This method is invoked by {@link Broker#registerConsumer(Consumer)}.
* @return Set of consumer functionality.
*/
public Collection<ConsumerFunctionality> getConsumerFunctionality();
* @return Set of consumer functionality.
*/
public Collection<ConsumerFunctionality> getConsumerFunctionality();
/**
* The marker interface for the interfaces describing the consumer
* functionality contracts.
/**
* The marker interface for the interfaces describing the consumer
* functionality contracts.
*/
public interface ConsumerFunctionality {
*/
public interface ConsumerFunctionality {
import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
/**
import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
/**
* Defines the component of controller and supplies additional metadata. A
* component of the controller or application supplies a concrete implementation
* of this interface.
* Defines the component of controller and supplies additional metadata. A
* component of the controller or application supplies a concrete implementation
* of this interface.
* <p>
* A user-implemented component (application) which facilitates the SAL and SAL
* services to access infrastructure services and to provide functionality to
* {@link Consumer}s and other providers.
* <p>
* A user-implemented component (application) which facilitates the SAL and SAL
* services to access infrastructure services and to provide functionality to
* {@link Consumer}s and other providers.
*/
public interface Provider {
/**
* Callback signaling initialization of the provider session to the SAL.
*/
public interface Provider {
/**
* Callback signaling initialization of the provider session to the SAL.
* <p>
* The provider <b>MUST use the session</b> for all communication with SAL
* or retrieving SAL infrastructure services.
* <p>
* The provider <b>MUST use the session</b> for all communication with SAL
* or retrieving SAL infrastructure services.
* <p>
* This method is invoked by {@link Broker#registerConsumer(Consumer)}
* <p>
* This method is invoked by {@link Broker#registerConsumer(Consumer)}
* @param session
* Unique session between provider and SAL.
*/
* @param session
* Unique session between provider and SAL.
*/
/**
* Gets a set of implementations of provider functionality to be registered
* into system during the provider registration to the SAL.
/**
* Gets a set of implementations of provider functionality to be registered
* into system during the provider registration to the SAL.
* <p>
* This method is invoked by {@link Broker#registerProvider(Provider)} to
* learn the initial provided functionality
* <p>
* This method is invoked by {@link Broker#registerProvider(Provider)} to
* learn the initial provided functionality
* @return Set of provider's functionality.
*/
public Collection<ProviderFunctionality> getProviderFunctionality();
/**
* Functionality provided by the {@link Provider}
* @return Set of provider's functionality.
*/
public Collection<ProviderFunctionality> getProviderFunctionality();
/**
* Functionality provided by the {@link Provider}
* <p>
* Marker interface used to mark the interfaces describing specific
* functionality which could be exposed by providers to other components.
* <p>
* Marker interface used to mark the interfaces describing specific
* functionality which could be exposed by providers to other components.
*/
public interface ProviderFunctionality {
*/
public interface ProviderFunctionality {
public interface RpcConsumptionRegistry {
/**
* Sends an RPC to other components registered to the broker.
public interface RpcConsumptionRegistry {
/**
* Sends an RPC to other components registered to the broker.
* @see RpcImplementation
* @param rpc
* Name of RPC
* @see RpcImplementation
* @param rpc
* Name of RPC
/**
* Registers an implementation of the rpc.
/**
* Registers an implementation of the rpc.
* <p>
* The registered rpc functionality will be available to all other
* consumers and providers registered to the broker, which are aware of
* the {@link QName} assigned to the rpc.
* <p>
* The registered rpc functionality will be available to all other
* consumers and providers registered to the broker, which are aware of
* the {@link QName} assigned to the rpc.
* <p>
* There is no assumption that rpc type is in the set returned by
* invoking {@link RpcImplementation#getSupportedRpcs()}. This allows
* for dynamic rpc implementations.
* <p>
* There is no assumption that rpc type is in the set returned by
* invoking {@link RpcImplementation#getSupportedRpcs()}. This allows
* for dynamic rpc implementations.
* @param rpcType
* Name of Rpc
* @param implementation
* @param rpcType
* Name of Rpc
* @param implementation
*/
RpcRegistration addRpcImplementation(QName rpcType, RpcImplementation implementation)
throws IllegalArgumentException;
*/
RpcRegistration addRpcImplementation(QName rpcType, RpcImplementation implementation)
throws IllegalArgumentException;
ListenerRegistration<RpcRegistrationListener> addRpcRegistrationListener(RpcRegistrationListener listener);
RoutedRpcRegistration addRoutedRpcImplementation(QName rpcType, RpcImplementation implementation);
ListenerRegistration<RpcRegistrationListener> addRpcRegistrationListener(RpcRegistrationListener listener);
RoutedRpcRegistration addRoutedRpcImplementation(QName rpcType, RpcImplementation implementation);
import org.opendaylight.yangtools.yang.common.QName;
public interface RpcRegistrationListener extends EventListener {
import org.opendaylight.yangtools.yang.common.QName;
public interface RpcRegistrationListener extends EventListener {
public void onRpcImplementationAdded(QName name);
public void onRpcImplementationAdded(QName name);
public void onRpcImplementationRemoved(QName name);
}
public void onRpcImplementationRemoved(QName name);
}
public class RpcRoutingContext implements Immutable, Serializable {
/**
public class RpcRoutingContext implements Immutable, Serializable {
/**
*/
private static final long serialVersionUID = -9079324728075883325L;
*/
private static final long serialVersionUID = -9079324728075883325L;
private final QName context;
private final QName rpc;
private final QName context;
private final QName rpc;
private RpcRoutingContext(QName context, QName rpc) {
super();
this.context = context;
this.rpc = rpc;
}
private RpcRoutingContext(QName context, QName rpc) {
super();
this.context = context;
this.rpc = rpc;
}
public static final RpcRoutingContext create(QName context, QName rpc) {
return new RpcRoutingContext(context, rpc);
}
public static final RpcRoutingContext create(QName context, QName rpc) {
return new RpcRoutingContext(context, rpc);
}
/**
* DataBrokerService provides unified access to the data stores available in the
* system.
/**
* DataBrokerService provides unified access to the data stores available in the
* system.
* @see DataProviderService
* @see DataProviderService
-public interface DataBrokerService extends
+public interface DataBrokerService extends
BrokerService, //
DataReader<InstanceIdentifier, CompositeNode>, //
DataModificationTransactionFactory<InstanceIdentifier, CompositeNode>, //
BrokerService, //
DataReader<InstanceIdentifier, CompositeNode>, //
DataModificationTransactionFactory<InstanceIdentifier, CompositeNode>, //
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
import org.opendaylight.controller.md.sal.common.api.data.DataReader;;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
import org.opendaylight.controller.md.sal.common.api.data.DataReader;;
-public interface DataProviderService extends
+public interface DataProviderService extends
DataBrokerService, //
DataProvisionService<InstanceIdentifier, CompositeNode>
{
/**
* Adds {@link DataValidator} for specified Data Store
DataBrokerService, //
DataProvisionService<InstanceIdentifier, CompositeNode>
{
/**
* Adds {@link DataValidator} for specified Data Store
* @param store
* Data Store
* @param validator
* @param store
* Data Store
* @param validator
/**
* Removes {@link DataValidator} from specified Data Store
/**
* Removes {@link DataValidator} from specified Data Store
* @param store
* @param validator
* Validator
* @param store
* @param validator
* Validator
/**
* Adds {@link DataRefresher} for specified data store
/**
* Adds {@link DataRefresher} for specified data store
* @param store
* @param refresher
*/
* @param store
* @param refresher
*/
/**
* Removes {@link DataRefresher} from specified data store
/**
* Removes {@link DataRefresher} from specified data store
* @param store
* @param refresher
*/
void removeRefresher(DataStoreIdentifier store, DataRefresher refresher);
* @param store
* @param refresher
*/
void removeRefresher(DataStoreIdentifier store, DataRefresher refresher);
Registration<DataReader<InstanceIdentifier, CompositeNode>> registerConfigurationReader(InstanceIdentifier path, DataReader<InstanceIdentifier, CompositeNode> reader);
Registration<DataReader<InstanceIdentifier, CompositeNode>> registerOperationalReader(InstanceIdentifier path, DataReader<InstanceIdentifier, CompositeNode> reader);
Registration<DataReader<InstanceIdentifier, CompositeNode>> registerConfigurationReader(InstanceIdentifier path, DataReader<InstanceIdentifier, CompositeNode> reader);
Registration<DataReader<InstanceIdentifier, CompositeNode>> registerOperationalReader(InstanceIdentifier path, DataReader<InstanceIdentifier, CompositeNode> reader);
public interface DataRefresher extends Provider.ProviderFunctionality {
/**
* Fired when some component explicitly requested the data refresh.
public interface DataRefresher extends Provider.ProviderFunctionality {
/**
* Fired when some component explicitly requested the data refresh.
* The provider which exposed the {@link DataRefresher} should republish
* its provided data by editing the data in all affected data stores.
*/
* The provider which exposed the {@link DataRefresher} should republish
* its provided data by editing the data in all affected data stores.
*/
public interface DataStore extends //
DataReader<InstanceIdentifier, CompositeNode>,
DataCommitHandler<InstanceIdentifier, CompositeNode> {
public interface DataStore extends //
DataReader<InstanceIdentifier, CompositeNode>,
DataCommitHandler<InstanceIdentifier, CompositeNode> {
Iterable<InstanceIdentifier> getStoredConfigurationPaths();
Iterable<InstanceIdentifier> getStoredOperationalPaths();
Iterable<InstanceIdentifier> getStoredConfigurationPaths();
Iterable<InstanceIdentifier> getStoredOperationalPaths();
boolean containsConfigurationPath(InstanceIdentifier path);
boolean containsOperationalPath(InstanceIdentifier path);
boolean containsConfigurationPath(InstanceIdentifier path);
boolean containsOperationalPath(InstanceIdentifier path);
/**
* {@link Provider}-supplied Validator of the data.
/**
* {@link Provider}-supplied Validator of the data.
* <p>
* The registration could be done by :
* <ul>
* <p>
* The registration could be done by :
* <ul>
* as arguments to the
* {@link DataProviderService#addValidator(DataStoreIdentifier, DataValidator)}
* </ul>
* as arguments to the
* {@link DataProviderService#addValidator(DataStoreIdentifier, DataValidator)}
* </ul>
**/
public interface DataValidator extends Provider.ProviderFunctionality {
/**
* A set of Data Stores supported by implementation.
**/
public interface DataValidator extends Provider.ProviderFunctionality {
/**
* A set of Data Stores supported by implementation.
* The set of {@link DataStoreIdentifier}s which identifies target data
* stores which are supported by this implementation. This set is used, when
* {@link Provider} is registered to the SAL, to register and expose the
* validation functionality to affected data stores.
* The set of {@link DataStoreIdentifier}s which identifies target data
* stores which are supported by this implementation. This set is used, when
* {@link Provider} is registered to the SAL, to register and expose the
* validation functionality to affected data stores.
* @return Set of Data Store identifiers
*/
Set<DataStoreIdentifier> getSupportedDataStores();
/**
* Performs validation on supplied data.
* @return Set of Data Store identifiers
*/
Set<DataStoreIdentifier> getSupportedDataStores();
/**
* Performs validation on supplied data.
* @param toValidate
* Data to validate
* @return Validation result. The
* @param toValidate
* Data to validate
* @return Validation result. The
public interface NotificationListener extends Consumer.ConsumerFunctionality, EventListener {
/**
* A set of notification types supported by listeners.
public interface NotificationListener extends Consumer.ConsumerFunctionality, EventListener {
/**
* A set of notification types supported by listeners.
* The set of notification {@link QName}s which are supported by this
* listener. This set is used, when {@link Consumer} is registered to the
* SAL, to automatically register the listener.
* The set of notification {@link QName}s which are supported by this
* listener. This set is used, when {@link Consumer} is registered to the
* SAL, to automatically register the listener.
* @return Set of QNames identifying supported notifications.
*/
Set<QName> getSupportedNotifications();
/**
* Fired when the notification occurs.
* @return Set of QNames identifying supported notifications.
*/
Set<QName> getSupportedNotifications();
/**
* Fired when the notification occurs.
* The type of the notification could be learned by
* <code>QName type = notification.getNodeType();</code>
* The type of the notification could be learned by
* <code>QName type = notification.getNodeType();</code>
* @param notification
* Notification content
*/
* @param notification
* Notification content
*/
/**
* Notification Publishing Service
/**
* Notification Publishing Service
* The simplified process of the notification publishing is following:
* The simplified process of the notification publishing is following:
* <ol>
* <li> {@link Provider} invokes {@link #sendNotification(CompositeNode)}
* <li> {@link Broker} finds {@link NotificationListener}s which subscribed for
* the notification type.
* <ol>
* <li> {@link Provider} invokes {@link #sendNotification(CompositeNode)}
* <li> {@link Broker} finds {@link NotificationListener}s which subscribed for
* the notification type.
* <li>For each subscriber {@link Broker} invokes
* {@link NotificationListener#onNotification(CompositeNode)}
* </ol>
* <li>For each subscriber {@link Broker} invokes
* {@link NotificationListener#onNotification(CompositeNode)}
* </ol>
public interface NotificationPublishService extends NotificationService {
/**
* Publishes a notification.
public interface NotificationPublishService extends NotificationService {
/**
* Publishes a notification.
* Notification type is determined by the
* {@link CompositeNode#getNodeType()} of the
* <code>notification<code> parameter.
* Notification type is determined by the
* {@link CompositeNode#getNodeType()} of the
* <code>notification<code> parameter.
* @param notification
* Notification to publish
*/
* @param notification
* Notification to publish
*/
/**
* NotificationService provides access to the notification functionality of the
* SAL.
/**
* NotificationService provides access to the notification functionality of the
* SAL.
* NotificationService allows for consumption of notifications by registering
* implementations of NotificationListener.
* NotificationService allows for consumption of notifications by registering
* implementations of NotificationListener.
* The registration of notification listeners could be done by:
* <ul>
* <li>returning an instance of implementation in the return value of
* The registration of notification listeners could be done by:
* <ul>
* <li>returning an instance of implementation in the return value of
* arguments to the
* {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)}
* </ul>
* arguments to the
* {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)}
* </ul>
*/
public interface NotificationService extends BrokerService {
/**
* Registers a notification listener for supplied notification type.
*/
public interface NotificationService extends BrokerService {
/**
* Registers a notification listener for supplied notification type.
* @param notification
* @param listener
*/
* @param notification
* @param listener
*/
public class DomBrokerRuntimeMXBeanImpl implements
DomBrokerImplRuntimeMXBean {
public class DomBrokerRuntimeMXBeanImpl implements
DomBrokerImplRuntimeMXBean {
private final DataBrokerImpl dataService;
private final Transactions transactions = new Transactions();
private final Data data = new Data();
private final DataBrokerImpl dataService;
private final Transactions transactions = new Transactions();
private final Data data = new Data();
public DomBrokerRuntimeMXBeanImpl(DataBrokerImpl dataService) {
public DomBrokerRuntimeMXBeanImpl(DataBrokerImpl dataService) {
- this.dataService = dataService;
+ this.dataService = dataService;
}
public Transactions getTransactions() {
}
public Transactions getTransactions() {
/**
* In-memory DOM Data Store
/**
* In-memory DOM Data Store
* Implementation of {@link DOMStore} which uses {@link DataTree} and other
* classes such as {@link SnapshotBackedWriteTransaction}.
* {@link SnapshotBackedReadTransaction} and {@link ResolveDataChangeEventsTask}
* to implement {@link DOMStore} contract.
* Implementation of {@link DOMStore} which uses {@link DataTree} and other
* classes such as {@link SnapshotBackedWriteTransaction}.
* {@link SnapshotBackedReadTransaction} and {@link ResolveDataChangeEventsTask}
* to implement {@link DOMStore} contract.
*/
public class InMemoryDOMDataStore implements DOMStore, Identifiable<String>, SchemaContextListener,
TransactionReadyPrototype {
*/
public class InMemoryDOMDataStore implements DOMStore, Identifiable<String>, SchemaContextListener,
TransactionReadyPrototype {
/*
* Make sure commit is not occurring right now. Listener has to be
* registered and its state capture enqueued at a consistent point.
/*
* Make sure commit is not occurring right now. Listener has to be
* registered and its state capture enqueued at a consistent point.
* FIXME: improve this to read-write lock, such that multiple listener
* registrations can occur simultaneously
*/
* FIXME: improve this to read-write lock, such that multiple listener
* registrations can occur simultaneously
*/
* Implementation of Write transaction which is backed by
* {@link DataTreeSnapshot} and executed according to
* {@link TransactionReadyPrototype}.
* Implementation of Write transaction which is backed by
* {@link DataTreeSnapshot} and executed according to
* {@link TransactionReadyPrototype}.
*/
class SnapshotBackedWriteTransaction extends AbstractDOMStoreTransaction implements DOMStoreWriteTransaction {
*/
class SnapshotBackedWriteTransaction extends AbstractDOMStoreTransaction implements DOMStoreWriteTransaction {
/**
* Creates new write-only transaction.
/**
* Creates new write-only transaction.
* @param identifier
* transaction Identifier
* @param snapshot
* @param identifier
* transaction Identifier
* @param snapshot
/**
* Prototype implementation of
* {@link #ready(SnapshotBackedWriteTransaction)}
/**
* Prototype implementation of
* {@link #ready(SnapshotBackedWriteTransaction)}
* This class is intended to be implemented by Transaction factories
* responsible for allocation of {@link SnapshotBackedWriteTransaction} and
* providing underlying logic for applying implementation.
* This class is intended to be implemented by Transaction factories
* responsible for allocation of {@link SnapshotBackedWriteTransaction} and
* providing underlying logic for applying implementation.
*/
public static interface TransactionReadyPrototype {
/**
* Returns a commit coordinator associated with supplied transactions.
*/
public static interface TransactionReadyPrototype {
/**
* Returns a commit coordinator associated with supplied transactions.
* This call must not fail.
* This call must not fail.
* @param tx
* Transaction on which ready was invoked.
* @return DOMStoreThreePhaseCommitCohort associated with transaction
* @param tx
* Transaction on which ready was invoked.
* @return DOMStoreThreePhaseCommitCohort associated with transaction
/**
* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
/**
* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
private AtomicLong nextTransaction = new AtomicLong();
private final AtomicLong createdTransactionsCount = new AtomicLong();
private AtomicLong nextTransaction = new AtomicLong();
private final AtomicLong createdTransactionsCount = new AtomicLong();
public DataBrokerImpl() {
setDataReadRouter(new DataReaderRouter());
setExecutor(MoreExecutors.sameThreadExecutor());
}
public DataBrokerImpl() {
setDataReadRouter(new DataReaderRouter());
setExecutor(MoreExecutors.sameThreadExecutor());
}
public AtomicLong getCreatedTransactionsCount() {
return createdTransactionsCount;
}
public AtomicLong getCreatedTransactionsCount() {
return createdTransactionsCount;
}
@Override
public DataTransactionImpl beginTransaction() {
String transactionId = "DOM-" + nextTransaction.getAndIncrement();
@Override
public DataTransactionImpl beginTransaction() {
String transactionId = "DOM-" + nextTransaction.getAndIncrement();
@Override
public void close() throws Exception {
@Override
public void close() throws Exception {
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-public class DataTransactionImpl extends AbstractDataTransaction<InstanceIdentifier, CompositeNode>
+public class DataTransactionImpl extends AbstractDataTransaction<InstanceIdentifier, CompositeNode>
implements DataModificationTransaction {
private final ListenerRegistry<DataTransactionListener> listeners = new ListenerRegistry<DataTransactionListener>();
implements DataModificationTransaction {
private final ListenerRegistry<DataTransactionListener> listeners = new ListenerRegistry<DataTransactionListener>();
public DataTransactionImpl(Object identifier,DataBrokerImpl dataBroker) {
super(identifier,dataBroker);
}
public DataTransactionImpl(Object identifier,DataBrokerImpl dataBroker) {
super(identifier,dataBroker);
}
public DataModificationTransaction beginTransaction() {
return getDelegate().beginTransaction();
}
public DataModificationTransaction beginTransaction() {
return getDelegate().beginTransaction();
}
public void removeValidator(DataStoreIdentifier store, DataValidator validator) {
getDelegate().removeValidator(store, validator);
}
public void removeValidator(DataStoreIdentifier store, DataValidator validator) {
getDelegate().removeValidator(store, validator);
}
@Override
public ListenerRegistration<RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier, CompositeNode>>> registerCommitHandlerListener(
RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier, CompositeNode>> commitHandlerListener) {
@Override
public ListenerRegistration<RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier, CompositeNode>>> registerCommitHandlerListener(
RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier, CompositeNode>> commitHandlerListener) {
/**
* Registers a notification listener for supplied notification type.
/**
* Registers a notification listener for supplied notification type.
* @param notification
* @param listener
*/
* @param notification
* @param listener
*/
// TODO Auto-generated constructor stub
}
// TODO Auto-generated constructor stub
}
public static Map<Map<QName,Object>,CompositeNode> toIndexMap(List<CompositeNode> nodes,List<QName> keys) {
ConcurrentHashMap<Map<QName,Object>,CompositeNode> ret = new ConcurrentHashMap<>();
for(CompositeNode node : nodes) {
public static Map<Map<QName,Object>,CompositeNode> toIndexMap(List<CompositeNode> nodes,List<QName> keys) {
ConcurrentHashMap<Map<QName,Object>,CompositeNode> ret = new ConcurrentHashMap<>();
for(CompositeNode node : nodes) {
checkArgument(keyNode != null,"Node must contains all keys.");
Object value = keyNode.getValue();
map.put(key, value);
checkArgument(keyNode != null,"Node must contains all keys.");
Object value = keyNode.getValue();
map.put(key, value);
public class YangSchemaUtils {
private static final Function<PathArgument, QName> QNAME_FROM_PATH_ARGUMENT = new Function<PathArgument, QName>(){
public class YangSchemaUtils {
private static final Function<PathArgument, QName> QNAME_FROM_PATH_ARGUMENT = new Function<PathArgument, QName>(){
@Override
public QName apply(PathArgument input) {
if(input == null) {
@Override
public QName apply(PathArgument input) {
if(input == null) {
private YangSchemaUtils() {
throw new UnsupportedOperationException("Utility class.");
}
private YangSchemaUtils() {
throw new UnsupportedOperationException("Utility class.");
}
public static DataSchemaNode getSchemaNode(SchemaContext schema,InstanceIdentifier path) {
checkArgument(schema != null,"YANG Schema must not be null.");
checkArgument(path != null,"Path must not be null.");
return getSchemaNode(schema, FluentIterable.from(path.getPath()).transform(QNAME_FROM_PATH_ARGUMENT));
}
public static DataSchemaNode getSchemaNode(SchemaContext schema,InstanceIdentifier path) {
checkArgument(schema != null,"YANG Schema must not be null.");
checkArgument(path != null,"Path must not be null.");
return getSchemaNode(schema, FluentIterable.from(path.getPath()).transform(QNAME_FROM_PATH_ARGUMENT));
}
public static DataSchemaNode getSchemaNode(SchemaContext schema,Iterable<QName> path) {
checkArgument(schema != null,"YANG Schema must not be null.");
checkArgument(path != null,"Path must not be null.");
if(!path.iterator().hasNext()){
return toRootDataNode(schema);
}
public static DataSchemaNode getSchemaNode(SchemaContext schema,Iterable<QName> path) {
checkArgument(schema != null,"YANG Schema must not be null.");
checkArgument(path != null,"Path must not be null.");
if(!path.iterator().hasNext()){
return toRootDataNode(schema);
}
QName firstNode = path.iterator().next();
DataNodeContainer previous = schema.findModuleByNamespaceAndRevision(firstNode.getNamespace(),
firstNode.getRevision());
Iterator<QName> iterator = path.iterator();
QName firstNode = path.iterator().next();
DataNodeContainer previous = schema.findModuleByNamespaceAndRevision(firstNode.getNamespace(),
firstNode.getRevision());
Iterator<QName> iterator = path.iterator();
while (iterator.hasNext()) {
checkArgument(previous!= null, "Supplied path does not resolve into valid schema node.");
QName arg = iterator.next();
while (iterator.hasNext()) {
checkArgument(previous!= null, "Supplied path does not resolve into valid schema node.");
QName arg = iterator.next();
}
private static final class NetconfDataRootNode implements ContainerSchemaNode {
}
private static final class NetconfDataRootNode implements ContainerSchemaNode {
public NetconfDataRootNode(SchemaContext schema) {
// TODO Auto-generated constructor stub
}
public NetconfDataRootNode(SchemaContext schema) {
// TODO Auto-generated constructor stub
}
@Override
public Set<TypeDefinition<?>> getTypeDefinitions() {
// TODO Auto-generated method stub
return null;
}
@Override
public Set<TypeDefinition<?>> getTypeDefinitions() {
// TODO Auto-generated method stub
return null;
}
@Override
public Set<DataSchemaNode> getChildNodes() {
// TODO Auto-generated method stub
return null;
}
@Override
public Set<DataSchemaNode> getChildNodes() {
// TODO Auto-generated method stub
return null;
}
@Override
public Set<GroupingDefinition> getGroupings() {
// TODO Auto-generated method stub
return null;
}
@Override
public Set<GroupingDefinition> getGroupings() {
// TODO Auto-generated method stub
return null;
}
@Override
public DataSchemaNode getDataChildByName(QName name) {
// TODO Auto-generated method stub
return null;
}
@Override
public DataSchemaNode getDataChildByName(QName name) {
// TODO Auto-generated method stub
return null;
}
@Override
public DataSchemaNode getDataChildByName(String name) {
// TODO Auto-generated method stub
return null;
}
@Override
public DataSchemaNode getDataChildByName(String name) {
// TODO Auto-generated method stub
return null;
}
@Override
public Set<UsesNode> getUses() {
// TODO Auto-generated method stub
return null;
}
@Override
public Set<UsesNode> getUses() {
// TODO Auto-generated method stub
return null;
}
@Override
public Set<AugmentationSchema> getAvailableAugmentations() {
// TODO Auto-generated method stub
return null;
}
@Override
public Set<AugmentationSchema> getAvailableAugmentations() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isAugmenting() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isAugmenting() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isAddedByUses() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isAddedByUses() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isConfiguration() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isConfiguration() {
// TODO Auto-generated method stub
return false;
}
@Override
public ConstraintDefinition getConstraints() {
// TODO Auto-generated method stub
return null;
}
@Override
public ConstraintDefinition getConstraints() {
// TODO Auto-generated method stub
return null;
}
@Override
public QName getQName() {
// TODO Auto-generated method stub
return null;
}
@Override
public QName getQName() {
// TODO Auto-generated method stub
return null;
}
@Override
public SchemaPath getPath() {
// TODO Auto-generated method stub
return null;
}
@Override
public SchemaPath getPath() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getDescription() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getDescription() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getReference() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getReference() {
// TODO Auto-generated method stub
return null;
}
@Override
public Status getStatus() {
// TODO Auto-generated method stub
return null;
}
@Override
public Status getStatus() {
// TODO Auto-generated method stub
return null;
}
@Override
public List<UnknownSchemaNode> getUnknownSchemaNodes() {
// TODO Auto-generated method stub
return null;
}
@Override
public List<UnknownSchemaNode> getUnknownSchemaNodes() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isPresenceContainer() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isPresenceContainer() {
// TODO Auto-generated method stub
return false;
}
DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
assertNotNull(writeTx);
/**
DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
assertNotNull(writeTx);
/**
* Writes /test in writeTx
* Writes /test in writeTx
*/
writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
/**
*/
writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
/**
* Reads /test from writeTx Read should return container.
* Reads /test from writeTx Read should return container.
*/
ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx.read(TestModel.TEST_PATH);
assertTrue(writeTxContainer.get().isPresent());
/**
*/
ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx.read(TestModel.TEST_PATH);
assertTrue(writeTxContainer.get().isPresent());
/**
* Reads /test from readTx Read should return Absent.
* Reads /test from readTx Read should return Absent.
*/
ListenableFuture<Optional<NormalizedNode<?, ?>>> readTxContainer = readTx.read(TestModel.TEST_PATH);
assertFalse(readTxContainer.get().isPresent());
*/
ListenableFuture<Optional<NormalizedNode<?, ?>>> readTxContainer = readTx.read(TestModel.TEST_PATH);
assertFalse(readTxContainer.get().isPresent());
DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
assertNotNull(writeTx);
/**
DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
assertNotNull(writeTx);
/**
* Writes /test in writeTx
* Writes /test in writeTx
*/
writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
/**
*/
writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
/**
* Reads /test from writeTx Read should return container.
* Reads /test from writeTx Read should return container.
*/
ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx.read(TestModel.TEST_PATH);
assertTrue(writeTxContainer.get().isPresent());
*/
ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx.read(TestModel.TEST_PATH);
assertTrue(writeTxContainer.get().isPresent());
/**
* We alocate new read-write transaction and write /test
/**
* We alocate new read-write transaction and write /test
*/
DOMStoreReadWriteTransaction firstTx = txChain.newReadWriteTransaction();
assertTestContainerWrite(firstTx);
*/
DOMStoreReadWriteTransaction firstTx = txChain.newReadWriteTransaction();
assertTestContainerWrite(firstTx);
DOMStoreReadTransaction secondReadTx = txChain.newReadOnlyTransaction();
/**
DOMStoreReadTransaction secondReadTx = txChain.newReadOnlyTransaction();
/**
* We test if we are able to read data from tx, read should not fail
* since we are using chained transaction.
* We test if we are able to read data from tx, read should not fail
* since we are using chained transaction.
*/
assertTestContainerExists(secondReadTx);
/**
*/
assertTestContainerExists(secondReadTx);
/**
* We alocate next transaction, which is still based on first one, but
* is read-write.
* We alocate next transaction, which is still based on first one, but
* is read-write.
*/
DOMStoreReadWriteTransaction thirdDeleteTx = txChain.newReadWriteTransaction();
/**
* We test existence of /test in third transaction container should
* still be visible from first one (which is still uncommmited).
*/
DOMStoreReadWriteTransaction thirdDeleteTx = txChain.newReadWriteTransaction();
/**
* We test existence of /test in third transaction container should
* still be visible from first one (which is still uncommmited).
*/
assertTestContainerExists(thirdDeleteTx);
*/
assertTestContainerExists(thirdDeleteTx);
/**
* We commit first transaction
/**
* We commit first transaction
*/
assertThreePhaseCommit(firstWriteTxCohort);
*/
assertThreePhaseCommit(firstWriteTxCohort);
assertTestContainerExists(storeReadTx);
/**
* We commit third transaction
assertTestContainerExists(storeReadTx);
/**
* We commit third transaction
*/
assertThreePhaseCommit(thirdDeleteTxCohort);
}
*/
assertThreePhaseCommit(thirdDeleteTxCohort);
}
private static Optional<NormalizedNode<?, ?>> assertTestContainerWrite(final DOMStoreReadWriteTransaction writeTx)
throws InterruptedException, ExecutionException {
/**
private static Optional<NormalizedNode<?, ?>> assertTestContainerWrite(final DOMStoreReadWriteTransaction writeTx)
throws InterruptedException, ExecutionException {
/**
* Writes /test in writeTx
* Writes /test in writeTx
*/
writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
*/
writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
* Reads /test from readTx Read should return container.
* Reads /test from readTx Read should return container.
*/
private static Optional<NormalizedNode<?, ?>> assertTestContainerExists(DOMStoreReadTransaction readTx)
throws InterruptedException, ExecutionException {
*/
private static Optional<NormalizedNode<?, ?>> assertTestContainerExists(DOMStoreReadTransaction readTx)
throws InterruptedException, ExecutionException {
module.setBundleContext(bundleContext);
return module;
}
module.setBundleContext(bundleContext);
return module;
}
@Override
public Module createModule(String instanceName, DependencyResolver dependencyResolver,
DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
@Override
public Module createModule(String instanceName, DependencyResolver dependencyResolver,
DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
private Message _message;
private ZMQ.Socket _receiveSocket;
private Message _message;
private ZMQ.Socket _receiveSocket;
public MessageWrapper(Message message, ZMQ.Socket receiveSocket) {
this._message = message;
this._receiveSocket = receiveSocket;
public MessageWrapper(Message message, ZMQ.Socket receiveSocket) {
this._message = message;
this._receiveSocket = receiveSocket;
// Adds a child SimpleNode containing the value "success" to the input CompositeNode
private CompositeNode addSuccessNode(CompositeNode input) {
List<Node<?>> list = new ArrayList<Node<?>>(input.getChildren());
// Adds a child SimpleNode containing the value "success" to the input CompositeNode
private CompositeNode addSuccessNode(CompositeNode input) {
List<Node<?>> list = new ArrayList<Node<?>>(input.getChildren());
@Inject
@Filter(timeout=60*1000)
Broker broker;
@Inject
@Filter(timeout=60*1000)
Broker broker;
private ZMQ.Context zmqCtx = ZMQ.context(1);
//private Server router;
//private ExampleProvider provider;
private ZMQ.Context zmqCtx = ZMQ.context(1);
//private Server router;
//private ExampleProvider provider;
private void printState(){
Bundle[] b = ctx.getBundles();
_logger.debug("\n\nNumber of bundles [{}]\n\n]", b.length);
private void printState(){
Bundle[] b = ctx.getBundles();
_logger.debug("\n\nNumber of bundles [{}]\n\n]", b.length);
* <ul>
* <li><b>/restconf</b> - {@link #getRoot()}
* <ul>
* <ul>
* <li><b>/restconf</b> - {@link #getRoot()}
* <ul>
- * <li><b>/config</b> - {@link #readConfigurationData(String)}
+ * <li><b>/config</b> - {@link #readConfigurationData(String)}
* {@link #updateConfigurationData(String, CompositeNode)}
* {@link #createConfigurationData(CompositeNode)}
* {@link #createConfigurationData(String, CompositeNode)}
* {@link #deleteConfigurationData(String)}
* {@link #updateConfigurationData(String, CompositeNode)}
* {@link #createConfigurationData(CompositeNode)}
* {@link #createConfigurationData(String, CompositeNode)}
* {@link #deleteConfigurationData(String)}
- * <li><b>/operational</b> - {@link #readOperationalData(String)}
+ * <li><b>/operational</b> - {@link #readOperationalData(String)}
* <li>/modules - {@link #getModules()}
* <ul>
* <li>/module
* <li>/modules - {@link #getModules()}
* <ul>
* <li>/module
Draft02.MediaTypes.DATA+JSON, Draft02.MediaTypes.DATA+XML,
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
public StructuredData invokeRpc(@Encoded @PathParam("identifier") String identifier, CompositeNode payload);
Draft02.MediaTypes.DATA+JSON, Draft02.MediaTypes.DATA+XML,
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
public StructuredData invokeRpc(@Encoded @PathParam("identifier") String identifier, CompositeNode payload);
@POST
@Path("/operations/{identifier:.+}")
@Produces({Draft02.MediaTypes.OPERATION+JSON, Draft02.MediaTypes.OPERATION+XML,
Draft02.MediaTypes.DATA+JSON, Draft02.MediaTypes.DATA+XML,
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
public StructuredData invokeRpc(@Encoded @PathParam("identifier") String identifier, @DefaultValue("") String noPayload);
@POST
@Path("/operations/{identifier:.+}")
@Produces({Draft02.MediaTypes.OPERATION+JSON, Draft02.MediaTypes.OPERATION+XML,
Draft02.MediaTypes.DATA+JSON, Draft02.MediaTypes.DATA+XML,
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
public StructuredData invokeRpc(@Encoded @PathParam("identifier") String identifier, @DefaultValue("") String noPayload);
@GET
@Path("/config/{identifier:.+}")
@GET
@Path("/config/{identifier:.+}")
- @Produces({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML,
+ @Produces({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML,
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
public StructuredData readConfigurationData(@Encoded @PathParam("identifier") String identifier);
@GET
@Path("/operational/{identifier:.+}")
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
public StructuredData readConfigurationData(@Encoded @PathParam("identifier") String identifier);
@GET
@Path("/operational/{identifier:.+}")
- @Produces({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML,
+ @Produces({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML,
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
public StructuredData readOperationalData(@Encoded @PathParam("identifier") String identifier);
@PUT
@Path("/config/{identifier:.+}")
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
public StructuredData readOperationalData(@Encoded @PathParam("identifier") String identifier);
@PUT
@Path("/config/{identifier:.+}")
- @Consumes({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML,
+ @Consumes({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML,
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
public Response updateConfigurationData(@Encoded @PathParam("identifier") String identifier, CompositeNode payload);
@POST
@Path("/config/{identifier:.+}")
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
public Response updateConfigurationData(@Encoded @PathParam("identifier") String identifier, CompositeNode payload);
@POST
@Path("/config/{identifier:.+}")
- @Consumes({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML,
+ @Consumes({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML,
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
public Response createConfigurationData(@Encoded @PathParam("identifier") String identifier, CompositeNode payload);
@POST
@Path("/config")
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
public Response createConfigurationData(@Encoded @PathParam("identifier") String identifier, CompositeNode payload);
@POST
@Path("/config")
- @Consumes({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML,
+ @Consumes({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML,
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
public Response createConfigurationData(CompositeNode payload);
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
public Response createConfigurationData(CompositeNode payload);
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
public final class RestUtil {
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
public final class RestUtil {
public static final String SQUOTE = "'";
public static final String DQUOTE = "\"";
private static final Pattern PREDICATE_PATTERN = Pattern.compile("\\[(.*?)\\]");
public static final String SQUOTE = "'";
public static final String DQUOTE = "\"";
private static final Pattern PREDICATE_PATTERN = Pattern.compile("\\[(.*?)\\]");
IdentityValuesDTO identityValuesDTO = new IdentityValuesDTO(value);
for (int i = 1; i < xPathParts.length; i++) {
String xPathPartTrimmed = xPathParts[i].trim();
IdentityValuesDTO identityValuesDTO = new IdentityValuesDTO(value);
for (int i = 1; i < xPathParts.length; i++) {
String xPathPartTrimmed = xPathParts[i].trim();
String xPathPartStr = getIdAndPrefixAsStr(xPathPartTrimmed);
IdentityValue identityValue = toIdentity(xPathPartStr, prefixMap);
if (identityValue == null) {
return null;
}
String xPathPartStr = getIdAndPrefixAsStr(xPathPartTrimmed);
IdentityValue identityValue = toIdentity(xPathPartStr, prefixMap);
if (identityValue == null) {
return null;
}
List<Predicate> predicates = toPredicates(xPathPartTrimmed, prefixMap);
if (predicates == null) {
return null;
}
identityValue.setPredicates(predicates);
List<Predicate> predicates = toPredicates(xPathPartTrimmed, prefixMap);
if (predicates == null) {
return null;
}
identityValue.setPredicates(predicates);
identityValuesDTO.add(identityValue);
}
return identityValuesDTO.getValuesWithNamespaces().isEmpty() ? null : identityValuesDTO;
}
identityValuesDTO.add(identityValue);
}
return identityValuesDTO.getValuesWithNamespaces().isEmpty() ? null : identityValuesDTO;
}
private static String getIdAndPrefixAsStr(String pathPart) {
int predicateStartIndex = pathPart.indexOf("[");
return predicateStartIndex == -1 ? pathPart : pathPart.substring(0, predicateStartIndex);
}
private static String getIdAndPrefixAsStr(String pathPart) {
int predicateStartIndex = pathPart.indexOf("[");
return predicateStartIndex == -1 ? pathPart : pathPart.substring(0, predicateStartIndex);
}
private static IdentityValue toIdentity(String xPathPart, PrefixesMaping prefixMap) {
String xPathPartTrimmed = xPathPart.trim();
if (xPathPartTrimmed.isEmpty()) {
private static IdentityValue toIdentity(String xPathPart, PrefixesMaping prefixMap) {
String xPathPartTrimmed = xPathPart.trim();
if (xPathPartTrimmed.isEmpty()) {
import com.google.common.base.Preconditions;
public final class EmptyNodeWrapper implements NodeWrapper<Node<?>>, Node<Void> {
import com.google.common.base.Preconditions;
public final class EmptyNodeWrapper implements NodeWrapper<Node<?>>, Node<Void> {
private Node<?> unwrapped;
private Node<?> unwrapped;
private String localName;
private URI namespace;
private QName name;
private String localName;
private URI namespace;
private QName name;
public boolean isComposite() {
return composite;
}
public boolean isComposite() {
return composite;
}
public void setComposite(boolean composite) {
this.composite = composite;
}
public void setComposite(boolean composite) {
this.composite = composite;
}
public EmptyNodeWrapper(URI namespace, String localName) {
this.localName = Preconditions.checkNotNull(localName);
this.namespace = namespace;
}
public EmptyNodeWrapper(URI namespace, String localName) {
this.localName = Preconditions.checkNotNull(localName);
this.namespace = namespace;
}
@Override
public void setQname(QName name) {
Preconditions.checkState(unwrapped == null, "Cannot change the object, due to data inconsistencies.");
this.name = name;
}
@Override
public void setQname(QName name) {
Preconditions.checkState(unwrapped == null, "Cannot change the object, due to data inconsistencies.");
this.name = name;
}
@Override
public QName getQname() {
return name;
}
@Override
public QName getQname() {
return name;
}
@Override
public String getLocalName() {
if (unwrapped != null) {
@Override
public String getLocalName() {
if (unwrapped != null) {
@Override
public URI getNamespace() {
if (unwrapped != null) {
@Override
public URI getNamespace() {
if (unwrapped != null) {
elementData.add(new IdentityValue(namespace, value, prefix));
this.originValue = originValue;
}
elementData.add(new IdentityValue(namespace, value, prefix));
this.originValue = originValue;
}
public IdentityValuesDTO(String originValue) {
this.originValue = originValue;
}
public IdentityValuesDTO(String originValue) {
this.originValue = originValue;
}
public IdentityValuesDTO() {
originValue = null;
}
public IdentityValuesDTO() {
originValue = null;
}
public void add(String namespace, String value, String prefix) {
elementData.add(new IdentityValue(namespace, value, prefix));
}
public void add(String namespace, String value, String prefix) {
elementData.add(new IdentityValue(namespace, value, prefix));
}
public void add(IdentityValue identityValue) {
elementData.add(identityValue);
}
public void add(IdentityValue identityValue) {
elementData.add(identityValue);
}
public List<IdentityValue> getValuesWithNamespaces() {
return Collections.unmodifiableList(elementData);
}
public List<IdentityValue> getValuesWithNamespaces() {
return Collections.unmodifiableList(elementData);
}
@Override
public String toString() {
return elementData.toString();
}
@Override
public String toString() {
return elementData.toString();
}
public String getOriginValue() {
return originValue;
}
public String getOriginValue() {
return originValue;
}
public void setPredicates(List<Predicate> predicates) {
this.predicates = predicates;
}
public void setPredicates(List<Predicate> predicates) {
this.predicates = predicates;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
public static final class Predicate {
public static final class Predicate {
private final IdentityValue name;
private final String value;
private final IdentityValue name;
private final String value;
public Predicate(IdentityValue name, String value) {
super();
this.name = name;
this.value = value;
}
public Predicate(IdentityValue name, String value) {
super();
this.name = name;
this.value = value;
}
public IdentityValue getName() {
return name;
}
public IdentityValue getName() {
return name;
}
public String getValue() {
return value;
}
public String getValue() {
return value;
}
}
return sb.toString();
}
}
return sb.toString();
}
public boolean isLeafList() {
return name == null ? true : false;
}
public boolean isLeafList() {
return name == null ? true : false;
}
public interface NodeWrapper<T extends Node<?>> {
void setQname(QName name);
public interface NodeWrapper<T extends Node<?>> {
void setQname(QName name);
boolean isChangeAllowed();
boolean isChangeAllowed();
URI getNamespace();
void setNamespace(URI namespace);
URI getNamespace();
void setNamespace(URI namespace);
import org.slf4j.LoggerFactory;
public class RestCodec {
import org.slf4j.LoggerFactory;
public class RestCodec {
private static final Logger logger = LoggerFactory.getLogger(RestCodec.class);
private RestCodec() {
private static final Logger logger = LoggerFactory.getLogger(RestCodec.class);
private RestCodec() {
logger.info("Idenetityref will be translated as NULL for data - {}", String.valueOf(valueWithNamespace));
return null;
}
logger.info("Idenetityref will be translated as NULL for data - {}", String.valueOf(valueWithNamespace));
return null;
}
return QName.create(module.getNamespace(), module.getRevision(), valueWithNamespace.getValue());
}
return QName.create(module.getNamespace(), module.getRevision(), valueWithNamespace.getValue());
}
return result.isEmpty() ? null : new InstanceIdentifier(result);
}
return result.isEmpty() ? null : new InstanceIdentifier(result);
}
private static Module getModuleByNamespace(String namespace, MountInstance mountPoint) {
URI validNamespace = resolveValidNamespace(namespace, mountPoint);
private static Module getModuleByNamespace(String namespace, MountInstance mountPoint) {
URI validNamespace = resolveValidNamespace(namespace, mountPoint);
private static URI resolveValidNamespace(String namespace, MountInstance mountPoint) {
URI validNamespace;
if (mountPoint != null) {
private static URI resolveValidNamespace(String namespace, MountInstance mountPoint) {
URI validNamespace;
if (mountPoint != null) {
import com.google.common.base.Preconditions;
public final class SimpleNodeWrapper implements NodeWrapper<SimpleNode<?>>, SimpleNode<Object> {
import com.google.common.base.Preconditions;
public final class SimpleNodeWrapper implements NodeWrapper<SimpleNode<?>>, SimpleNode<Object> {
private SimpleNode<Object> simpleNode;
private SimpleNode<Object> simpleNode;
private String localName;
private Object value;
private URI namespace;
private String localName;
private Object value;
private URI namespace;
this.localName = Preconditions.checkNotNull(localName);
this.value = value;
}
this.localName = Preconditions.checkNotNull(localName);
this.value = value;
}
public SimpleNodeWrapper(URI namespace, String localName, Object value) {
this(localName, value);
this.namespace = namespace;
}
public SimpleNodeWrapper(URI namespace, String localName, Object value) {
this(localName, value);
this.namespace = namespace;
}
@Override
public void setQname(QName name) {
Preconditions.checkState(simpleNode == null, "Cannot change the object, due to data inconsistencies.");
this.name = name;
}
@Override
public void setQname(QName name) {
Preconditions.checkState(simpleNode == null, "Cannot change the object, due to data inconsistencies.");
this.name = name;
}
@Override
public QName getQname() {
return name;
}
@Override
public QName getQname() {
return name;
}
@Override
public String getLocalName() {
if (simpleNode != null) {
@Override
public String getLocalName() {
if (simpleNode != null) {
@Override
public URI getNamespace() {
if (simpleNode != null) {
@Override
public URI getNamespace() {
if (simpleNode != null) {
name = new QName(namespace, localName);
}
simpleNode = NodeFactory.createImmutableSimpleNode(name, null, value);
name = new QName(namespace, localName);
}
simpleNode = NodeFactory.createImmutableSimpleNode(name, null, value);
value = null;
namespace = null;
localName = null;
value = null;
namespace = null;
localName = null;
public Object setValue(Object value) {
return unwrap().setValue(value);
}
public Object setValue(Object value) {
return unwrap().setValue(value);
}
/**
* Creates new {@link ListenerAdapter} listener specified by path and stream
* name.
/**
* Creates new {@link ListenerAdapter} listener specified by path and stream
* name.
* @param path
* Path to data in data store.
* @param streamName
* @param path
* Path to data in data store.
* @param streamName
/**
* Creates new event specified by {@link EventType} type.
/**
* Creates new event specified by {@link EventType} type.
* @param type
* EventType
*/
* @param type
* EventType
*/
/**
* Gets the {@link Channel} subscriber.
/**
* Gets the {@link Channel} subscriber.
* @return Channel
*/
public Channel getSubscriber() {
* @return Channel
*/
public Channel getSubscriber() {
/**
* Sets subscriber for event.
/**
* Sets subscriber for event.
* @param subscriber
* Channel
*/
* @param subscriber
* Channel
*/
* @return String representation of event data.
*/
public String getData() {
* @return String representation of event data.
*/
public String getData() {
* @param String
* data.
*/
* @param String
* data.
*/
* @return The type of the event.
*/
public EventType getType() {
* @return The type of the event.
*/
public EventType getType() {
/**
* Prepare data in printable form and transform it to String.
/**
* Prepare data in printable form and transform it to String.
* @param change
* DataChangeEvent
* @return Data in printable form.
* @param change
* DataChangeEvent
* @return Data in printable form.
/**
* Formats data specified by RFC3339.
/**
* Formats data specified by RFC3339.
* @param d
* Date
* @return Data specified by RFC3339.
* @param d
* Date
* @return Data specified by RFC3339.
/**
* Creates {@link Document} document.
/**
* Creates {@link Document} document.
* @return {@link Document} document.
*/
private Document createDocument() {
* @return {@link Document} document.
*/
private Document createDocument() {
/**
* Adds values to data changed notification event element.
/**
* Adds values to data changed notification event element.
* @param doc
* {@link Document}
* @param dataChangedNotificationEventElement
* @param doc
* {@link Document}
* @param dataChangedNotificationEventElement
/**
* Adds values from data to element.
/**
* Adds values from data to element.
* @param doc
* {@link Document}
* @param data
* @param doc
* {@link Document}
* @param data
/**
* Adds values from data to element.
/**
* Adds values from data to element.
* @param doc
* {@link Document}
* @param data
* @param doc
* {@link Document}
* @param data
/**
* Creates changed event element from data.
/**
* Creates changed event element from data.
* @param doc
* {@link Document}
* @param path
* @param doc
* {@link Document}
* @param path
/**
* Translates {@link CompositeNode} data to XML format.
/**
* Translates {@link CompositeNode} data to XML format.
* @param path
* Path to data in data store.
* @param data
* @param path
* Path to data in data store.
* @param data
/**
* Adds path as value to element.
/**
* Adds path as value to element.
* @param path
* Path to data in data store.
* @param element
* @param path
* Path to data in data store.
* @param element
/**
* Writes identifier that consists of prefix and QName.
/**
* Writes identifier that consists of prefix and QName.
* @param element
* {@link Element}
* @param textContent
* @param element
* {@link Element}
* @param textContent
/**
* Generates new prefix which consists of four random characters <a-z>.
/**
* Generates new prefix which consists of four random characters <a-z>.
* @param prefixes
* Collection of prefixes.
* @return New prefix which consists of four random characters <a-z>.
* @param prefixes
* Collection of prefixes.
* @return New prefix which consists of four random characters <a-z>.
/**
* Gets path pointed to data in data store.
/**
* Gets path pointed to data in data store.
* @return Path pointed to data in data store.
*/
public InstanceIdentifier getPath() {
* @return Path pointed to data in data store.
*/
public InstanceIdentifier getPath() {
/**
* Sets {@link ListenerRegistration} registration.
/**
* Sets {@link ListenerRegistration} registration.
* @param registration
* ListenerRegistration<DataChangeListener>
*/
* @param registration
* ListenerRegistration<DataChangeListener>
*/
/**
* Gets the name of the stream.
/**
* Gets the name of the stream.
* @return The name of the stream.
*/
public String getStreamName() {
* @return The name of the stream.
*/
public String getStreamName() {
/**
* Checks if {@link ListenerRegistration} registration exist.
/**
* Checks if {@link ListenerRegistration} registration exist.
* @return True if exist, false otherwise.
*/
public boolean isListening() {
* @return True if exist, false otherwise.
*/
public boolean isListening() {
/**
* Creates event of type {@link EventType#REGISTER}, set {@link Channel}
* subscriber to the event and post event into event bus.
/**
* Creates event of type {@link EventType#REGISTER}, set {@link Channel}
* subscriber to the event and post event into event bus.
* @param subscriber
* Channel
*/
* @param subscriber
* Channel
*/
/**
* Creates event of type {@link EventType#DEREGISTER}, sets {@link Channel}
* subscriber to the event and posts event into event bus.
/**
* Creates event of type {@link EventType#DEREGISTER}, sets {@link Channel}
* subscriber to the event and posts event into event bus.
* @param subscriber
*/
public void removeSubscriber(Channel subscriber) {
* @param subscriber
*/
public void removeSubscriber(Channel subscriber) {
/**
* Checks if exists at least one {@link Channel} subscriber.
/**
* Checks if exists at least one {@link Channel} subscriber.
* @return True if exist at least one {@link Channel} subscriber, false
* otherwise.
*/
* @return True if exist at least one {@link Channel} subscriber, false
* otherwise.
*/
/**
* Gets {@link ListenerAdapter} specified by stream name.
/**
* Gets {@link ListenerAdapter} specified by stream name.
* @param streamName
* The name of the stream.
* @return {@link ListenerAdapter} specified by stream name.
* @param streamName
* The name of the stream.
* @return {@link ListenerAdapter} specified by stream name.
/**
* Gets {@link ListenerAdapter} listener specified by
* {@link InstanceIdentifier} path.
/**
* Gets {@link ListenerAdapter} listener specified by
* {@link InstanceIdentifier} path.
* @param path
* Path to data in data repository.
* @return ListenerAdapter
* @param path
* Path to data in data repository.
* @return ListenerAdapter
/**
* Checks if the listener specified by {@link InstanceIdentifier} path
* exist.
/**
* Checks if the listener specified by {@link InstanceIdentifier} path
* exist.
* @param path
* Path to data in data repository.
* @return True if the listener exist, false otherwise.
* @param path
* Path to data in data repository.
* @return True if the listener exist, false otherwise.
/**
* Creates new {@link ListenerAdapter} listener from
* {@link InstanceIdentifier} path and stream name.
/**
* Creates new {@link ListenerAdapter} listener from
* {@link InstanceIdentifier} path and stream name.
* @param path
* Path to data in data repository.
* @param streamName
* @param path
* Path to data in data repository.
* @param streamName
/**
* Looks for listener determined by {@link InstanceIdentifier} path and
* removes it.
/**
* Looks for listener determined by {@link InstanceIdentifier} path and
* removes it.
* @param path
* InstanceIdentifier
*/
* @param path
* InstanceIdentifier
*/
/**
* Creates String representation of stream name from URI. Removes slash from
* URI in start and end position.
/**
* Creates String representation of stream name from URI. Removes slash from
* URI in start and end position.
* @param uri
* URI for creation stream name.
* @return String representation of stream name.
* @param uri
* URI for creation stream name.
* @return String representation of stream name.
/**
* Checks if listener has at least one subscriber. In case it doesn't have any, delete
* listener.
/**
* Checks if listener has at least one subscriber. In case it doesn't have any, delete
* listener.
* @param listener
* ListenerAdapter
*/
* @param listener
* ListenerAdapter
*/
/**
* Delete {@link ListenerAdapter} listener specified in parameter.
/**
* Delete {@link ListenerAdapter} listener specified in parameter.
* @param listener
* ListenerAdapter
*/
* @param listener
* ListenerAdapter
*/
/**
* Checks if HTTP request method is GET and if is possible to decode HTTP
* result of request.
/**
* Checks if HTTP request method is GET and if is possible to decode HTTP
* result of request.
* @param ctx
* ChannelHandlerContext
* @param req
* @param ctx
* ChannelHandlerContext
* @param req
/**
* Checks response status, send response and close connection if necessary
/**
* Checks response status, send response and close connection if necessary
* @param ctx
* ChannelHandlerContext
* @param req
* @param ctx
* ChannelHandlerContext
* @param req
/**
* Handles web socket frame.
/**
* Handles web socket frame.
* @param ctx
* {@link ChannelHandlerContext}
* @param frame
* @param ctx
* {@link ChannelHandlerContext}
* @param frame
/**
* Get web socket location from HTTP request.
/**
* Get web socket location from HTTP request.
* @param req
* HTTP request from which the location will be returned
* @return String representation of web socket location.
* @param req
* HTTP request from which the location will be returned
* @return String representation of web socket location.
* Test when some data are in one case node and other in another. This isn't
* correct. Next Json validator should return error because nodes has to be
* from one case below concrete choice.
* Test when some data are in one case node and other in another. This isn't
* correct. Next Json validator should return error because nodes has to be
* from one case below concrete choice.
*/
@Test
public void nodeSchemasOnVariousChoiceCasePathTest() {
*/
@Test
public void nodeSchemasOnVariousChoiceCasePathTest() {
* Additionally data are loadef from various choices. This isn't correct.
* Next Json validator should return error because nodes has to be from one
* case below concrete choice.
* Additionally data are loadef from various choices. This isn't correct.
* Next Json validator should return error because nodes has to be from one
* case below concrete choice.
*/
@Test
public void nodeSchemasOnVariousChoiceCasePathAndMultipleChoicesTest() {
*/
@Test
public void nodeSchemasOnVariousChoiceCasePathAndMultipleChoicesTest() {
*/
@Test
public void nodeSchemasInMultipleChoicesTest() {
*/
@Test
public void nodeSchemasInMultipleChoicesTest() {
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
/**
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
/**
* All tests are commented now because leafref isn't supported now
* All tests are commented now because leafref isn't supported now
*/
public class CnSnToJsonLeafrefType extends YangAndXmlAndDataSchemaLoader {
*/
public class CnSnToJsonLeafrefType extends YangAndXmlAndDataSchemaLoader {
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
/**
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
/**
* CnSn = Composite node and Simple node data structure Class contains test of
* serializing simple nodes data values according data types from YANG schema to
* XML file
* CnSn = Composite node and Simple node data structure Class contains test of
* serializing simple nodes data values according data types from YANG schema to
* XML file
*/
public class CnSnInstanceIdentifierToXmlTest extends YangAndXmlAndDataSchemaLoader {
*/
public class CnSnInstanceIdentifierToXmlTest extends YangAndXmlAndDataSchemaLoader {
@BeforeClass
public static void initialization() throws URISyntaxException {
dataLoad("/instanceidentifier/yang", 4, "instance-identifier-module", "cont");
@BeforeClass
public static void initialization() throws URISyntaxException {
dataLoad("/instanceidentifier/yang", 4, "instance-identifier-module", "cont");
regex.append(".*<data.*");
regex.append(".*xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"");
regex.append(".*>");
regex.append(".*<data.*");
regex.append(".*xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"");
regex.append(".*>");
regex.append(".*<contB_m1.*\\/>");
regex.append(".*xmlns=\"module:one\"");
regex.append(".*>");
regex.append(".*<contB_m1.*\\/>");
regex.append(".*xmlns=\"module:one\"");
regex.append(".*>");
SimpleNodeWrapper lf1_m1 = new SimpleNodeWrapper(uriModule1, "lf1_m1", "lf1 m1 value");
cont_m1.addValue(lf1_m1);
CompositeNodeWrapper contB_m1 = new CompositeNodeWrapper(uriModule1, "contB_m1");
SimpleNodeWrapper lf1_m1 = new SimpleNodeWrapper(uriModule1, "lf1_m1", "lf1 m1 value");
cont_m1.addValue(lf1_m1);
CompositeNodeWrapper contB_m1 = new CompositeNodeWrapper(uriModule1, "contB_m1");
data.addValue(contB_m1);
data.addValue(cont_m1);
data.addValue(contB_m1);
data.addValue(cont_m1);
import org.opendaylight.yangtools.yang.common.RpcResult;
public class DummyFuture implements Future<RpcResult<TransactionStatus>> {
import org.opendaylight.yangtools.yang.common.RpcResult;
public class DummyFuture implements Future<RpcResult<TransactionStatus>> {
private final boolean cancel;
private final boolean isCancelled;
private final boolean isDone;
private final RpcResult<TransactionStatus> result;
private final boolean cancel;
private final boolean isCancelled;
private final boolean isDone;
private final RpcResult<TransactionStatus> result;
public DummyFuture() {
cancel = false;
isCancelled = false;
isDone = false;
result = null;
}
public DummyFuture() {
cancel = false;
isCancelled = false;
isDone = false;
result = null;
}
private DummyFuture(Builder builder) {
cancel = builder.cancel;
isCancelled = builder.isCancelled;
isDone = builder.isDone;
result = builder.result;
}
private DummyFuture(Builder builder) {
cancel = builder.cancel;
isCancelled = builder.isCancelled;
isDone = builder.isDone;
result = builder.result;
}
public static Builder builder() {
return new DummyFuture.Builder();
}
public static Builder builder() {
return new DummyFuture.Builder();
}
ExecutionException, TimeoutException {
return result;
}
ExecutionException, TimeoutException {
return result;
}
public static class Builder {
public static class Builder {
private boolean cancel;
private boolean isCancelled;
private boolean isDone;
private boolean cancel;
private boolean isCancelled;
private boolean isDone;
this.cancel = cancel;
return this;
}
this.cancel = cancel;
return this;
}
public Builder isCancelled(boolean isCancelled) {
this.isCancelled = isCancelled;
return this;
}
public Builder isCancelled(boolean isCancelled) {
this.isCancelled = isCancelled;
return this;
}
public Builder isDone(boolean isDone) {
this.isDone = isDone;
return this;
}
public Builder isDone(boolean isDone) {
this.isDone = isDone;
return this;
}
public Builder rpcResult(RpcResult<TransactionStatus> result) {
this.result = result;
return this;
}
public Builder rpcResult(RpcResult<TransactionStatus> result) {
this.result = result;
return this;
}
public Future<RpcResult<TransactionStatus>> build() {
return new DummyFuture(this);
}
public Future<RpcResult<TransactionStatus>> build() {
return new DummyFuture(this);
}
when(brokerFacade.commitConfigurationDataDelete(any(InstanceIdentifier.class))).thenReturn(dummyFuture);
Response response = target(uri).request(MediaType.APPLICATION_XML).delete();
assertEquals(200, response.getStatus());
when(brokerFacade.commitConfigurationDataDelete(any(InstanceIdentifier.class))).thenReturn(dummyFuture);
Response response = target(uri).request(MediaType.APPLICATION_XML).delete();
assertEquals(200, response.getStatus());
dummyFuture = createFuture(TransactionStatus.FAILED);
when(brokerFacade.commitConfigurationDataDelete(any(InstanceIdentifier.class))).thenReturn(dummyFuture);
response = target(uri).request(MediaType.APPLICATION_XML).delete();
assertEquals(500, response.getStatus());
}
dummyFuture = createFuture(TransactionStatus.FAILED);
when(brokerFacade.commitConfigurationDataDelete(any(InstanceIdentifier.class))).thenReturn(dummyFuture);
response = target(uri).request(MediaType.APPLICATION_XML).delete();
assertEquals(500, response.getStatus());
}
private Future<RpcResult<TransactionStatus>> createFuture(TransactionStatus statusName) {
RpcResult<TransactionStatus> rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(statusName).build();
return DummyFuture.builder().rpcResult(rpcResult).build();
private Future<RpcResult<TransactionStatus>> createFuture(TransactionStatus statusName) {
RpcResult<TransactionStatus> rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(statusName).build();
return DummyFuture.builder().rpcResult(rpcResult).build();
* Fill missing data (namespaces) and build correct data type in
* {@code compositeNode} according to {@code dataSchemaNode}. The method
* {@link RestconfImpl#createConfigurationData createConfigurationData} is
* Fill missing data (namespaces) and build correct data type in
* {@code compositeNode} according to {@code dataSchemaNode}. The method
* {@link RestconfImpl#createConfigurationData createConfigurationData} is
* Searches module with name {@code searchedModuleName} in {@code modules}.
* If module name isn't specified and module set has only one element then
* this element is returned.
* Searches module with name {@code searchedModuleName} in {@code modules}.
* If module name isn't specified and module set has only one element then
* this element is returned.
*/
public static Module resolveModule(String searchedModuleName, Set<Module> modules) {
assertNotNull("Modules can't be null.", modules);
*/
public static Module resolveModule(String searchedModuleName, Set<Module> modules) {
assertNotNull("Modules can't be null.", modules);
Lf lf2 = new Lf("name", "value");
Lf lf3 = new Lf("name1", "value");
Lf lf4 = new Lf("name", "value1");
Lf lf2 = new Lf("name", "value");
Lf lf3 = new Lf("name1", "value");
Lf lf4 = new Lf("name", "value1");
assertTrue(lf1.equals(lf2));
assertFalse(lf1.equals(lf3));
assertFalse(lf1.equals(lf4));
assertTrue(lf1.equals(lf2));
assertFalse(lf1.equals(lf3));
assertFalse(lf1.equals(lf4));
loadAndNormalizeData("/common/augment/xml/dataa.xml", "/common/augment/yang", "main","cont");
loadAndNormalizeData("/common/augment/xml/datab.xml", "/common/augment/yang", "main","cont");
}
loadAndNormalizeData("/common/augment/xml/dataa.xml", "/common/augment/yang", "main","cont");
loadAndNormalizeData("/common/augment/xml/datab.xml", "/common/augment/yang", "main","cont");
}
private void loadAndNormalizeData(String xmlPath, String yangPath, String topLevelElementName, String moduleName) {
CompositeNode compNode = TestUtils.readInputToCnSn(xmlPath, false,
XmlToCompositeNodeProvider.INSTANCE);
private void loadAndNormalizeData(String xmlPath, String yangPath, String topLevelElementName, String moduleName) {
CompositeNode compNode = TestUtils.readInputToCnSn(xmlPath, false,
XmlToCompositeNodeProvider.INSTANCE);
final OpendaylightGroupStatisticsService groupStatsService,
final OpendaylightMeterStatisticsService meterStatsService,
final OpendaylightPortStatisticsService portStatsService,
final OpendaylightGroupStatisticsService groupStatsService,
final OpendaylightMeterStatisticsService meterStatsService,
final OpendaylightPortStatisticsService portStatsService,
- final OpendaylightQueueStatisticsService queueStatsService,
+ final OpendaylightQueueStatisticsService queueStatsService,
final StatisticsRequestScheduler srScheduler) {
this.dps = Preconditions.checkNotNull(dps);
this.targetNodeKey = Preconditions.checkNotNull(nodeKey);
final StatisticsRequestScheduler srScheduler) {
this.dps = Preconditions.checkNotNull(dps);
this.targetNodeKey = Preconditions.checkNotNull(nodeKey);
this.srScheduler.addRequestToSchedulerQueue(flowTableStats);
this.srScheduler.addRequestToSchedulerQueue(flowStats);
this.srScheduler.addRequestToSchedulerQueue(flowTableStats);
this.srScheduler.addRequestToSchedulerQueue(flowStats);
this.srScheduler.addRequestToSchedulerQueue(nodeConnectorStats);
this.srScheduler.addRequestToSchedulerQueue(nodeConnectorStats);
this.srScheduler.addRequestToSchedulerQueue(groupStats);
this.srScheduler.addRequestToSchedulerQueue(groupStats);
this.srScheduler.addRequestToSchedulerQueue(groupDescStats);
this.srScheduler.addRequestToSchedulerQueue(groupDescStats);
this.srScheduler.addRequestToSchedulerQueue(meterStats);
this.srScheduler.addRequestToSchedulerQueue(meterStats);
this.srScheduler.addRequestToSchedulerQueue(meterConfigStats);
this.srScheduler.addRequestToSchedulerQueue(meterConfigStats);
this.srScheduler.addRequestToSchedulerQueue(queueStats);
}
this.srScheduler.addRequestToSchedulerQueue(queueStats);
}
public synchronized void start(final Timer timer) {
flowStats.start(dps);
groupDescStats.start(dps);
public synchronized void start(final Timer timer) {
flowStats.start(dps);
groupDescStats.start(dps);
meterStats.close();
queueStats.close();
meterStats.close();
queueStats.close();
- //Clean up queued statistics request from scheduler queue
+ //Clean up queued statistics request from scheduler queue
srScheduler.removeRequestsFromSchedulerQueue(this.getNodeRef());
logger.debug("Statistics handler for {} shut down", targetNodeKey.getId());
srScheduler.removeRequestsFromSchedulerQueue(this.getNodeRef());
logger.debug("Statistics handler for {} shut down", targetNodeKey.getId());
private OpendaylightFlowTableStatisticsService flowTableStatsService;
private OpendaylightQueueStatisticsService queueStatsService;
private OpendaylightFlowTableStatisticsService flowTableStatsService;
private OpendaylightQueueStatisticsService queueStatsService;
private final StatisticsRequestScheduler srScheduler;
public StatisticsProvider(final DataProviderService dataService) {
private final StatisticsRequestScheduler srScheduler;
public StatisticsProvider(final DataProviderService dataService) {
flowTableStatsService = rpcRegistry.getRpcService(OpendaylightFlowTableStatisticsService.class);
queueStatsService = rpcRegistry.getRpcService(OpendaylightQueueStatisticsService.class);
this.srScheduler.start();
flowTableStatsService = rpcRegistry.getRpcService(OpendaylightFlowTableStatisticsService.class);
queueStatsService = rpcRegistry.getRpcService(OpendaylightQueueStatisticsService.class);
this.srScheduler.start();
// Start receiving notifications
this.listenerRegistration = nps.registerNotificationListener(this.updateCommiter);
// Start receiving notifications
this.listenerRegistration = nps.registerNotificationListener(this.updateCommiter);
/**
* Main responsibility of the class is to check the MD-SAL data store read/write
/**
* Main responsibility of the class is to check the MD-SAL data store read/write
- * transaction accumulation level and send statistics request if number of pending
+ * transaction accumulation level and send statistics request if number of pending
* read/write transactions are zero.
* @author avishnoi@in.ibm.com
*
* read/write transactions are zero.
* @author avishnoi@in.ibm.com
*
private final Timer timer = new Timer("request-monitor", true);
// We need ordered retrieval, and O(1) contains operation
private final Timer timer = new Timer("request-monitor", true);
// We need ordered retrieval, and O(1) contains operation
- private final Map<AbstractStatsTracker,Integer> requestQueue =
+ private final Map<AbstractStatsTracker,Integer> requestQueue =
Collections.synchronizedMap(new LinkedHashMap<AbstractStatsTracker,Integer>());
Collections.synchronizedMap(new LinkedHashMap<AbstractStatsTracker,Integer>());
private Long PendingTransactions;
private Long PendingTransactions;
private long lastRequestTime = System.nanoTime();
private long lastRequestTime = System.nanoTime();
private static final long REQUEST_MONITOR_INTERVAL = 1000;
private static final long REQUEST_MONITOR_INTERVAL = 1000;
private final TimerTask task = new TimerTask() {
@Override
public void run() {
private final TimerTask task = new TimerTask() {
@Override
public void run() {
public StatisticsRequestScheduler(){
PendingTransactions = (long) 0;
}
public StatisticsRequestScheduler(){
PendingTransactions = (long) 0;
}
public void addRequestToSchedulerQueue(AbstractStatsTracker statsRequest){
requestQueue.put(statsRequest, null);
}
public void addRequestToSchedulerQueue(AbstractStatsTracker statsRequest){
requestQueue.put(statsRequest, null);
}
public void removeRequestsFromSchedulerQueue(NodeRef node){
AbstractStatsTracker stats = null;
synchronized(requestQueue){
public void removeRequestsFromSchedulerQueue(NodeRef node){
AbstractStatsTracker stats = null;
synchronized(requestQueue){
}
@Override
public void onStatusUpdated(DataModificationTransaction transaction, TransactionStatus status) {
}
@Override
public void onStatusUpdated(DataModificationTransaction transaction, TransactionStatus status) {
AbstractStatsTracker stats = null;
synchronized(PendingTransactions){
switch(status){
AbstractStatsTracker stats = null;
synchronized(PendingTransactions){
switch(status){
}
sendStatsRequest(stats);
}
}
sendStatsRequest(stats);
}
private void sendStatsRequest(AbstractStatsTracker stats){
if(stats != null){
try{
private void sendStatsRequest(AbstractStatsTracker stats){
if(stats != null){
try{
LLDPDiscoveryListener(LLDPDiscoveryProvider manager) {
this.manager = manager;
}
LLDPDiscoveryListener(LLDPDiscoveryProvider manager) {
this.manager = manager;
}
public void onPacketReceived(PacketReceived lldp) {
NodeConnectorRef src = LLDPDiscoveryUtils.lldpToNodeConnectorRef(lldp.getPayload());
if(src != null) {
public void onPacketReceived(PacketReceived lldp) {
NodeConnectorRef src = LLDPDiscoveryUtils.lldpToNodeConnectorRef(lldp.getPayload());
if(src != null) {
ldb.setDestination(lldp.getIngress());
ldb.setSource(new NodeConnectorRef(src));
LinkDiscovered ld = ldb.build();
ldb.setDestination(lldp.getIngress());
ldb.setSource(new NodeConnectorRef(src));
LinkDiscovered ld = ldb.build();
manager.getNotificationService().publish(ld);
LLDPLinkAger.getInstance().put(ld);
}
}
manager.getNotificationService().publish(ld);
LLDPLinkAger.getInstance().put(ld);
}
}
public static LLDPLinkAger getInstance() {
return instance;
}
public static LLDPLinkAger getInstance() {
return instance;
}
public void put(LinkDiscovered link) {
Date expires = new Date();
expires.setTime(expires.getTime() + LLDPDiscoveryUtils.LLDP_EXPIRATION_TIME);
linkToDate.put(link, expires);
}
public void put(LinkDiscovered link) {
Date expires = new Date();
expires.setTime(expires.getTime() + LLDPDiscoveryUtils.LLDP_EXPIRATION_TIME);
linkToDate.put(link, expires);
}
public void close() {
timer.cancel();
}
public void close() {
timer.cancel();
}
private class LLDPAgingTask extends TimerTask {
@Override
private class LLDPAgingTask extends TimerTask {
@Override
public class LLDPDiscoveryUtils {
static Logger LOG = LoggerFactory.getLogger(LLDPDiscoveryUtils.class);
public class LLDPDiscoveryUtils {
static Logger LOG = LoggerFactory.getLogger(LLDPDiscoveryUtils.class);
public static final Long LLDP_INTERVAL = (long) (1000*5); // Send LLDP every five seconds
public static final Long LLDP_EXPIRATION_TIME = LLDP_INTERVAL*3; // Let up to three intervals pass before we decide we are expired.
public static final Long LLDP_INTERVAL = (long) (1000*5); // Send LLDP every five seconds
public static final Long LLDP_EXPIRATION_TIME = LLDP_INTERVAL*3; // Let up to three intervals pass before we decide we are expired.
public static String macToString(byte[] mac) {
StringBuilder b = new StringBuilder();
for (int i = 0; i < mac.length; i++) {
public static String macToString(byte[] mac) {
StringBuilder b = new StringBuilder();
for (int i = 0; i < mac.length; i++) {
public static NodeConnectorRef lldpToNodeConnectorRef(byte[] payload) {
Ethernet ethPkt = new Ethernet();
try {
public static NodeConnectorRef lldpToNodeConnectorRef(byte[] payload) {
Ethernet ethPkt = new Ethernet();
try {
if (ethPkt.getPayload() instanceof LLDP) {
LLDP lldp = (LLDP) ethPkt.getPayload();
if (ethPkt.getPayload() instanceof LLDP) {
LLDP lldp = (LLDP) ethPkt.getPayload();
try {
NodeId srcNodeId = null;
NodeConnectorId srcNodeConnectorId = null;
try {
NodeId srcNodeId = null;
NodeConnectorId srcNodeConnectorId = null;