From: Tony Tkacik Date: Tue, 10 Jun 2014 11:30:42 +0000 (+0000) Subject: Merge "BUG-614: Remove YangtoolsMappingHelper in favor of BindingReflections" X-Git-Tag: release/helium~669 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=0a2c659c014737c7e12a39001310de14d5f85149;hp=721677fcf9f9f4085422eb3523e1cf752d698b4d Merge "BUG-614: Remove YangtoolsMappingHelper in favor of BindingReflections" --- diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FromSalConversionsUtils.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FromSalConversionsUtils.java index 53257f8c83..a879a36f8c 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FromSalConversionsUtils.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FromSalConversionsUtils.java @@ -261,11 +261,11 @@ public class FromSalConversionsUtils { .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)|| dataLinkType != null ) { - return targetEthMatchBuild.build(); - } + return targetEthMatchBuild.build(); + } return null; } @@ -372,7 +372,7 @@ public class FromSalConversionsUtils { .toAddrString(inetDestAddress); layer4MatchBuild .setIpv4Destination(new Ipv4Prefix(inetDstAddressString)); - } + } return layer4MatchBuild.build(); } @@ -388,13 +388,13 @@ public class FromSalConversionsUtils { } if(inetDestAddress != null) { String inetDstAddressString = InetAddresses - .toAddrString(inetDestAddress); + .toAddrString(inetDestAddress); layer6MatchBuild .setIpv6Destination(new Ipv6Prefix(inetDstAddressString)); } return layer6MatchBuild.build(); } - + public static boolean flowEquals(Flow statsFlow, Flow storedFlow) { if (statsFlow.getClass() != storedFlow.getClass()) { return false; diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java index 74b94c7cba..da3477ee45 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java @@ -168,7 +168,7 @@ public class ToSalConversionsUtils { public static List actionFrom(List actions, Node node) { List targetAction = new ArrayList<>(); for (Action action : actions) { - org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action sourceAction = action + org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action sourceAction = action .getAction(); if (sourceAction instanceof ControllerActionCase) { @@ -585,7 +585,7 @@ public class ToSalConversionsUtils { } return macAddress; } - + public static byte[] bytesFromDpid(long dpid) { byte[] mac = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/NodeMappingTest.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/NodeMappingTest.java index b9a2f5bff0..041924af33 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/NodeMappingTest.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/NodeMappingTest.java @@ -45,7 +45,7 @@ public class NodeMappingTest { {(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++) { diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestFromSalConversionsUtils.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestFromSalConversionsUtils.java index 81ccb35cd9..5d5a409445 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestFromSalConversionsUtils.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestFromSalConversionsUtils.java @@ -249,7 +249,7 @@ public class TestFromSalConversionsUtils { boolean b) { int numOfFoundActions = 0; for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action action : actions) { - org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action innerAction = action + org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action innerAction = action .getAction(); if (cl.isInstance(innerAction)) { numOfFoundActions++; diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java index 71f2e94805..e1fd294d2f 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java @@ -155,9 +155,9 @@ public class TestToSalConversionsUtils { public void testToSalConversion() throws ConstructionException { FlowAddedBuilder odNodeFlowBuilder = new FlowAddedBuilder(); odNodeFlowBuilder = prepareOdFlowCommon(); - + Node node = new Node(NodeIDType.OPENFLOW,(long)1); - + Flow salFlow = ToSalConversionsUtils.toFlow(prepareOdFlow(odNodeFlowBuilder, MtchType.other), node); checkSalMatch(salFlow.getMatch(), MtchType.other); @@ -185,7 +185,7 @@ public class TestToSalConversionsUtils { 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())); @@ -431,14 +431,14 @@ public class TestToSalConversionsUtils { 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 instructions = Collections.singletonList(applyActions ); InstructionsBuilder instBuilder = new InstructionsBuilder(); - + instBuilder.setInstruction(instructions); - + return instBuilder.build(); } @@ -492,7 +492,7 @@ public class TestToSalConversionsUtils { private void prepareActionSetNwDst(List 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()); diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/AbstractChangeListener.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/AbstractChangeListener.java index 426f4ba2d5..c8a7f01e13 100644 --- a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/AbstractChangeListener.java +++ b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/AbstractChangeListener.java @@ -1,6 +1,6 @@ /** * 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 @@ -19,7 +19,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** - * + * * @author Vaclav Demcak * */ @@ -32,17 +32,17 @@ public abstract class AbstractChangeListener implements DataChangeListener { public void onDataChanged(DataChangeEvent, DataObject> changeEvent) { this.transactionId = this.newTransactionIdentifier().toString(); - final Set, DataObject>> createdEntries = + final Set, DataObject>> createdEntries = changeEvent.getCreatedConfigurationData().entrySet(); - final Set, DataObject>> updatedEntries = + final Set, DataObject>> updatedEntries = new HashSet, DataObject>>(); - Set, DataObject>> updateConfigEntrySet = + Set, DataObject>> updateConfigEntrySet = changeEvent.getUpdatedConfigurationData().entrySet(); updatedEntries.addAll(updateConfigEntrySet); updatedEntries.removeAll(createdEntries); - final Set> removeEntriesInstanceIdentifiers = + final Set> removeEntriesInstanceIdentifiers = changeEvent.getRemovedConfigurationData(); for (final Entry, DataObject> createdEntry : createdEntries) { @@ -52,7 +52,7 @@ public abstract class AbstractChangeListener implements DataChangeListener { } for (final Entry, DataObject> updatedEntrie : updatedEntries) { - Map, DataObject> origConfigData = + Map, DataObject> origConfigData = changeEvent.getOriginalConfigurationData(); InstanceIdentifier u_key = updatedEntrie.getKey(); @@ -62,7 +62,7 @@ public abstract class AbstractChangeListener implements DataChangeListener { } for (final InstanceIdentifier instanceId : removeEntriesInstanceIdentifiers) { - Map, DataObject> origConfigData = + Map, DataObject> origConfigData = changeEvent.getOriginalConfigurationData(); final DataObject removeValue = origConfigData.get(instanceId); diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/FRMActivator.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/FRMActivator.java index 929c489eaf..2f986ea5bc 100644 --- a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/FRMActivator.java +++ b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/FRMActivator.java @@ -1,6 +1,6 @@ /** * 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 @@ -24,10 +24,10 @@ public class FRMActivator extends AbstractBindingAwareProvider { 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(); - + @Override public void onSessionInitiated(final ProviderContext session) { DataProviderService flowSalService = session.getSALService(DataProviderService.class); @@ -46,7 +46,7 @@ public class FRMActivator extends AbstractBindingAwareProvider { FRMActivator.meterProvider.setSalMeterService(rpcMeterSalService); FRMActivator.meterProvider.start(); } - + @Override protected void stopImpl(final BundleContext context) { try { diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowChangeListener.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowChangeListener.java index df086c7acc..b60424513f 100644 --- a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowChangeListener.java +++ b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowChangeListener.java @@ -1,6 +1,6 @@ /** * 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 @@ -32,7 +32,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * + * * @author Vaclav Demcak * */ @@ -45,7 +45,7 @@ public class FlowChangeListener extends AbstractChangeListener { public SalFlowService getSalFlowService() { return this.salFlowService; } - + public FlowChangeListener(final SalFlowService manager) { this.salFlowService = manager; } @@ -58,16 +58,16 @@ public class FlowChangeListener extends AbstractChangeListener { @Override protected void remove(InstanceIdentifier identifier, DataObject removeDataObj) { if ((removeDataObj instanceof Flow)) { - + final Flow flow = ((Flow) removeDataObj); final InstanceIdentifier tableInstanceId = identifier.
firstIdentifierOf(Table.class); final InstanceIdentifier nodeInstanceId = identifier. firstIdentifierOf(Node.class); final RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(flow); - + 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()); @@ -78,21 +78,21 @@ public class FlowChangeListener extends AbstractChangeListener { @Override protected void update(InstanceIdentifier identifier, DataObject original, DataObject update) { if (original instanceof Flow && update instanceof Flow) { - + final Flow originalFlow = ((Flow) original); final Flow updatedFlow = ((Flow) update); final InstanceIdentifier nodeInstanceId = identifier.firstIdentifierOf(Node.class); final UpdateFlowInputBuilder builder = new UpdateFlowInputBuilder(); - + builder.setNode(new NodeRef(nodeInstanceId)); builder.setFlowRef(new FlowRef(identifier)); - + Uri uri = new Uri(this.getTransactionId()); builder.setTransactionUri(uri); - + 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}); } @@ -101,16 +101,16 @@ public class FlowChangeListener extends AbstractChangeListener { @Override protected void add(InstanceIdentifier identifier, DataObject addDataObj) { if ((addDataObj instanceof Flow)) { - + final Flow flow = ((Flow) addDataObj); final InstanceIdentifier
tableInstanceId = identifier.
firstIdentifierOf(Table.class); final InstanceIdentifier nodeInstanceId = identifier. firstIdentifierOf(Node.class); final AddFlowInputBuilder builder = new AddFlowInputBuilder(flow); - + 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()); diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowProvider.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowProvider.java index afdd628bbb..33db529598 100644 --- a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowProvider.java +++ b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowProvider.java @@ -1,6 +1,6 @@ /** * 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 @@ -42,7 +42,7 @@ public class FlowProvider implements AutoCloseable { InstanceIdentifierBuilder
tableChild = augmentFlowCapNode.
child(Table.class); InstanceIdentifierBuilder flowChild = tableChild. child(Flow.class); final InstanceIdentifier flowDataObjectPath = flowChild.toInstance(); - + /* DataChangeListener registration */ this.flowDataChangeListener = new FlowChangeListener(this.salFlowService); this.flowDataChangeListenerRegistration = this.dataService.registerDataChangeListener(flowDataObjectPath, flowDataChangeListener); diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowTransactionValidator.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowTransactionValidator.java index 4ef93a55e9..9cd42466a6 100644 --- a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowTransactionValidator.java +++ b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowTransactionValidator.java @@ -1,6 +1,6 @@ /** * 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 diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupChangeListener.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupChangeListener.java index 1260f0ec53..54f12bfdcf 100644 --- a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupChangeListener.java +++ b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupChangeListener.java @@ -1,6 +1,6 @@ /** * 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 @@ -30,7 +30,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * + * * @author Vaclav Demcak * */ @@ -43,7 +43,7 @@ public class GroupChangeListener extends AbstractChangeListener { public SalGroupService getSalGroupService() { return this.salGroupService; } - + public GroupChangeListener(final SalGroupService manager) { this.salGroupService = manager; } @@ -56,14 +56,14 @@ public class GroupChangeListener extends AbstractChangeListener { @Override protected void remove(InstanceIdentifier identifier, DataObject removeDataObj) { if ((removeDataObj instanceof Group)) { - + final Group group = ((Group) removeDataObj); final InstanceIdentifier nodeInstanceId = identifier. firstIdentifierOf(Node.class); final RemoveGroupInputBuilder builder = new RemoveGroupInputBuilder(group); - + 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()); @@ -74,21 +74,21 @@ public class GroupChangeListener extends AbstractChangeListener { @Override protected void update(InstanceIdentifier identifier, DataObject original, DataObject update) { if (original instanceof Group && update instanceof Group) { - + final Group originalGroup = ((Group) original); final Group updatedGroup = ((Group) update); final InstanceIdentifier nodeInstanceId = identifier. firstIdentifierOf(Node.class); final UpdateGroupInputBuilder builder = new UpdateGroupInputBuilder(); - + builder.setNode(new NodeRef(nodeInstanceId)); builder.setGroupRef(new GroupRef(identifier)); - + Uri uri = new Uri(this.getTransactionId()); builder.setTransactionUri(uri); - + 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}); } @@ -100,10 +100,10 @@ public class GroupChangeListener extends AbstractChangeListener { final Group group = ((Group) addDataObj); final InstanceIdentifier nodeInstanceId = identifier. firstIdentifierOf(Node.class); final AddGroupInputBuilder builder = new AddGroupInputBuilder(group); - + 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()); diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupProvider.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupProvider.java index 14b1b6f2fd..9f2806e929 100644 --- a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupProvider.java +++ b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupProvider.java @@ -1,6 +1,6 @@ /** * 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 @@ -46,11 +46,11 @@ public class GroupProvider implements AutoCloseable { this.groupDataChangeListenerRegistration = this.dataService.registerDataChangeListener(groupDataObjectPath, groupDataChangeListener); LOG.info("Group Config Provider started."); } - + protected DataModificationTransaction startChange() { return this.dataService.beginTransaction(); } - + public void close() throws Exception { if(groupDataChangeListenerRegistration != null){ groupDataChangeListenerRegistration.close(); diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterChangeListener.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterChangeListener.java index 839e556fbc..48d5257978 100644 --- a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterChangeListener.java +++ b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterChangeListener.java @@ -1,6 +1,6 @@ /** * 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 @@ -30,7 +30,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * + * * @author Vaclav Demcak * */ @@ -43,7 +43,7 @@ public class MeterChangeListener extends AbstractChangeListener { public SalMeterService getSalMeterService() { return this.salMeterService; } - + public MeterChangeListener(final SalMeterService manager) { this.salMeterService = manager; } @@ -56,14 +56,14 @@ public class MeterChangeListener extends AbstractChangeListener { @Override protected void remove(InstanceIdentifier identifier, DataObject removeDataObj) { if ((removeDataObj instanceof Meter)) { - + final Meter meter = ((Meter) removeDataObj); final InstanceIdentifier nodeInstanceId = identifier. firstIdentifierOf(Node.class); final RemoveMeterInputBuilder builder = new RemoveMeterInputBuilder(meter); - + 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()); @@ -74,21 +74,21 @@ public class MeterChangeListener extends AbstractChangeListener { @Override protected void update(InstanceIdentifier identifier, DataObject original, DataObject update) { if (original instanceof Meter && update instanceof Meter) { - + final Meter originalMeter = ((Meter) original); final Meter updatedMeter = ((Meter) update); final InstanceIdentifier nodeInstanceId = identifier. firstIdentifierOf(Node.class); final UpdateMeterInputBuilder builder = new UpdateMeterInputBuilder(); - + builder.setNode(new NodeRef(nodeInstanceId)); builder.setMeterRef(new MeterRef(identifier)); - + Uri uri = new Uri(this.getTransactionId()); builder.setTransactionUri(uri); - + 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}); } @@ -97,14 +97,14 @@ public class MeterChangeListener extends AbstractChangeListener { @Override protected void add(InstanceIdentifier identifier, DataObject addDataObj) { if ((addDataObj instanceof Meter)) { - + final Meter meter = ((Meter) addDataObj); final InstanceIdentifier nodeInstanceId = identifier. firstIdentifierOf(Node.class); final AddMeterInputBuilder builder = new AddMeterInputBuilder(meter); - + 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()); diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterProvider.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterProvider.java index 620801fba5..8596c3fec6 100644 --- a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterProvider.java +++ b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterProvider.java @@ -1,6 +1,6 @@ /** * 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 @@ -46,7 +46,7 @@ public class MeterProvider implements AutoCloseable { this.meterDataChangeListenerRegistration = this.dataService.registerDataChangeListener(meterDataObjectPath, meterDataChangeListener); LOG.info("Meter Config Provider started."); } - + protected DataModificationTransaction startChange() { return this.dataService.beginTransaction(); } diff --git a/opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/NodeChangeCommiter.java b/opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/NodeChangeCommiter.java index 2a3d8fd37e..674ae398d3 100644 --- a/opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/NodeChangeCommiter.java +++ b/opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/NodeChangeCommiter.java @@ -126,7 +126,7 @@ public class NodeChangeCommiter implements OpendaylightInventoryListener { Future> commitResult = it.commit(); listenOnTransactionState(it.getIdentifier(), commitResult, "node update", ref.getValue()); } - + /** * @param txId transaction identificator * @param future transaction result @@ -136,13 +136,13 @@ public class NodeChangeCommiter implements OpendaylightInventoryListener { private static void listenOnTransactionState(final Object txId, Future> future, final String action, final InstanceIdentifier nodeConnectorPath) { Futures.addCallback(JdkFutureAdapters.listenInPoolThread(future),new FutureCallback>() { - + @Override public void onFailure(Throwable t) { LOG.error("Action {} [{}] failed for Tx:{}", action, nodeConnectorPath, txId, t); - + } - + @Override public void onSuccess(RpcResult result) { if(!result.isSuccessful()) { diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBrokerAwareActivator.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBrokerAwareActivator.java index 4d008295a3..6047f058b7 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBrokerAwareActivator.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBrokerAwareActivator.java @@ -23,12 +23,12 @@ public abstract class AbstractBrokerAwareActivator implements BundleActivator { private ServiceTracker tracker; private BindingAwareBroker broker; private ServiceTrackerCustomizer customizer = new ServiceTrackerCustomizer() { - + @Override public BindingAwareBroker addingService(ServiceReference reference) { broker = context.getService(reference); mdActivationPool.execute(new Runnable() { - + @Override public void run() { onBrokerAvailable(broker, context);; @@ -36,50 +36,50 @@ public abstract class AbstractBrokerAwareActivator implements BundleActivator { }); return broker; } - + @Override public void modifiedService(ServiceReference reference, BindingAwareBroker service) { // TODO Auto-generated method stub - + } @Override public void removedService(ServiceReference 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 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. - * + * *

* 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 @@ -99,10 +99,10 @@ public abstract class AbstractBrokerAwareActivator implements BundleActivator { * 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. - * + * *

* 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 @@ -112,11 +112,11 @@ public abstract class AbstractBrokerAwareActivator implements BundleActivator { protected void stopImpl(BundleContext context) { // NOOP } - + protected abstract void onBrokerAvailable(BindingAwareBroker broker, BundleContext context); - + protected void onBrokerRemoved(BindingAwareBroker broker, BundleContext context) { - + } } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareConsumer.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareConsumer.java index 871abb2117..4327451d21 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareConsumer.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareConsumer.java @@ -10,28 +10,28 @@ package org.opendaylight.controller.sal.binding.api; 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. - * + * * 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. - * + * * 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)} - * + * * @param session * Unique session between consumer and SAL. */ diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareProvider.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareProvider.java index 120674fa0d..0812e5f53c 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareProvider.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareProvider.java @@ -14,24 +14,24 @@ import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderCo 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. - * + * *

* 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. - * - * + * + * * @return Set of provided implementation of YANG modules and their Rpcs */ Collection getImplementations(); @@ -39,24 +39,24 @@ public interface BindingAwareProvider { /** * Gets a set of implementations of provider functionality to be registered * into system during the provider registration to the SAL. - * + * *

* This method is invoked by {@link Broker#registerProvider(Provider)} to * learn the initial provided functionality - * + * * @return Set of provider's functionality. */ Collection getFunctionality(); /** * Functionality provided by the {@link BindingAwareProvider} - * + * *

* Marker interface used to mark the interfaces describing specific * functionality which could be exposed by providers to other components. - * - * - * + * + * + * */ public interface ProviderFunctionality { diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareService.java index b3680568bb..20d69a4ca9 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareService.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareService.java @@ -10,20 +10,20 @@ package org.opendaylight.controller.sal.binding.api; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext; /** - * + * * Session-specific instance of the broker functionality. - * + * *

* 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. - * + * *

* 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. - * + * *

* {@link BindingAwareService} and {@link BindingAwareProvider} may seem * similar, but provider provides YANG model-based functionality and @@ -31,9 +31,9 @@ import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerCo * to implement specific functionality of YANG and to reuse it in the * development of {@link BindingAwareConsumer}s and {@link BindingAwareProvider} * s. - * - * - * + * + * + * */ public interface BindingAwareService { diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationListener.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationListener.java index dd454c6620..9429d3f8fa 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationListener.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationListener.java @@ -19,13 +19,13 @@ import org.opendaylight.yangtools.yang.binding.Notification; * @param Notification type */ public interface NotificationListener extends EventListener { - /** - * Invoked to deliver the notification. Note that this method may be invoked - * from a shared thread pool, so implementations SHOULD NOT perform CPU-intensive - * operations and they definitely MUST NOT invoke any potentially blocking - * operations. - * - * @param notification Notification being delivered. - */ + /** + * Invoked to deliver the notification. Note that this method may be invoked + * from a shared thread pool, so implementations SHOULD NOT perform CPU-intensive + * operations and they definitely MUST NOT invoke any potentially blocking + * operations. + * + * @param notification Notification being delivered. + */ void onNotification(T notification); } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/RpcConsumerRegistry.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/RpcConsumerRegistry.java index f71d69b860..7da0a48517 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/RpcConsumerRegistry.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/RpcConsumerRegistry.java @@ -12,13 +12,13 @@ import org.opendaylight.yangtools.yang.binding.RpcService; /** * 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. - * + * * @return Session specific implementation of service */ T getRpcService(Class module); diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataBrokerService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataBrokerService.java index 65f1ff2fe3..d0225768b4 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataBrokerService.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataBrokerService.java @@ -33,7 +33,7 @@ public interface DataBrokerService extends // * @return new blank data modification transaction. */ @Override - DataModificationTransaction beginTransaction(); + DataModificationTransaction beginTransaction(); /** * Reads data subtree from configurational store. diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/mount/MountProviderInstance.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/mount/MountProviderInstance.java index dec44f364f..0d9a90286e 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/mount/MountProviderInstance.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/mount/MountProviderInstance.java @@ -15,9 +15,9 @@ import org.opendaylight.controller.sal.binding.api.data.DataProviderService; * 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. - * + * * @author ttkacik - * + * */ public interface MountProviderInstance // extends // diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/rpc/RpcContextIdentifier.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/rpc/RpcContextIdentifier.java index d6374fff90..e3bedd33f9 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/rpc/RpcContextIdentifier.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/rpc/RpcContextIdentifier.java @@ -15,7 +15,7 @@ public final class RpcContextIdentifier implements Immutable{ public final Class rpcService; public final Class routingContext; - + private RpcContextIdentifier(Class rpcService, Class routingContext) { super(); this.rpcService = rpcService; @@ -29,11 +29,11 @@ public final class RpcContextIdentifier implements Immutable{ public Class getRoutingContext() { return routingContext; } - + public static final RpcContextIdentifier contextForGlobalRpc(Class serviceType) { return new RpcContextIdentifier(serviceType, null); } - + public static final RpcContextIdentifier contextFor(Class serviceType,Class routingContext) { return new RpcContextIdentifier(serviceType, routingContext); } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/rpc/RpcRoutingTable.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/rpc/RpcRoutingTable.java index cc800b6bbb..61c7cfc953 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/rpc/RpcRoutingTable.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/rpc/RpcRoutingTable.java @@ -22,7 +22,7 @@ public interface RpcRoutingTable e /** * Updates route for particular path to specified instance of * {@link RpcService}. - * + * * @param path * Path for which RpcService routing is to be updated * @param service @@ -33,19 +33,19 @@ public interface RpcRoutingTable e /** * Deletes a route for particular path - * + * * @param path * Path for which */ void removeRoute(InstanceIdentifier path); /** - * + * */ S getRoute(InstanceIdentifier nodeInstance); /** - * + * * @return */ Map, S> getRoutes(); diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModuleFactory.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModuleFactory.java index df3b7ece5d..a11a7d67f5 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModuleFactory.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModuleFactory.java @@ -26,14 +26,14 @@ import org.osgi.framework.BundleContext; */ 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, DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception { diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeGenerator.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeGenerator.java index 8aff12b44a..fb6f6ca101 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeGenerator.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeGenerator.java @@ -18,7 +18,7 @@ public interface RuntimeCodeGenerator { /** * Returns an instance of provided RpcService type which delegates all calls * to the delegate. - * + * *

* Returned instance: *

    @@ -36,23 +36,23 @@ public interface RuntimeCodeGenerator { * all calls are delegated. *
  • {@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 - * + * */ T getDirectProxyFor(Class serviceType) throws IllegalArgumentException; /** * Returns an instance of provided RpcService type which routes all calls to * other instances selected on particular input field. - * + * *

* Returned instance: *

    @@ -80,7 +80,7 @@ public interface RuntimeCodeGenerator { * is not present on any field invocation will be delegated to default * service {@link RpcRouter#getDefaultService()}. *
- * + * * @param serviceType * - Subclass of RpcService for which Router is to be generated. * @return Instance of RpcService of provided serviceType which implements diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java index 3ad1dabffe..75d44db9d1 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java @@ -112,7 +112,7 @@ public class RootBindingAwareBroker implements // LOG.info("Starting Binding Aware Broker: {}", identifier); controllerRoot = new RootSalInstance(getRpcProviderRegistry(), getNotificationBroker(), getDataBroker()); - + supportedConsumerServices = ImmutableClassToInstanceMap. builder() .put(NotificationService.class, getRoot()) // @@ -144,19 +144,19 @@ public class RootBindingAwareBroker implements // public void close() throws Exception { // FIXME: Close all sessions } - + @Override public RoutedRpcRegistration addRoutedRpcImplementation(Class type, T implementation) throws IllegalStateException { return getRoot().addRoutedRpcImplementation(type, implementation); } - + @Override public RpcRegistration addRpcImplementation(Class type, T implementation) throws IllegalStateException { return getRoot().addRpcImplementation(type, implementation); } - + @Override public T getRpcService(Class module) { return getRoot().getRpcService(module); @@ -166,7 +166,7 @@ public class RootBindingAwareBroker implements // L arg0) { return getRoot().registerRouteChangeListener(arg0); } - + public class RootSalInstance extends AbstractBindingSalProviderInstance { diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingDomConnectorDeployer.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingDomConnectorDeployer.java index 978c79ea02..bfafc1f9b7 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingDomConnectorDeployer.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingDomConnectorDeployer.java @@ -80,7 +80,7 @@ public class BindingDomConnectorDeployer { connector.startDataForwarding(); } - public static void startNotificationForwarding(BindingIndependentConnector connector, + public static void startNotificationForwarding(BindingIndependentConnector connector, NotificationProviderService baService, NotificationPublishService domService) { if(connector.isNotificationForwarding()) { return; diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardingUtils.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardingUtils.java index e455bea19c..d28b3b5c91 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardingUtils.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardingUtils.java @@ -21,7 +21,7 @@ public class DomForwardingUtils { DomForwardedBroker forwardedSource = (DomForwardedBroker) source; DomForwardedBroker forwardedTarget = (DomForwardedBroker) target; reuseForwardingFrom(forwardedTarget, forwardedSource); - + } private static void reuseForwardingFrom(DomForwardedBroker target, DomForwardedBroker source) { diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/DelegateProxy.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/DelegateProxy.java index e34ee28a31..d22335e66e 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/DelegateProxy.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/DelegateProxy.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.sal.binding.spi; public interface DelegateProxy { - + void setDelegate(T delegate); T getDelegate(); } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/remote/RemoteRpcRouter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/remote/RemoteRpcRouter.java index 526ca40595..068c68a81f 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/remote/RemoteRpcRouter.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/remote/RemoteRpcRouter.java @@ -12,13 +12,13 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration; public interface RemoteRpcRouter { - - - - + + + + ListenerRegistration registerRouteChangeListener(RouteChangeListener listener); - - + + } diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/UnionSerializationTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/UnionSerializationTest.java index 36a172d09c..9f8a443bbf 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/UnionSerializationTest.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/UnionSerializationTest.java @@ -19,22 +19,22 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp import org.opendaylight.yangtools.yang.data.api.CompositeNode; public class UnionSerializationTest extends AbstractDataServiceTest { - + public static final String PREFIX_STRING = "192.168.0.1/32"; - - + + @Test public void testPrefixSerialization() throws Exception { - + 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()); - + Prefix deserialized = (Prefix) testContext.getBindingToDomMappingService().dataObjectFromDataDom(Prefix.class, serialized); assertNotNull(deserialized); assertNotNull(deserialized.getPrefix()); diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/BarListener.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/BarListener.java index f7c19ba1c3..6c133728b6 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/BarListener.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/BarListener.java @@ -12,7 +12,7 @@ import org.opendaylight.yangtools.yang.binding.NotificationListener; public interface BarListener extends NotificationListener { void onBarUpdate(BarUpdate notification); - + void onFlowDelete(FlowDelete notification); } diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooListener.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooListener.java index 3b872d0149..cb8020e3fd 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooListener.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooListener.java @@ -12,5 +12,5 @@ import org.opendaylight.yangtools.yang.binding.NotificationListener; public interface FooListener extends NotificationListener { void onFooUpdate(FooUpdate notification); - + } diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooService.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooService.java index e844809662..2bd211995d 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooService.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooService.java @@ -13,11 +13,11 @@ import org.opendaylight.yangtools.yang.binding.RpcService; import org.opendaylight.yangtools.yang.common.RpcResult; public interface FooService extends RpcService { - + Future> foo(); - + Future> simple(SimpleInput obj); - + Future> inheritedContext(InheritedContextInput obj); } diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/RpcRegistrationNullPointer.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/RpcRegistrationNullPointer.java index 23ae4cd532..b54461c7c1 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/RpcRegistrationNullPointer.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/RpcRegistrationNullPointer.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.sal.binding.test.bugfix; public class RpcRegistrationNullPointer { - - - + + + } diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/BrokerIntegrationTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/BrokerIntegrationTest.java index 1480f0c610..6d0226849f 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/BrokerIntegrationTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/BrokerIntegrationTest.java @@ -78,14 +78,14 @@ public class BrokerIntegrationTest extends AbstractDataServiceTest { /** * We create transaction no 2 - * + * */ DataModificationTransaction removalTransaction = baDataService.beginTransaction(); assertNotNull(transaction); /** * We remove node 1 - * + * */ removalTransaction.removeConfigurationData(node1.getValue()); diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/MessageCapturingFlowService.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/MessageCapturingFlowService.java index cfdab37651..df287791ef 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/MessageCapturingFlowService.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/MessageCapturingFlowService.java @@ -114,16 +114,16 @@ public class MessageCapturingFlowService implements SalFlowService, AutoCloseabl registration.unregisterPath(context, path); return this; } - + public static MessageCapturingFlowService create() { return new MessageCapturingFlowService(); } - + public static MessageCapturingFlowService create(RpcProviderRegistry registry) { MessageCapturingFlowService ret = new MessageCapturingFlowService(); ret.registerTo(registry); return ret; } - - + + } diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/RegistrationListener.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/RegistrationListener.java index b4f51f5771..f088c0a0bd 100644 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/RegistrationListener.java +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/RegistrationListener.java @@ -14,6 +14,6 @@ import org.opendaylight.yangtools.concepts.Registration; public interface RegistrationListener> extends EventListener { void onRegister(T registration); - + void onUnregister(T registration); } diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataProvisionService.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataProvisionService.java index 7d78fd283d..da7efebdfe 100644 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataProvisionService.java +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataProvisionService.java @@ -16,8 +16,8 @@ import org.opendaylight.yangtools.concepts.Registration; public interface DataProvisionService

, D> { public Registration> registerCommitHandler(P path, DataCommitHandler commitHandler); - - public ListenerRegistration>> + + public ListenerRegistration>> registerCommitHandlerListener(RegistrationListener> commitHandlerListener); } diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/notify/NotificationPublishService.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/notify/NotificationPublishService.java index 6a906c5b88..f5f03a106b 100644 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/notify/NotificationPublishService.java +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/notify/NotificationPublishService.java @@ -12,6 +12,6 @@ import java.util.concurrent.ExecutorService; public interface NotificationPublishService { void publish(N notification); - + void publish(N notification,ExecutorService executor); } diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/MutableRoutingTable.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/MutableRoutingTable.java index f99c13ecf5..0ecb2c5768 100644 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/MutableRoutingTable.java +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/MutableRoutingTable.java @@ -11,7 +11,7 @@ import org.opendaylight.yangtools.concepts.Mutable; import org.opendaylight.yangtools.concepts.Path; public interface MutableRoutingTable, T> extends RoutingTable, Mutable { - + void setDefaultRoute(T target); void updateRoute(P path,T target); void removeRoute(P path); diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/Route.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/Route.java index fbf735fa75..4bfb30f828 100644 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/Route.java +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/Route.java @@ -12,6 +12,6 @@ import org.opendaylight.yangtools.concepts.Immutable; public interface Route extends Immutable { C getType(); - + P getPath(); } diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutingTable.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutingTable.java index 4402f69a5f..9e72b68cd6 100644 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutingTable.java +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutingTable.java @@ -14,10 +14,10 @@ import org.opendaylight.yangtools.concepts.Path; public interface RoutingTable, T> { C getIdentifier(); - + T getDefaultRoute(); - + Map getRoutes(); - + T getRoute(P path); } diff --git a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/routing/AbstractDataReadRouter.java b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/routing/AbstractDataReadRouter.java index 4d395267dd..ee9af6cb80 100644 --- a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/routing/AbstractDataReadRouter.java +++ b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/routing/AbstractDataReadRouter.java @@ -24,7 +24,7 @@ import com.google.common.collect.Multimaps; /** * Base abstract implementation of DataReadRouter, which performs * a read operation on multiple data readers and then merges result. - * + * * @param

* @param */ @@ -50,7 +50,7 @@ public abstract class AbstractDataReadRouter

, D> implements Da /** * 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. @@ -59,11 +59,11 @@ public abstract class AbstractDataReadRouter

, D> implements Da /** * Returns a function which performs configuration read for supplied path - * + * * @param path * @return function which performs configuration read for supplied path */ - + private Function, D> configurationRead(final P path) { return new Function, D>() { @Override @@ -75,7 +75,7 @@ public abstract class AbstractDataReadRouter

, D> implements Da /** * Returns a function which performs operational read for supplied path - * + * * @param path * @return function which performs operational read for supplied path */ @@ -92,10 +92,10 @@ public abstract class AbstractDataReadRouter

, D> implements Da /** * 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. - * @return + * @return */ public Registration> registerOperationalReader(P path, DataReader reader) { OperationalDataReaderRegistration ret = new OperationalDataReaderRegistration<>(path, reader); @@ -142,15 +142,15 @@ public abstract class AbstractDataReadRouter

, D> implements Da } private Predicate>> affects(final P path) { - + return new Predicate>>() { - + @Override public boolean apply(Entry> input) { final P key = input.getKey(); return key.contains(path) || ((P) path).contains(key); } - + }; } diff --git a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/service/DataChangeEventImpl.java b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/service/DataChangeEventImpl.java index 691c303688..c86aec96d1 100644 --- a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/service/DataChangeEventImpl.java +++ b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/service/DataChangeEventImpl.java @@ -24,9 +24,9 @@ public class DataChangeEventImpl

, D> implements DataChangeEven private final D updatedOperationalSubtree; private final D updatedConfigurationSubtree; - - - + + + public DataChangeEventImpl(DataChange dataChange, D originalConfigurationSubtree, D originalOperationalSubtree, D updatedOperationalSubtree, D updatedConfigurationSubtree) { super(); diff --git a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/service/InitialDataChangeEventImpl.java b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/service/InitialDataChangeEventImpl.java index d904427502..f35d6dc6af 100644 --- a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/service/InitialDataChangeEventImpl.java +++ b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/service/InitialDataChangeEventImpl.java @@ -28,24 +28,24 @@ public class InitialDataChangeEventImpl

,D> implements DataChan updatedConfigurationData = Collections.emptyMap(); updatedOperationalData = Collections.emptyMap(); } - + public InitialDataChangeEventImpl(D configTree, D operTree, Map updatedCfgData, Map updatedOperData) { updatedConfigurationTree = configTree; updatedOperationalTree = operTree; updatedConfigurationData = updatedCfgData; updatedOperationalData = updatedOperData; } - + @Override public Map getCreatedConfigurationData() { return Collections.emptyMap(); } - + @Override public Map getCreatedOperationalData() { return Collections.emptyMap(); } - + @Override public Map getOriginalConfigurationData() { return Collections.emptyMap(); @@ -66,7 +66,7 @@ public class InitialDataChangeEventImpl

,D> implements DataChan public Map getUpdatedConfigurationData() { return updatedConfigurationData; } - + @Override public D getUpdatedConfigurationSubtree() { return updatedConfigurationTree; @@ -75,21 +75,21 @@ public class InitialDataChangeEventImpl

,D> implements DataChan public D getUpdatedOperationalSubtree() { return updatedOperationalTree; } - + @Override public D getOriginalConfigurationSubtree() { return updatedConfigurationTree; } - + @Override public D getOriginalOperationalSubtree() { return updatedOperationalTree; } - + @Override public Map getUpdatedOperationalData() { return updatedOperationalData; } - + } diff --git a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationException.java b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationException.java index f7a15b614e..daecfdb59b 100644 --- a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationException.java +++ b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationException.java @@ -8,13 +8,13 @@ package org.opendaylight.controller.md.sal.common.impl.util.compat; public class DataNormalizationException extends Exception { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - public DataNormalizationException(String message) { - super(message); - } + public DataNormalizationException(String message) { + super(message); + } - public DataNormalizationException(String message, Throwable cause) { - super(message, cause); - } + public DataNormalizationException(String message, Throwable cause) { + super(message, cause); + } } diff --git a/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/sal/common/util/CommitHandlerTransactions.java b/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/sal/common/util/CommitHandlerTransactions.java index 5d73b1eefb..1af7ccc79a 100644 --- a/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/sal/common/util/CommitHandlerTransactions.java +++ b/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/sal/common/util/CommitHandlerTransactions.java @@ -18,7 +18,7 @@ import org.opendaylight.yangtools.yang.common.RpcResult; public class CommitHandlerTransactions { private static class AllwaysSuccessfulTransaction

,D> implements DataCommitTransaction { - + private final DataModification modification; public AllwaysSuccessfulTransaction(DataModification modification) { @@ -32,13 +32,13 @@ public class CommitHandlerTransactions { public RpcResult finish() throws IllegalStateException { return Rpcs.getRpcResult(true, null, Collections.emptyList()); } - + @Override public DataModification getModification() { return modification; } } - + public static final

,D> AllwaysSuccessfulTransaction allwaysSuccessfulTransaction(DataModification modification) { return new AllwaysSuccessfulTransaction<>(modification); } diff --git a/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/sal/common/util/RpcErrors.java b/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/sal/common/util/RpcErrors.java index 86dcba9596..4d41249b4d 100644 --- a/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/sal/common/util/RpcErrors.java +++ b/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/sal/common/util/RpcErrors.java @@ -16,20 +16,20 @@ import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; * */ public class RpcErrors { - + /** * @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) { - RpcErrorTO ret = new RpcErrorTO(applicationTag, tag, info, severity, message, + RpcErrorTO ret = new RpcErrorTO(applicationTag, tag, info, severity, message, errorType, cause); return ret; } @@ -94,7 +94,7 @@ public class RpcErrors { public Throwable getCause() { return cause; } - + @Override public ErrorType getErrorType() { return errorType; diff --git a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ToSalPropertyClassUtils.java b/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ToSalPropertyClassUtils.java index ff9f037f5a..670a7c8f22 100644 --- a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ToSalPropertyClassUtils.java +++ b/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ToSalPropertyClassUtils.java @@ -14,36 +14,36 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.No 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) { - 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) { - 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) { - FlowCapableNodeConnector flowCapNodeConn = nodeConnector.getAugmentation(FlowCapableNodeConnector.class); + FlowCapableNodeConnector flowCapNodeConn = nodeConnector.getAugmentation(FlowCapableNodeConnector.class); String hwAddress = flowCapNodeConn.getHardwareAddress().getValue(); - return new MacAddress(bytesFrom(hwAddress)); + return new MacAddress(bytesFrom(hwAddress)); } - - + + public static Name salNameFrom(NodeConnector nodeConnector) { - FlowCapableNodeConnector flowCapNodeConn = nodeConnector.getAugmentation(FlowCapableNodeConnector.class); + FlowCapableNodeConnector flowCapNodeConn = nodeConnector.getAugmentation(FlowCapableNodeConnector.class); return new Name(flowCapNodeConn.getName()); } - - + + private static byte[] bytesFrom(String hwAddress) { String[] mac = hwAddress.split(":"); diff --git a/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/BindingAwareRpcRouter.java b/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/BindingAwareRpcRouter.java index a1d573db08..cf59eb4a90 100644 --- a/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/BindingAwareRpcRouter.java +++ b/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/BindingAwareRpcRouter.java @@ -53,8 +53,8 @@ public interface BindingAwareRpcRouter extends RpcRouter> receivedRequest(RpcRequest input) { - + return mdSalRouter.sendRpc(input); } diff --git a/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/Connector.java b/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/Connector.java index efa24d099f..519d21bf4f 100644 --- a/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/Connector.java +++ b/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/Connector.java @@ -15,11 +15,11 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; public interface Connector extends RpcImplementation, NotificationListener { - - + + Set getConfigurationPrefixes(); Set getRuntimePrefixes(); - + void registerListener(ConnectorListener listener); void unregisterListener(ConnectorListener listener); } diff --git a/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/RpcRouter.java b/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/RpcRouter.java index f161644f6d..fa4c8048fa 100644 --- a/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/RpcRouter.java +++ b/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/RpcRouter.java @@ -10,7 +10,7 @@ package org.opendaylight.controller.sal.connector.api; import java.util.concurrent.Future; /** - * + * * @author ttkacik * * @param Routing Context Identifier @@ -20,14 +20,14 @@ import java.util.concurrent.Future; */ public interface RpcRouter { - - + + Future> sendRpc(RpcRequest input); - - + + /** - * - * @author + * + * @author * * @param Routing Context Identifier * @param Route Type @@ -39,14 +39,14 @@ public interface RpcRouter { RouteIdentifier getRoutingInformation(); D getPayload(); } - + public interface RouteIdentifier { - + C getContext(); // defines a routing table (e.g. NodeContext) T getType(); // rpc type R getRoute(); // e.g. (node identity) } - + public interface RpcReply { D getPayload(); } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/AbstractConsumer.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/AbstractConsumer.java index 99a38ca43a..c14d5a679c 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/AbstractConsumer.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/AbstractConsumer.java @@ -18,9 +18,9 @@ import org.osgi.util.tracker.ServiceTrackerCustomizer; public abstract class AbstractConsumer implements Consumer, BundleActivator,ServiceTrackerCustomizer { - - - + + + private BundleContext context; private ServiceTracker tracker; private Broker broker; @@ -54,7 +54,7 @@ public abstract class AbstractConsumer implements Consumer, BundleActivator,Serv return Collections.emptySet(); } - + @Override public Broker addingService(ServiceReference reference) { if(broker == null) { @@ -62,15 +62,15 @@ public abstract class AbstractConsumer implements Consumer, BundleActivator,Serv broker.registerConsumer(this, context); return broker; } - + return null; } - + @Override public void modifiedService(ServiceReference reference, Broker service) { // NOOP } - + @Override public void removedService(ServiceReference reference, Broker service) { stopImpl(context); diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/BrokerService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/BrokerService.java index c1518b1ec6..dec2f7a484 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/BrokerService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/BrokerService.java @@ -10,28 +10,28 @@ package org.opendaylight.controller.sal.core.api; import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession; /** - * + * * Session-specific instance of the broker functionality. - * + * *

* 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. - * + * *

* 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. - * + * *

* {@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 { diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Consumer.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Consumer.java index 3127df521f..a693cd6c49 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Consumer.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Consumer.java @@ -12,26 +12,26 @@ import java.util.Collection; 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. - * + * * 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. - * + * * 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)} - * + * * @param session * Unique session between consumer and SAL. */ @@ -40,9 +40,9 @@ public interface Consumer { /** * 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)}. - * + * * @return Set of consumer functionality. */ public Collection getConsumerFunctionality(); @@ -50,8 +50,8 @@ public interface Consumer { /** * The marker interface for the interfaces describing the consumer * functionality contracts. - * - * + * + * */ public interface ConsumerFunctionality { diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Provider.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Provider.java index fef8618b2c..0a57d12579 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Provider.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Provider.java @@ -12,30 +12,30 @@ import java.util.Collection; 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. - * + * *

* 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. - * + * *

* The provider MUST use the session for all communication with SAL * or retrieving SAL infrastructure services. - * + * *

* This method is invoked by {@link Broker#registerConsumer(Consumer)} - * + * * @param session * Unique session between provider and SAL. */ @@ -44,24 +44,24 @@ public interface Provider { /** * Gets a set of implementations of provider functionality to be registered * into system during the provider registration to the SAL. - * + * *

* This method is invoked by {@link Broker#registerProvider(Provider)} to * learn the initial provided functionality - * + * * @return Set of provider's functionality. */ public Collection getProviderFunctionality(); /** * Functionality provided by the {@link Provider} - * + * *

* Marker interface used to mark the interfaces describing specific * functionality which could be exposed by providers to other components. - * + * - * + * */ public interface ProviderFunctionality { diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcConsumptionRegistry.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcConsumptionRegistry.java index 665a50f9ca..da592e9b22 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcConsumptionRegistry.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcConsumptionRegistry.java @@ -16,7 +16,7 @@ import org.opendaylight.yangtools.yang.data.api.CompositeNode; public interface RpcConsumptionRegistry { /** * Sends an RPC to other components registered to the broker. - * + * * @see RpcImplementation * @param rpc * Name of RPC diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcProvisionRegistry.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcProvisionRegistry.java index f43dcd6b43..a22a6ef75e 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcProvisionRegistry.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcProvisionRegistry.java @@ -18,17 +18,17 @@ public interface RpcProvisionRegistry extends RpcImplementation, BrokerService, /** * Registers an implementation of the rpc. - * + * *

* 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. - * + * *

* 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 @@ -38,7 +38,7 @@ public interface RpcProvisionRegistry extends RpcImplementation, BrokerService, */ RpcRegistration addRpcImplementation(QName rpcType, RpcImplementation implementation) throws IllegalArgumentException; - + ListenerRegistration addRpcRegistrationListener(RpcRegistrationListener listener); RoutedRpcRegistration addRoutedRpcImplementation(QName rpcType, RpcImplementation implementation); diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcRegistrationListener.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcRegistrationListener.java index 2ba5c4ba20..a0be886b24 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcRegistrationListener.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcRegistrationListener.java @@ -12,8 +12,8 @@ import java.util.EventListener; import org.opendaylight.yangtools.yang.common.QName; public interface RpcRegistrationListener extends EventListener { - + public void onRpcImplementationAdded(QName name); - + public void onRpcImplementationRemoved(QName name); } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcRoutingContext.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcRoutingContext.java index 64195303e8..66d290f531 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcRoutingContext.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcRoutingContext.java @@ -15,20 +15,20 @@ import org.opendaylight.yangtools.yang.common.QName; public class RpcRoutingContext implements Immutable, Serializable { /** - * + * */ private static final long serialVersionUID = -9079324728075883325L; - + private final QName context; private final QName 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); } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataBrokerService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataBrokerService.java index 2d5f4b2a55..266b6976af 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataBrokerService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataBrokerService.java @@ -18,12 +18,12 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; /** * DataBrokerService provides unified access to the data stores available in the * system. - * - * + * + * * @see DataProviderService - * + * */ -public interface DataBrokerService extends +public interface DataBrokerService extends BrokerService, // DataReader, // DataModificationTransactionFactory, // diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataProviderService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataProviderService.java index 20fa29dceb..0538660fd7 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataProviderService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataProviderService.java @@ -15,14 +15,14 @@ import org.opendaylight.yangtools.yang.data.api.CompositeNode; 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 { /** * Adds {@link DataValidator} for specified Data Store - * + * * @param store * Data Store * @param validator @@ -32,7 +32,7 @@ public interface DataProviderService extends /** * Removes {@link DataValidator} from specified Data Store - * + * * @param store * @param validator * Validator @@ -42,7 +42,7 @@ public interface DataProviderService extends /** * Adds {@link DataRefresher} for specified data store - * + * * @param store * @param refresher */ @@ -50,22 +50,22 @@ public interface DataProviderService extends /** * Removes {@link DataRefresher} from specified data store - * + * * @param store * @param refresher */ void removeRefresher(DataStoreIdentifier store, DataRefresher refresher); - + Registration> registerConfigurationReader(InstanceIdentifier path, DataReader reader); Registration> registerOperationalReader(InstanceIdentifier path, DataReader reader); - + 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. */ diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataStore.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataStore.java index 8bdd061871..58ffb38365 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataStore.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataStore.java @@ -15,11 +15,11 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; public interface DataStore extends // DataReader, DataCommitHandler { - - + + Iterable getStoredConfigurationPaths(); Iterable getStoredOperationalPaths(); - + boolean containsConfigurationPath(InstanceIdentifier path); boolean containsOperationalPath(InstanceIdentifier path); diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataValidator.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataValidator.java index 2bcb84be34..286770b048 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataValidator.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataValidator.java @@ -17,7 +17,7 @@ import org.opendaylight.yangtools.yang.data.api.CompositeNode; /** * {@link Provider}-supplied Validator of the data. - * + * *

* The registration could be done by : *

    @@ -27,25 +27,25 @@ import org.opendaylight.yangtools.yang.data.api.CompositeNode; * as arguments to the * {@link DataProviderService#addValidator(DataStoreIdentifier, DataValidator)} *
- * + * **/ 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. - * + * * @return Set of Data Store identifiers */ Set getSupportedDataStores(); /** * Performs validation on supplied data. - * + * * @param toValidate * Data to validate * @return Validation result. The diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationListener.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationListener.java index f87fee5bce..7dc8cb36c5 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationListener.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationListener.java @@ -21,21 +21,21 @@ import org.opendaylight.yangtools.yang.data.api.CompositeNode; 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. - * + * * @return Set of QNames identifying supported notifications. */ Set getSupportedNotifications(); /** * Fired when the notification occurs. - * + * * The type of the notification could be learned by * QName type = notification.getNodeType(); - * + * * @param notification * Notification content */ diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationPublishService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationPublishService.java index aa22b90f65..8dab4cd705 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationPublishService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationPublishService.java @@ -13,14 +13,14 @@ import org.opendaylight.yangtools.yang.data.api.CompositeNode; /** * Notification Publishing Service - * + * * The simplified process of the notification publishing is following: - * + * *
    *
  1. {@link Provider} invokes {@link #sendNotification(CompositeNode)} *
  2. {@link Broker} finds {@link NotificationListener}s which subscribed for * the notification type. - * + * *
  3. For each subscriber {@link Broker} invokes * {@link NotificationListener#onNotification(CompositeNode)} *
@@ -28,11 +28,11 @@ import org.opendaylight.yangtools.yang.data.api.CompositeNode; public interface NotificationPublishService extends NotificationService { /** * Publishes a notification. - * + * * Notification type is determined by the * {@link CompositeNode#getNodeType()} of the * notification parameter. - * + * * @param notification * Notification to publish */ diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationService.java index f654ca9ad6..7a60f2d677 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationService.java @@ -18,10 +18,10 @@ import org.opendaylight.yangtools.yang.common.QName; /** * NotificationService provides access to the notification functionality of the * SAL. - * + * * NotificationService allows for consumption of notifications by registering * implementations of NotificationListener. - * + * * The registration of notification listeners could be done by: *
    *
  • returning an instance of implementation in the return value of @@ -30,14 +30,14 @@ import org.opendaylight.yangtools.yang.common.QName; * arguments to the * {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)} *
- * - * + * + * */ public interface NotificationService extends BrokerService { /** * Registers a notification listener for supplied notification type. - * + * * @param notification * @param listener */ diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/statistics/DomBrokerRuntimeMXBeanImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/statistics/DomBrokerRuntimeMXBeanImpl.java index 692a0babdf..8e2a11184c 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/statistics/DomBrokerRuntimeMXBeanImpl.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/statistics/DomBrokerRuntimeMXBeanImpl.java @@ -14,13 +14,13 @@ import org.opendaylight.controller.sal.dom.broker.DataBrokerImpl; public class DomBrokerRuntimeMXBeanImpl implements DomBrokerImplRuntimeMXBean { - + private final DataBrokerImpl dataService; private final Transactions transactions = new Transactions(); private final Data data = new Data(); - + public DomBrokerRuntimeMXBeanImpl(DataBrokerImpl dataService) { - this.dataService = dataService; + this.dataService = dataService; } public Transactions getTransactions() { diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java index 25e6d04721..10b838a2c6 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java @@ -50,12 +50,12 @@ import com.google.common.util.concurrent.ListeningExecutorService; /** * 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. - * + * */ public class InMemoryDOMDataStore implements DOMStore, Identifiable, SchemaContextListener, TransactionReadyPrototype { @@ -108,7 +108,7 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch /* * 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 */ diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedWriteTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedWriteTransaction.java index 717fb11987..534ee64b8a 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedWriteTransaction.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SnapshotBackedWriteTransaction.java @@ -26,7 +26,7 @@ import com.google.common.base.Throwables; * Implementation of Write transaction which is backed by * {@link DataTreeSnapshot} and executed according to * {@link TransactionReadyPrototype}. - * + * */ class SnapshotBackedWriteTransaction extends AbstractDOMStoreTransaction implements DOMStoreWriteTransaction { @@ -37,7 +37,7 @@ class SnapshotBackedWriteTransaction extends AbstractDOMStoreTransaction impleme /** * Creates new write-only transaction. - * + * * @param identifier * transaction Identifier * @param snapshot @@ -140,19 +140,19 @@ class SnapshotBackedWriteTransaction extends AbstractDOMStoreTransaction impleme /** * 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. - * + * */ public static interface TransactionReadyPrototype { /** * Returns a commit coordinator associated with supplied transactions. - * + * * This call must not fail. - * + * * @param tx * Transaction on which ready was invoked. * @return DOMStoreThreePhaseCommitCohort associated with transaction diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeFactory.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeFactory.java index 7422c116ef..c6dd25c76b 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeFactory.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeFactory.java @@ -11,10 +11,10 @@ package org.opendaylight.controller.md.sal.dom.store.impl.tree; * Factory interface for creating data trees. */ public interface DataTreeFactory { - /** - * Create a new data tree. - * - * @return A data tree instance. - */ - DataTree create(); + /** + * Create a new data tree. + * + * @return A data tree instance. + */ + DataTree create(); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerConfigActivator.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerConfigActivator.java index 7f834351d3..3291afa061 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerConfigActivator.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerConfigActivator.java @@ -1,6 +1,6 @@ /** * 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 diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataBrokerImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataBrokerImpl.java index ba3dcc8c86..69f518bb32 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataBrokerImpl.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataBrokerImpl.java @@ -27,16 +27,16 @@ public class DataBrokerImpl extends AbstractDataBroker +public class DataTransactionImpl extends AbstractDataTransaction implements DataModificationTransaction { private final ListenerRegistry listeners = new ListenerRegistry(); - - - + + + public DataTransactionImpl(Object identifier,DataBrokerImpl dataBroker) { super(identifier,dataBroker); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataBrokerServiceProxy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataBrokerServiceProxy.java index 5839db46ca..30027ec929 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataBrokerServiceProxy.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataBrokerServiceProxy.java @@ -37,6 +37,6 @@ public class DataBrokerServiceProxy extends AbstractBrokerServiceProxy>> registerCommitHandlerListener( RegistrationListener> commitHandlerListener) { diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/NotificationRouter.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/NotificationRouter.java index 74923dd8b8..ebe95d6eb5 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/NotificationRouter.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/NotificationRouter.java @@ -18,7 +18,7 @@ public interface NotificationRouter { /** * Registers a notification listener for supplied notification type. - * + * * @param notification * @param listener */ diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangDataUtils.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangDataUtils.java index 8b78b83e2f..9cc96e147f 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangDataUtils.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangDataUtils.java @@ -24,8 +24,8 @@ public class YangDataUtils { // TODO Auto-generated constructor stub } - - + + public static Map,CompositeNode> toIndexMap(List nodes,List keys) { ConcurrentHashMap,CompositeNode> ret = new ConcurrentHashMap<>(); for(CompositeNode node : nodes) { @@ -44,7 +44,7 @@ public class YangDataUtils { checkArgument(keyNode != null,"Node must contains all keys."); Object value = keyNode.getValue(); map.put(key, value); - + } return map; } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangSchemaUtils.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangSchemaUtils.java index 7f6918f2a1..a478aaac97 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangSchemaUtils.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangSchemaUtils.java @@ -40,7 +40,7 @@ import com.google.common.collect.FluentIterable; public class YangSchemaUtils { private static final Function QNAME_FROM_PATH_ARGUMENT = new Function(){ - + @Override public QName apply(PathArgument input) { if(input == null) { @@ -53,26 +53,26 @@ public class YangSchemaUtils { 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,Iterable 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 iterator = path.iterator(); - + while (iterator.hasNext()) { checkArgument(previous!= null, "Supplied path does not resolve into valid schema node."); QName arg = iterator.next(); @@ -122,119 +122,119 @@ public class YangSchemaUtils { } private static final class NetconfDataRootNode implements ContainerSchemaNode { - + public NetconfDataRootNode(SchemaContext schema) { // TODO Auto-generated constructor stub } - + @Override public Set> getTypeDefinitions() { // TODO Auto-generated method stub return null; } - + @Override public Set getChildNodes() { // TODO Auto-generated method stub return null; } - + @Override public Set 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(String name) { // TODO Auto-generated method stub return null; } - + @Override public Set getUses() { // TODO Auto-generated method stub return null; } - + @Override public Set getAvailableAugmentations() { // TODO Auto-generated method stub return null; } - + @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 isConfiguration() { // TODO Auto-generated method stub return false; } - + @Override public ConstraintDefinition getConstraints() { // 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 String getDescription() { // 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 List getUnknownSchemaNodes() { // TODO Auto-generated method stub return null; } - + @Override public boolean isPresenceContainer() { // TODO Auto-generated method stub return false; } - + } } diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java index 94ac8d652e..413d81d029 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java @@ -45,24 +45,24 @@ public class InMemoryDataStoreTest { DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction(); assertNotNull(writeTx); /** - * + * * Writes /test in writeTx - * + * */ writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); /** - * + * * Reads /test from writeTx Read should return container. - * + * */ ListenableFuture>> writeTxContainer = writeTx.read(TestModel.TEST_PATH); assertTrue(writeTxContainer.get().isPresent()); /** - * + * * Reads /test from readTx Read should return Absent. - * + * */ ListenableFuture>> readTxContainer = readTx.read(TestModel.TEST_PATH); assertFalse(readTxContainer.get().isPresent()); @@ -74,16 +74,16 @@ public class InMemoryDataStoreTest { DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction(); assertNotNull(writeTx); /** - * + * * Writes /test in writeTx - * + * */ writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); /** - * + * * Reads /test from writeTx Read should return container. - * + * */ ListenableFuture>> writeTxContainer = writeTx.read(TestModel.TEST_PATH); assertTrue(writeTxContainer.get().isPresent()); @@ -123,8 +123,8 @@ public class InMemoryDataStoreTest { /** * We alocate new read-write transaction and write /test - * - * + * + * */ DOMStoreReadWriteTransaction firstTx = txChain.newReadWriteTransaction(); assertTestContainerWrite(firstTx); @@ -142,27 +142,27 @@ public class InMemoryDataStoreTest { 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. - * - * + * + * */ assertTestContainerExists(secondReadTx); /** - * + * * 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). - * - * + * + * */ assertTestContainerExists(thirdDeleteTx); @@ -178,7 +178,7 @@ public class InMemoryDataStoreTest { /** * We commit first transaction - * + * */ assertThreePhaseCommit(firstWriteTxCohort); @@ -191,7 +191,7 @@ public class InMemoryDataStoreTest { assertTestContainerExists(storeReadTx); /** * We commit third transaction - * + * */ assertThreePhaseCommit(thirdDeleteTxCohort); } @@ -225,9 +225,9 @@ public class InMemoryDataStoreTest { private static Optional> assertTestContainerWrite(final DOMStoreReadWriteTransaction writeTx) throws InterruptedException, ExecutionException { /** - * + * * Writes /test in writeTx - * + * */ writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); @@ -235,9 +235,9 @@ public class InMemoryDataStoreTest { } /** - * + * * Reads /test from readTx Read should return container. - * + * */ private static Optional> assertTestContainerExists(DOMStoreReadTransaction readTx) throws InterruptedException, ExecutionException { diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/config/yang/md/sal/remote/rpc/ZeroMQServerModuleFactory.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/config/yang/md/sal/remote/rpc/ZeroMQServerModuleFactory.java index c8d6806344..0c2a370e06 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/config/yang/md/sal/remote/rpc/ZeroMQServerModuleFactory.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/config/yang/md/sal/remote/rpc/ZeroMQServerModuleFactory.java @@ -24,7 +24,7 @@ public class ZeroMQServerModuleFactory extends org.opendaylight.controller.confi module.setBundleContext(bundleContext); return module; } - + @Override public Module createModule(String instanceName, DependencyResolver dependencyResolver, DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception { diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/MessageWrapper.java b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/MessageWrapper.java index 8d2198c365..85f4113663 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/MessageWrapper.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/MessageWrapper.java @@ -16,7 +16,7 @@ public class MessageWrapper { private Message _message; private ZMQ.Socket _receiveSocket; - + public MessageWrapper(Message message, ZMQ.Socket receiveSocket) { this._message = message; this._receiveSocket = receiveSocket; diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/provider-service/src/main/java/org/opendaylight/controller/sample/zeromq/provider/ExampleProvider.java b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/provider-service/src/main/java/org/opendaylight/controller/sample/zeromq/provider/ExampleProvider.java index e33011b92b..5703799bb5 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/provider-service/src/main/java/org/opendaylight/controller/sample/zeromq/provider/ExampleProvider.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/provider-service/src/main/java/org/opendaylight/controller/sample/zeromq/provider/ExampleProvider.java @@ -91,7 +91,7 @@ public class ExampleProvider extends AbstractProvider implements RpcImplementati } return false; } - + // Adds a child SimpleNode containing the value "success" to the input CompositeNode private CompositeNode addSuccessNode(CompositeNode input) { List> list = new ArrayList>(input.getChildren()); diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/src/test/java/org/opendaylight/controller/sample/zeromq/test/it/RouterTest.java b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/src/test/java/org/opendaylight/controller/sample/zeromq/test/it/RouterTest.java index 5ee982009e..30f8fd4ed1 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/src/test/java/org/opendaylight/controller/sample/zeromq/test/it/RouterTest.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/src/test/java/org/opendaylight/controller/sample/zeromq/test/it/RouterTest.java @@ -67,7 +67,7 @@ public class RouterTest { @Inject @Filter(timeout=60*1000) Broker broker; - + private ZMQ.Context zmqCtx = ZMQ.context(1); //private Server router; //private ExampleProvider provider; @@ -336,7 +336,7 @@ public class RouterTest { return msg; } - + private void printState(){ Bundle[] b = ctx.getBundles(); _logger.debug("\n\nNumber of bundles [{}]\n\n]", b.length); diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestconfService.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestconfService.java index 067b7d96ec..4d9b198795 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestconfService.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestconfService.java @@ -31,12 +31,12 @@ import org.opendaylight.yangtools.yang.data.api.CompositeNode; *
    *
  • /restconf - {@link #getRoot()} *
      - *
    • /config - {@link #readConfigurationData(String)} + *
    • /config - {@link #readConfigurationData(String)} * {@link #updateConfigurationData(String, CompositeNode)} * {@link #createConfigurationData(CompositeNode)} * {@link #createConfigurationData(String, CompositeNode)} * {@link #deleteConfigurationData(String)} - *
    • /operational - {@link #readOperationalData(String)} + *
    • /operational - {@link #readOperationalData(String)} *
    • /modules - {@link #getModules()} *
        *
      • /module @@ -95,41 +95,41 @@ public interface RestconfService { 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); - + @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:.+}") - @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:.+}") - @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:.+}") - @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") - @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); diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestUtil.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestUtil.java index ba3e315e72..290d976b28 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestUtil.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestUtil.java @@ -20,7 +20,7 @@ import org.opendaylight.controller.sal.restconf.impl.IdentityValuesDTO.Predicate 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("\\[(.*?)\\]"); @@ -45,29 +45,29 @@ public final class RestUtil { 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; } - + List predicates = toPredicates(xPathPartTrimmed, prefixMap); if (predicates == null) { return null; } identityValue.setPredicates(predicates); - + 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 IdentityValue toIdentity(String xPathPart, PrefixesMaping prefixMap) { String xPathPartTrimmed = xPathPart.trim(); if (xPathPartTrimmed.isEmpty()) { diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/EmptyNodeWrapper.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/EmptyNodeWrapper.java index f7f70e8d87..934d4434c3 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/EmptyNodeWrapper.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/EmptyNodeWrapper.java @@ -18,9 +18,9 @@ import org.opendaylight.yangtools.yang.data.impl.NodeFactory; import com.google.common.base.Preconditions; public final class EmptyNodeWrapper implements NodeWrapper>, Node { - + private Node unwrapped; - + private String localName; private URI namespace; private QName name; @@ -30,27 +30,27 @@ public final class EmptyNodeWrapper implements NodeWrapper>, Node public boolean isComposite() { return composite; } - + public void setComposite(boolean composite) { this.composite = composite; } - + 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 QName getQname() { return name; } - + @Override public String getLocalName() { if (unwrapped != null) { @@ -58,7 +58,7 @@ public final class EmptyNodeWrapper implements NodeWrapper>, Node } return localName; } - + @Override public URI getNamespace() { if (unwrapped != null) { diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/IdentityValuesDTO.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/IdentityValuesDTO.java index 14a558967d..d66e1610a5 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/IdentityValuesDTO.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/IdentityValuesDTO.java @@ -20,11 +20,11 @@ public final class IdentityValuesDTO { elementData.add(new IdentityValue(namespace, value, prefix)); this.originValue = originValue; } - + public IdentityValuesDTO(String originValue) { this.originValue = originValue; } - + public IdentityValuesDTO() { originValue = null; } @@ -32,21 +32,21 @@ public final class IdentityValuesDTO { 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 List getValuesWithNamespaces() { return Collections.unmodifiableList(elementData); } - + @Override public String toString() { return elementData.toString(); } - + public String getOriginValue() { return originValue; } @@ -86,7 +86,7 @@ public final class IdentityValuesDTO { public void setPredicates(List predicates) { this.predicates = predicates; } - + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -110,22 +110,22 @@ public final class IdentityValuesDTO { } } - + public static final class Predicate { - + private final IdentityValue name; private final String value; - + public Predicate(IdentityValue name, String value) { super(); this.name = name; this.value = value; } - + public IdentityValue getName() { return name; } - + public String getValue() { return value; } @@ -141,10 +141,10 @@ public final class IdentityValuesDTO { } return sb.toString(); } - + public boolean isLeafList() { return name == null ? true : false; } - + } } diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/NodeWrapper.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/NodeWrapper.java index f9bd7d7aaa..48fd1a3dfc 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/NodeWrapper.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/NodeWrapper.java @@ -15,16 +15,16 @@ import org.opendaylight.yangtools.yang.data.api.Node; public interface NodeWrapper> { void setQname(QName name); - + QName getQname(); - + T unwrap(); - + boolean isChangeAllowed(); - + URI getNamespace(); void setNamespace(URI namespace); - + String getLocalName(); } diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java index 42658d79f1..265cc5db45 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java @@ -41,7 +41,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class RestCodec { - + private static final Logger logger = LoggerFactory.getLogger(RestCodec.class); private RestCodec() { @@ -180,7 +180,7 @@ public class RestCodec { logger.info("Idenetityref will be translated as NULL for data - {}", String.valueOf(valueWithNamespace)); return null; } - + return QName.create(module.getNamespace(), module.getRevision(), valueWithNamespace.getValue()); } @@ -292,7 +292,7 @@ public class RestCodec { } } } - + return result.isEmpty() ? null : new InstanceIdentifier(result); } @@ -312,7 +312,7 @@ public class RestCodec { return null; } } - + private static Module getModuleByNamespace(String namespace, MountInstance mountPoint) { URI validNamespace = resolveValidNamespace(namespace, mountPoint); @@ -328,7 +328,7 @@ public class RestCodec { } return module; } - + private static URI resolveValidNamespace(String namespace, MountInstance mountPoint) { URI validNamespace; if (mountPoint != null) { diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/SimpleNodeWrapper.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/SimpleNodeWrapper.java index 4d22bfa73a..3131668ed9 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/SimpleNodeWrapper.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/SimpleNodeWrapper.java @@ -19,9 +19,9 @@ import org.opendaylight.yangtools.yang.data.impl.NodeFactory; import com.google.common.base.Preconditions; public final class SimpleNodeWrapper implements NodeWrapper>, SimpleNode { - + private SimpleNode simpleNode; - + private String localName; private Object value; private URI namespace; @@ -31,23 +31,23 @@ public final class SimpleNodeWrapper implements NodeWrapper>, Simp this.localName = Preconditions.checkNotNull(localName); this.value = value; } - + 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 QName getQname() { return name; } - + @Override public String getLocalName() { if (simpleNode != null) { @@ -55,7 +55,7 @@ public final class SimpleNodeWrapper implements NodeWrapper>, Simp } return localName; } - + @Override public URI getNamespace() { if (simpleNode != null) { @@ -83,7 +83,7 @@ public final class SimpleNodeWrapper implements NodeWrapper>, Simp name = new QName(namespace, localName); } simpleNode = NodeFactory.createImmutableSimpleNode(name, null, value); - + value = null; namespace = null; localName = null; @@ -126,7 +126,7 @@ public final class SimpleNodeWrapper implements NodeWrapper>, Simp public Object setValue(Object value) { return unwrap().setValue(value); } - + } diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/ListenerAdapter.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/ListenerAdapter.java index f2a0d48e0a..6282f37602 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/ListenerAdapter.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/ListenerAdapter.java @@ -64,611 +64,611 @@ import com.google.common.eventbus.Subscribe; */ public class ListenerAdapter implements DataChangeListener { - private static final Logger logger = LoggerFactory - .getLogger(ListenerAdapter.class); - private final XmlMapper xmlMapper = new XmlMapper(); - private final SimpleDateFormat rfc3339 = new SimpleDateFormat( - "yyyy-MM-dd'T'hh:mm:ssZ"); - - private final InstanceIdentifier path; - private ListenerRegistration registration; - private final String streamName; - private Set subscribers = new ConcurrentSet<>(); - private final EventBus eventBus; - private final EventBusChangeRecorder eventBusChangeRecorder; - - /** - * Creates new {@link ListenerAdapter} listener specified by path and stream - * name. - * - * @param path - * Path to data in data store. - * @param streamName - * The name of the stream. - */ - ListenerAdapter(InstanceIdentifier path, String streamName) { - Preconditions.checkNotNull(path); - Preconditions - .checkArgument(streamName != null && !streamName.isEmpty()); - this.path = path; - this.streamName = streamName; - eventBus = new AsyncEventBus(Executors.newSingleThreadExecutor()); - eventBusChangeRecorder = new EventBusChangeRecorder(); - eventBus.register(eventBusChangeRecorder); - } - - @Override - public void onDataChanged( - DataChangeEvent change) { - if (!change.getCreatedConfigurationData().isEmpty() - || !change.getCreatedOperationalData().isEmpty() - || !change.getUpdatedConfigurationData().isEmpty() - || !change.getUpdatedOperationalData().isEmpty() - || !change.getRemovedConfigurationData().isEmpty() - || !change.getRemovedOperationalData().isEmpty()) { - String xml = prepareXmlFrom(change); - Event event = new Event(EventType.NOTIFY); - event.setData(xml); - eventBus.post(event); - } - } - - /** - * Tracks events of data change by customer. - */ - private final class EventBusChangeRecorder { - @Subscribe - public void recordCustomerChange(Event event) { - if (event.getType() == EventType.REGISTER) { - Channel subscriber = event.getSubscriber(); - if (!subscribers.contains(subscriber)) { - subscribers.add(subscriber); - } - } else if (event.getType() == EventType.DEREGISTER) { - subscribers.remove(event.getSubscriber()); - Notificator - .removeListenerIfNoSubscriberExists(ListenerAdapter.this); - } else if (event.getType() == EventType.NOTIFY) { - for (Channel subscriber : subscribers) { - if (subscriber.isActive()) { - logger.debug("Data are sent to subscriber {}:", - subscriber.remoteAddress()); - subscriber.writeAndFlush(new TextWebSocketFrame(event - .getData())); - } else { - logger.debug( - "Subscriber {} is removed - channel is not active yet.", - subscriber.remoteAddress()); - subscribers.remove(subscriber); - } - } - } - } - } - - /** - * Represents event of specific {@link EventType} type, holds data and - * {@link Channel} subscriber. - */ - private final class Event { - private final EventType type; - private Channel subscriber; - private String data; - - /** - * Creates new event specified by {@link EventType} type. - * - * @param type - * EventType - */ - public Event(EventType type) { - this.type = type; - } - - /** - * Gets the {@link Channel} subscriber. - * - * @return Channel - */ - public Channel getSubscriber() { - return subscriber; - } - - /** - * Sets subscriber for event. - * - * @param subscriber - * Channel - */ - public void setSubscriber(Channel subscriber) { - this.subscriber = subscriber; - } - - /** - * Gets event data. - * - * @return String representation of event data. - */ - public String getData() { - return data; - } - - /** - * Sets event data. - * - * @param String - * data. - */ - public void setData(String data) { - this.data = data; - } - - /** - * Gets event type. - * - * @return The type of the event. - */ - public EventType getType() { - return type; - } - } - - /** - * Type of the event. - */ - private enum EventType { - REGISTER, DEREGISTER, NOTIFY; - } - - /** - * Prepare data in printable form and transform it to String. - * - * @param change - * DataChangeEvent - * @return Data in printable form. - */ - private String prepareXmlFrom( - DataChangeEvent change) { - Document doc = createDocument(); - Element notificationElement = doc.createElementNS( - "urn:ietf:params:xml:ns:netconf:notification:1.0", - "notification"); - doc.appendChild(notificationElement); - - Element eventTimeElement = doc.createElement("eventTime"); - eventTimeElement.setTextContent(toRFC3339(new Date())); - notificationElement.appendChild(eventTimeElement); - - Element dataChangedNotificationEventElement = doc.createElementNS( - "urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote", - "data-changed-notification"); - addValuesToDataChangedNotificationEventElement(doc, - dataChangedNotificationEventElement, change); - notificationElement.appendChild(dataChangedNotificationEventElement); - - try { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer transformer = tf.newTransformer(); - transformer - .setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); - transformer.setOutputProperty(OutputKeys.METHOD, "xml"); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); - transformer.setOutputProperty( - "{http://xml.apache.org/xslt}indent-amount", "4"); - transformer.transform(new DOMSource(doc), new StreamResult( - new OutputStreamWriter(out, "UTF-8"))); - byte[] charData = out.toByteArray(); - return new String(charData, "UTF-8"); - } catch (TransformerException | UnsupportedEncodingException e) { - String msg = "Error during transformation of Document into String"; - logger.error(msg, e); - return msg; - } - } - - /** - * Formats data specified by RFC3339. - * - * @param d - * Date - * @return Data specified by RFC3339. - */ - private String toRFC3339(Date d) { - return rfc3339.format(d).replaceAll("(\\d\\d)(\\d\\d)$", "$1:$2"); - } - - /** - * Creates {@link Document} document. - * - * @return {@link Document} document. - */ - private Document createDocument() { - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - Document doc = null; - try { - DocumentBuilder bob = dbf.newDocumentBuilder(); - doc = bob.newDocument(); - } catch (ParserConfigurationException e) { - return null; - } - return doc; - } - - /** - * Adds values to data changed notification event element. - * - * @param doc - * {@link Document} - * @param dataChangedNotificationEventElement - * {@link Element} - * @param change - * {@link DataChangeEvent} - */ - private void addValuesToDataChangedNotificationEventElement(Document doc, - Element dataChangedNotificationEventElement, - DataChangeEvent change) { - addValuesFromDataToElement(doc, change.getCreatedConfigurationData(), - dataChangedNotificationEventElement, Store.CONFIG, - Operation.CREATED); - addValuesFromDataToElement(doc, change.getCreatedOperationalData(), - dataChangedNotificationEventElement, Store.OPERATION, - Operation.CREATED); - if (change.getCreatedConfigurationData().isEmpty()) { - addValuesFromDataToElement(doc, - change.getUpdatedConfigurationData(), - dataChangedNotificationEventElement, Store.CONFIG, - Operation.UPDATED); - } - if (change.getCreatedOperationalData().isEmpty()) { - addValuesFromDataToElement(doc, change.getUpdatedOperationalData(), - dataChangedNotificationEventElement, Store.OPERATION, - Operation.UPDATED); - } - addValuesFromDataToElement(doc, change.getRemovedConfigurationData(), - dataChangedNotificationEventElement, Store.CONFIG, - Operation.DELETED); - addValuesFromDataToElement(doc, change.getRemovedOperationalData(), - dataChangedNotificationEventElement, Store.OPERATION, - Operation.DELETED); - } - - /** - * Adds values from data to element. - * - * @param doc - * {@link Document} - * @param data - * Set of {@link InstanceIdentifier}. - * @param element - * {@link Element} - * @param store - * {@link Store} - * @param operation - * {@link Operation} - */ - private void addValuesFromDataToElement(Document doc, - Set data, Element element, Store store, - Operation operation) { - if (data == null || data.isEmpty()) { - return; - } - for (InstanceIdentifier path : data) { - Node node = createDataChangeEventElement(doc, path, null, store, - operation); - element.appendChild(node); - } - } - - /** - * Adds values from data to element. - * - * @param doc - * {@link Document} - * @param data - * Map of {@link InstanceIdentifier} and {@link CompositeNode}. - * @param element - * {@link Element} - * @param store - * {@link Store} - * @param operation - * {@link Operation} - */ - private void addValuesFromDataToElement(Document doc, - Map data, Element element, - Store store, Operation operation) { - if (data == null || data.isEmpty()) { - return; - } - for (Entry entry : data.entrySet()) { - Node node = createDataChangeEventElement(doc, entry.getKey(), - entry.getValue(), store, operation); - element.appendChild(node); - } - } - - /** - * Creates changed event element from data. - * - * @param doc - * {@link Document} - * @param path - * Path to data in data store. - * @param data - * {@link CompositeNode} - * @param store - * {@link Store} - * @param operation - * {@link Operation} - * @return {@link Node} node represented by changed event element. - */ - private Node createDataChangeEventElement(Document doc, - InstanceIdentifier path, CompositeNode data, Store store, - Operation operation) { - Element dataChangeEventElement = doc.createElement("data-change-event"); - - Element pathElement = doc.createElement("path"); - addPathAsValueToElement(path, pathElement); - dataChangeEventElement.appendChild(pathElement); - - Element storeElement = doc.createElement("store"); - storeElement.setTextContent(store.value); - dataChangeEventElement.appendChild(storeElement); - - Element operationElement = doc.createElement("operation"); - operationElement.setTextContent(operation.value); - dataChangeEventElement.appendChild(operationElement); - - if (data != null) { - Element dataElement = doc.createElement("data"); - Node dataAnyXml = translateToXml(path, data); - Node adoptedNode = doc.adoptNode(dataAnyXml); - dataElement.appendChild(adoptedNode); - dataChangeEventElement.appendChild(dataElement); - } - - return dataChangeEventElement; - } - - /** - * Translates {@link CompositeNode} data to XML format. - * - * @param path - * Path to data in data store. - * @param data - * {@link CompositeNode} - * @return Data in XML format. - */ - private Node translateToXml(InstanceIdentifier path, CompositeNode data) { - DataNodeContainer schemaNode = ControllerContext.getInstance() - .getDataNodeContainerFor(path); - if (schemaNode == null) { - logger.info( - "Path '{}' contains node with unsupported type (supported type is Container or List) or some node was not found.", - path); - return null; - } - try { - Document xml = xmlMapper.write(data, schemaNode); - return xml.getFirstChild(); - } catch (UnsupportedDataTypeException e) { - logger.error( - "Error occured during translation of notification to XML.", - e); - return null; - } - } - - /** - * Adds path as value to element. - * - * @param path - * Path to data in data store. - * @param element - * {@link Element} - */ - private void addPathAsValueToElement(InstanceIdentifier path, - Element element) { - // Map< key = namespace, value = prefix> - Map prefixes = new HashMap<>(); - InstanceIdentifier instanceIdentifier = path; - StringBuilder textContent = new StringBuilder(); - for (PathArgument pathArgument : instanceIdentifier.getPath()) { - textContent.append("/"); - writeIdentifierWithNamespacePrefix(element, textContent, - pathArgument.getNodeType(), prefixes); - if (pathArgument instanceof NodeIdentifierWithPredicates) { - Map predicates = ((NodeIdentifierWithPredicates) pathArgument) - .getKeyValues(); - for (QName keyValue : predicates.keySet()) { - String predicateValue = String.valueOf(predicates - .get(keyValue)); - textContent.append("["); - writeIdentifierWithNamespacePrefix(element, textContent, - keyValue, prefixes); - textContent.append("='"); - textContent.append(predicateValue); - textContent.append("'"); - textContent.append("]"); - } - } else if (pathArgument instanceof NodeWithValue) { - textContent.append("[.='"); - textContent.append(((NodeWithValue) pathArgument).getValue()); - textContent.append("'"); - textContent.append("]"); - } - } - element.setTextContent(textContent.toString()); - } - - /** - * Writes identifier that consists of prefix and QName. - * - * @param element - * {@link Element} - * @param textContent - * StringBuilder - * @param qName - * QName - * @param prefixes - * Map of namespaces and prefixes. - */ - private static void writeIdentifierWithNamespacePrefix(Element element, - StringBuilder textContent, QName qName, Map prefixes) { - String namespace = qName.getNamespace().toString(); - String prefix = prefixes.get(namespace); - if (prefix == null) { - prefix = qName.getPrefix(); - if (prefix == null || prefix.isEmpty() - || prefixes.containsValue(prefix)) { - prefix = generateNewPrefix(prefixes.values()); - } - } - - element.setAttribute("xmlns:" + prefix, namespace); - textContent.append(prefix); - prefixes.put(namespace, prefix); - - textContent.append(":"); - textContent.append(qName.getLocalName()); - } - - /** - * Generates new prefix which consists of four random characters . - * - * @param prefixes - * Collection of prefixes. - * @return New prefix which consists of four random characters . - */ - private static String generateNewPrefix(Collection prefixes) { - StringBuilder result = null; - Random random = new Random(); - do { - result = new StringBuilder(); - for (int i = 0; i < 4; i++) { - int randomNumber = 0x61 + (Math.abs(random.nextInt()) % 26); - result.append(Character.toChars(randomNumber)); - } - } while (prefixes.contains(result.toString())); - - return result.toString(); - } - - /** - * Gets path pointed to data in data store. - * - * @return Path pointed to data in data store. - */ - public InstanceIdentifier getPath() { - return path; - } - - /** - * Sets {@link ListenerRegistration} registration. - * - * @param registration - * ListenerRegistration - */ - public void setRegistration( - ListenerRegistration registration) { - this.registration = registration; - } - - /** - * Gets the name of the stream. - * - * @return The name of the stream. - */ - public String getStreamName() { - return streamName; - } - - /** - * Removes all subscribers and unregisters event bus change recorder form - * event bus. - */ - public void close() throws Exception { - subscribers = new ConcurrentSet<>(); - registration.close(); - registration = null; - eventBus.unregister(eventBusChangeRecorder); - } - - /** - * Checks if {@link ListenerRegistration} registration exist. - * - * @return True if exist, false otherwise. - */ - public boolean isListening() { - return registration == null ? false : true; - } - - /** - * Creates event of type {@link EventType#REGISTER}, set {@link Channel} - * subscriber to the event and post event into event bus. - * - * @param subscriber - * Channel - */ - public void addSubscriber(Channel subscriber) { - if (!subscriber.isActive()) { - logger.debug("Channel is not active between websocket server and subscriber {}" - + subscriber.remoteAddress()); - } - Event event = new Event(EventType.REGISTER); - event.setSubscriber(subscriber); - eventBus.post(event); - } - - /** - * 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) { - logger.debug("Subscriber {} is removed.", subscriber.remoteAddress()); - Event event = new Event(EventType.DEREGISTER); - event.setSubscriber(subscriber); - eventBus.post(event); - } - - /** - * Checks if exists at least one {@link Channel} subscriber. - * - * @return True if exist at least one {@link Channel} subscriber, false - * otherwise. - */ - public boolean hasSubscribers() { - return !subscribers.isEmpty(); - } - - /** - * Consists of two types {@link Store#CONFIG} and {@link Store#OPERATION}. - */ - private static enum Store { - CONFIG("config"), OPERATION("operation"); - - private final String value; - - private Store(String value) { - this.value = value; - } - } - - /** - * Consists of three types {@link Operation#CREATED}, - * {@link Operation#UPDATED} and {@link Operation#DELETED}. - */ - private static enum Operation { - CREATED("created"), UPDATED("updated"), DELETED("deleted"); - - private final String value; - - private Operation(String value) { - this.value = value; - } - } + private static final Logger logger = LoggerFactory + .getLogger(ListenerAdapter.class); + private final XmlMapper xmlMapper = new XmlMapper(); + private final SimpleDateFormat rfc3339 = new SimpleDateFormat( + "yyyy-MM-dd'T'hh:mm:ssZ"); + + private final InstanceIdentifier path; + private ListenerRegistration registration; + private final String streamName; + private Set subscribers = new ConcurrentSet<>(); + private final EventBus eventBus; + private final EventBusChangeRecorder eventBusChangeRecorder; + + /** + * Creates new {@link ListenerAdapter} listener specified by path and stream + * name. + * + * @param path + * Path to data in data store. + * @param streamName + * The name of the stream. + */ + ListenerAdapter(InstanceIdentifier path, String streamName) { + Preconditions.checkNotNull(path); + Preconditions + .checkArgument(streamName != null && !streamName.isEmpty()); + this.path = path; + this.streamName = streamName; + eventBus = new AsyncEventBus(Executors.newSingleThreadExecutor()); + eventBusChangeRecorder = new EventBusChangeRecorder(); + eventBus.register(eventBusChangeRecorder); + } + + @Override + public void onDataChanged( + DataChangeEvent change) { + if (!change.getCreatedConfigurationData().isEmpty() + || !change.getCreatedOperationalData().isEmpty() + || !change.getUpdatedConfigurationData().isEmpty() + || !change.getUpdatedOperationalData().isEmpty() + || !change.getRemovedConfigurationData().isEmpty() + || !change.getRemovedOperationalData().isEmpty()) { + String xml = prepareXmlFrom(change); + Event event = new Event(EventType.NOTIFY); + event.setData(xml); + eventBus.post(event); + } + } + + /** + * Tracks events of data change by customer. + */ + private final class EventBusChangeRecorder { + @Subscribe + public void recordCustomerChange(Event event) { + if (event.getType() == EventType.REGISTER) { + Channel subscriber = event.getSubscriber(); + if (!subscribers.contains(subscriber)) { + subscribers.add(subscriber); + } + } else if (event.getType() == EventType.DEREGISTER) { + subscribers.remove(event.getSubscriber()); + Notificator + .removeListenerIfNoSubscriberExists(ListenerAdapter.this); + } else if (event.getType() == EventType.NOTIFY) { + for (Channel subscriber : subscribers) { + if (subscriber.isActive()) { + logger.debug("Data are sent to subscriber {}:", + subscriber.remoteAddress()); + subscriber.writeAndFlush(new TextWebSocketFrame(event + .getData())); + } else { + logger.debug( + "Subscriber {} is removed - channel is not active yet.", + subscriber.remoteAddress()); + subscribers.remove(subscriber); + } + } + } + } + } + + /** + * Represents event of specific {@link EventType} type, holds data and + * {@link Channel} subscriber. + */ + private final class Event { + private final EventType type; + private Channel subscriber; + private String data; + + /** + * Creates new event specified by {@link EventType} type. + * + * @param type + * EventType + */ + public Event(EventType type) { + this.type = type; + } + + /** + * Gets the {@link Channel} subscriber. + * + * @return Channel + */ + public Channel getSubscriber() { + return subscriber; + } + + /** + * Sets subscriber for event. + * + * @param subscriber + * Channel + */ + public void setSubscriber(Channel subscriber) { + this.subscriber = subscriber; + } + + /** + * Gets event data. + * + * @return String representation of event data. + */ + public String getData() { + return data; + } + + /** + * Sets event data. + * + * @param String + * data. + */ + public void setData(String data) { + this.data = data; + } + + /** + * Gets event type. + * + * @return The type of the event. + */ + public EventType getType() { + return type; + } + } + + /** + * Type of the event. + */ + private enum EventType { + REGISTER, DEREGISTER, NOTIFY; + } + + /** + * Prepare data in printable form and transform it to String. + * + * @param change + * DataChangeEvent + * @return Data in printable form. + */ + private String prepareXmlFrom( + DataChangeEvent change) { + Document doc = createDocument(); + Element notificationElement = doc.createElementNS( + "urn:ietf:params:xml:ns:netconf:notification:1.0", + "notification"); + doc.appendChild(notificationElement); + + Element eventTimeElement = doc.createElement("eventTime"); + eventTimeElement.setTextContent(toRFC3339(new Date())); + notificationElement.appendChild(eventTimeElement); + + Element dataChangedNotificationEventElement = doc.createElementNS( + "urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote", + "data-changed-notification"); + addValuesToDataChangedNotificationEventElement(doc, + dataChangedNotificationEventElement, change); + notificationElement.appendChild(dataChangedNotificationEventElement); + + try { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer transformer = tf.newTransformer(); + transformer + .setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + transformer.setOutputProperty( + "{http://xml.apache.org/xslt}indent-amount", "4"); + transformer.transform(new DOMSource(doc), new StreamResult( + new OutputStreamWriter(out, "UTF-8"))); + byte[] charData = out.toByteArray(); + return new String(charData, "UTF-8"); + } catch (TransformerException | UnsupportedEncodingException e) { + String msg = "Error during transformation of Document into String"; + logger.error(msg, e); + return msg; + } + } + + /** + * Formats data specified by RFC3339. + * + * @param d + * Date + * @return Data specified by RFC3339. + */ + private String toRFC3339(Date d) { + return rfc3339.format(d).replaceAll("(\\d\\d)(\\d\\d)$", "$1:$2"); + } + + /** + * Creates {@link Document} document. + * + * @return {@link Document} document. + */ + private Document createDocument() { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + Document doc = null; + try { + DocumentBuilder bob = dbf.newDocumentBuilder(); + doc = bob.newDocument(); + } catch (ParserConfigurationException e) { + return null; + } + return doc; + } + + /** + * Adds values to data changed notification event element. + * + * @param doc + * {@link Document} + * @param dataChangedNotificationEventElement + * {@link Element} + * @param change + * {@link DataChangeEvent} + */ + private void addValuesToDataChangedNotificationEventElement(Document doc, + Element dataChangedNotificationEventElement, + DataChangeEvent change) { + addValuesFromDataToElement(doc, change.getCreatedConfigurationData(), + dataChangedNotificationEventElement, Store.CONFIG, + Operation.CREATED); + addValuesFromDataToElement(doc, change.getCreatedOperationalData(), + dataChangedNotificationEventElement, Store.OPERATION, + Operation.CREATED); + if (change.getCreatedConfigurationData().isEmpty()) { + addValuesFromDataToElement(doc, + change.getUpdatedConfigurationData(), + dataChangedNotificationEventElement, Store.CONFIG, + Operation.UPDATED); + } + if (change.getCreatedOperationalData().isEmpty()) { + addValuesFromDataToElement(doc, change.getUpdatedOperationalData(), + dataChangedNotificationEventElement, Store.OPERATION, + Operation.UPDATED); + } + addValuesFromDataToElement(doc, change.getRemovedConfigurationData(), + dataChangedNotificationEventElement, Store.CONFIG, + Operation.DELETED); + addValuesFromDataToElement(doc, change.getRemovedOperationalData(), + dataChangedNotificationEventElement, Store.OPERATION, + Operation.DELETED); + } + + /** + * Adds values from data to element. + * + * @param doc + * {@link Document} + * @param data + * Set of {@link InstanceIdentifier}. + * @param element + * {@link Element} + * @param store + * {@link Store} + * @param operation + * {@link Operation} + */ + private void addValuesFromDataToElement(Document doc, + Set data, Element element, Store store, + Operation operation) { + if (data == null || data.isEmpty()) { + return; + } + for (InstanceIdentifier path : data) { + Node node = createDataChangeEventElement(doc, path, null, store, + operation); + element.appendChild(node); + } + } + + /** + * Adds values from data to element. + * + * @param doc + * {@link Document} + * @param data + * Map of {@link InstanceIdentifier} and {@link CompositeNode}. + * @param element + * {@link Element} + * @param store + * {@link Store} + * @param operation + * {@link Operation} + */ + private void addValuesFromDataToElement(Document doc, + Map data, Element element, + Store store, Operation operation) { + if (data == null || data.isEmpty()) { + return; + } + for (Entry entry : data.entrySet()) { + Node node = createDataChangeEventElement(doc, entry.getKey(), + entry.getValue(), store, operation); + element.appendChild(node); + } + } + + /** + * Creates changed event element from data. + * + * @param doc + * {@link Document} + * @param path + * Path to data in data store. + * @param data + * {@link CompositeNode} + * @param store + * {@link Store} + * @param operation + * {@link Operation} + * @return {@link Node} node represented by changed event element. + */ + private Node createDataChangeEventElement(Document doc, + InstanceIdentifier path, CompositeNode data, Store store, + Operation operation) { + Element dataChangeEventElement = doc.createElement("data-change-event"); + + Element pathElement = doc.createElement("path"); + addPathAsValueToElement(path, pathElement); + dataChangeEventElement.appendChild(pathElement); + + Element storeElement = doc.createElement("store"); + storeElement.setTextContent(store.value); + dataChangeEventElement.appendChild(storeElement); + + Element operationElement = doc.createElement("operation"); + operationElement.setTextContent(operation.value); + dataChangeEventElement.appendChild(operationElement); + + if (data != null) { + Element dataElement = doc.createElement("data"); + Node dataAnyXml = translateToXml(path, data); + Node adoptedNode = doc.adoptNode(dataAnyXml); + dataElement.appendChild(adoptedNode); + dataChangeEventElement.appendChild(dataElement); + } + + return dataChangeEventElement; + } + + /** + * Translates {@link CompositeNode} data to XML format. + * + * @param path + * Path to data in data store. + * @param data + * {@link CompositeNode} + * @return Data in XML format. + */ + private Node translateToXml(InstanceIdentifier path, CompositeNode data) { + DataNodeContainer schemaNode = ControllerContext.getInstance() + .getDataNodeContainerFor(path); + if (schemaNode == null) { + logger.info( + "Path '{}' contains node with unsupported type (supported type is Container or List) or some node was not found.", + path); + return null; + } + try { + Document xml = xmlMapper.write(data, schemaNode); + return xml.getFirstChild(); + } catch (UnsupportedDataTypeException e) { + logger.error( + "Error occured during translation of notification to XML.", + e); + return null; + } + } + + /** + * Adds path as value to element. + * + * @param path + * Path to data in data store. + * @param element + * {@link Element} + */ + private void addPathAsValueToElement(InstanceIdentifier path, + Element element) { + // Map< key = namespace, value = prefix> + Map prefixes = new HashMap<>(); + InstanceIdentifier instanceIdentifier = path; + StringBuilder textContent = new StringBuilder(); + for (PathArgument pathArgument : instanceIdentifier.getPath()) { + textContent.append("/"); + writeIdentifierWithNamespacePrefix(element, textContent, + pathArgument.getNodeType(), prefixes); + if (pathArgument instanceof NodeIdentifierWithPredicates) { + Map predicates = ((NodeIdentifierWithPredicates) pathArgument) + .getKeyValues(); + for (QName keyValue : predicates.keySet()) { + String predicateValue = String.valueOf(predicates + .get(keyValue)); + textContent.append("["); + writeIdentifierWithNamespacePrefix(element, textContent, + keyValue, prefixes); + textContent.append("='"); + textContent.append(predicateValue); + textContent.append("'"); + textContent.append("]"); + } + } else if (pathArgument instanceof NodeWithValue) { + textContent.append("[.='"); + textContent.append(((NodeWithValue) pathArgument).getValue()); + textContent.append("'"); + textContent.append("]"); + } + } + element.setTextContent(textContent.toString()); + } + + /** + * Writes identifier that consists of prefix and QName. + * + * @param element + * {@link Element} + * @param textContent + * StringBuilder + * @param qName + * QName + * @param prefixes + * Map of namespaces and prefixes. + */ + private static void writeIdentifierWithNamespacePrefix(Element element, + StringBuilder textContent, QName qName, Map prefixes) { + String namespace = qName.getNamespace().toString(); + String prefix = prefixes.get(namespace); + if (prefix == null) { + prefix = qName.getPrefix(); + if (prefix == null || prefix.isEmpty() + || prefixes.containsValue(prefix)) { + prefix = generateNewPrefix(prefixes.values()); + } + } + + element.setAttribute("xmlns:" + prefix, namespace); + textContent.append(prefix); + prefixes.put(namespace, prefix); + + textContent.append(":"); + textContent.append(qName.getLocalName()); + } + + /** + * Generates new prefix which consists of four random characters . + * + * @param prefixes + * Collection of prefixes. + * @return New prefix which consists of four random characters . + */ + private static String generateNewPrefix(Collection prefixes) { + StringBuilder result = null; + Random random = new Random(); + do { + result = new StringBuilder(); + for (int i = 0; i < 4; i++) { + int randomNumber = 0x61 + (Math.abs(random.nextInt()) % 26); + result.append(Character.toChars(randomNumber)); + } + } while (prefixes.contains(result.toString())); + + return result.toString(); + } + + /** + * Gets path pointed to data in data store. + * + * @return Path pointed to data in data store. + */ + public InstanceIdentifier getPath() { + return path; + } + + /** + * Sets {@link ListenerRegistration} registration. + * + * @param registration + * ListenerRegistration + */ + public void setRegistration( + ListenerRegistration registration) { + this.registration = registration; + } + + /** + * Gets the name of the stream. + * + * @return The name of the stream. + */ + public String getStreamName() { + return streamName; + } + + /** + * Removes all subscribers and unregisters event bus change recorder form + * event bus. + */ + public void close() throws Exception { + subscribers = new ConcurrentSet<>(); + registration.close(); + registration = null; + eventBus.unregister(eventBusChangeRecorder); + } + + /** + * Checks if {@link ListenerRegistration} registration exist. + * + * @return True if exist, false otherwise. + */ + public boolean isListening() { + return registration == null ? false : true; + } + + /** + * Creates event of type {@link EventType#REGISTER}, set {@link Channel} + * subscriber to the event and post event into event bus. + * + * @param subscriber + * Channel + */ + public void addSubscriber(Channel subscriber) { + if (!subscriber.isActive()) { + logger.debug("Channel is not active between websocket server and subscriber {}" + + subscriber.remoteAddress()); + } + Event event = new Event(EventType.REGISTER); + event.setSubscriber(subscriber); + eventBus.post(event); + } + + /** + * 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) { + logger.debug("Subscriber {} is removed.", subscriber.remoteAddress()); + Event event = new Event(EventType.DEREGISTER); + event.setSubscriber(subscriber); + eventBus.post(event); + } + + /** + * Checks if exists at least one {@link Channel} subscriber. + * + * @return True if exist at least one {@link Channel} subscriber, false + * otherwise. + */ + public boolean hasSubscribers() { + return !subscribers.isEmpty(); + } + + /** + * Consists of two types {@link Store#CONFIG} and {@link Store#OPERATION}. + */ + private static enum Store { + CONFIG("config"), OPERATION("operation"); + + private final String value; + + private Store(String value) { + this.value = value; + } + } + + /** + * Consists of three types {@link Operation#CREATED}, + * {@link Operation#UPDATED} and {@link Operation#DELETED}. + */ + private static enum Operation { + CREATED("created"), UPDATED("updated"), DELETED("deleted"); + + private final String value; + + private Operation(String value) { + this.value = value; + } + } } diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/Notificator.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/Notificator.java index 6f154f8aff..a576eed269 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/Notificator.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/Notificator.java @@ -21,11 +21,11 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; public class Notificator { private static Map listenersByStreamName = new ConcurrentHashMap<>(); - private static Map listenersByInstanceIdentifier = new ConcurrentHashMap<>(); - private static final Lock lock = new ReentrantLock(); + private static Map listenersByInstanceIdentifier = new ConcurrentHashMap<>(); + private static final Lock lock = new ReentrantLock(); - private Notificator() { - } + private Notificator() { + } /** * Returns list of all stream names @@ -35,152 +35,152 @@ public class Notificator { } - /** - * Gets {@link ListenerAdapter} specified by stream name. - * - * @param streamName - * The name of the stream. - * @return {@link ListenerAdapter} specified by stream name. - */ - public static ListenerAdapter getListenerFor(String streamName) { - return listenersByStreamName.get(streamName); - } - - /** - * Gets {@link ListenerAdapter} listener specified by - * {@link InstanceIdentifier} path. - * - * @param path - * Path to data in data repository. - * @return ListenerAdapter - */ - public static ListenerAdapter getListenerFor(InstanceIdentifier path) { - return listenersByInstanceIdentifier.get(path); - } - - /** - * 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. - */ - public static boolean existListenerFor(InstanceIdentifier path) { - return listenersByInstanceIdentifier.containsKey(path); - } - - /** - * Creates new {@link ListenerAdapter} listener from - * {@link InstanceIdentifier} path and stream name. - * - * @param path - * Path to data in data repository. - * @param streamName - * The name of the stream. - * @return New {@link ListenerAdapter} listener from - * {@link InstanceIdentifier} path and stream name. - */ - public static ListenerAdapter createListener(InstanceIdentifier path, - String streamName) { - ListenerAdapter listener = new ListenerAdapter(path, streamName); - try { - lock.lock(); - listenersByInstanceIdentifier.put(path, listener); - listenersByStreamName.put(streamName, listener); - } finally { - lock.unlock(); - } - return listener; - } - - /** - * Looks for listener determined by {@link InstanceIdentifier} path and - * removes it. - * - * @param path - * InstanceIdentifier - */ - public static void removeListener(InstanceIdentifier path) { - ListenerAdapter listener = listenersByInstanceIdentifier.get(path); - deleteListener(listener); - } - - /** - * 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. - */ - public static String createStreamNameFromUri(String uri) { - if (uri == null) { - return null; - } - String result = uri; - if (result.startsWith("/")) { - result = result.substring(1); - } - if (result.endsWith("/")) { - result = result.substring(0, result.length()); - } - return result; - } - - /** - * Removes all listeners. - */ - public static void removeAllListeners() { - for (ListenerAdapter listener : listenersByInstanceIdentifier.values()) { - try { - listener.close(); - } catch (Exception e) { - } - } - try { - lock.lock(); - listenersByStreamName = new ConcurrentHashMap<>(); - listenersByInstanceIdentifier = new ConcurrentHashMap<>(); - } finally { - lock.unlock(); - } - } - - /** - * Checks if listener has at least one subscriber. In case it doesn't have any, delete - * listener. - * - * @param listener - * ListenerAdapter - */ - public static void removeListenerIfNoSubscriberExists( - ListenerAdapter listener) { - if (!listener.hasSubscribers()) { - deleteListener(listener); - } - } - - /** - * Delete {@link ListenerAdapter} listener specified in parameter. - * - * @param listener - * ListenerAdapter - */ - private static void deleteListener(ListenerAdapter listener) { - if (listener != null) { - try { - listener.close(); - } catch (Exception e) { - } - try { - lock.lock(); - listenersByInstanceIdentifier.remove(listener.getPath()); - listenersByStreamName.remove(listener.getStreamName()); - } finally { - lock.unlock(); - } - } - } + /** + * Gets {@link ListenerAdapter} specified by stream name. + * + * @param streamName + * The name of the stream. + * @return {@link ListenerAdapter} specified by stream name. + */ + public static ListenerAdapter getListenerFor(String streamName) { + return listenersByStreamName.get(streamName); + } + + /** + * Gets {@link ListenerAdapter} listener specified by + * {@link InstanceIdentifier} path. + * + * @param path + * Path to data in data repository. + * @return ListenerAdapter + */ + public static ListenerAdapter getListenerFor(InstanceIdentifier path) { + return listenersByInstanceIdentifier.get(path); + } + + /** + * 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. + */ + public static boolean existListenerFor(InstanceIdentifier path) { + return listenersByInstanceIdentifier.containsKey(path); + } + + /** + * Creates new {@link ListenerAdapter} listener from + * {@link InstanceIdentifier} path and stream name. + * + * @param path + * Path to data in data repository. + * @param streamName + * The name of the stream. + * @return New {@link ListenerAdapter} listener from + * {@link InstanceIdentifier} path and stream name. + */ + public static ListenerAdapter createListener(InstanceIdentifier path, + String streamName) { + ListenerAdapter listener = new ListenerAdapter(path, streamName); + try { + lock.lock(); + listenersByInstanceIdentifier.put(path, listener); + listenersByStreamName.put(streamName, listener); + } finally { + lock.unlock(); + } + return listener; + } + + /** + * Looks for listener determined by {@link InstanceIdentifier} path and + * removes it. + * + * @param path + * InstanceIdentifier + */ + public static void removeListener(InstanceIdentifier path) { + ListenerAdapter listener = listenersByInstanceIdentifier.get(path); + deleteListener(listener); + } + + /** + * 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. + */ + public static String createStreamNameFromUri(String uri) { + if (uri == null) { + return null; + } + String result = uri; + if (result.startsWith("/")) { + result = result.substring(1); + } + if (result.endsWith("/")) { + result = result.substring(0, result.length()); + } + return result; + } + + /** + * Removes all listeners. + */ + public static void removeAllListeners() { + for (ListenerAdapter listener : listenersByInstanceIdentifier.values()) { + try { + listener.close(); + } catch (Exception e) { + } + } + try { + lock.lock(); + listenersByStreamName = new ConcurrentHashMap<>(); + listenersByInstanceIdentifier = new ConcurrentHashMap<>(); + } finally { + lock.unlock(); + } + } + + /** + * Checks if listener has at least one subscriber. In case it doesn't have any, delete + * listener. + * + * @param listener + * ListenerAdapter + */ + public static void removeListenerIfNoSubscriberExists( + ListenerAdapter listener) { + if (!listener.hasSubscribers()) { + deleteListener(listener); + } + } + + /** + * Delete {@link ListenerAdapter} listener specified in parameter. + * + * @param listener + * ListenerAdapter + */ + private static void deleteListener(ListenerAdapter listener) { + if (listener != null) { + try { + listener.close(); + } catch (Exception e) { + } + try { + lock.lock(); + listenersByInstanceIdentifier.remove(listener.getPath()); + listenersByStreamName.remove(listener.getStreamName()); + } finally { + lock.unlock(); + } + } + } } diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServer.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServer.java index 1640035420..fcfa8858ee 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServer.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServer.java @@ -16,45 +16,45 @@ import org.slf4j.LoggerFactory; */ public class WebSocketServer implements Runnable { - private static final Logger logger = LoggerFactory - .getLogger(WebSocketServer.class); - - public static final int PORT = 8181; - private EventLoopGroup bossGroup; - private EventLoopGroup workerGroup; - - @Override - public void run() { - bossGroup = new NioEventLoopGroup(); - workerGroup = new NioEventLoopGroup(); - try { - ServerBootstrap b = new ServerBootstrap(); - b.group(bossGroup, workerGroup) - .channel(NioServerSocketChannel.class) - .childHandler(new WebSocketServerInitializer()); - - Channel ch = b.bind(PORT).sync().channel(); - logger.info("Web socket server started at port {}.", PORT); - - ch.closeFuture().sync(); - } catch (InterruptedException e) { - // NOOP - } finally { - stop(); - } - } - - /** - * Stops the web socket server and removes all listeners. - */ - private void stop() { - Notificator.removeAllListeners(); - if (bossGroup != null) { - bossGroup.shutdownGracefully(); - } - if (workerGroup != null) { - workerGroup.shutdownGracefully(); - } - } + private static final Logger logger = LoggerFactory + .getLogger(WebSocketServer.class); + + public static final int PORT = 8181; + private EventLoopGroup bossGroup; + private EventLoopGroup workerGroup; + + @Override + public void run() { + bossGroup = new NioEventLoopGroup(); + workerGroup = new NioEventLoopGroup(); + try { + ServerBootstrap b = new ServerBootstrap(); + b.group(bossGroup, workerGroup) + .channel(NioServerSocketChannel.class) + .childHandler(new WebSocketServerInitializer()); + + Channel ch = b.bind(PORT).sync().channel(); + logger.info("Web socket server started at port {}.", PORT); + + ch.closeFuture().sync(); + } catch (InterruptedException e) { + // NOOP + } finally { + stop(); + } + } + + /** + * Stops the web socket server and removes all listeners. + */ + private void stop() { + Notificator.removeAllListeners(); + if (bossGroup != null) { + bossGroup.shutdownGracefully(); + } + if (workerGroup != null) { + workerGroup.shutdownGracefully(); + } + } } diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServerHandler.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServerHandler.java index bf899a0b25..b5d6a6ea9b 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServerHandler.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServerHandler.java @@ -40,147 +40,147 @@ import org.slf4j.LoggerFactory; */ public class WebSocketServerHandler extends SimpleChannelInboundHandler { - private static final Logger logger = LoggerFactory - .getLogger(WebSocketServerHandler.class); - - private WebSocketServerHandshaker handshaker; - - @Override - protected void channelRead0(ChannelHandlerContext ctx, Object msg) - throws Exception { - if (msg instanceof FullHttpRequest) { - handleHttpRequest(ctx, (FullHttpRequest) msg); - } else if (msg instanceof WebSocketFrame) { - handleWebSocketFrame(ctx, (WebSocketFrame) msg); - } - } - - /** - * Checks if HTTP request method is GET and if is possible to decode HTTP - * result of request. - * - * @param ctx - * ChannelHandlerContext - * @param req - * FullHttpRequest - */ - private void handleHttpRequest(ChannelHandlerContext ctx, - FullHttpRequest req) throws Exception { - // Handle a bad request. - if (!req.getDecoderResult().isSuccess()) { - sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, - BAD_REQUEST)); - return; - } - - // Allow only GET methods. - if (req.getMethod() != GET) { - sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, - FORBIDDEN)); - return; - } - - String streamName = Notificator.createStreamNameFromUri(req.getUri()); - ListenerAdapter listener = Notificator.getListenerFor(streamName); - if (listener != null) { - listener.addSubscriber(ctx.channel()); - logger.debug("Subscriber successfully registered."); - } else { - logger.error("Listener for stream with name '{}' was not found.", - streamName); - sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, - INTERNAL_SERVER_ERROR)); - } - - // Handshake - WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory( - getWebSocketLocation(req), null, false); - handshaker = wsFactory.newHandshaker(req); - if (handshaker == null) { - WebSocketServerHandshakerFactory - .sendUnsupportedWebSocketVersionResponse(ctx.channel()); - } else { - handshaker.handshake(ctx.channel(), req); - } - - } - - /** - * Checks response status, send response and close connection if necessary - * - * @param ctx - * ChannelHandlerContext - * @param req - * HttpRequest - * @param res - * FullHttpResponse - */ - private static void sendHttpResponse(ChannelHandlerContext ctx, - HttpRequest req, FullHttpResponse res) { - // Generate an error page if response getStatus code is not OK (200). - if (res.getStatus().code() != 200) { - ByteBuf buf = Unpooled.copiedBuffer(res.getStatus().toString(), - CharsetUtil.UTF_8); - res.content().writeBytes(buf); - buf.release(); - setContentLength(res, res.content().readableBytes()); - } - - // Send the response and close the connection if necessary. - ChannelFuture f = ctx.channel().writeAndFlush(res); - if (!isKeepAlive(req) || res.getStatus().code() != 200) { - f.addListener(ChannelFutureListener.CLOSE); - } - } - - /** - * Handles web socket frame. - * - * @param ctx - * {@link ChannelHandlerContext} - * @param frame - * {@link WebSocketFrame} - */ - private void handleWebSocketFrame(ChannelHandlerContext ctx, - WebSocketFrame frame) throws IOException { - if (frame instanceof CloseWebSocketFrame) { - handshaker.close(ctx.channel(), - (CloseWebSocketFrame) frame.retain()); - String streamName = Notificator - .createStreamNameFromUri(((CloseWebSocketFrame) frame) - .reasonText()); - ListenerAdapter listener = Notificator.getListenerFor(streamName); - if (listener != null) { - listener.removeSubscriber(ctx.channel()); - logger.debug("Subscriber successfully registered."); - } - Notificator.removeListenerIfNoSubscriberExists(listener); - return; - } else if (frame instanceof PingWebSocketFrame) { - ctx.channel().write( - new PongWebSocketFrame(frame.content().retain())); - return; - } - } - - @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) - throws Exception { - if (cause instanceof java.nio.channels.ClosedChannelException == false) { - // cause.printStackTrace(); - } - ctx.close(); - } - - /** - * 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. - */ - private static String getWebSocketLocation(HttpRequest req) { - return "http://" + req.headers().get(HOST) + req.getUri(); - } + private static final Logger logger = LoggerFactory + .getLogger(WebSocketServerHandler.class); + + private WebSocketServerHandshaker handshaker; + + @Override + protected void channelRead0(ChannelHandlerContext ctx, Object msg) + throws Exception { + if (msg instanceof FullHttpRequest) { + handleHttpRequest(ctx, (FullHttpRequest) msg); + } else if (msg instanceof WebSocketFrame) { + handleWebSocketFrame(ctx, (WebSocketFrame) msg); + } + } + + /** + * Checks if HTTP request method is GET and if is possible to decode HTTP + * result of request. + * + * @param ctx + * ChannelHandlerContext + * @param req + * FullHttpRequest + */ + private void handleHttpRequest(ChannelHandlerContext ctx, + FullHttpRequest req) throws Exception { + // Handle a bad request. + if (!req.getDecoderResult().isSuccess()) { + sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, + BAD_REQUEST)); + return; + } + + // Allow only GET methods. + if (req.getMethod() != GET) { + sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, + FORBIDDEN)); + return; + } + + String streamName = Notificator.createStreamNameFromUri(req.getUri()); + ListenerAdapter listener = Notificator.getListenerFor(streamName); + if (listener != null) { + listener.addSubscriber(ctx.channel()); + logger.debug("Subscriber successfully registered."); + } else { + logger.error("Listener for stream with name '{}' was not found.", + streamName); + sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, + INTERNAL_SERVER_ERROR)); + } + + // Handshake + WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory( + getWebSocketLocation(req), null, false); + handshaker = wsFactory.newHandshaker(req); + if (handshaker == null) { + WebSocketServerHandshakerFactory + .sendUnsupportedWebSocketVersionResponse(ctx.channel()); + } else { + handshaker.handshake(ctx.channel(), req); + } + + } + + /** + * Checks response status, send response and close connection if necessary + * + * @param ctx + * ChannelHandlerContext + * @param req + * HttpRequest + * @param res + * FullHttpResponse + */ + private static void sendHttpResponse(ChannelHandlerContext ctx, + HttpRequest req, FullHttpResponse res) { + // Generate an error page if response getStatus code is not OK (200). + if (res.getStatus().code() != 200) { + ByteBuf buf = Unpooled.copiedBuffer(res.getStatus().toString(), + CharsetUtil.UTF_8); + res.content().writeBytes(buf); + buf.release(); + setContentLength(res, res.content().readableBytes()); + } + + // Send the response and close the connection if necessary. + ChannelFuture f = ctx.channel().writeAndFlush(res); + if (!isKeepAlive(req) || res.getStatus().code() != 200) { + f.addListener(ChannelFutureListener.CLOSE); + } + } + + /** + * Handles web socket frame. + * + * @param ctx + * {@link ChannelHandlerContext} + * @param frame + * {@link WebSocketFrame} + */ + private void handleWebSocketFrame(ChannelHandlerContext ctx, + WebSocketFrame frame) throws IOException { + if (frame instanceof CloseWebSocketFrame) { + handshaker.close(ctx.channel(), + (CloseWebSocketFrame) frame.retain()); + String streamName = Notificator + .createStreamNameFromUri(((CloseWebSocketFrame) frame) + .reasonText()); + ListenerAdapter listener = Notificator.getListenerFor(streamName); + if (listener != null) { + listener.removeSubscriber(ctx.channel()); + logger.debug("Subscriber successfully registered."); + } + Notificator.removeListenerIfNoSubscriberExists(listener); + return; + } else if (frame instanceof PingWebSocketFrame) { + ctx.channel().write( + new PongWebSocketFrame(frame.content().retain())); + return; + } + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) + throws Exception { + if (cause instanceof java.nio.channels.ClosedChannelException == false) { + // cause.printStackTrace(); + } + ctx.close(); + } + + /** + * 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. + */ + private static String getWebSocketLocation(HttpRequest req) { + return "http://" + req.headers().get(HOST) + req.getUri(); + } } diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServerInitializer.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServerInitializer.java index 65ae5d6fab..983cd9bda9 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServerInitializer.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/websockets/WebSocketServerInitializer.java @@ -12,14 +12,14 @@ import io.netty.handler.codec.http.HttpServerCodec; * {@link ChannelPipeline} of a {@link Channel}. */ public class WebSocketServerInitializer extends - ChannelInitializer { + ChannelInitializer { - @Override - protected void initChannel(SocketChannel ch) throws Exception { - ChannelPipeline pipeline = ch.pipeline(); - pipeline.addLast("codec-http", new HttpServerCodec()); - pipeline.addLast("aggregator", new HttpObjectAggregator(65536)); - pipeline.addLast("handler", new WebSocketServerHandler()); - } + @Override + protected void initChannel(SocketChannel ch) throws Exception { + ChannelPipeline pipeline = ch.pipeline(); + pipeline.addLast("codec-http", new HttpServerCodec()); + pipeline.addLast("aggregator", new HttpObjectAggregator(65536)); + pipeline.addLast("handler", new WebSocketServerHandler()); + } } diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/resources/WEB-INF/web.xml b/opendaylight/md-sal/sal-rest-connector/src/main/resources/WEB-INF/web.xml index 840887ecec..4b62bf7c2f 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/resources/WEB-INF/web.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/main/resources/WEB-INF/web.xml @@ -31,7 +31,7 @@ cors.allowed.headers - Content-Type,X-Requested-With,accept,authorization, + Content-Type,X-Requested-With,accept,authorization, origin,Origin,Access-Control-Request-Method,Access-Control-Request-Headers diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnJsonChoiceCaseTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnJsonChoiceCaseTest.java index 8abf366bf7..21590ecb33 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnJsonChoiceCaseTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnJsonChoiceCaseTest.java @@ -32,7 +32,7 @@ public class CnSnJsonChoiceCaseTest extends YangAndXmlAndDataSchemaLoader { * 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() { @@ -44,7 +44,7 @@ public class CnSnJsonChoiceCaseTest extends YangAndXmlAndDataSchemaLoader { * 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() { @@ -95,7 +95,7 @@ public class CnSnJsonChoiceCaseTest extends YangAndXmlAndDataSchemaLoader { } /** - * + * */ @Test public void nodeSchemasInMultipleChoicesTest() { diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonLeafrefType.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonLeafrefType.java index 12555bc9a2..21a46a6cc3 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonLeafrefType.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonLeafrefType.java @@ -25,9 +25,9 @@ import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchem import org.opendaylight.yangtools.yang.data.api.CompositeNode; /** - * + * * All tests are commented now because leafref isn't supported now - * + * */ public class CnSnToJsonLeafrefType extends YangAndXmlAndDataSchemaLoader { diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/xml/test/CnSnInstanceIdentifierToXmlTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/xml/test/CnSnInstanceIdentifierToXmlTest.java index 92de14bba4..086e648097 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/xml/test/CnSnInstanceIdentifierToXmlTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/xml/test/CnSnInstanceIdentifierToXmlTest.java @@ -25,14 +25,14 @@ import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchem 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 - * + * */ public class CnSnInstanceIdentifierToXmlTest extends YangAndXmlAndDataSchemaLoader { - + @BeforeClass public static void initialization() throws URISyntaxException { dataLoad("/instanceidentifier/yang", 4, "instance-identifier-module", "cont"); diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/xml/test/CnSnToXmlWithDataFromSeveralModulesTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/xml/test/CnSnToXmlWithDataFromSeveralModulesTest.java index b7a58886dc..f8d04c157f 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/xml/test/CnSnToXmlWithDataFromSeveralModulesTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/xml/test/CnSnToXmlWithDataFromSeveralModulesTest.java @@ -42,10 +42,10 @@ public class CnSnToXmlWithDataFromSeveralModulesTest extends YangAndXmlAndDataSc // String output = // String.format("" + -// "\n" + -// "\n\t" + -// "\n\t\tlf1 m1 value" + -// "\n\t" + +// "\n" + +// "\n\t" + +// "\n\t\tlf1 m1 value" + +// "\n\t" + // "\n" + // "\n" + // "\n\t" + @@ -60,8 +60,8 @@ public class CnSnToXmlWithDataFromSeveralModulesTest extends YangAndXmlAndDataSc regex.append(".*"); - - + + regex.append(".*"); regex.append(".*xmlns=\"module:one\""); regex.append(".*>"); @@ -97,7 +97,7 @@ public class CnSnToXmlWithDataFromSeveralModulesTest extends YangAndXmlAndDataSc 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); diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyFuture.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyFuture.java index 67b5b8c93a..f6664ed34d 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyFuture.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyFuture.java @@ -13,26 +13,26 @@ import org.opendaylight.controller.md.sal.common.api.TransactionStatus; import org.opendaylight.yangtools.yang.common.RpcResult; public class DummyFuture implements Future> { - + private final boolean cancel; private final boolean isCancelled; private final boolean isDone; private final RpcResult result; - + 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; } - + public static Builder builder() { return new DummyFuture.Builder(); } @@ -62,9 +62,9 @@ public class DummyFuture implements Future> { ExecutionException, TimeoutException { return result; } - + public static class Builder { - + private boolean cancel; private boolean isCancelled; private boolean isDone; @@ -74,22 +74,22 @@ public class DummyFuture implements Future> { this.cancel = cancel; return this; } - + public Builder isCancelled(boolean isCancelled) { this.isCancelled = isCancelled; return this; } - + public Builder isDone(boolean isDone) { this.isDone = isDone; return this; } - + public Builder rpcResult(RpcResult result) { this.result = result; return this; } - + public Future> build() { return new DummyFuture(this); } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestDeleteOperationTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestDeleteOperationTest.java index 408b14acfe..56a58eeadd 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestDeleteOperationTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestDeleteOperationTest.java @@ -76,13 +76,13 @@ public class RestDeleteOperationTest extends JerseyTest { 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()); } - + private Future> createFuture(TransactionStatus statusName) { RpcResult rpcResult = new DummyRpcResult.Builder().result(statusName).build(); return DummyFuture.builder().rpcResult(rpcResult).build(); diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java index eb623096de..853c19f935 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java @@ -147,7 +147,7 @@ public final class TestUtils { } /** - * + * * Fill missing data (namespaces) and build correct data type in * {@code compositeNode} according to {@code dataSchemaNode}. The method * {@link RestconfImpl#createConfigurationData createConfigurationData} is @@ -165,7 +165,7 @@ public final class TestUtils { * 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 modules) { assertNotNull("Modules can't be null.", modules); diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/structures/CompareLf.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/structures/CompareLf.java index e935a268a2..34036edc05 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/structures/CompareLf.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/structures/CompareLf.java @@ -19,7 +19,7 @@ public class CompareLf { 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)); diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlAugmentedElementToCnSnTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlAugmentedElementToCnSnTest.java index ffddb00485..62159ccad6 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlAugmentedElementToCnSnTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlAugmentedElementToCnSnTest.java @@ -24,7 +24,7 @@ public class XmlAugmentedElementToCnSnTest { 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); diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/augmentation/xml/data.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/augmentation/xml/data.xml index 08cdb34290..5b1c8324ac 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/augmentation/xml/data.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/augmentation/xml/data.xml @@ -1,16 +1,16 @@ - lf1 - lf2 - - lf11 - - - lf1_1 - - - lf1_2 - - lflst1_1 - lflst1_2 - lflst1_3 + lf1 + lf2 + + lf11 + + + lf1_1 + + + lf1_2 + + lflst1_1 + lflst1_2 + lflst1_3 \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_case_defined_without_case.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_case_defined_without_case.xml index b669842c22..c6e42dfb77 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_case_defined_without_case.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_case_defined_without_case.xml @@ -1,4 +1,4 @@ - 45 - lf2b val + 45 + lf2b val \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_container.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_container.xml index 9c751949d0..0d5fa4a514 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_container.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_container.xml @@ -1,5 +1,5 @@ - - lf11c val - + + lf11c val + \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_leaflist.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_leaflist.xml index 6cebb6424a..0278389d73 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_leaflist.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_leaflist.xml @@ -1,4 +1,4 @@ - lflst1d_1 val - lflst1d_2 val + lflst1d_1 val + lflst1d_2 val \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_list.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_list.xml index 710da55de6..488873d5ef 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_list.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_list.xml @@ -1,8 +1,8 @@ - - lf11b_1 val - - - lf11b_2 val - + + lf11b_1 val + + + lf11b_2 val + \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_more_choices_same_level.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_more_choices_same_level.xml index 97e219736f..f21d83f8f0 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_more_choices_same_level.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_more_choices_same_level.xml @@ -1,6 +1,6 @@ - - lf11c val - - lf2b value + + lf11c val + + lf2b value \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_more_choices_same_level_various_paths_err.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_more_choices_same_level_various_paths_err.xml index 331c8aec08..9e28730355 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_more_choices_same_level_various_paths_err.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_more_choices_same_level_various_paths_err.xml @@ -1,7 +1,7 @@ - - lf11c val - - lf2b value - lf2b value + + lf11c val + + lf2b value + lf2b value \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_no_first_case.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_no_first_case.xml index 43e9974a2c..dbd2684526 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_no_first_case.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_no_first_case.xml @@ -1,5 +1,5 @@ - lf1 val - 121 - lf1ab val + lf1 val + 121 + lf1ab val \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_random_level.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_random_level.xml index b1b78e4744..e3e66b78e6 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_random_level.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_random_level.xml @@ -1,6 +1,6 @@ - lf1aa val - lf1 val - 121 - lf1aaa val + lf1aa val + lf1 val + 121 + lf1aaa val \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_three_choices_same_level.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_three_choices_same_level.xml index ecc0caae56..49b4143a2e 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_three_choices_same_level.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_three_choices_same_level.xml @@ -1,13 +1,13 @@ - lf1aaa value - lf2b value - - 33 - - - 33 - - - 37 - + lf1aaa value + lf2b value + + 33 + + + 33 + + + 37 + \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_various_path_err.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_various_path_err.xml index c43dab60c0..e8634682cd 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_various_path_err.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/choice/xml/data_various_path_err.xml @@ -1,6 +1,6 @@ - lf1aa val - lf1 val - 121 - lf1ab value + lf1aa val + lf1 val + 121 + lf1ab value \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_absolut_ref_to_existing_leaf.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_absolut_ref_to_existing_leaf.xml index bbebabec4e..6bb975947b 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_absolut_ref_to_existing_leaf.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_absolut_ref_to_existing_leaf.xml @@ -1,6 +1,6 @@ - - true - - true + + true + + true \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_from_leafref_to_leafref.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_from_leafref_to_leafref.xml index 1bb9013a7f..c6c20cb638 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_from_leafref_to_leafref.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_from_leafref_to_leafref.xml @@ -1,3 +1,3 @@ - 200 + 200 \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_ref_to_non_existing_leaf.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_ref_to_non_existing_leaf.xml index dfea9c811d..401247a367 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_ref_to_non_existing_leaf.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_ref_to_non_existing_leaf.xml @@ -1,3 +1,3 @@ - 137 + 137 \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_ref_to_not_leaf.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_ref_to_not_leaf.xml index 7b05b0c89f..10632a44af 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_ref_to_not_leaf.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_ref_to_not_leaf.xml @@ -1,3 +1,3 @@ - 44.33 + 44.33 \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_relativ_ref_from_leaflist_to_existing_leaf.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_relativ_ref_from_leaflist_to_existing_leaf.xml index 0d8cf660ac..49d2dc39aa 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_relativ_ref_from_leaflist_to_existing_leaf.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_relativ_ref_from_leaflist_to_existing_leaf.xml @@ -1,5 +1,5 @@ - 345 - 346 - 347 + 345 + 346 + 347 \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_relativ_ref_to_existing_leaf.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_relativ_ref_to_existing_leaf.xml index 4a73a8b0c4..06200a69b5 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_relativ_ref_to_existing_leaf.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_relativ_ref_to_existing_leaf.xml @@ -1,4 +1,4 @@ - 121 - 121 + 121 + 121 \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-data-types/xml/data.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-data-types/xml/data.xml index f73ce1b65c..28d355dbab 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-data-types/xml/data.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-data-types/xml/data.xml @@ -1,42 +1,42 @@ - -128 - 127 - -32768 - 32767 - -2147483648 - 2147483647 - -9223372036854775808 - 9223372036854775807 - 255 - 65535 - 4294967295 - lfstr - - true - false - bla - 43.32 - -0.43 - 43 - 43E3 - 33.12345 - enum3 - bit3 bit2 - ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz - - 324 - 33.3 - 55 - true - true - 10 - - - - bt1 - 33 - false - b1 - zero - x:iden + -128 + 127 + -32768 + 32767 + -2147483648 + 2147483647 + -9223372036854775808 + 9223372036854775807 + 255 + 65535 + 4294967295 + lfstr + + true + false + bla + 43.32 + -0.43 + 43 + 43E3 + 33.12345 + enum3 + bit3 bit2 + ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz + + 324 + 33.3 + 55 + true + true + 10 + + + + bt1 + 33 + false + b1 + zero + x:iden \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-yang-types/xml/data.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-yang-types/xml/data.xml index 17dc2657b0..61858d28b6 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-yang-types/xml/data.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-yang-types/xml/data.xml @@ -1,63 +1,63 @@ - lf - 56 - 55 - 57 - lflst12 str3 - - - lf1121 str22 - - 141 - lf112 str2 - - 55 - - - 4097 - 2049 - 1025 - - lf1111A str22 - 8 - - lf1111 str2 - - 5 - lf1111A str21 - - - - 56 - - - lf1121 str21 - - - lflst12 str1 - - 140 - lf112 str - - lf1111 str - 2048 - 1024 - 4096 - - lf1111A str11 - 4 - - - lf1111A str12 - 7 - - - - 65 - - - lf1121 str11 - - - lflst12 str2 + lf + 56 + 55 + 57 + lflst12 str3 + + + lf1121 str22 + + 141 + lf112 str2 + + 55 + + + 4097 + 2049 + 1025 + + lf1111A str22 + 8 + + lf1111 str2 + + 5 + lf1111A str21 + + + + 56 + + + lf1121 str21 + + + lflst12 str1 + + 140 + lf112 str + + lf1111 str + 2048 + 1024 + 4096 + + lf1111A str11 + 4 + + + lf1111A str12 + 7 + + + + 65 + + + lf1121 str11 + + + lflst12 str2 diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-yang-types/xml/empty_data.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-yang-types/xml/empty_data.xml index 68470eab26..9cd503e09b 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-yang-types/xml/empty_data.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-yang-types/xml/empty_data.xml @@ -1,40 +1,40 @@ - - 1 - - - - - - - 35 - - - - - 2 - - - - 1024 - 4096 - - 4 - - - lf1111A str12 - - - - - - 3 - - - - - - - - + + 1 + + + + + + + 35 + + + + + 2 + + + + 1024 + 4096 + + 4 + + + lf1111A str12 + + + + + + 3 + + + + + + + + diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data-rpc-input.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data-rpc-input.xml index 5954c091e3..fb9726d5b1 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data-rpc-input.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-data2/data-rpc-input.xml @@ -1,8 +1,8 @@ - - - lf1 data - lf2 data - - + + + lf1 data + lf2 data + + \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/xml/xmldata.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/xml/xmldata.xml index 768cb663eb..bd558fb6b9 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/xml/xmldata.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/instanceidentifier/xml/xmldata.xml @@ -1,10 +1,10 @@ - - value1 - value2 - /a:cont/a:cont1/b:lst11[b:keyvalue111="value1"][b:keyvalue112="value2"]/c:lf112 - lf112 value - + + value1 + value2 + /a:cont/a:cont1/b:lst11[b:keyvalue111="value1"][b:keyvalue112="value2"]/c:lf112 + lf112 value + diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces_absolute_path.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces_absolute_path.xml index 7e3aa97987..313f32dce1 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces_absolute_path.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/parts/ietf-interfaces_interfaces_absolute_path.xml @@ -1,8 +1,8 @@ - - eth0 - ethernetCsmacd - false - some interface - + + eth0 + ethernetCsmacd + false + some interface + \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-container.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-container.xml index ce97dd1715..841d351049 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-container.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-container.xml @@ -1,14 +1,14 @@ - str0 - - - 121 - 131 - str1 - - str2 - - - 100 - + str0 + + + 121 + 131 + str1 + + str2 + + + 100 + diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-list.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-list.xml index cab23c656e..9c4256a50c 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-list.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/data-list.xml @@ -1,21 +1,21 @@ - - str0 - 121 - 131 - str1 - - str2 - - - 100 - - - - 221 - - 100 - - - lf1 + + str0 + 121 + 131 + str1 + + str2 + + + 100 + + + + 221 + + 100 + + + lf1 diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/empty-data.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/empty-data.xml index 162a556887..7d62b9e24d 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/empty-data.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/empty-data.xml @@ -1,8 +1,8 @@ - - - - - - + + + + + + diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-default-nmspc-in-element.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-default-nmspc-in-element.xml index aae2af36d1..ebf7ac61ea 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-default-nmspc-in-element.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-default-nmspc-in-element.xml @@ -1,5 +1,5 @@ - - iden + + iden \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-default-nmspc-in-parrent-element.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-default-nmspc-in-parrent-element.xml index 621d2bc84c..3fe1e4bf48 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-default-nmspc-in-parrent-element.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-default-nmspc-in-parrent-element.xml @@ -1,5 +1,5 @@ - - iden + + iden \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-nmspc-in-parrent-element.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-nmspc-in-parrent-element.xml index 497c35f2fc..30a54185ff 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-nmspc-in-parrent-element.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-nmspc-in-parrent-element.xml @@ -1,5 +1,5 @@ - - z:iden + + z:iden \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-no-nmspc-value-with-prefix.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-no-nmspc-value-with-prefix.xml index 925442fee1..7d31fa7a95 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-no-nmspc-value-with-prefix.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-no-nmspc-value-with-prefix.xml @@ -1,5 +1,5 @@ - - x:iden + + x:iden \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-no-nmspc-value-without-prefix.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-no-nmspc-value-without-prefix.xml index 5a86eb02a8..c65df1ab1e 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-no-nmspc-value-without-prefix.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/identityref/xml/data-no-nmspc-value-without-prefix.xml @@ -1,5 +1,5 @@ - iden + iden \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/ModelGenerator.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/ModelGenerator.java index 597051ed30..b2c258825e 100644 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/ModelGenerator.java +++ b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/ModelGenerator.java @@ -95,9 +95,9 @@ public class ModelGenerator { for(DataSchemaNode childNode : childNodes){ JSONObject moduleJSON=null; String filename = childNode.getQName().getLocalName(); - /* - * For every container in the module - */ + /* + * For every container in the module + */ if(childNode instanceof ContainerSchemaNode) { moduleJSON = processContainer((ContainerSchemaNode)childNode, moduleName, true, models); } @@ -307,11 +307,11 @@ public class ModelGenerator { childSchema.put(TYPE_KEY, OBJECT_TYPE); childSchema.put(PROPERTIES_KEY, childSchemaProperties); - /* - * Due to a limitation of the RAML--->JAX-RS tool, sub-properties - * must be in a separate JSON schema file. Hence, we have to write - * some properties to a new file, while continuing to process the rest. - */ + /* + * Due to a limitation of the RAML--->JAX-RS tool, sub-properties + * must be in a separate JSON schema file. Hence, we have to write + * some properties to a new file, while continuing to process the rest. + */ //writeToFile(fileName, childSchema.toString(2), moduleName); childSchema.put("id", fileName); models.put(fileName, childSchema); diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/WEB-INF/web.xml b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/WEB-INF/web.xml index 356a395b97..2a778180d4 100644 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/WEB-INF/web.xml +++ b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/WEB-INF/web.xml @@ -31,7 +31,7 @@ cors.allowed.headers - Content-Type,X-Requested-With,accept,authorization, + Content-Type,X-Requested-With,accept,authorization, origin,Origin,Access-Control-Request-Method,Access-Control-Request-Headers diff --git a/opendaylight/md-sal/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/DocGeneratorTest.java b/opendaylight/md-sal/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/DocGeneratorTest.java index 127529a3c6..264bc67004 100644 --- a/opendaylight/md-sal/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/DocGeneratorTest.java +++ b/opendaylight/md-sal/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/DocGeneratorTest.java @@ -69,4 +69,4 @@ public class DocGeneratorTest { } } -} +} diff --git a/opendaylight/md-sal/samples/toaster-it/src/test/resources/controller.xml b/opendaylight/md-sal/samples/toaster-it/src/test/resources/controller.xml index c5a2a0d340..61c24c6b64 100644 --- a/opendaylight/md-sal/samples/toaster-it/src/test/resources/controller.xml +++ b/opendaylight/md-sal/samples/toaster-it/src/test/resources/controller.xml @@ -55,7 +55,7 @@ binding:binding-data-broker ref_binding-data-broker - + binding:binding-notification-service diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeStatisticsHandler.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeStatisticsHandler.java index 7d9cc7ecbd..db216237d0 100644 --- a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeStatisticsHandler.java +++ b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeStatisticsHandler.java @@ -103,7 +103,7 @@ public final class NodeStatisticsHandler implements AutoCloseable, FlowCapableCo 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); @@ -274,20 +274,20 @@ public final class NodeStatisticsHandler implements AutoCloseable, FlowCapableCo this.srScheduler.addRequestToSchedulerQueue(flowTableStats); this.srScheduler.addRequestToSchedulerQueue(flowStats); - + this.srScheduler.addRequestToSchedulerQueue(nodeConnectorStats); - + this.srScheduler.addRequestToSchedulerQueue(groupStats); - + this.srScheduler.addRequestToSchedulerQueue(groupDescStats); - + this.srScheduler.addRequestToSchedulerQueue(meterStats); - + this.srScheduler.addRequestToSchedulerQueue(meterConfigStats); - + this.srScheduler.addRequestToSchedulerQueue(queueStats); } - + public synchronized void start(final Timer timer) { flowStats.start(dps); groupDescStats.start(dps); @@ -313,7 +313,7 @@ public final class NodeStatisticsHandler implements AutoCloseable, FlowCapableCo 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()); diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsProvider.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsProvider.java index d8bea7c63a..b96d2be47e 100644 --- a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsProvider.java +++ b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsProvider.java @@ -66,7 +66,7 @@ public class StatisticsProvider implements AutoCloseable { private OpendaylightFlowTableStatisticsService flowTableStatsService; private OpendaylightQueueStatisticsService queueStatsService; - + private final StatisticsRequestScheduler srScheduler; public StatisticsProvider(final DataProviderService dataService) { @@ -90,7 +90,7 @@ public class StatisticsProvider implements AutoCloseable { flowTableStatsService = rpcRegistry.getRpcService(OpendaylightFlowTableStatisticsService.class); queueStatsService = rpcRegistry.getRpcService(OpendaylightQueueStatisticsService.class); this.srScheduler.start(); - + // Start receiving notifications this.listenerRegistration = nps.registerNotificationListener(this.updateCommiter); diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsRequestScheduler.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsRequestScheduler.java index bea43ef68a..0ae33b8c71 100644 --- a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsRequestScheduler.java +++ b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsRequestScheduler.java @@ -24,7 +24,7 @@ import org.slf4j.LoggerFactory; /** * 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 * @@ -36,15 +36,15 @@ public class StatisticsRequestScheduler implements DataTransactionListener { private final Timer timer = new Timer("request-monitor", true); // We need ordered retrieval, and O(1) contains operation - private final Map requestQueue = + private final Map requestQueue = Collections.synchronizedMap(new LinkedHashMap()); - + private Long PendingTransactions; - + private long lastRequestTime = System.nanoTime(); - + private static final long REQUEST_MONITOR_INTERVAL = 1000; - + private final TimerTask task = new TimerTask() { @Override public void run() { @@ -58,11 +58,11 @@ public class StatisticsRequestScheduler implements DataTransactionListener { public StatisticsRequestScheduler(){ PendingTransactions = (long) 0; } - + public void addRequestToSchedulerQueue(AbstractStatsTracker statsRequest){ requestQueue.put(statsRequest, null); } - + public void removeRequestsFromSchedulerQueue(NodeRef node){ AbstractStatsTracker stats = null; synchronized(requestQueue){ @@ -97,7 +97,7 @@ public class StatisticsRequestScheduler implements DataTransactionListener { } @Override public void onStatusUpdated(DataModificationTransaction transaction, TransactionStatus status) { - + AbstractStatsTracker stats = null; synchronized(PendingTransactions){ switch(status){ @@ -119,7 +119,7 @@ public class StatisticsRequestScheduler implements DataTransactionListener { } sendStatsRequest(stats); } - + private void sendStatsRequest(AbstractStatsTracker stats){ if(stats != null){ try{ diff --git a/opendaylight/md-sal/topology-lldp-discovery/src/main/java/org/opendaylight/md/controller/topology/lldp/LLDPDiscoveryListener.java b/opendaylight/md-sal/topology-lldp-discovery/src/main/java/org/opendaylight/md/controller/topology/lldp/LLDPDiscoveryListener.java index ed96e3aa0c..c539ac81d4 100644 --- a/opendaylight/md-sal/topology-lldp-discovery/src/main/java/org/opendaylight/md/controller/topology/lldp/LLDPDiscoveryListener.java +++ b/opendaylight/md-sal/topology-lldp-discovery/src/main/java/org/opendaylight/md/controller/topology/lldp/LLDPDiscoveryListener.java @@ -24,7 +24,7 @@ class LLDPDiscoveryListener implements PacketProcessingListener { LLDPDiscoveryListener(LLDPDiscoveryProvider manager) { this.manager = manager; } - + public void onPacketReceived(PacketReceived lldp) { NodeConnectorRef src = LLDPDiscoveryUtils.lldpToNodeConnectorRef(lldp.getPayload()); if(src != null) { @@ -32,10 +32,10 @@ class LLDPDiscoveryListener implements PacketProcessingListener { ldb.setDestination(lldp.getIngress()); ldb.setSource(new NodeConnectorRef(src)); LinkDiscovered ld = ldb.build(); - + manager.getNotificationService().publish(ld); LLDPLinkAger.getInstance().put(ld); } } - + } diff --git a/opendaylight/md-sal/topology-lldp-discovery/src/main/java/org/opendaylight/md/controller/topology/lldp/LLDPLinkAger.java b/opendaylight/md-sal/topology-lldp-discovery/src/main/java/org/opendaylight/md/controller/topology/lldp/LLDPLinkAger.java index 7d2570551d..face5967c2 100644 --- a/opendaylight/md-sal/topology-lldp-discovery/src/main/java/org/opendaylight/md/controller/topology/lldp/LLDPLinkAger.java +++ b/opendaylight/md-sal/topology-lldp-discovery/src/main/java/org/opendaylight/md/controller/topology/lldp/LLDPLinkAger.java @@ -37,17 +37,17 @@ public class LLDPLinkAger { 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 close() { timer.cancel(); } - + private class LLDPAgingTask extends TimerTask { @Override @@ -64,9 +64,9 @@ public class LLDPLinkAger { } } } - + } - + } } diff --git a/opendaylight/md-sal/topology-lldp-discovery/src/main/java/org/opendaylight/md/controller/topology/lldp/utils/LLDPDiscoveryUtils.java b/opendaylight/md-sal/topology-lldp-discovery/src/main/java/org/opendaylight/md/controller/topology/lldp/utils/LLDPDiscoveryUtils.java index ce42283ebe..82ab443246 100644 --- a/opendaylight/md-sal/topology-lldp-discovery/src/main/java/org/opendaylight/md/controller/topology/lldp/utils/LLDPDiscoveryUtils.java +++ b/opendaylight/md-sal/topology-lldp-discovery/src/main/java/org/opendaylight/md/controller/topology/lldp/utils/LLDPDiscoveryUtils.java @@ -27,10 +27,10 @@ import org.slf4j.LoggerFactory; 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 String macToString(byte[] mac) { StringBuilder b = new StringBuilder(); for (int i = 0; i < mac.length; i++) { @@ -39,7 +39,7 @@ public class LLDPDiscoveryUtils { return b.toString(); } - + public static NodeConnectorRef lldpToNodeConnectorRef(byte[] payload) { Ethernet ethPkt = new Ethernet(); try { @@ -50,7 +50,7 @@ public class LLDPDiscoveryUtils { if (ethPkt.getPayload() instanceof LLDP) { LLDP lldp = (LLDP) ethPkt.getPayload(); - + try { NodeId srcNodeId = null; NodeConnectorId srcNodeConnectorId = null; diff --git a/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyExporter.java b/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyExporter.java index 542e972deb..6dbfd7225b 100644 --- a/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyExporter.java +++ b/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyExporter.java @@ -15,12 +15,8 @@ import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMap import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.toTopologyNode; import static org.opendaylight.md.controller.topology.manager.FlowCapableNodeMapping.toTopologyNodeId; -import java.util.concurrent.Future; - import org.opendaylight.controller.md.sal.binding.util.TypeSafeDataReader; -import org.opendaylight.controller.md.sal.common.api.TransactionStatus; import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; -import org.opendaylight.controller.sal.binding.api.data.DataProviderService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdated; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdated; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.FlowTopologyDiscoveryListener; @@ -36,146 +32,128 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRem import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.OpendaylightInventoryListener; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.JdkFutureAdapters; - -class FlowCapableTopologyExporter implements // - FlowTopologyDiscoveryListener, // - OpendaylightInventoryListener // -{ - protected final static Logger LOG = LoggerFactory.getLogger(FlowCapableTopologyExporter.class); - public static TopologyKey topology = new TopologyKey(new TopologyId("flow:1")); +import com.google.common.base.Preconditions; - // FIXME: Flow capable topology exporter should use transaction chaining API - private DataProviderService dataService; +class FlowCapableTopologyExporter implements FlowTopologyDiscoveryListener, OpendaylightInventoryListener { + private final InstanceIdentifier topology; + private final OperationProcessor processor; - public DataProviderService getDataService() { - return dataService; - } - - public void setDataService(final DataProviderService dataService) { - this.dataService = dataService; - } - - private InstanceIdentifier topologyPath; - - public void start() { - TopologyBuilder tb = new TopologyBuilder(); - tb.setKey(topology); - topologyPath = InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class, topology).build(); - Topology top = tb.build(); - DataModificationTransaction tx = dataService.beginTransaction(); - tx.putOperationalData(topologyPath, top); - listenOnTransactionState(tx.getIdentifier(),tx.commit()); + FlowCapableTopologyExporter(final OperationProcessor processor, final InstanceIdentifier topology) { + this.processor = Preconditions.checkNotNull(processor); + this.topology = Preconditions.checkNotNull(topology); } @Override - public synchronized void onNodeRemoved(final NodeRemoved notification) { - NodeId nodeId = toTopologyNodeId(getNodeKey(notification.getNodeRef()).getId()); - InstanceIdentifier nodeInstance = toNodeIdentifier(notification.getNodeRef()); - - DataModificationTransaction tx = dataService.beginTransaction(); - tx.removeOperationalData(nodeInstance); - removeAffectedLinks(tx, nodeId); - listenOnTransactionState(tx.getIdentifier(),tx.commit()); + public void onNodeRemoved(final NodeRemoved notification) { + processor.enqueueOperation(new TopologyOperation() { + @Override + public void applyOperation(final DataModificationTransaction transaction) { + NodeId nodeId = toTopologyNodeId(getNodeKey(notification.getNodeRef()).getId()); + InstanceIdentifier nodeInstance = toNodeIdentifier(notification.getNodeRef()); + transaction.removeOperationalData(nodeInstance); + removeAffectedLinks(transaction, nodeId); + } + }); } @Override - public synchronized void onNodeUpdated(final NodeUpdated notification) { + public void onNodeUpdated(final NodeUpdated notification) { FlowCapableNodeUpdated fcnu = notification.getAugmentation(FlowCapableNodeUpdated.class); if (fcnu != null) { - Node node = toTopologyNode(toTopologyNodeId(notification.getId()), notification.getNodeRef()); - InstanceIdentifier path = getNodePath(toTopologyNodeId(notification.getId())); - DataModificationTransaction tx = dataService.beginTransaction(); - tx.putOperationalData(path, node); - listenOnTransactionState(tx.getIdentifier(),tx.commit()); + processor.enqueueOperation(new TopologyOperation() { + @Override + public void applyOperation(final DataModificationTransaction transaction) { + Node node = toTopologyNode(toTopologyNodeId(notification.getId()), notification.getNodeRef()); + InstanceIdentifier path = getNodePath(toTopologyNodeId(notification.getId())); + transaction.putOperationalData(path, node); + } + }); } } @Override - public synchronized void onNodeConnectorRemoved(final NodeConnectorRemoved notification) { - InstanceIdentifier tpInstance = toTerminationPointIdentifier(notification - .getNodeConnectorRef()); - TpId tpId = toTerminationPointId(getNodeConnectorKey(notification.getNodeConnectorRef()).getId()); - DataModificationTransaction tx = dataService.beginTransaction(); - tx.removeOperationalData(tpInstance); - removeAffectedLinks(tx, tpId); - listenOnTransactionState(tx.getIdentifier(),tx.commit()); + public void onNodeConnectorRemoved(final NodeConnectorRemoved notification) { + processor.enqueueOperation(new TopologyOperation() { + @Override + public void applyOperation(final DataModificationTransaction transaction) { + InstanceIdentifier tpInstance = toTerminationPointIdentifier(notification + .getNodeConnectorRef()); + TpId tpId = toTerminationPointId(getNodeConnectorKey(notification.getNodeConnectorRef()).getId()); + transaction.removeOperationalData(tpInstance); + removeAffectedLinks(transaction, tpId); + } + }); } @Override - public synchronized void onNodeConnectorUpdated(final NodeConnectorUpdated notification) { - FlowCapableNodeConnectorUpdated fcncu = notification.getAugmentation(FlowCapableNodeConnectorUpdated.class); + public void onNodeConnectorUpdated(final NodeConnectorUpdated notification) { + final FlowCapableNodeConnectorUpdated fcncu = notification.getAugmentation(FlowCapableNodeConnectorUpdated.class); if (fcncu != null) { - NodeId nodeId = toTopologyNodeId(getNodeKey(notification.getNodeConnectorRef()).getId()); - TerminationPoint point = toTerminationPoint(toTerminationPointId(notification.getId()), - notification.getNodeConnectorRef()); - InstanceIdentifier path = tpPath(nodeId, point.getKey().getTpId()); - - DataModificationTransaction tx = dataService.beginTransaction(); - tx.putOperationalData(path, point); - if ((fcncu.getState() != null && fcncu.getState().isLinkDown()) - || (fcncu.getConfiguration() != null && fcncu.getConfiguration().isPORTDOWN())) { - removeAffectedLinks(tx, point.getTpId()); - } - listenOnTransactionState(tx.getIdentifier(),tx.commit()); + processor.enqueueOperation(new TopologyOperation() { + @Override + public void applyOperation(final DataModificationTransaction transaction) { + NodeId nodeId = toTopologyNodeId(getNodeKey(notification.getNodeConnectorRef()).getId()); + TerminationPoint point = toTerminationPoint(toTerminationPointId(notification.getId()), + notification.getNodeConnectorRef()); + InstanceIdentifier path = tpPath(nodeId, point.getKey().getTpId()); + + transaction.putOperationalData(path, point); + if ((fcncu.getState() != null && fcncu.getState().isLinkDown()) + || (fcncu.getConfiguration() != null && fcncu.getConfiguration().isPORTDOWN())) { + removeAffectedLinks(transaction, point.getTpId()); + } + } + }); } } @Override - public synchronized void onLinkDiscovered(final LinkDiscovered notification) { - Link link = toTopologyLink(notification); - InstanceIdentifier path = linkPath(link); - DataModificationTransaction tx = dataService.beginTransaction(); - tx.putOperationalData(path, link); - listenOnTransactionState(tx.getIdentifier(),tx.commit()); - + public void onLinkDiscovered(final LinkDiscovered notification) { + processor.enqueueOperation(new TopologyOperation() { + @Override + public void applyOperation(final DataModificationTransaction transaction) { + Link link = toTopologyLink(notification); + InstanceIdentifier path = linkPath(link); + transaction.putOperationalData(path, link); + } + }); } @Override - public synchronized void onLinkOverutilized(final LinkOverutilized notification) { + public void onLinkOverutilized(final LinkOverutilized notification) { // NOOP } @Override - public synchronized void onLinkRemoved(final LinkRemoved notification) { - InstanceIdentifier path = linkPath(toTopologyLink(notification)); - DataModificationTransaction tx = dataService.beginTransaction(); - tx.removeOperationalData(path); - listenOnTransactionState(tx.getIdentifier(),tx.commit()); + public void onLinkRemoved(final LinkRemoved notification) { + processor.enqueueOperation(new TopologyOperation() { + @Override + public void applyOperation(final DataModificationTransaction transaction) { + transaction.removeOperationalData(linkPath(toTopologyLink(notification))); + } + }); } @Override - public synchronized void onLinkUtilizationNormal(final LinkUtilizationNormal notification) { + public void onLinkUtilizationNormal(final LinkUtilizationNormal notification) { // NOOP } - private static InstanceIdentifier toNodeIdentifier(final NodeRef ref) { + private InstanceIdentifier toNodeIdentifier(final NodeRef ref) { org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey invNodeKey = getNodeKey(ref); - NodeKey nodeKey = new NodeKey(toTopologyNodeId(invNodeKey.getId())); - return InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class, topology) - .child(Node.class, nodeKey).build(); + return topology.child(Node.class, nodeKey); } private InstanceIdentifier toTerminationPointIdentifier(final NodeConnectorRef ref) { @@ -186,71 +164,39 @@ class FlowCapableTopologyExporter implements // private void removeAffectedLinks(final DataModificationTransaction transaction, final NodeId id) { TypeSafeDataReader reader = TypeSafeDataReader.forReader(transaction); - - Topology topologyData = reader.readOperationalData(topologyPath); - if (topologyData == null) { - return; - } - for (Link link : topologyData.getLink()) { - if (id.equals(link.getSource().getSourceNode()) || id.equals(link.getDestination().getDestNode())) { - InstanceIdentifier path = topologyPath.child(Link.class, link.getKey()); - transaction.removeOperationalData(path); + Topology topologyData = reader.readOperationalData(topology); + if (topologyData != null) { + for (Link link : topologyData.getLink()) { + if (id.equals(link.getSource().getSourceNode()) || id.equals(link.getDestination().getDestNode())) { + transaction.removeOperationalData(linkPath(link)); + } } } } private void removeAffectedLinks(final DataModificationTransaction transaction, final TpId id) { TypeSafeDataReader reader = TypeSafeDataReader.forReader(transaction); - Topology topologyData = reader.readOperationalData(topologyPath); - if (topologyData == null) { - return; - } - for (Link link : topologyData.getLink()) { - if (id.equals(link.getSource().getSourceTp()) || id.equals(link.getDestination().getDestTp())) { - InstanceIdentifier path = topologyPath.child(Link.class, link.getKey()); - transaction.removeOperationalData(path); + Topology topologyData = reader.readOperationalData(topology); + if (topologyData != null) { + for (Link link : topologyData.getLink()) { + if (id.equals(link.getSource().getSourceTp()) || id.equals(link.getDestination().getDestTp())) { + transaction.removeOperationalData(linkPath(link)); + } } } } private InstanceIdentifier getNodePath(final NodeId nodeId) { - NodeKey nodeKey = new NodeKey(nodeId); - return InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class, topology) - .child(Node.class, nodeKey).build(); + return topology.child(Node.class, new NodeKey(nodeId)); } private InstanceIdentifier tpPath(final NodeId nodeId, final TpId tpId) { NodeKey nodeKey = new NodeKey(nodeId); TerminationPointKey tpKey = new TerminationPointKey(tpId); - return InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class, topology) - .child(Node.class, nodeKey).child(TerminationPoint.class, tpKey).build(); + return topology.child(Node.class, nodeKey).child(TerminationPoint.class, tpKey); } private InstanceIdentifier linkPath(final Link link) { - InstanceIdentifier linkInstanceId = InstanceIdentifier.builder(NetworkTopology.class) - .child(Topology.class, topology).child(Link.class, link.getKey()).build(); - return linkInstanceId; - } - - /** - * @param txId transaction identificator - * @param future transaction result - */ - private static void listenOnTransactionState(final Object txId, Future> future) { - Futures.addCallback(JdkFutureAdapters.listenInPoolThread(future),new FutureCallback>() { - - @Override - public void onFailure(Throwable t) { - LOG.error("Topology export failed for Tx:{}", txId, t); - - } - - @Override - public void onSuccess(RpcResult result) { - if(!result.isSuccessful()) { - LOG.error("Topology export failed for Tx:{}", txId); - } - } - }); + return topology.child(Link.class, link.getKey()); } } diff --git a/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyProvider.java b/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyProvider.java index e77ba8769c..d656bda932 100644 --- a/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyProvider.java +++ b/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyProvider.java @@ -7,11 +7,20 @@ */ package org.opendaylight.md.controller.topology.manager; +import java.util.concurrent.ExecutionException; + import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; import org.opendaylight.controller.sal.binding.api.data.DataProviderService; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey; import org.opendaylight.yangtools.concepts.Registration; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.NotificationListener; import org.osgi.framework.BundleContext; import org.slf4j.Logger; @@ -19,58 +28,60 @@ import org.slf4j.LoggerFactory; public class FlowCapableTopologyProvider extends AbstractBindingAwareProvider implements AutoCloseable { private final static Logger LOG = LoggerFactory.getLogger(FlowCapableTopologyProvider.class); + private Registration listenerRegistration; + private Thread thread; - private DataProviderService dataService; - - public DataProviderService getDataService() { - return this.dataService; - } + /** + * Gets called on start of a bundle. + * + * @param session + */ + @Override + public synchronized void onSessionInitiated(final ProviderContext session) { + final DataProviderService dataService = session.getSALService(DataProviderService.class); + final NotificationProviderService notificationService = session.getSALService(NotificationProviderService.class); - public void setDataService(final DataProviderService dataService) { - this.dataService = dataService; - } + final String name = "flow:1"; + final TopologyKey key = new TopologyKey(new TopologyId(name)); + final InstanceIdentifier path = InstanceIdentifier + .builder(NetworkTopology.class) + .child(Topology.class, key) + .build(); - private NotificationProviderService notificationService; + final OperationProcessor processor = new OperationProcessor(dataService); + final FlowCapableTopologyExporter listener = new FlowCapableTopologyExporter(processor, path); + this.listenerRegistration = notificationService.registerNotificationListener(listener); - public NotificationProviderService getNotificationService() { - return this.notificationService; - } + final DataModificationTransaction tx = dataService.beginTransaction(); + tx.putOperationalData(path, new TopologyBuilder().setKey(key).build()); + try { + tx.commit().get(); + } catch (InterruptedException | ExecutionException e) { + LOG.warn("Initial topology export failed, continuing anyway", e); + } - public void setNotificationService(final NotificationProviderService notificationService) { - this.notificationService = notificationService; + thread = new Thread(processor); + thread.setDaemon(true); + thread.setName("FlowCapableTopologyExporter-" + name); + thread.start(); } - private final FlowCapableTopologyExporter exporter = new FlowCapableTopologyExporter(); - private Registration listenerRegistration; - @Override - public void close() { - - FlowCapableTopologyProvider.LOG.info("FlowCapableTopologyProvider stopped."); - dataService = null; - notificationService = null; + public synchronized void close() throws InterruptedException { + LOG.info("FlowCapableTopologyProvider stopped."); if (this.listenerRegistration != null) { try { this.listenerRegistration.close(); } catch (Exception e) { - throw new IllegalStateException("Exception during close of listener registration.",e); + LOG.error("Failed to close listener registration", e); } + listenerRegistration = null; + } + if (thread != null) { + thread.interrupt(); + thread.join(); + thread = null; } - } - - /** - * Gets called on start of a bundle. - * - * @param session - */ - @Override - public void onSessionInitiated(final ProviderContext session) { - dataService = session.getSALService(DataProviderService.class); - notificationService = session.getSALService(NotificationProviderService.class); - this.exporter.setDataService(dataService); - this.exporter.start(); - this.listenerRegistration = notificationService.registerNotificationListener(this.exporter); - ; } /** @@ -81,6 +92,10 @@ public class FlowCapableTopologyProvider extends AbstractBindingAwareProvider im */ @Override public void stopImpl(final BundleContext context) { - this.close(); + try { + this.close(); + } catch (InterruptedException e) { + LOG.error("Failed to stop provider", e); + } } } diff --git a/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/OperationProcessor.java b/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/OperationProcessor.java new file mode 100644 index 0000000000..d60c88032d --- /dev/null +++ b/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/OperationProcessor.java @@ -0,0 +1,85 @@ +/* + * 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 + */ +package org.opendaylight.md.controller.topology.manager; + +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.LinkedBlockingQueue; + +import org.opendaylight.controller.md.sal.common.api.TransactionStatus; +import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; +import org.opendaylight.controller.sal.binding.api.data.DataProviderService; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.Preconditions; + +final class OperationProcessor implements Runnable { + private static final Logger LOG = LoggerFactory.getLogger(OperationProcessor.class); + private static final int MAX_TRANSACTION_OPERATIONS = 100; + private static final int OPERATION_QUEUE_DEPTH = 500; + + private final BlockingQueue queue = new LinkedBlockingQueue<>(OPERATION_QUEUE_DEPTH); + // FIXME: Flow capable topology exporter should use transaction chaining API + private final DataProviderService dataService; + + OperationProcessor(final DataProviderService dataService) { + this.dataService = Preconditions.checkNotNull(dataService); + } + + void enqueueOperation(final TopologyOperation task) { + try { + queue.put(task); + } catch (InterruptedException e) { + LOG.warn("Interrupted while submitting task {}", task, e); + } + } + + @Override + public void run() { + try { + for (;;) { + TopologyOperation op = queue.take(); + + LOG.debug("New operations available, starting transaction"); + final DataModificationTransaction tx = dataService.beginTransaction(); + + int ops = 0; + do { + op.applyOperation(tx); + + ops++; + if (ops < MAX_TRANSACTION_OPERATIONS) { + op = queue.poll(); + } else { + op = null; + } + } while (op != null); + + LOG.debug("Processed {} operations, submitting transaction", ops); + + try { + final RpcResult s = tx.commit().get(); + if (!s.isSuccessful()) { + LOG.error("Topology export failed for Tx:{}", tx.getIdentifier()); + } + } catch (ExecutionException e) { + LOG.error("Topology export transaction {} failed", tx.getIdentifier(), e.getCause()); + } + } + } catch (InterruptedException e) { + LOG.info("Interrupted processing, terminating", e); + } + + // Drain all events, making sure any blocked threads are unblocked + while (!queue.isEmpty()) { + queue.poll(); + } + } +} diff --git a/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/TopologyOperation.java b/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/TopologyOperation.java new file mode 100644 index 0000000000..29d06beade --- /dev/null +++ b/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/TopologyOperation.java @@ -0,0 +1,23 @@ +/* + * 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 + */ +package org.opendaylight.md.controller.topology.manager; + +import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; + +/** + * Internal interface for submitted operations. Implementations of this + * interface are enqueued and batched into data store transactions. + */ +interface TopologyOperation { + /** + * Execute the operation on top of the transaction. + * + * @param transaction Datastore transaction + */ + void applyOperation(DataModificationTransaction transaction); +} \ No newline at end of file