Correct ampersand escapes
[openflowplugin.git] / docs / devs / plugin.rst
1 OpenFlow Plugin Project Developer Guide
2 =======================================
3
4 This section covers topics which are developer specific and which have
5 not been covered in the user guide. Please see the OpenFlow
6 plugin user guide first.
7
8 It can be found on `the OpenDaylight software download
9 page <https://www.opendaylight.org/downloads>`__.
10
11 Event Sequences
12 ---------------
13
14 Session Establishment
15 ~~~~~~~~~~~~~~~~~~~~~
16
17 The OpenFlow Protocol
18 Library provides
19 interface **SwitchConnectionHandler** which contains method
20 *onSwitchConnected* (step 1). This event is raised in the OpenFlow
21 Protocol Library when an OpenFlow device connects to OpenDaylight and
22 caught in the **ConnectionManagerImpl** class in the OpenFlow plugin.
23
24 There the plugin creates a new instance of the **ConnectionContextImpl**
25 class (step 1.1) and also instances of **HandshakeManagerImpl** (which
26 uses **HandshakeListenerImpl**) and **ConnectionReadyListenerImpl**.
27 **ConnectionReadyListenerImpl** contains method *onConnectionReady()*
28 which is called when connection is prepared. This method starts the
29 handshake with the OpenFlow device (switch) from the OpenFlow plugin
30 side. Then handshake can be also started from device side. In this case
31 method *shake()* from **HandshakeManagerImpl** is called (steps 1.1.1
32 and 2).
33
34 The handshake consists of an exchange of HELLO messages in addition to
35 an exchange of device features (steps 2.1. and 3). The handshake is
36 completed by **HandshakeManagerImpl**. After receiving device features,
37 the **HandshakeListenerImpl** is notifed via the
38 *onHanshakeSuccessfull()* method. After this, the device features, node
39 id and connection state are stored in a **ConnectionContext** and the
40 method *deviceConnected()* of **DeviceManagerImpl** is called.
41
42 When *deviceConnected()* is called, it does the following:
43
44 1. creates a new transaction chain (step 4.1)
45
46 2. creates a new instance of **DeviceContext** (step 4.2.2)
47
48 3. initializes the device context: the static context of device is
49    populated by calling *createDeviceFeaturesForOF<version>()* to
50    populate table, group, meter features and port descriptions (step
51    4.2.1 and 4.2.1.1)
52
53 4. creates an instance of **RequestContext** for each type of feature
54
55 When the OpenFlow device responds to these requests (step 4.2.1.1) with
56 multipart replies (step 5) they are processed and stored to MD-SAL
57 operational datastore. The *createDeviceFeaturesForOF<version>()* method
58 returns a **Future** which is processed in the callback (step 5.1) (part
59 of *initializeDeviceContext()* in the *deviceConnected()* method) by
60 calling the method *onDeviceCtxLevelUp()* from **StatisticsManager**
61 (step 5.1.1).
62
63 The call to *createDeviceFeaturesForOF<version>()*: . creates a new
64 instance of **StatisticsContextImpl** (step 5.1.1.1).
65
66 1. calls *gatherDynamicStatistics()* on that instance which returns a
67    **Future** which will produce a value when done
68
69    a. this method calls methods to get dynamic data (flows, tables,
70       groups) from the device (step 5.1.1.2, 5.1.1.2.1, 5.1.1.2.1.1)
71
72    b. if everything works, this data is also stored in the MD-SAL
73       operational datastore
74
75 If the **Future** is successful, it is processed (step 6.1.1) in a
76 callback in **StatisticsManagerImpl** which:
77
78 1. schedules the next time to poll the device for statistics
79
80 2. sets the device state to synchronized (step 6.1.1.2)
81
82 3. calls *onDeviceContextLevelUp()* in **RpcManagerImpl**
83
84 The *onDeviceContextLevelUp()* call:
85
86 1. creates a new instance of **RequestContextImpl**
87
88 2. registers implementation for supported services
89
90 3. calls *onDeviceContextLevelUp()* in **DeviceManagerImpl** (step
91    6.1.1.2.1.2) which causes the information about the new device be be
92    written to the MD-SAL operational datastore (step 6.1.1.2.2)
93
94 .. figure:: ../images/odl-ofp-session-establishment.jpg
95    :alt: Session establishment
96
97    Session establishment
98
99 Handshake
100 ~~~~~~~~~
101
102 The first thing that happens when an OpenFlow device connects to
103 OpenDaylight is that the OpenFlow plugin gathers basic information about
104 the device and establishes agreement on key facts like the version of
105 OpenFlow which will be used. This process is called the handshake.
106
107 The handshake starts with HELLO message which can be sent either by the
108 OpenFlow device or the OpenFlow plugin. After this, there are several
109 scenarios which can happen:
110
111 1. if the first HELLO message contains a *version bitmap*, it is
112    possible to determine if there is a common version of OpenFlow or
113    not:
114
115    a. if there is a single common version use it and the **VERSION IS
116       SETTLED**
117
118    b. if there are more than one common versions, use the highest
119       (newest) protocol and the **VERSION IS SETTLED**
120
121    c. if there are no common versions, the device is **DISCONNECTED**
122
123 2. if the first HELLO message does not contain a *version bitmap*, then
124    STEB-BY-STEP negotiation is used
125
126 3. if second (or more) HELLO message is received, then STEP-BY-STEP
127    negotiation is used
128
129 STEP-BY-STEP negotiation:
130 ^^^^^^^^^^^^^^^^^^^^^^^^^
131
132 -  if last version proposed by the OpenFlow plugin is the same as the
133    version received from the OpenFlow device, then the **VERSION IS
134    SETTLED**
135
136 -  if the version received in the current HELLO message from the device
137    is the same as from previous then negotiation has failed and the
138    device is **DISCONNECTED**
139
140 -  if the last version from the device is greater than the last version
141    proposed from the plugin, wait for the next HELLO message in the hope
142    that it will advertise support for a lower version
143
144 -  if the last version from the device is is less than the last version
145    proposed from the plugin:
146
147    -  propose the highest version the plugin supports that is less than
148       or equal to the version received from the device and wait for the
149       next HELLO message
150
151    -  if if the plugin doesn’t support a lower version, the device is
152       **DISCONNECTED**
153
154 After selecting of version we can say that the **VERSION IS SETTLED**
155 and the OpenFlow plugin can ask device for its features. At this point
156 handshake ends.
157
158 .. figure:: ../images/odl-ofp-handshake.png
159    :alt: Handshake process
160
161    Handshake process
162
163 Adding a Flow
164 ~~~~~~~~~~~~~
165
166 There are two ways to add a flow in in the OpenFlow plugin: adding it to
167 the MD-SAL config datastore or calling an RPC. Both of these can either
168 be done using the native MD-SAL interfaces or using RESTCONF. This
169 discussion focuses on calling the RPC.
170
171 If user send flow via REST interface (step 1) it will cause that
172 *invokeRpc()* is called on **RpcBroker**. The **RpcBroker** then looks
173 for an appropriate implementation of the interface. In the case of the
174 OpenFlow plugin, this is the *addFlow()* method of
175 **SalFlowServiceImpl** (step 1.1). The same thing happens if the RPC is
176 called directly from the native MD-SAL interfaces.
177
178 The *addFlow()* method then
179
180 1. calls the *commitEntry()* method (step 2) from the OpenFlow Protocol
181    Library which is responsible for sending the flow to the device
182
183 2. creates a new **RequestContext** by calling *createRequestContext()*
184    (step 3)
185
186 3. creates a callback to handle any events that happen because of
187    sending the flow to the device
188
189 The callback method is triggered when a barrier reply message (step 2.1)
190 is received from the device indicating that the flow was either
191 installed or an appropriate error message was sent. If the flow was
192 successfully sent to the device, the RPC result is set to success (step
193 5). // **SalFlowService** contains inside method *addFlow()* other
194 callback which caught notification from callback for barrier message.
195
196 At this point, no information pertaining to the flow has been added to
197 the MD-SAL operational datastore. That is accomplished by the periodic
198 gathering of statistics from OpenFlow devices.
199
200 The **StatisticsContext** for each given OpenFlow device periodically
201 polls it using *gatherStatistics()* of **StatisticsGatheringUtil** which
202 issues an OpenFlow OFPT\_MULTIPART\_REQUEST - OFPMP\_FLOW. The response
203 to this request (step 7) is processed in **StatisticsGatheringUtil**
204 class where flow data is written to the MD-SAL operational datastore via
205 the *writeToTransaction()* method of **DeviceContext**.
206
207 .. figure:: ../images/odl-ofp-add-flow.png
208    :alt: Add flow
209
210    Add flow
211
212 Description of OpenFlow Plugin Modules
213 --------------------------------------
214
215 The OpenFlow plugin project contains a variety of OpenDaylight modules,
216 which are loaded using the configuration subsystem. This section
217 describes the YANG files used to model each module.
218
219 **General model (interfaces)** - openflow-plugin-cfg.yang.
220
221 -  the provided module is defined (``identity openflow-provider``)
222
223 -  and target implementation is assigned (``...OpenflowPluginProvider``)
224
225 .. code::
226
227     module openflow-provider {
228        yang-version 1;
229        namespace "urn:opendaylight:params:xml:ns:yang:openflow:common:config[urn:opendaylight:params:xml:ns:yang:openflow:common:config]";
230        prefix "ofplugin-cfg";
231
232        import config {prefix config; revision-date 2013-04-05; }
233        description
234            "openflow-plugin-custom-config";
235        revision "2014-03-26" {
236            description
237                "Initial revision";
238        }
239        identity openflow-provider{
240            base config:service-type;
241            config:java-class "org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider";
242        }
243     }
244
245 **Implementation model** - openflow-plugin-cfg-impl.yang
246
247 -  the implementation of module is defined
248    (``identity openflow-provider-impl``)
249
250    -  class name of generated implementation is defined
251       (ConfigurableOpenFlowProvider)
252
253 -  via augmentation the configuration of module is defined:
254
255    -  this module requires instance of binding-aware-broker
256       (``container binding-aware-broker``)
257
258    -  and list of openflow-switch-connection-provider (those are
259       provided by openflowjava, one plugin instance will orchestrate
260       multiple openflowjava modules)
261
262 .. code::
263
264     module openflow-provider-impl {
265        yang-version 1;
266        namespace "urn:opendaylight:params:xml:ns:yang:openflow:common:config:impl[urn:opendaylight:params:xml:ns:yang:openflow:common:config:impl]";
267        prefix "ofplugin-cfg-impl";
268
269        import config {prefix config; revision-date 2013-04-05;}
270        import openflow-provider {prefix openflow-provider;}
271        import openflow-switch-connection-provider {prefix openflow-switch-connection-provider;revision-date 2014-03-28;}
272        import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
273
274
275        description
276            "openflow-plugin-custom-config-impl";
277
278        revision "2014-03-26" {
279            description
280                "Initial revision";
281        }
282
283        identity openflow-provider-impl {
284            base config:module-type;
285            config:provided-service openflow-provider:openflow-provider;
286            config:java-name-prefix ConfigurableOpenFlowProvider;
287        }
288
289        augment "/config:modules/config:module/config:configuration" {
290            case openflow-provider-impl {
291                when "/config:modules/config:module/config:type = 'openflow-provider-impl'";
292
293                container binding-aware-broker {
294                    uses config:service-ref {
295                        refine type {
296                            mandatory true;
297                            config:required-identity md-sal-binding:binding-broker-osgi-registry;
298                        }
299                    }
300                }
301                list openflow-switch-connection-provider {
302                    uses config:service-ref {
303                        refine type {
304                            mandatory true;
305                            config:required-identity openflow-switch-connection-provider:openflow-switch-connection-provider;
306                        }
307                    }
308                }
309            }
310        }
311     }
312
313 Generating config and sal classes out of yangs
314 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
315
316 In order to involve suitable code generators, this is needed in pom:
317
318 .. code:: xml
319
320     <build> ...
321       <plugins>
322         <plugin>
323           <groupId>org.opendaylight.yangtools</groupId>
324           <artifactId>yang-maven-plugin</artifactId>
325           <executions>
326             <execution>
327               <goals>
328                 <goal>generate-sources</goal>
329               </goals>
330               <configuration>
331                 <codeGenerators>
332                   <generator>
333                     <codeGeneratorClass>
334                       org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
335                     </codeGeneratorClass>
336                     <outputBaseDir>${project.build.directory}/generated-sources/config</outputBaseDir>
337                     <additionalConfiguration>
338                       <namespaceToPackage1>
339                         urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang
340                       </namespaceToPackage1>
341                     </additionalConfiguration>
342                   </generator>
343                   <generator>
344                     <codeGeneratorClass>
345                       org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl
346                     </codeGeneratorClass>
347                     <outputBaseDir>${project.build.directory}/generated-sources/sal</outputBaseDir>
348                   </generator>
349                   <generator>
350                     <codeGeneratorClass>org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl</codeGeneratorClass>
351                     <outputBaseDir>${project.build.directory}/site/models</outputBaseDir>
352                   </generator>
353                 </codeGenerators>
354                 <inspectDependencies>true</inspectDependencies>
355               </configuration>
356             </execution>
357           </executions>
358           <dependencies>
359             <dependency>
360               <groupId>org.opendaylight.controller</groupId>
361               <artifactId>yang-jmx-generator-plugin</artifactId>
362               <version>0.2.5-SNAPSHOT</version>
363             </dependency>
364             <dependency>
365               <groupId>org.opendaylight.yangtools</groupId>
366               <artifactId>maven-sal-api-gen-plugin</artifactId>
367               <version>${yangtools.version}</version>
368               <type>jar</type>
369             </dependency>
370           </dependencies>
371         </plugin>
372         ...
373
374 -  JMX generator (target/generated-sources/config)
375
376 -  sal CodeGeneratorImpl (target/generated-sources/sal)
377
378 Altering generated files
379 ~~~~~~~~~~~~~~~~~~~~~~~~
380
381 Those files were generated under src/main/java in package as referred in
382 yangs (if exist, generator will not overwrite them):
383
384 -  ConfigurableOpenFlowProviderModuleFactory
385
386        here the **instantiateModule** methods are extended in order to
387        capture and inject osgi BundleContext into module, so it can be
388        injected into final implementation - **OpenflowPluginProvider** +
389        ``module.setBundleContext(bundleContext);``
390
391 -  ConfigurableOpenFlowProviderModule
392
393        here the **createInstance** method is extended in order to inject
394        osgi BundleContext into module implementation +
395        ``pluginProvider.setContext(bundleContext);``
396
397 Configuration xml file
398 ~~~~~~~~~~~~~~~~~~~~~~
399
400 Configuration file contains
401
402 -  required capabilities
403
404    -  modules definitions from openflowjava
405
406    -  modules definitions from openflowplugin
407
408 -  modules definition
409
410    -  openflow:switch:connection:provider:impl (listening on port 6633,
411       name=openflow-switch-connection-provider-legacy-impl)
412
413    -  openflow:switch:connection:provider:impl (listening on port 6653,
414       name=openflow-switch-connection-provider-default-impl)
415
416    -  openflow:common:config:impl (having 2 services (wrapping those 2
417       previous modules) and binding-broker-osgi-registry injected)
418
419 -  provided services
420
421    -  openflow-switch-connection-provider-default
422
423    -  openflow-switch-connection-provider-legacy
424
425    -  openflow-provider
426
427 .. code:: xml
428
429     <snapshot>
430      <required-capabilities>
431        <capability>urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider:impl?module=openflow-switch-connection-provider-impl&amp;revision=2014-03-28</capability>
432        <capability>urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider?module=openflow-switch-connection-provider&amp;revision=2014-03-28</capability>
433        <capability>urn:opendaylight:params:xml:ns:yang:openflow:common:config:impl?module=openflow-provider-impl&amp;revision=2014-03-26</capability>
434        <capability>urn:opendaylight:params:xml:ns:yang:openflow:common:config?module=openflow-provider&amp;revision=2014-03-26</capability>
435      </required-capabilities>
436      <configuration>
437          <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
438            <module>
439              <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider:impl">prefix:openflow-switch-connection-provider-impl</type>
440              <name>openflow-switch-connection-provider-default-impl</name>
441              <port>6633</port>
442              <switch-idle-timeout>15000</switch-idle-timeout>
443            </module>
444            <module>
445              <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider:impl">prefix:openflow-switch-connection-provider-impl</type>
446              <name>openflow-switch-connection-provider-legacy-impl</name>
447              <port>6653</port>
448              <switch-idle-timeout>15000</switch-idle-timeout>
449            </module>
450            <module>
451              <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:openflow:common:config:impl">prefix:openflow-provider-impl</type>
452              <name>openflow-provider-impl</name>
453              <openflow-switch-connection-provider>
454                <type xmlns:ofSwitch="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider">ofSwitch:openflow-switch-connection-provider</type>
455                <name>openflow-switch-connection-provider-default</name>
456              </openflow-switch-connection-provider>
457              <openflow-switch-connection-provider>
458                <type xmlns:ofSwitch="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider">ofSwitch:openflow-switch-connection-provider</type>
459                <name>openflow-switch-connection-provider-legacy</name>
460              </openflow-switch-connection-provider>
461              <binding-aware-broker>
462                <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
463                <name>binding-osgi-broker</name>
464              </binding-aware-broker>
465            </module>
466          </modules>
467          <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
468            <service>
469              <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider">prefix:openflow-switch-connection-provider</type>
470              <instance>
471                <name>openflow-switch-connection-provider-default</name>
472                <provider>/modules/module[type='openflow-switch-connection-provider-impl'][name='openflow-switch-connection-provider-default-impl']</provider>
473              </instance>
474              <instance>
475                <name>openflow-switch-connection-provider-legacy</name>
476                <provider>/modules/module[type='openflow-switch-connection-provider-impl'][name='openflow-switch-connection-provider-legacy-impl']</provider>
477              </instance>
478            </service>
479            <service>
480              <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:openflow:common:config">prefix:openflow-provider</type>
481              <instance>
482                <name>openflow-provider</name>
483                <provider>/modules/module[type='openflow-provider-impl'][name='openflow-provider-impl']</provider>
484              </instance>
485            </service>
486          </services>
487      </configuration>
488     </snapshot>
489
490 API changes
491 ~~~~~~~~~~~
492
493 In order to provide multiple instances of modules from openflowjava
494 there is an API change. Previously OFPlugin got access to
495 SwitchConnectionProvider exposed by OFJava and injected collection of
496 configurations so that for each configuration new instance of tcp
497 listening server was created. Now those configurations are provided by
498 configSubsystem and configured modules (wrapping the original
499 SwitchConnectionProvider) are injected into OFPlugin (wrapping
500 SwitchConnectionHandler).
501
502 Providing config file (IT, local distribution/base, integration/distributions/base)
503 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
504
505 openflowplugin-it
506 ^^^^^^^^^^^^^^^^^
507
508 Here the whole configuration is contained in one file (controller.xml).
509 Required entries needed in order to startup and wire OEPlugin + OFJava
510 are simply added there.
511
512 OFPlugin/distribution/base
513 ^^^^^^^^^^^^^^^^^^^^^^^^^^
514
515 Here new config file has been added
516 (src/main/resources/configuration/initial/42-openflow-protocol-impl.xml)
517 and is being copied to config/initial subfolder of build.
518
519 integration/distributions/build
520 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
521
522 In order to push the actual config into config/initial subfolder of
523 distributions/base in integration project there was a new artifact in
524 OFPlugin created - **openflowplugin-controller-config**, containing only
525 the config xml file under src/main/resources. Another change was
526 committed into integration project. During build this config xml is
527 being extracted and copied to the final folder in order to be accessible
528 during controller run.
529
530 Internal message statistics API
531 -------------------------------
532
533 To aid in testing and diagnosis, the OpenFlow plugin provides
534 information about the number and rate of different internal events.
535
536 The implementation does two things: collects event counts and exposes
537 counts. Event counts are grouped by message type, e.g.,
538 **PacketInMessage**, and checkpoint, e.g.,
539 *TO\_SWITCH\_ENQUEUED\_SUCCESS*. Once gathered, the results are logged
540 as well as being exposed using OSGi command line (deprecated) and JMX.
541
542 Collect
543 ~~~~~~~
544
545 Each message is counted as it passes through various processing
546 checkpoints. The following checkpoints are defined as a Java enum and
547 tracked:
548
549 .. code:: java
550
551       /**
552         * statistic groups overall in OFPlugin
553         */
554       enum STATISTIC_GROUP {
555            /** message from switch, enqueued for processing */
556            FROM_SWITCH_ENQUEUED,
557            /** message from switch translated successfully - source */
558            FROM_SWITCH_TRANSLATE_IN_SUCCESS,
559            /** message from switch translated successfully - target */
560            FROM_SWITCH_TRANSLATE_OUT_SUCCESS,
561            /** message from switch where translation failed - source */
562            FROM_SWITCH_TRANSLATE_SRC_FAILURE,
563            /** message from switch finally published into MD-SAL */
564            FROM_SWITCH_PUBLISHED_SUCCESS,
565            /** message from switch - publishing into MD-SAL failed */
566            FROM_SWITCH_PUBLISHED_FAILURE,
567
568            /** message from MD-SAL to switch via RPC enqueued */
569            TO_SWITCH_ENQUEUED_SUCCESS,
570            /** message from MD-SAL to switch via RPC NOT enqueued */
571            TO_SWITCH_ENQUEUED_FAILED,
572            /** message from MD-SAL to switch - sent to OFJava successfully */
573            TO_SWITCH_SUBMITTED_SUCCESS,
574            /** message from MD-SAL to switch - sent to OFJava but failed*/
575            TO_SWITCH_SUBMITTED_FAILURE
576       }
577
578 When a message passes through any of those checkpoints then counter
579 assigned to corresponding checkpoint and message is incremented by 1.
580
581 Expose statistics
582 ~~~~~~~~~~~~~~~~~
583
584 As described above, there are three ways to access the statistics:
585
586 -  OSGi command line (this is considered deprecated)
587
588        ``osgi> dumpMsgCount``
589
590 -  OpenDaylight logging console (statistics are logged here every 10
591    seconds)
592
593        required logback settings :
594        ``<logger name="org.opendaylight.openflowplugin.openflow.md.queue.MessageSpyCounterImpl" level="DEBUG"\/>``
595
596 -  JMX (via JConsole)
597
598        start OpenFlow plugin with the ``-jmx`` parameter
599
600        start JConsole by running ``jconsole``
601
602        the JConsole MBeans tab should contain
603        org.opendaylight.controller
604
605        RuntimeBean has a msg-spy-service-impl
606
607        Operations provides makeMsgStatistics report functionality
608
609 Example results
610 ^^^^^^^^^^^^^^^
611
612 .. figure:: ../images/odl-ofp-ofplugin-debug-stats.png
613    :alt: OFplugin Debug stats.png
614
615    OFplugin Debug stats.png
616
617 ::
618
619     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_ENQUEUED: MSG[PortStatusMessage] -> +0 | 1
620     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_ENQUEUED: MSG[MultipartReplyMessage] -> +24 | 81
621     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_ENQUEUED: MSG[PacketInMessage] -> +8 | 111
622     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_TRANSLATE_IN_SUCCESS: MSG[PortStatusMessage] -> +0 | 1
623     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_TRANSLATE_IN_SUCCESS: MSG[MultipartReplyMessage] -> +24 | 81
624     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_TRANSLATE_IN_SUCCESS: MSG[PacketInMessage] -> +8 | 111
625     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_TRANSLATE_OUT_SUCCESS: MSG[QueueStatisticsUpdate] -> +3 | 7
626     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_TRANSLATE_OUT_SUCCESS: MSG[NodeUpdated] -> +0 | 3
627     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_TRANSLATE_OUT_SUCCESS: MSG[NodeConnectorStatisticsUpdate] -> +3 | 7
628     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_TRANSLATE_OUT_SUCCESS: MSG[GroupDescStatsUpdated] -> +3 | 7
629     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_TRANSLATE_OUT_SUCCESS: MSG[FlowsStatisticsUpdate] -> +3 | 19
630     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_TRANSLATE_OUT_SUCCESS: MSG[PacketReceived] -> +8 | 111
631     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_TRANSLATE_OUT_SUCCESS: MSG[MeterFeaturesUpdated] -> +0 | 3
632     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_TRANSLATE_OUT_SUCCESS: MSG[GroupStatisticsUpdated] -> +3 | 7
633     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_TRANSLATE_OUT_SUCCESS: MSG[GroupFeaturesUpdated] -> +0 | 3
634     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_TRANSLATE_OUT_SUCCESS: MSG[MeterConfigStatsUpdated] -> +3 | 7
635     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_TRANSLATE_OUT_SUCCESS: MSG[MeterStatisticsUpdated] -> +3 | 7
636     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_TRANSLATE_OUT_SUCCESS: MSG[NodeConnectorUpdated] -> +0 | 12
637     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_TRANSLATE_OUT_SUCCESS: MSG[FlowTableStatisticsUpdate] -> +3 | 8
638     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_TRANSLATE_SRC_FAILURE: no activity detected
639     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_PUBLISHED_SUCCESS: MSG[QueueStatisticsUpdate] -> +3 | 7
640     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_PUBLISHED_SUCCESS: MSG[NodeUpdated] -> +0 | 3
641     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_PUBLISHED_SUCCESS: MSG[NodeConnectorStatisticsUpdate] -> +3 | 7
642     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_PUBLISHED_SUCCESS: MSG[GroupDescStatsUpdated] -> +3 | 7
643     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_PUBLISHED_SUCCESS: MSG[FlowsStatisticsUpdate] -> +3 | 19
644     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_PUBLISHED_SUCCESS: MSG[PacketReceived] -> +8 | 111
645     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_PUBLISHED_SUCCESS: MSG[MeterFeaturesUpdated] -> +0 | 3
646     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_PUBLISHED_SUCCESS: MSG[GroupStatisticsUpdated] -> +3 | 7
647     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_PUBLISHED_SUCCESS: MSG[GroupFeaturesUpdated] -> +0 | 3
648     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_PUBLISHED_SUCCESS: MSG[MeterConfigStatsUpdated] -> +3 | 7
649     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_PUBLISHED_SUCCESS: MSG[MeterStatisticsUpdated] -> +3 | 7
650     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_PUBLISHED_SUCCESS: MSG[NodeConnectorUpdated] -> +0 | 12
651     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_PUBLISHED_SUCCESS: MSG[FlowTableStatisticsUpdate] -> +3 | 8
652     DEBUG o.o.o.s.MessageSpyCounterImpl - FROM_SWITCH_PUBLISHED_FAILURE: no activity detected
653     DEBUG o.o.o.s.MessageSpyCounterImpl - TO_SWITCH_ENQUEUED_SUCCESS: MSG[AddFlowInput] -> +0 | 12
654     DEBUG o.o.o.s.MessageSpyCounterImpl - TO_SWITCH_ENQUEUED_FAILED: no activity detected
655     DEBUG o.o.o.s.MessageSpyCounterImpl - TO_SWITCH_SUBMITTED_SUCCESS: MSG[AddFlowInput] -> +0 | 12
656     DEBUG o.o.o.s.MessageSpyCounterImpl - TO_SWITCH_SUBMITTED_FAILURE: no activity detected
657
658 Application: Forwarding Rules Synchronizer
659 ------------------------------------------
660
661 Basics
662 ~~~~~~
663
664 Description
665 ^^^^^^^^^^^
666
667 Forwarding Rules Synchronizer (FRS) is a newer version of Forwarding
668 Rules Manager (FRM). It was created to solve most shortcomings of FRM.
669 FRS solving errors with retry mechanism. Sending barrier if needed.
670 Using one service for flows, groups and meters. And it has less changes
671 requests send to device since calculating difference and using
672 compression queue.
673
674 It is located in the Java package:
675
676 .. code:: java
677
678     package org.opendaylight.openflowplugin.applications.frsync;
679
680 Listeners
681 ^^^^^^^^^
682
683 -  1x config - FlowCapableNode
684
685 -  1x operational - Node
686
687 System of work
688 ^^^^^^^^^^^^^^
689
690 -  one listener in config datastore waiting for changes
691
692    -  update cache
693
694    -  skip event if operational not present for node
695
696    -  send syncup entry to reactor for synchronization
697
698       -  node added: after part of modification and whole operational
699          snapshot
700
701       -  node updated: after and before part of modification
702
703       -  node deleted: null and before part of modification
704
705 -  one listener in operational datastore waiting for changes
706
707    -  update cache
708
709    -  on device connected
710
711       -  register for cluster services
712
713    -  on device disconnected remove from cache
714
715       -  remove from cache
716
717       -  unregister for cluster services
718
719    -  if registered for reconciliation
720
721       -  do reconciliation through syncup (only when config present)
722
723 -  reactor *(provides syncup w/decorators assembled in this order)*
724
725    -  Cluster decorator - skip action if not master for device
726
727    -  FutureZip decorator (FutureZip extends Future decorator)
728
729       -  Future - run delegate syncup in future - submit task to
730          executor service
731
732       -  FutureZip - provides state compression - compress optimized
733          config delta if waiting for execution with new one
734
735    -  Guard decorator - per device level locking
736
737    -  Retry decorator - register for reconciliation if syncup failed
738
739    -  Reactor impl - calculate diff from after/before parts of syncup
740       entry and execute
741
742 Strategy
743 ^^^^^^^^
744
745 In the *old* FRM uses an incremental strategy with all changes made one
746 by one, where FRS uses a flat batch system with changes made in bulk. It
747 uses one service SalFlatBatchService instead of three (flow, group,
748 meter).
749
750 Boron release
751 ^^^^^^^^^^^^^
752
753 FRS is used in Boron as separate feature and it is not loaded by any
754 other feature. It has to be run separately.
755
756 ::
757
758     odl-openflowplugin-app-forwardingrules-sync
759
760 FRS additions
761 ~~~~~~~~~~~~~
762
763 Retry mechanism
764 ^^^^^^^^^^^^^^^
765
766 -  is started when change request to device return as failed (register
767    for reconcile)
768
769 -  wait for next consistent operational and do reconciliation with
770    actual config (not only diff)
771
772 ZipQueue
773 ^^^^^^^^
774
775 -  only the diff (before/after) between last config changes is sent to
776    device
777
778 -  when there are more config changes for device in a row waiting to be
779    processed they are compressed into one entry (after is still replaced
780    with the latest)
781
782 Cluster-aware
783 ^^^^^^^^^^^^^
784
785 -  FRS is cluster aware using ClusteringSingletonServiceProvider from
786    the MD-SAL
787
788 -  on mastership change reconciliation is done (register for reconcile)
789
790 SalFlatBatchService
791 ^^^^^^^^^^^^^^^^^^^
792
793 FRS uses service with implemented barrier waiting logic between
794 dependent objects
795
796 Service: SalFlatBatchService
797 ----------------------------
798
799 Basics
800 ~~~~~~
801
802 SalFlatBatchService was created along forwardingrules-sync application
803 as the service that should application used by default. This service uses
804 only one input with bag of flow/group/meter objects and their common
805 add/update/remove action. So you practically send only one input (of specific
806 bags) to this service.
807
808 -  interface: *org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.SalFlatBatchService*
809
810 -  implementation: *org.opendaylight.openflowplugin.impl.services.SalFlatBatchServiceImpl*
811
812 -  method: *processFlatBatch(input)*
813
814 -  input: *org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchInput*
815
816 Usage benefits
817 ^^^^^^^^^^^^^^
818
819 -  possibility to use only one input bag with particular failure analysis preserved
820
821 -  automatic barrier decision (chain+wait)
822
823 -  less RPC routing in cluster environment (since one call encapsulates all others)
824
825 ProcessFlatBatchInput
826 ~~~~~~~~~~~~~~~~~~~~~
827
828 Input for SalFlatBatchService (ProcessFlatBatchInput object) consists of:
829
830 -  node - NodeRef
831
832 -  batch steps - List<Batch> - defined action + bag of objects + order for failures analysis
833
834    -  BatchChoice - yang-modeled action choice (e.g. FlatBatchAddFlowCase) containing batch bag of objects (e.g. flows to be added)
835
836    -  BatchOrder - (integer) order of batch step (should be incremented by single action)
837
838 -  exitOnFirstError - boolean flag
839
840 Workflow
841 ~~~~~~~~
842 #. prepare **list of steps** based on input
843
844 #. **mark barriers** in steps where needed
845
846 #. prepare particular **F/G/M-batch** service calls from **Flat-batch** steps
847
848    -  F/G/M-batch services encapsulate bulk of single service calls
849
850    -  they actually chain barrier after processing all single calls if actual step is marked as barrier-needed
851
852 #. **chain** futures and **start** executing
853
854    - start all actions that can be run simultaneously (chain all on one starting point)
855
856    -  in case there is a step marked as barrier-needed
857
858       -  wait for all fired jobs up to one with barrier
859
860       - merge rpc results (status, errors, batch failures) into single one
861
862       - the latest job with barrier is new starting point for chaining
863
864 Services encapsulation
865 ^^^^^^^^^^^^^^^^^^^^^^
866
867 -  SalFlatBatchService
868
869    -  SalFlowBatchService
870
871       -  SalFlowService
872
873    -  SalGroupBatchService
874
875       -  SalGroupService
876
877    -  SalMeterBatchService
878
879       -  SalMeterService
880
881 Barrier decision
882 ^^^^^^^^^^^^^^^^
883
884 -  decide on actual step and all previous steps since the latest barrier
885
886 -  if condition in table below is satisfied the latest step before actual is marked as barrier-needed
887
888 +---------------------------+------------------------------------------------------------------+
889 | actual step               | previous steps contain                                           |
890 +===========================+==================================================================+
891 | FLOW_ADD *or* FLOW_UPDATE | GROUP_ADD *or* METER_ADD                                         |
892 +---------------------------+------------------------------------------------------------------+
893 | GROUP_ADD                 | GROUP_ADD *or* GROUP_UPDATE                                      |
894 +---------------------------+------------------------------------------------------------------+
895 | GROUP_REMOVE              | FLOW_UPDATE *or* FLOW_REMOVE *or* GROUP_UPDATE *or* GROUP_REMOVE |
896 +---------------------------+------------------------------------------------------------------+
897 | METER_REMOVE              | FLOW_UPDATE *or* FLOW_REMOVE                                     |
898 +---------------------------+------------------------------------------------------------------+
899
900 Error handling
901 ^^^^^^^^^^^^^^
902
903 There is flag in ProcessFlatBatchInput to stop process on the first error.
904
905 -  *true* - if partial step is not successful stop whole processing
906
907 -  *false* (default) - try to process all steps regardless partial results
908
909 If error occurs in any of partial steps upper FlatBatchService call will return as unsuccessful in both cases.
910 However every partial error is attached to general flat batch result along with BatchFailure (contains BatchOrder
911 and BatchItemIdChoice to identify failed step).
912
913 Cluster singleton approach in plugin
914 ------------------------------------
915
916 Basics
917 ~~~~~~
918
919 Description
920 ^^^^^^^^^^^
921
922 The existing OpenDaylight service deployment model assumes symmetric
923 clusters, where all services are activated on all nodes in the cluster.
924 However, many services require that there is a single active service
925 instance per cluster. We call such services *singleton services*. The
926 Entity Ownership Service (EOS) represents the base Leadership choice for
927 one Entity instance. Every Cluster Singleton service **type** must have
928 its own Entity and every Cluster Singleton service **instance** must
929 have its own Entity Candidate. Every registered Entity Candidate should
930 be notified about its actual role. All this "work" is done by MD-SAL so
931 the Openflowplugin need "only" to register as service in
932 **SingletonClusteringServiceProvider** given by MD-SAL.
933
934 Change against using EOS service listener
935 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
936
937 In this new clustering singleton approach plugin uses API from the
938 MD-SAL project: SingletonClusteringService which comes with three
939 methods.
940
941 ::
942
943     instantiateServiceInstance()
944     closeServiceInstance()
945     getIdentifier()
946
947 This service has to be registered to a
948 SingletonClusteringServiceProvider from MD-SAL which take care if
949 mastership is changed in cluster environment.
950
951 First method in SingletonClusteringService is being called when the
952 cluster node becomes a MASTER. Second is being called when status
953 changes to SLAVE or device is disconnected from cluster. Last method
954 plugins returns NodeId as ServiceGroupIdentifier Startup after device is
955 connected
956
957 On the start up the plugin we need to initialize first four managers for
958 each working area providing information and services
959
960 -  Device manager
961
962 -  RPC manager
963
964 -  Role manager
965
966 -  Statistics manager
967
968 After connection the device the listener Device manager get the event
969 and start up to creating the context for this connection. Startup after
970 device connection
971
972 Services are managed by SinlgetonClusteringServiceProvider from MD-SAL
973 project. So in startup we simply create a instance of LifecycleService
974 and register all contexts into it.
975
976 Role change
977 ~~~~~~~~~~~
978
979 Plugin is no longer registered as Entity Ownership Service (EOS)
980 listener therefore does not need to and cannot respond on EOS ownership
981 changes.
982
983 Service start
984 ^^^^^^^^^^^^^
985
986 Services start asynchronously but the start is managed by
987 LifecycleService. If something goes wrong LifecycleService stop starting
988 services in context and this speeds up the reconnect process. But the
989 services haven’t changed and plugin need to start all this:
990
991 -  Activating transaction chain manager
992
993 -  Initial gathering of device statistics
994
995 -  Initial submit to DS
996
997 -  Sending role MASTER to device
998
999 -  RPC services registration
1000
1001 -  Statistics gathering start
1002
1003 Service stop
1004 ^^^^^^^^^^^^
1005
1006 If closeServiceInstance occurred plugin just simply try to store all
1007 unsubmitted transactions and close the transaction chain manager, stop
1008 RPC services, stop Statistics gathering and after that all unregister
1009 txEntity from EOS.
1010
1011 Yang models and API
1012 -------------------
1013
1014 +--------------------------------------------------------+
1015 | Model                                                  |
1016 +========================================================+
1017 | ***Openflow basic types***                             |
1018 +--------------------------------------------------------+
1019 | `opendaylight-table-types.yang <https://git.opendaylig |
1020 | ht.org/gerrit/gitweb?p=openflowplugin.git;f=model/mode |
1021 | l-flow-base/src/main/yang/opendaylight-table-types.yan |
1022 | g;a=blob;hb=refs/heads/stable/boron>`__                |
1023 +--------------------------------------------------------+
1024 | `opendaylight-action-types.yang <https://git.opendayli |
1025 | ght.org/gerrit/gitweb?p=openflowplugin.git;f=model/mod |
1026 | el-flow-base/src/main/yang/opendaylight-action-types.y |
1027 | ang;a=blob;hb=refs/heads/stable/boron>`__              |
1028 +--------------------------------------------------------+
1029 | `opendaylight-flow-types.yang <https://git.opendayligh |
1030 | t.org/gerrit/gitweb?p=openflowplugin.git;f=model/model |
1031 | -flow-base/src/main/yang/opendaylight-flow-types.yang; |
1032 | a=blob;hb=refs/heads/stable/boron>`__                  |
1033 +--------------------------------------------------------+
1034 | `opendaylight-meter-types.yang <https://git.opendaylig |
1035 | ht.org/gerrit/gitweb?p=openflowplugin.git;f=model/mode |
1036 | l-flow-base/src/main/yang/opendaylight-meter-types.yan |
1037 | g;a=blob;hb=refs/heads/stable/boron>`__                |
1038 +--------------------------------------------------------+
1039 | `opendaylight-group-types.yang <https://git.opendaylig |
1040 | ht.org/gerrit/gitweb?p=openflowplugin.git;f=model/mode |
1041 | l-flow-base/src/main/yang/opendaylight-group-types.yan |
1042 | g;a=blob;hb=refs/heads/stable/boron>`__                |
1043 +--------------------------------------------------------+
1044 | `opendaylight-match-types.yang <https://git.opendaylig |
1045 | ht.org/gerrit/gitweb?p=openflowplugin.git;f=model/mode |
1046 | l-flow-base/src/main/yang/opendaylight-match-types.yan |
1047 | g;a=blob;hb=refs/heads/stable/boron>`__                |
1048 +--------------------------------------------------------+
1049 | `opendaylight-port-types.yang <https://git.opendayligh |
1050 | t.org/gerrit/gitweb?p=openflowplugin.git;f=model/model |
1051 | -flow-base/src/main/yang/opendaylight-port-types.yang; |
1052 | a=blob;hb=refs/heads/stable/boron>`__                  |
1053 +--------------------------------------------------------+
1054 | `opendaylight-queue-types.yang <https://git.opendaylig |
1055 | ht.org/gerrit/gitweb?p=openflowplugin.git;f=model/mode |
1056 | l-flow-base/src/main/yang/opendaylight-queue-types.yan |
1057 | g;a=blob;hb=refs/heads/stable/boron>`__                |
1058 +--------------------------------------------------------+
1059 | ***Openflow services***                                |
1060 +--------------------------------------------------------+
1061 | `sal-table.yang <https://git.opendaylight.org/gerrit/g |
1062 | itweb?p=openflowplugin.git;f=model/model-flow-service/ |
1063 | src/main/yang/sal-table.yang;a=blob;hb=refs/heads/stab |
1064 | le/boron>`__                                           |
1065 +--------------------------------------------------------+
1066 | `sal-group.yang <https://git.opendaylight.org/gerrit/g |
1067 | itweb?p=openflowplugin.git;f=model/model-flow-service/ |
1068 | src/main/yang/sal-group.yang;a=blob;hb=refs/heads/stab |
1069 | le/boron>`__                                           |
1070 +--------------------------------------------------------+
1071 | `sal-queue.yang <https://git.opendaylight.org/gerrit/g |
1072 | itweb?p=openflowplugin.git;f=model/model-flow-service/ |
1073 | src/main/yang/sal-queue.yang;a=blob;hb=refs/heads/stab |
1074 | le/boron>`__                                           |
1075 +--------------------------------------------------------+
1076 | `flow-errors.yang <https://git.opendaylight.org/gerrit |
1077 | /gitweb?p=openflowplugin.git;f=model/model-flow-servic |
1078 | e/src/main/yang/flow-errors.yang;a=blob;hb=refs/heads/ |
1079 | stable/boron>`__                                       |
1080 +--------------------------------------------------------+
1081 | `flow-capable-transaction.yang <https://git.opendaylig |
1082 | ht.org/gerrit/gitweb?p=openflowplugin.git;f=model/mode |
1083 | l-flow-service/src/main/yang/flow-capable-transaction. |
1084 | yang;a=blob;hb=refs/heads/stable/boron>`__             |
1085 +--------------------------------------------------------+
1086 | `sal-flow.yang <https://git.opendaylight.org/gerrit/gi |
1087 | tweb?p=openflowplugin.git;f=model/model-flow-service/s |
1088 | rc/main/yang/sal-flow.yang;a=blob;hb=refs/heads/stable |
1089 | /boron>`__                                             |
1090 +--------------------------------------------------------+
1091 | `sal-meter.yang <https://git.opendaylight.org/gerrit/g |
1092 | itweb?p=openflowplugin.git;f=model/model-flow-service/ |
1093 | src/main/yang/sal-meter.yang;a=blob;hb=refs/heads/stab |
1094 | le/boron>`__                                           |
1095 +--------------------------------------------------------+
1096 | `flow-topology-discovery.yang <https://git.opendayligh |
1097 | t.org/gerrit/gitweb?p=openflowplugin.git;f=model/model |
1098 | -flow-service/src/main/yang/flow-topology-discovery.ya |
1099 | ng;a=blob;hb=refs/heads/stable/boron>`__               |
1100 +--------------------------------------------------------+
1101 | `node-errors.yang <https://git.opendaylight.org/gerrit |
1102 | /gitweb?p=openflowplugin.git;f=model/model-flow-servic |
1103 | e/src/main/yang/node-errors.yang;a=blob;hb=refs/heads/ |
1104 | stable/boron>`__                                       |
1105 +--------------------------------------------------------+
1106 | `node-config.yang <https://git.opendaylight.org/gerrit |
1107 | /gitweb?p=openflowplugin.git;f=model/model-flow-servic |
1108 | e/src/main/yang/node-config.yang;a=blob;hb=refs/heads/ |
1109 | stable/boron>`__                                       |
1110 +--------------------------------------------------------+
1111 | `sal-echo.yang <https://git.opendaylight.org/gerrit/gi |
1112 | tweb?p=openflowplugin.git;f=model/model-flow-service/s |
1113 | rc/main/yang/sal-echo.yang;a=blob;hb=refs/heads/stable |
1114 | /boron>`__                                             |
1115 +--------------------------------------------------------+
1116 | `sal-port.yang <https://git.opendaylight.org/gerrit/gi |
1117 | tweb?p=openflowplugin.git;f=model/model-flow-service/s |
1118 | rc/main/yang/sal-port.yang;a=blob;hb=refs/heads/stable |
1119 | /boron>`__                                             |
1120 +--------------------------------------------------------+
1121 | `packet-processing.yang <https://git.opendaylight.org/ |
1122 | gerrit/gitweb?p=openflowplugin.git;f=model/model-flow- |
1123 | service/src/main/yang/packet-processing.yang;a=blob;hb |
1124 | =refs/heads/stable/boron>`__                           |
1125 +--------------------------------------------------------+
1126 | `flow-node-inventory.yang <https://git.opendaylight.or |
1127 | g/gerrit/gitweb?p=openflowplugin.git;f=model/model-flo |
1128 | w-service/src/main/yang/flow-node-inventory.yang;a=blo |
1129 | b;hb=refs/heads/stable/boron>`__                       |
1130 +--------------------------------------------------------+
1131 | ***Openflow statistics***                              |
1132 +--------------------------------------------------------+
1133 | `opendaylight-queue-statistics.yang <https://git.opend |
1134 | aylight.org/gerrit/gitweb?p=openflowplugin.git;f=model |
1135 | /model-flow-statistics/src/main/yang/opendaylight-queu |
1136 | e-statistics.yang;a=blob;hb=refs/heads/stable/boron>`_ |
1137 +--------------------------------------------------------+
1138 | `opendaylight-flow-table-statistics.yang <https://git. |
1139 | opendaylight.org/gerrit/gitweb?p=openflowplugin.git;f= |
1140 | model/model-flow-statistics/src/main/yang/opendaylight |
1141 | -flow-table-statistics.yang;a=blob;hb=refs/heads/stabl |
1142 | e/boron>`__                                            |
1143 +--------------------------------------------------------+
1144 | `opendaylight-port-statistics.yang <https://git.openda |
1145 | ylight.org/gerrit/gitweb?p=openflowplugin.git;f=model/ |
1146 | model-flow-statistics/src/main/yang/opendaylight-port- |
1147 | statistics.yang;a=blob;hb=refs/heads/stable/boron>`__  |
1148 +--------------------------------------------------------+
1149 | `opendaylight-statistics-types.yang <https://git.opend |
1150 | aylight.org/gerrit/gitweb?p=openflowplugin.git;f=model |
1151 | /model-flow-statistics/src/main/yang/opendaylight-stat |
1152 | istics-types.yang;a=blob;hb=refs/heads/stable/boron>`_ |
1153 +--------------------------------------------------------+
1154 | `opendaylight-group-statistics.yang <https://git.opend |
1155 | aylight.org/gerrit/gitweb?p=openflowplugin.git;f=model |
1156 | /model-flow-statistics/src/main/yang/opendaylight-grou |
1157 | p-statistics.yang;a=blob;hb=refs/heads/stable/boron>`_ |
1158 +--------------------------------------------------------+
1159 | `opendaylight-flow-statistics.yang <https://git.openda |
1160 | ylight.org/gerrit/gitweb?p=openflowplugin.git;f=model/ |
1161 | model-flow-statistics/src/main/yang/opendaylight-flow- |
1162 | statistics.yang;a=blob;hb=refs/heads/stable/boron>`__  |
1163 +--------------------------------------------------------+
1164 | `opendaylight-meter-statistics.yang <https://git.opend |
1165 | aylight.org/gerrit/gitweb?p=openflowplugin.git;f=model |
1166 | /model-flow-statistics/src/main/yang/opendaylight-mete |
1167 | r-statistics.yang;a=blob;hb=refs/heads/stable/boron>`_ |
1168 +--------------------------------------------------------+
1169
1170 Karaf feature tree
1171 ------------------
1172
1173 .. figure:: ../images/odl-ofp-feature-tree.png
1174    :alt: Openflow plugin karaf feature tree
1175
1176    Openflow plugin karaf feature tree
1177
1178 Short
1179 `HOWTO <https://wiki.opendaylight.org/view/OpenDaylight_OpenFlow_Plugin:FeatureTreeHowto>`__
1180 create such a tree.
1181
1182 Wiring up notifications
1183 -----------------------
1184
1185 Introduction
1186 ~~~~~~~~~~~~
1187
1188 We need to translate OpenFlow messages coming up from the OpenFlow
1189 Protocol Library into
1190 MD-SAL Notification objects and then publish them to the MD-SAL.
1191
1192 Mechanics
1193 ~~~~~~~~~
1194
1195 1. Create a Translator class
1196
1197 2. Register the Translator
1198
1199 3. Register the notificationPopListener to handle your Notification
1200    Objects
1201
1202 Create a Translator class
1203 ^^^^^^^^^^^^^^^^^^^^^^^^^
1204
1205 You can see an example in
1206 `PacketInTranslator.java <https://git.opendaylight.org/gerrit/gitweb?p=openflowplugin.git;a=blob;f=openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/PacketInTranslator.java;hb=refs/heads/stable/boron>`__.
1207
1208 First, simply create the class
1209
1210 ::
1211
1212     public class PacketInTranslator implements IMDMessageTranslator<OfHeader, List<DataObject>> {
1213
1214 Then implement the translate function:
1215
1216 ::
1217
1218     public class PacketInTranslator implements IMDMessageTranslator<OfHeader, List<DataObject>> {
1219
1220         protected static final Logger LOG = LoggerFactory
1221                 .getLogger(PacketInTranslator.class);
1222         @Override
1223         public PacketReceived translate(SwitchConnectionDistinguisher cookie,
1224                 SessionContext sc, OfHeader msg) {
1225                 ...
1226         }
1227
1228 Make sure to check that you are dealing with the expected type and cast
1229 it:
1230
1231 ::
1232
1233     if(msg instanceof PacketInMessage) {
1234         PacketInMessage message = (PacketInMessage)msg;
1235         List<DataObject> list = new CopyOnWriteArrayList<DataObject>();
1236
1237 Do your transation work and return
1238
1239 ::
1240
1241     PacketReceived pktInEvent = pktInBuilder.build();
1242     list.add(pktInEvent);
1243     return list;
1244
1245 Register your Translator Class
1246 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1247
1248 Next you need to go to
1249 `MDController.java <https://git.opendaylight.org/gerrit/gitweb?p=openflowplugin.git;a=blob;f=openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/MDController.java;hb=refs/heads/stable/boron>`__
1250 and in init() add register your Translator:
1251
1252 ::
1253
1254     public void init() {
1255             LOG.debug("Initializing!");
1256             messageTranslators = new ConcurrentHashMap<>();
1257             popListeners = new ConcurrentHashMap<>();
1258             //TODO: move registration to factory
1259             addMessageTranslator(ErrorMessage.class, OF10, new ErrorTranslator());
1260             addMessageTranslator(ErrorMessage.class, OF13, new ErrorTranslator());
1261             addMessageTranslator(PacketInMessage.class,OF10, new PacketInTranslator());
1262             addMessageTranslator(PacketInMessage.class,OF13, new PacketInTranslator());
1263
1264 Notice that there is a separate registration for each of OpenFlow 1.0
1265 and OpenFlow 1.3. Basically, you indicate the type of OpenFlow Protocol
1266 Library message you wish to translate for, the OpenFlow version, and an
1267 instance of your Translator.
1268
1269 Register your MD-SAL Message for Notification to the MD-SAL
1270 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1271
1272 Now, also in MDController.init() register to have the
1273 notificationPopListener handle your MD-SAL Message:
1274
1275 ::
1276
1277     addMessagePopListener(PacketReceived.class, new NotificationPopListener<DataObject>());
1278
1279 You are done
1280 ^^^^^^^^^^^^
1281
1282 That’s all there is to it. Now when a message comes up from the OpenFlow
1283 Protocol Library, it will be translated and published to the MD-SAL.
1284
1285 Message Order Preservation
1286 --------------------------
1287
1288 While the Helium release of OpenFlow Plugin relied on queues to ensure
1289 messages were delivered in order, subsequent releases instead ensure
1290 that all the messages from a given device are delivered using the same
1291 thread and thus message order is guaranteed without queues. The OpenFlow
1292 plugin allocates a number of threads equal to twice the number of
1293 processor cores on machine it is run, e.g., 8 threads if the machine has
1294 4 cores.
1295
1296 .. note::
1297
1298     While each device is assigned to one thread, multiple devices can be
1299     assigned to the same thread.