First complete pass over the developer guide
[docs.git] / manuals / developer-guide / src / main / asciidoc / controller / config-threadpool.adoc
1 === Examples of Threadpool
2
3 === Configuration example of thread pools using yangcli-pro
4
5 For a yangcli-pro example, see the https://wiki.opendaylight.org/view/OpenDaylight_Controller:Config:Examples:User_guide[Examples User Guide].
6
7 === Configuration example of thread pools using telnet
8 It is also possible to manipulate the configuration without the yuma cli. With just a telnet or ssh connection, it is possible to send the plain text containing netconf rpcs encoded in the xml format and achieve the same results as with yuma cli.
9
10 This example reproduces the configuration of a threadpool and a threadfactory from the previous example using just a telnet connection. We can also use ssh connection, with the netconf rpcs sending procedure remaining the same. For detailed information about initial configuration for the controller as well as the configuration process, see the example using yuma cli.
11
12 === Connecting to plaintext TCP socket
13
14 . Open a telnet connection:
15 ----
16 telnet 127.0.0.1 8383
17 ----
18 [start=2]
19 . Open an ssh connection:
20 ----
21 ssh netconf@127.0.0.1 -p 1830 -s netconf
22 ----
23 The password for user netconf is : netconf, and the separator for the messages is: +
24 ----
25 ]]>]]>
26 ----
27 Every message needs end with these 6 characters.
28
29 The server sends a hello message: +
30 ----
31 <hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
32 <capabilities>
33 <capability>urn:ietf:params:netconf:base:1.0</capability>
34 <capability>urn:ietf:params:netconf:capability:exi:1.0</capability>
35 <capability>urn:opendaylight:l2:types?module=opendaylight-l2-types&amp;revision=2013-08-27</capability>
36 <capability>urn:opendaylight:params:xml:ns:yang:controller:netty:threadgroup?module=threadgroup&amp;revision=2013-11-07</capability>
37 <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
38 <capability>urn:opendaylight:params:xml:ns:yang:controller:threadpool?module=threadpool&amp;revision=2013-04-09</capability>
39 <capability>urn:ietf:params:netconf:capability:candidate:1.0</capability>
40 <capability>urn:opendaylight:params:xml:ns:yang:controller:config?module=config&amp;revision=2013-04-05</capability>
41 <capability>urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring?module=ietf-netconf-monitoring&amp;revision=2010-10-04</capability>
42 <capability>urn:opendaylight:params:xml:ns:yang:controller:netty:eventexecutor?module=netty-event-executor&amp;revision=2013-11-12</capability>
43 <capability>urn:ietf:params:xml:ns:yang:rpc-context?module=rpc-context&amp;revision=2013-06-17</capability>
44 <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&amp;revision=2013-10-28</capability>
45 <capability>urn:opendaylight:params:xml:ns:yang:controller:netty:timer?module=netty-timer&amp;revision=2013-11-19</capability>
46 <capability>urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&amp;revision=2010-09-24</capability>
47 <capability>urn:ietf:params:netconf:capability:rollback-on-error:1.0</capability>
48 <capability>urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl?module=threadpool-impl&amp;revision=2013-04-05</capability>
49 <capability>urn:ietf:params:xml:ns:yang:ietf-yang-types?module=ietf-yang-types&amp;revision=2010-09-24</capability>
50 <capability>urn:opendaylight:params:xml:ns:yang:controller:logback:config?module=config-logging&amp;revision=2013-07-16</capability>
51 <capability>urn:opendaylight:params:xml:ns:yang:iana?module=iana&amp;revision=2013-08-16</capability>
52 <capability>urn:opendaylight:yang:extension:yang-ext?module=yang-ext&amp;revision=2013-07-09</capability>
53 <capability>urn:opendaylight:params:xml:ns:yang:controller:netty?module=netty&amp;revision=2013-11-19</capability>
54 <capability>http://netconfcentral.org/ns/toaster?module=toaster&amp;revision=2009-11-20</capability>
55 <capability>urn:opendaylight:params:xml:ns:yang:ieee754?module=ieee754&amp;revision=2013-08-19</capability>
56 <capability>urn:opendaylight:params:xml:ns:yang:nps-concepts?module=nps-concepts&amp;revision=2013-09-30</capability>
57 </capabilities>
58
59 <session-id>4</session-id>
60 </hello>
61 ]]>]]>
62 ----
63 [start=3]
64 . As the client, you must respond with a hello message:
65 ----
66 <hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
67     <capabilities>
68         <capability>urn:ietf:params:netconf:base:1.0</capability>
69     </capabilities>
70 </hello>
71 ]]>]]>
72 ----
73 Although there is no response to the hello message, the session is already established.
74
75 === Configuring threadfactory
76
77 . The following is the Xml equivalent to *get-config source=running*: +
78 ----
79 <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
80     <get-config>
81         <source>
82             <running/>
83         </source>
84     </get-config>
85 </rpc>
86 ]]>]]>
87 ----
88 The response containing the current configuration: +
89 ----
90 <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
91         <data>
92                 <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
93                         <module>
94                                 <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-broker-impl-singleton</type>
95                                 <name>binding-broker-singleton</name>
96                         </module>
97                 </modules>
98                 <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
99                         <service>
100                                 <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
101                                 <instance>
102                                         <name>ref_binding-broker-singleton</name>
103                                         <provider>/modules/module[type='binding-broker-impl-singleton'][name='binding-broker-singleton']</provider>
104                                 </instance>
105                         </service>
106                 </services>
107         </data>
108 </rpc-reply>]]>]]>
109 ----
110 [start=2]
111 . To create an instance of threadfactory-naming with the name threadfactory-bgp, and the attribute name-prefix set to bgp, send the message:
112 ----
113 <rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
114         <edit-config>
115                 <target>
116                         <candidate/>
117                 </target>
118                 <default-operation>merge</default-operation>
119                 <config>
120                         <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
121                                 <module xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="merge">
122                                         <name>threadfactory-bgp</name>
123                                         <type xmlns:th-java="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl">th-java:threadfactory-naming</type>
124                                         <name-prefix xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl">bgp</name-prefix>
125                                 </module>
126                         </modules>
127                 </config>
128         </edit-config>
129 </rpc>]]>]]>
130 ----
131 [start=3]
132 . To commit the threadfactory instance, send a commit message:
133 ----
134 <rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
135         <commit/>
136 </rpc>]]>]]>
137 ----
138 The NETCONF endpoint should respond with ok to edit-config, as well as the commit message: +
139
140 ----
141 <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
142         <ok/>
143 </rpc-reply>]]>]]>
144 ----
145 [start=4]
146 . The response to the get-config message (the same as the first message sent in this example) should contain the commited instance of threadfactory-naming:
147 ----
148 <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
149         <data>
150                 <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
151                         <module>
152                                 <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-broker-impl-singleton</type>
153                                 <name>binding-broker-singleton</name>
154                         </module>
155
156                         <module>
157                                 <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl">prefix:threadfactory-naming</type>
158                                 <name>threadfactory-bgp</name>
159                                 <name-prefix xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl">bgp</name-prefix>
160                         </module>
161                 </modules>
162
163                 <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
164                         <service>
165                                 <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadfactory</type>
166                                 <instance>
167                                         <name>ref_threadfactory-bgp</name>
168                                         <provider>/modules/module[type='threadfactory-naming'][name='threadfactory-bgp']</provider>
169                                 </instance>
170                         </service>
171                         <service>
172                                 <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
173                                 <instance>
174                                         <name>ref_binding-broker-singleton</name>
175                                         <provider>/modules/module[type='binding-broker-impl-singleton'][name='binding-broker-singleton']</provider>
176                                 </instance>
177                         </service>
178                 </services>
179         </data>
180 </rpc-reply>]]>]]>
181 ----
182 === Configuring fixed threadpool
183
184 * To create an instance of *threadpool-fixed* , with the same configuration and the same dependency as before, send the following message:
185
186 ----
187 <rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
188         <edit-config>
189                 <target>
190                         <candidate/>
191                 </target>
192                 <default-operation>merge</default-operation>
193                 <config>
194                         <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
195                                 <module xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="merge">
196                                         <name>bgp-threadpool</name>
197                                         <type xmlns:th-java="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl">th-java:threadpool-fixed</type>
198                                         <max-thread-count xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl">100</max-thread-count>
199                                         <threadFactory xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl">
200                                                 <type xmlns:th="urn:opendaylight:params:xml:ns:yang:controller:threadpool">th:threadfactory</type>
201                                                 <name>ref_th-bgp</name>
202                                         </threadFactory>
203                                 </module>
204                         </modules>
205
206                         <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
207                         <service>
208                                 <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadfactory</type>
209                                 <instance>
210                                         <name>ref_th-bgp</name>
211                                         <provider>/modules/module[type='threadfactory-naming'][name='threadfactory-bgp']</provider>
212                                 </instance>
213                         </service>
214                 </services>
215                 </config>
216         </edit-config>
217 </rpc>]]>]]>
218 ----
219 Notice the _services_ tag. If an instance is to be referenced as a dependency by another module, it needs to be placed under this tag as a service instance with a unique reference name. Tag _provider_ points to a unique instance that is already present in the config subsystem, or is created within the current edit-config operation.
220 The tag _name_ contains the reference name that can be referenced by other modules to create a dependency. In this case, a new instance of threadpool uses this reference in its configuration under the _threadFactory_ tag).
221
222 You should get an ok response again, and the configuration subsystem will inject the dependency into the threadpool. Now you can commit the configuration (ok response once more) and the process is finished. The config subsystem is now in the same state as it was at the end of the previous example.