Merge "Fixed for bug 1197"
[controller.git] / opendaylight / config / yang-jmx-generator / src / test / resources / test-config-threads-java.yang
1 module config-threads-java {
2     yang-version 1;
3     namespace "urn:opendaylight:params:xml:ns:yang:controller:config:threads:java";
4     prefix "th-java";
5
6     import config-threads { prefix th2; revision-date 2013-04-09; }
7     import config { prefix config; revision-date 2013-04-05; }
8     import rpc-context { prefix rpcx; revision-date 2013-06-17; }
9
10     description
11         "This module contains the base YANG definitions for NS-OS
12          thread services pure Java implementation.";
13
14     revision "2013-04-05" {
15         description
16             "Updated to work with new anchors.";
17     }
18
19     revision "2013-04-03" {
20         description
21             "Initial revision";
22     }
23
24    identity thread-rpc-context;
25
26     identity eventbus {
27         base config:module-type;
28         config:provided-service "th2:eventbus";
29         config:java-name-prefix EventBus;
30     }
31
32     identity async-eventbus {
33         base config:module-type;
34         config:provided-service "th2:eventbus";
35         config:java-name-prefix AsyncEventBus;
36     }
37
38     identity threadfactory-naming {
39         base config:module-type;
40         config:provided-service "th2:threadfactory";
41         config:java-name-prefix NamingThreadFactory;
42     }
43
44     identity threadpool-dynamic {
45         base config:module-type;
46         description "threadpool-dynamic description";
47         config:provided-service "th2:threadpool";
48         config:provided-service "th2:scheduled-threadpool";
49         config:java-name-prefix DynamicThreadPool;
50     }
51
52     augment "/config:modules/config:module/config:configuration" {
53         case eventbus {
54             when "/config:modules/config:module/config:type = 'eventbus'";
55             // No real configuration
56         }
57     }
58
59     grouping async-eventbus-config-attrs {
60         leaf cfg-attr {
61             type string;
62         }
63     }
64
65     augment "/config:modules/config:module/config:configuration" {
66         case async-eventbus {
67             when "/config:modules/config:module/config:type = 'async-eventbus'";
68             container threadpool {
69                 uses config:service-ref {
70                     refine type {
71                         config:required-identity th2:threadpool;
72                     }
73                 }
74             }
75
76             container from-grouping {
77                 uses async-eventbus-config-attrs;
78             }
79         }
80     }
81     augment "/config:modules/config:module/config:state" {
82         case async-eventbus {
83             when "/config:modules/config:module/config:type = 'async-eventbus'";
84             // simulate not having root runtime bean
85             list event {
86                 config:inner-state-bean;
87                 key "name";
88                 leaf name {
89                     type string;
90                 }
91             }
92         }
93     }
94
95     typedef thread-state {
96         type enumeration {
97             enum "STARTED";
98             enum "STOPPED";
99         }
100         description "Enum type holding state in which a thread can be.";
101     }
102
103     augment "/config:modules/config:module/config:configuration" {
104         case threadfactory-naming {
105             when "/config:modules/config:module/config:type = 'threadfactory-naming'";
106             leaf name-prefix {
107                 description "String that will be prefixed to each created thread. Suffix will be constructed from
108                     underscore (_) and auto-incremented index number.";
109                 type string;
110             }
111         }
112     }
113
114     augment "/config:modules/config:module/config:state" {
115         case threadfactory-naming {
116             when "/config:modules/config:module/config:type = 'threadfactory-naming'";
117             list thread {
118                 config:inner-state-bean;
119                 key "name";
120                 leaf name {
121                     type string;
122                 }
123                 // add rpc context
124                 rpcx:rpc-context-instance "thread-rpc-context";
125
126                 list stream {
127                     config:inner-state-bean;
128                     config:java-name-prefix ThreadStream;
129                     // no key – key will be generated by incrementing a counter
130                     leaf timestamp {
131                         type string;
132                     }
133                     leaf state {
134                         type thread-state;
135                     }
136
137                     container peer {
138                         leaf port {
139                             type uint32;
140                             default 179;
141                         }
142                         leaf core-size {
143                             type uint32;
144                         }
145                     }
146
147                     list inner-stream-list {
148                         leaf timestamp {
149                             type string;
150                         }
151                     }
152
153                 }
154             }
155
156             list stream {
157                 config:inner-state-bean;
158
159                 leaf timestamp {
160                     type string;
161                 }
162             }
163
164             // root runtime bean
165             leaf created-sessions {
166                 type uint32;
167             }
168         }
169     }
170
171
172     rpc dump-stack {
173         config:java-name-prefix dumpStack;
174         input {
175             uses rpcx:rpc-context-ref {
176                 refine context-instance {
177                     rpcx:rpc-context-instance thread-rpc-context;
178                 }
179             }
180         }
181     }
182
183     rpc sleep {
184         input {
185             uses rpcx:rpc-context-ref {
186                 refine context-instance {
187                     rpcx:rpc-context-instance thread-rpc-context;
188                 }
189             }
190             leaf millis {
191                 type uint32;
192             }
193         }
194         output {
195             leaf result {
196                 type thread-state;
197             }
198         }
199     }
200
201
202     augment "/config:modules/config:module/config:configuration" {
203         case threadpool-dynamic {
204             when "/config:modules/config:module/config:type = 'threadpool-dynamic'";
205             container threadpool-dynamic {
206                 leaf core-size {
207                     type uint32;
208                 }
209
210                 leaf keep-alive {
211                     type uint32;
212                     units seconds;
213                     default 10;
214                 }
215
216                 leaf maximum-size {
217                     type uint32;
218                     description "maximum-size description";
219                 }
220
221                 leaf binary {
222                     type binary;
223                 }
224
225                 container threadfactory {
226                     description "threadfactory description";
227                     uses config:service-ref {
228                         refine type {
229                             mandatory true;
230                             config:required-identity th2:threadfactory;
231                         }
232                     }
233                 }
234
235                 leaf-list users  {
236                     type string;
237                 }
238
239                  leaf-list users-numbers {
240                     type uint32;
241                     description "numbers of users description";
242                 }
243             }
244         }
245     }
246
247     augment "/config:modules/config:module/config:state" {
248         case threadpool-dynamic {
249             when "/config:modules/config:module/config:type = 'threadpool-dynamic'";
250             container threadpool-dynamic {
251                 // root runtime bean
252                 leaf created-sessions {
253                     type uint32;
254                 }
255             }
256         }
257     }
258
259     identity threadpool-registry-impl {
260         base config:module-type;
261         config:java-name-prefix ThreadPoolRegistryImpl;
262     }
263
264     augment "/config:modules/config:module/config:configuration" {
265         case threadpool-registry-impl {
266             when "/config:modules/config:module/config:type = 'threadpool-registry-impl'";
267
268             // list of dependencies:
269             list threadpools {
270                 uses config:service-ref {
271                     refine type {
272                         mandatory true;
273                         config:required-identity th2:threadpool;
274                     }
275                 }
276             }
277         }
278     }
279 }