Brian O'Connor

Moving some apps to new repository

Repo URL: https://gerrit.onosproject.org/onos-app-samples

Apps moved
- calendar
- database-perf
- demo
- election
- ifwd
- intent-perf
- tvue

Apps removed
- foo

Change-Id: I90e8313554246aaeb92e46f9e9efcb93d951585b
Showing 74 changed files with 0 additions and 6460 deletions
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2014 Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -<project xmlns="http://maven.apache.org/POM/4.0.0"
18 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
20 - <modelVersion>4.0.0</modelVersion>
21 -
22 - <parent>
23 - <groupId>org.onosproject</groupId>
24 - <artifactId>onos-apps</artifactId>
25 - <version>1.2.0-SNAPSHOT</version>
26 - <relativePath>../pom.xml</relativePath>
27 - </parent>
28 -
29 - <artifactId>onos-app-calendar</artifactId>
30 - <packaging>bundle</packaging>
31 -
32 - <description>ONOS simple calendaring REST interface for intents</description>
33 -
34 - <properties>
35 - <web.context>/onos/calendar</web.context>
36 - </properties>
37 -
38 - <dependencies>
39 - <dependency>
40 - <groupId>org.onosproject</groupId>
41 - <artifactId>onlab-rest</artifactId>
42 - <version>${project.version}</version>
43 - </dependency>
44 -
45 - <dependency>
46 - <groupId>com.sun.jersey</groupId>
47 - <artifactId>jersey-servlet</artifactId>
48 - </dependency>
49 - <dependency>
50 - <groupId>com.sun.jersey.jersey-test-framework</groupId>
51 - <artifactId>jersey-test-framework-core</artifactId>
52 - <version>1.18.1</version>
53 - <scope>test</scope>
54 - </dependency>
55 - <dependency>
56 - <groupId>com.sun.jersey.jersey-test-framework</groupId>
57 - <artifactId>jersey-test-framework-grizzly2</artifactId>
58 - <version>1.18.1</version>
59 - <scope>test</scope>
60 - </dependency>
61 - <dependency>
62 - <groupId>org.osgi</groupId>
63 - <artifactId>org.osgi.core</artifactId>
64 - </dependency>
65 -
66 - <dependency>
67 - <groupId>org.onosproject</groupId>
68 - <artifactId>onlab-thirdparty</artifactId>
69 - </dependency>
70 -
71 - <dependency>
72 - <groupId>org.onosproject</groupId>
73 - <artifactId>onlab-misc</artifactId>
74 - </dependency>
75 -
76 - <dependency>
77 - <groupId>org.onosproject</groupId>
78 - <artifactId>onlab-junit</artifactId>
79 - <scope>test</scope>
80 - </dependency>
81 -
82 - <dependency>
83 - <groupId>org.onosproject</groupId>
84 - <artifactId>onos-cli</artifactId>
85 - <version>${project.version}</version>
86 - </dependency>
87 - <dependency>
88 - <groupId>org.apache.karaf.shell</groupId>
89 - <artifactId>org.apache.karaf.shell.console</artifactId>
90 - </dependency>
91 - </dependencies>
92 -
93 - <build>
94 - <plugins>
95 - <plugin>
96 - <groupId>org.apache.felix</groupId>
97 - <artifactId>maven-bundle-plugin</artifactId>
98 - <extensions>true</extensions>
99 - <configuration>
100 - <instructions>
101 - <_wab>src/main/webapp/</_wab>
102 - <Bundle-SymbolicName>
103 - ${project.groupId}.${project.artifactId}
104 - </Bundle-SymbolicName>
105 - <Import-Package>
106 - org.slf4j,
107 - org.osgi.framework,
108 - javax.ws.rs,javax.ws.rs.core,
109 - com.sun.jersey.api.core,
110 - com.sun.jersey.spi.container.servlet,
111 - com.sun.jersey.server.impl.container.servlet,
112 - org.onlab.packet.*,
113 - org.onlab.rest.*,
114 - org.onosproject.*
115 - </Import-Package>
116 - <Web-ContextPath>${web.context}</Web-ContextPath>
117 - </instructions>
118 - </configuration>
119 - </plugin>
120 - </plugins>
121 - </build>
122 -
123 -</project>
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.calendar;
17 -
18 -import org.onlab.packet.Ethernet;
19 -import org.onlab.rest.BaseResource;
20 -import org.onlab.util.Tools;
21 -import org.onosproject.core.ApplicationId;
22 -import org.onosproject.core.CoreService;
23 -import org.onosproject.net.ConnectPoint;
24 -import org.onosproject.net.DeviceId;
25 -import org.onosproject.net.HostId;
26 -import org.onosproject.net.flow.DefaultTrafficSelector;
27 -import org.onosproject.net.flow.TrafficSelector;
28 -import org.onosproject.net.flow.TrafficTreatment;
29 -import org.onosproject.net.intent.ConnectivityIntent;
30 -import org.onosproject.net.intent.Constraint;
31 -import org.onosproject.net.intent.HostToHostIntent;
32 -import org.onosproject.net.intent.Intent;
33 -import org.onosproject.net.intent.IntentEvent;
34 -import org.onosproject.net.intent.IntentListener;
35 -import org.onosproject.net.intent.IntentService;
36 -import org.onosproject.net.intent.IntentState;
37 -import org.onosproject.net.intent.Key;
38 -import org.onosproject.net.intent.TwoWayP2PIntent;
39 -import org.onosproject.net.intent.constraint.BandwidthConstraint;
40 -import org.onosproject.net.intent.constraint.LatencyConstraint;
41 -import org.onosproject.net.resource.Bandwidth;
42 -import org.slf4j.Logger;
43 -
44 -import javax.ws.rs.DELETE;
45 -import javax.ws.rs.POST;
46 -import javax.ws.rs.PUT;
47 -import javax.ws.rs.PathParam;
48 -import javax.ws.rs.core.Response;
49 -import java.net.URI;
50 -import java.time.Duration;
51 -import java.time.temporal.ChronoUnit;
52 -import java.util.LinkedList;
53 -import java.util.List;
54 -import java.util.concurrent.CountDownLatch;
55 -import java.util.concurrent.TimeUnit;
56 -
57 -import static org.onosproject.net.PortNumber.portNumber;
58 -import static org.onosproject.net.flow.DefaultTrafficTreatment.builder;
59 -import static org.onosproject.net.intent.IntentState.*;
60 -import static org.slf4j.LoggerFactory.getLogger;
61 -
62 -/**
63 - * Web resource for triggering calendared intents.
64 - */
65 -@javax.ws.rs.Path("intent")
66 -public class BandwidthCalendarResource extends BaseResource {
67 -
68 - private static final Logger log = getLogger(BandwidthCalendarResource.class);
69 - private static final long TIMEOUT = 10; // seconds
70 -
71 - private static final String INVALID_PARAMETER = "INVALID_PARAMETER\n";
72 - private static final String OPERATION_INSTALLED = "INSTALLED\n";
73 - private static final String OPERATION_FAILED = "FAILED\n";
74 - private static final String OPERATION_WITHDRAWN = "WITHDRAWN\n";
75 -
76 - /**
77 - * Setup a bi-directional path with constraints between switch to switch.
78 - * Switch is identified by DPID.
79 - *
80 - * @param src the path source (DPID or hostID)
81 - * @param dst the path destination (DPID or hostID)
82 - * @param srcPort the source port (-1 if src/dest is a host)
83 - * @param dstPort the destination port (-1 if src/dest is a host)
84 - * @param bandwidth the bandwidth (mbps) requirement for the path
85 - * @param latency the latency (micro sec) requirement for the path
86 - * @return intent key if successful,
87 - * server error message or "FAILED" if failed to create or submit intent
88 - */
89 - @javax.ws.rs.Path("/{src}/{dst}/{srcPort}/{dstPort}/{bandwidth}/{latency}")
90 - @POST
91 - // TODO could allow applications to provide optional key
92 - // ... if you do, you will need to change from LongKeys to StringKeys
93 - public Response setupPath(@PathParam("src") String src,
94 - @PathParam("dst") String dst,
95 - @PathParam("srcPort") String srcPort,
96 - @PathParam("dstPort") String dstPort,
97 - @PathParam("bandwidth") String bandwidth,
98 - @PathParam("latency") String latency) {
99 -
100 - log.info("Path Constraints: Src = {} SrcPort = {} Dest = {} DestPort = {} " +
101 - "BW = {} latency = {}",
102 - src, srcPort, dst, dstPort, bandwidth, latency);
103 -
104 - if (src == null || dst == null || srcPort == null || dstPort == null) {
105 - return Response.ok(INVALID_PARAMETER).build();
106 - }
107 -
108 - Long bandwidthL = 0L;
109 - Long latencyL = 0L;
110 - try {
111 - bandwidthL = Long.parseLong(bandwidth, 10);
112 - latencyL = Long.parseLong(latency, 10);
113 - } catch (Exception e) {
114 - return Response.ok(INVALID_PARAMETER).build();
115 - }
116 -
117 - Intent intent = createIntent(null, src, dst, srcPort, dstPort, bandwidthL, latencyL);
118 - try {
119 - if (submitIntent(intent)) {
120 - return Response.ok(intent.key() + "\n").build();
121 - } else {
122 - return Response.ok(OPERATION_FAILED).build();
123 - }
124 - } catch (Exception e) {
125 - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
126 - }
127 - }
128 -
129 - /**
130 - * Modify a bi-directional path's bandwidth.
131 - *
132 - * @param intentKey the path intent key
133 - * @param src the path source (DPID or hostID)
134 - * @param dst the path destination (DPID or hostID)
135 - * @param srcPort the source port (-1 if src/dest is a host)
136 - * @param dstPort the destination port (-1 if src/dest is a host)
137 - * @param bandwidth the bandwidth (mbps) requirement for the path
138 - * @return Intent state, "INSTALLED", if successful,
139 - * server error message or "FAILED" if failed to modify any direction intent
140 - */
141 - @javax.ws.rs.Path("/{intentKey}/{src}/{dst}/{srcPort}/{dstPort}/{bandwidth}")
142 - @PUT
143 - public Response modifyBandwidth(@PathParam("intentKey") String intentKey,
144 - @PathParam("src") String src,
145 - @PathParam("dst") String dst,
146 - @PathParam("srcPort") String srcPort,
147 - @PathParam("dstPort") String dstPort,
148 - @PathParam("bandwidth") String bandwidth) {
149 -
150 - log.info("Modify bw for intentKey = {}; src = {}; dst = {};" +
151 - "srcPort = {}; dstPort = {}; with new bandwidth = {}",
152 - intentKey, src, dst, srcPort, dstPort, bandwidth);
153 -
154 - if (src == null || dst == null || srcPort == null || dstPort == null) {
155 - return Response.ok(INVALID_PARAMETER).build();
156 - }
157 -
158 - Long bandwidthL = 0L;
159 - try {
160 - bandwidthL = Long.parseLong(bandwidth, 10);
161 - } catch (Exception e) {
162 - return Response.ok(INVALID_PARAMETER).build();
163 - }
164 -
165 - IntentService service = get(IntentService.class);
166 - Intent originalIntent
167 - = service.getIntent(Key.of(Tools.fromHex(intentKey.replace("0x", "")), appId()));
168 -
169 - if (originalIntent == null) {
170 - return Response.status(Response.Status.NOT_FOUND).build();
171 - }
172 -
173 - // get the latency constraint from the original intent
174 - Long latencyL = 0L;
175 - if (originalIntent instanceof ConnectivityIntent) {
176 - ConnectivityIntent connectivityIntent = (ConnectivityIntent) originalIntent;
177 - for (Constraint constraint : connectivityIntent.constraints()) {
178 - if (constraint instanceof LatencyConstraint) {
179 - latencyL = ((LatencyConstraint) constraint).latency().get(ChronoUnit.MICROS);
180 - }
181 - }
182 - }
183 -
184 - Intent newIntent = createIntent(originalIntent.key(), src, dst,
185 - srcPort, dstPort, bandwidthL, latencyL);
186 - try {
187 - if (submitIntent(newIntent)) {
188 - return Response.ok(OPERATION_INSTALLED).build();
189 - } else {
190 - return Response.ok(OPERATION_FAILED).build();
191 - }
192 - } catch (Exception e) {
193 - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
194 - }
195 - }
196 -
197 -
198 - /**
199 - * Create an Intent for a bidirectional path with constraints.
200 - *
201 - * @param key optional intent key
202 - * @param src the path source (DPID or hostID)
203 - * @param dst the path destination (DPID or hostID)
204 - * @param srcPort the source port (-1 if src/dest is a host)
205 - * @param dstPort the destination port (-1 if src/dest is a host)
206 - * @param bandwidth the bandwidth (mbps) requirement for the path
207 - * @param latency the latency (micro sec) requirement for the path
208 - * @return the appropriate intent
209 - */
210 - private Intent createIntent(Key key,
211 - String src,
212 - String dst,
213 - String srcPort,
214 - String dstPort,
215 - Long bandwidth,
216 - Long latency) {
217 -
218 - TrafficSelector selector = buildTrafficSelector();
219 - TrafficTreatment treatment = builder().build();
220 -
221 - final Constraint constraintBandwidth =
222 - new BandwidthConstraint(Bandwidth.mbps(bandwidth));
223 - final Constraint constraintLatency =
224 - new LatencyConstraint(Duration.of(latency, ChronoUnit.MICROS));
225 - final List<Constraint> constraints = new LinkedList<>();
226 -
227 - constraints.add(constraintBandwidth);
228 - constraints.add(constraintLatency);
229 -
230 - if (srcPort.equals("-1")) {
231 - HostId srcPoint = HostId.hostId(src);
232 - HostId dstPoint = HostId.hostId(dst);
233 - return new HostToHostIntent(appId(), key, srcPoint, dstPoint,
234 - selector, treatment, constraints,
235 - Intent.DEFAULT_INTENT_PRIORITY);
236 - } else {
237 - ConnectPoint srcPoint = new ConnectPoint(deviceId(src), portNumber(srcPort));
238 - ConnectPoint dstPoint = new ConnectPoint(deviceId(dst), portNumber(dstPort));
239 - return new TwoWayP2PIntent(appId(), key, srcPoint, dstPoint,
240 - selector, treatment, constraints,
241 - Intent.DEFAULT_INTENT_PRIORITY);
242 - }
243 - }
244 -
245 -
246 - /**
247 - * Synchronously submits an intent to the Intent Service.
248 - *
249 - * @param intent intent to submit
250 - * @return true if operation succeed, false otherwise
251 - */
252 - private boolean submitIntent(Intent intent)
253 - throws InterruptedException {
254 - IntentService service = get(IntentService.class);
255 -
256 - CountDownLatch latch = new CountDownLatch(1);
257 - InternalIntentListener listener = new InternalIntentListener(intent, service, latch);
258 - service.addListener(listener);
259 - service.submit(intent);
260 - log.info("Submitted Calendar App intent and waiting: {}", intent);
261 - if (latch.await(TIMEOUT, TimeUnit.SECONDS) &&
262 - listener.getState() == INSTALLED) {
263 - return true;
264 - }
265 - return false;
266 - }
267 -
268 - /**
269 - * Remove a bi-directional path with created intent key.
270 - *
271 - * @param intentKey the string key for the intent to remove
272 - * @return Intent state, "WITHDRAWN", if successful,
273 - * server error message or FAILED" if any direction intent remove failed
274 - */
275 - @javax.ws.rs.Path("/{intentKey}")
276 - @DELETE
277 - public Response removePath(@PathParam("intentKey") String intentKey) {
278 -
279 - log.info("Receiving tear down request for {}", intentKey);
280 -
281 - if (intentKey == null) {
282 - return Response.ok(INVALID_PARAMETER).build();
283 - }
284 -
285 - IntentService service = get(IntentService.class);
286 - Intent intent = service.getIntent(Key.of(Tools.fromHex(intentKey.replace("0x", "")), appId()));
287 -
288 - if (intent == null) {
289 - return Response.status(Response.Status.NOT_FOUND).build();
290 - }
291 -
292 - try {
293 - if (withdrawIntent(intent)) {
294 - return Response.ok(OPERATION_WITHDRAWN).build();
295 - } else {
296 - return Response.ok(OPERATION_FAILED).build();
297 - }
298 - } catch (Exception e) {
299 - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
300 - }
301 - }
302 -
303 - /**
304 - * Synchronously withdraws an intent to the Intent Service.
305 - *
306 - * @param intent intent to submit
307 - * @return true if operation succeed, false otherwise
308 - */
309 - private boolean withdrawIntent(Intent intent)
310 - throws InterruptedException {
311 - IntentService service = get(IntentService.class);
312 -
313 - CountDownLatch latch = new CountDownLatch(1);
314 - InternalIntentListener listener = new InternalIntentListener(intent, service, latch);
315 - service.addListener(listener);
316 - service.withdraw(intent);
317 - log.info("Withdrawing intent and waiting: {}", intent);
318 - if (latch.await(TIMEOUT, TimeUnit.SECONDS) &&
319 - listener.getState() == WITHDRAWN) {
320 - return true;
321 - }
322 - return false;
323 - }
324 -
325 -
326 - private static TrafficSelector buildTrafficSelector() {
327 - TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
328 - Short ethType = Ethernet.TYPE_IPV4;
329 -
330 - selectorBuilder.matchEthType(ethType);
331 -
332 - return selectorBuilder.build();
333 - }
334 -
335 - private static DeviceId deviceId(String dpid) {
336 - return DeviceId.deviceId(URI.create("of:" + dpid));
337 - }
338 -
339 - protected ApplicationId appId() {
340 - return get(CoreService.class).registerApplication("org.onosproject.calendar");
341 - }
342 -
343 - // Auxiliary listener to wait until the given intent reaches the installed or failed states.
344 - private final class InternalIntentListener implements IntentListener {
345 - private final Intent intent;
346 - private final IntentService service;
347 - private final CountDownLatch latch;
348 - private IntentState state;
349 -
350 - private InternalIntentListener(Intent intent, IntentService service,
351 - CountDownLatch latch) {
352 - this.intent = intent;
353 - this.service = service;
354 - this.latch = latch;
355 - }
356 -
357 - @Override
358 - public void event(IntentEvent event) {
359 - if (event.subject().equals(intent)) {
360 - state = service.getIntentState(intent.key());
361 - if (state == INSTALLED || state == FAILED || state == WITHDRAWN) {
362 - latch.countDown();
363 - service.removeListener(this);
364 - }
365 - }
366 - }
367 -
368 - public IntentState getState() {
369 - return state;
370 - }
371 - }
372 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -
17 -/**
18 - * Application providing integration between OSCARS and ONOS intent
19 - * framework via REST API.
20 - */
21 -package org.onosproject.calendar;
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2014 Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
18 - xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
19 - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
20 - id="ONOS" version="2.5">
21 - <display-name>ONOS GUI</display-name>
22 -
23 - <servlet>
24 - <servlet-name>JAX-RS Service</servlet-name>
25 - <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
26 - <init-param>
27 - <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
28 - <param-value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value>
29 - </init-param>
30 - <init-param>
31 - <param-name>com.sun.jersey.config.property.classnames</param-name>
32 - <param-value>org.onosproject.calendar.BandwidthCalendarResource</param-value>
33 - </init-param>
34 - <load-on-startup>10</load-on-startup>
35 - </servlet>
36 -
37 - <servlet-mapping>
38 - <servlet-name>JAX-RS Service</servlet-name>
39 - <url-pattern>/*</url-pattern>
40 - </servlet-mapping>
41 -
42 -</web-app>
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2015 Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -<project xmlns="http://maven.apache.org/POM/4.0.0"
18 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
20 - <modelVersion>4.0.0</modelVersion>
21 -
22 - <parent>
23 - <groupId>org.onosproject</groupId>
24 - <artifactId>onos-apps</artifactId>
25 - <version>1.2.0-SNAPSHOT</version>
26 - <relativePath>../pom.xml</relativePath>
27 - </parent>
28 -
29 - <artifactId>onos-app-database-perf</artifactId>
30 - <packaging>bundle</packaging>
31 -
32 - <description>ONOS partitioned database perf test app bundle</description>
33 -
34 - <build>
35 - <plugins>
36 - <plugin>
37 - <groupId>org.apache.maven.plugins</groupId>
38 - <artifactId>maven-assembly-plugin</artifactId>
39 - <version>2.5.3</version>
40 - <configuration>
41 - <descriptor>src/assembly/bin.xml</descriptor>
42 - </configuration>
43 - <executions>
44 - <execution>
45 - <phase>package</phase>
46 - <goals>
47 - <goal>single</goal>
48 - </goals>
49 - </execution>
50 - </executions>
51 - </plugin>
52 - </plugins>
53 - </build>
54 -</project>
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2015 Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -<app name="org.onosproject.databaseperf" origin="ON.Lab" version="1.1.0"
18 - features="onos-app-database-perf">
19 - <description>Partitioned database performance measurement application</description>
20 -</app>
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2015 Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -<assembly
18 - xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
19 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20 - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
21 - <formats>
22 - <format>zip</format>
23 - </formats>
24 - <id>onos</id>
25 - <includeBaseDirectory>false</includeBaseDirectory>
26 - <files>
27 - <file>
28 - <source>src/assembly/app.xml</source>
29 - <destName>app.xml</destName>
30 - </file>
31 - <file>
32 - <source>target/${project.artifactId}-${project.version}.jar</source>
33 - <destName>m2/org/onosproject/${project.artifactId}/${project.version}/${project.artifactId}-${project.version}.jar</destName>
34 - </file>
35 - </files>
36 -</assembly>
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.databaseperf;
17 -
18 -import static org.apache.felix.scr.annotations.ReferenceCardinality.MANDATORY_UNARY;
19 -import static org.onlab.util.Tools.delay;
20 -import static org.onlab.util.Tools.groupedThreads;
21 -import static org.slf4j.LoggerFactory.getLogger;
22 -
23 -import java.util.Timer;
24 -import java.util.TimerTask;
25 -import java.util.UUID;
26 -import java.util.concurrent.ExecutorService;
27 -import java.util.concurrent.Executors;
28 -import java.util.concurrent.TimeUnit;
29 -import java.util.concurrent.atomic.AtomicInteger;
30 -import java.util.stream.IntStream;
31 -
32 -import org.apache.commons.lang.math.RandomUtils;
33 -import org.apache.felix.scr.annotations.Activate;
34 -import org.apache.felix.scr.annotations.Component;
35 -import org.apache.felix.scr.annotations.Deactivate;
36 -import org.apache.felix.scr.annotations.Reference;
37 -import org.onlab.util.KryoNamespace;
38 -import org.onosproject.cluster.ClusterService;
39 -import org.onosproject.cluster.ControllerNode;
40 -import org.onosproject.core.ApplicationId;
41 -import org.onosproject.core.CoreService;
42 -import org.onosproject.store.service.ConsistentMap;
43 -import org.onosproject.store.service.Serializer;
44 -import org.onosproject.store.service.StorageService;
45 -import org.slf4j.Logger;
46 -
47 -/**
48 - * Application to measure partitioned database performance.
49 - */
50 -@Component(immediate = true)
51 -public class DatabasePerfInstaller {
52 -
53 - private final Logger log = getLogger(getClass());
54 -
55 - @Reference(cardinality = MANDATORY_UNARY)
56 - protected CoreService coreService;
57 -
58 - @Reference(cardinality = MANDATORY_UNARY)
59 - protected ClusterService clusterService;
60 -
61 - @Reference(cardinality = MANDATORY_UNARY)
62 - protected StorageService storageService;
63 -
64 - private boolean stopped;
65 -
66 - private ApplicationId appId;
67 -
68 - private static final long REPORT_PERIOD = 5000L; //ms
69 - private Timer reportTimer;
70 -
71 - private AtomicInteger successCount = new AtomicInteger(0);
72 - private AtomicInteger failureCount = new AtomicInteger(0);
73 -
74 - private ConsistentMap<String, String> cmap;
75 -
76 - private ControllerNode localNode;
77 -
78 - private long reportStartTime = System.currentTimeMillis();
79 -
80 - private static final int NUM_TASK_THREADS = 2;
81 - private ExecutorService taskExecutor;
82 -
83 - private static final Serializer SERIALIZER = new Serializer() {
84 -
85 - KryoNamespace kryo = new KryoNamespace.Builder().build();
86 -
87 - @Override
88 - public <T> byte[] encode(T object) {
89 - return kryo.serialize(object);
90 - }
91 -
92 - @Override
93 - public <T> T decode(byte[] bytes) {
94 - return kryo.deserialize(bytes);
95 - }
96 -
97 - };
98 -
99 - @Activate
100 - public void activate() {
101 - localNode = clusterService.getLocalNode();
102 - String nodeId = localNode.ip().toString();
103 - appId = coreService.registerApplication("org.onosproject.nettyperf."
104 - + nodeId);
105 -
106 - cmap = storageService.createConsistentMap("onos-app-database-perf-test-map", SERIALIZER);
107 - taskExecutor = Executors.newFixedThreadPool(NUM_TASK_THREADS, groupedThreads("onos/database-perf", "worker"));
108 - log.info("Started with Application ID {}", appId.id());
109 - start();
110 - }
111 -
112 - @Deactivate
113 - public void deactivate() {
114 - stop();
115 - log.info("Stopped");
116 - }
117 -
118 - public void start() {
119 - long delay = System.currentTimeMillis() % REPORT_PERIOD;
120 - reportTimer = new Timer("onos-netty-perf-reporter");
121 - reportTimer.scheduleAtFixedRate(new TimerTask() {
122 - @Override
123 - public void run() {
124 - report();
125 - }
126 - }, delay, REPORT_PERIOD);
127 -
128 - stopped = false;
129 - IntStream.range(0, NUM_TASK_THREADS).forEach(i -> {
130 - taskExecutor.submit(() -> {
131 - delay(2000); // take a breath to start
132 - while (!stopped) {
133 - performDBOperation();
134 - delay(2); // take a breather
135 - }
136 - });
137 - });
138 - }
139 -
140 - private void performDBOperation() {
141 - String key = String.format("test%d", RandomUtils.nextInt(1000));
142 - try {
143 - if (RandomUtils.nextBoolean()) {
144 - cmap.put(key, UUID.randomUUID().toString());
145 - } else {
146 - cmap.get(key);
147 - }
148 - successCount.incrementAndGet();
149 - } catch (Exception e) {
150 - failureCount.incrementAndGet();
151 - }
152 - }
153 -
154 - private void report() {
155 - long delta = System.currentTimeMillis() - reportStartTime;
156 - if (delta > 0) {
157 - int rate = (int) Math.round(((successCount.get() * 1000.0) / delta));
158 - log.info("Passed: {}, Failed: {}, Rate: {}",
159 - successCount.getAndSet(0), failureCount.getAndSet(0), rate);
160 - reportStartTime = System.currentTimeMillis();
161 - }
162 - }
163 -
164 - public void stop() {
165 - reportTimer.cancel();
166 - reportTimer = null;
167 - stopped = true;
168 - try {
169 - taskExecutor.awaitTermination(5, TimeUnit.SECONDS);
170 - } catch (InterruptedException e) {
171 - log.warn("Failed to stop worker.");
172 - }
173 - }
174 -}
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -
17 -/**
18 - * Performance test application that induces steady load on the partitioned database.
19 - */
20 -package org.onosproject.databaseperf;
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2014 Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -<project xmlns="http://maven.apache.org/POM/4.0.0"
18 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
20 - <modelVersion>4.0.0</modelVersion>
21 -
22 - <parent>
23 - <groupId>org.onosproject</groupId>
24 - <artifactId>onos-apps</artifactId>
25 - <version>1.2.0-SNAPSHOT</version>
26 - <relativePath>../pom.xml</relativePath>
27 - </parent>
28 -
29 - <artifactId>onos-app-demo</artifactId>
30 - <packaging>bundle</packaging>
31 -
32 - <description>ONOS demo app bundle</description>
33 -
34 - <properties>
35 - <web.context>/onos/demo</web.context>
36 - </properties>
37 -
38 - <dependencies>
39 - <dependency>
40 - <groupId>org.osgi</groupId>
41 - <artifactId>org.osgi.compendium</artifactId>
42 - </dependency>
43 - <dependency>
44 - <groupId>org.onosproject</groupId>
45 - <artifactId>onlab-rest</artifactId>
46 - <version>${project.version}</version>
47 - </dependency>
48 -
49 - <dependency>
50 - <groupId>org.onosproject</groupId>
51 - <artifactId>onos-rest</artifactId>
52 - <version>${project.version}</version>
53 - </dependency>
54 -
55 - <dependency>
56 - <groupId>com.sun.jersey</groupId>
57 - <artifactId>jersey-servlet</artifactId>
58 - </dependency>
59 - <dependency>
60 - <groupId>com.sun.jersey.jersey-test-framework</groupId>
61 - <artifactId>jersey-test-framework-core</artifactId>
62 - <version>1.18.1</version>
63 - <scope>test</scope>
64 - </dependency>
65 - <dependency>
66 - <groupId>com.sun.jersey.jersey-test-framework</groupId>
67 - <artifactId>jersey-test-framework-grizzly2</artifactId>
68 - <version>1.18.1</version>
69 - <scope>test</scope>
70 - </dependency>
71 -
72 - <dependency>
73 - <groupId>com.fasterxml.jackson.core</groupId>
74 - <artifactId>jackson-databind</artifactId>
75 - </dependency>
76 -
77 - <dependency>
78 - <groupId>com.fasterxml.jackson.core</groupId>
79 - <artifactId>jackson-annotations</artifactId>
80 - </dependency>
81 -
82 - <dependency>
83 - <groupId>org.osgi</groupId>
84 - <artifactId>org.osgi.core</artifactId>
85 - </dependency>
86 - </dependencies>
87 -
88 - <build>
89 - <plugins>
90 - <plugin>
91 - <groupId>org.apache.felix</groupId>
92 - <artifactId>maven-bundle-plugin</artifactId>
93 - <extensions>true</extensions>
94 - <configuration>
95 - <instructions>
96 - <_wab>src/main/webapp/</_wab>
97 - <Bundle-SymbolicName>
98 - ${project.groupId}.${project.artifactId}
99 - </Bundle-SymbolicName>
100 - <Import-Package>
101 - org.slf4j,
102 - org.osgi.framework,
103 - javax.ws.rs,javax.ws.rs.core,
104 - com.sun.jersey.api.core,
105 - com.sun.jersey.spi.container.servlet,
106 - com.sun.jersey.server.impl.container.servlet,
107 - com.fasterxml.jackson.databind,
108 - com.fasterxml.jackson.databind.node,
109 - org.apache.commons.lang.math.*,
110 - com.google.common.*,
111 - org.onlab.packet.*,
112 - org.onlab.rest.*,
113 - org.onosproject.*,
114 - org.onlab.util.*,
115 - org.jboss.netty.util.*
116 - </Import-Package>
117 - <Web-ContextPath>${web.context}</Web-ContextPath>
118 - </instructions>
119 - </configuration>
120 - </plugin>
121 - </plugins>
122 - </build>
123 -
124 -</project>
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.demo;
17 -
18 -import com.fasterxml.jackson.databind.JsonNode;
19 -
20 -import java.util.Optional;
21 -
22 -/**
23 - * Simple demo api interface.
24 - */
25 -public interface DemoAPI {
26 -
27 - enum InstallType { MESH, RANDOM };
28 -
29 - /**
30 - * Tests flow subsystem based on the parameters supplied.
31 - *
32 - * @param params the test parameters
33 - * @return JSON representation
34 - */
35 - JsonNode flowTest(Optional<JsonNode> params);
36 -
37 - /**
38 - * Installs intents based on the installation type.
39 - * @param type the installation type.
40 - * @param runParams run params
41 - */
42 - void setup(InstallType type, Optional<JsonNode> runParams);
43 -
44 - /**
45 - * Uninstalls all existing intents.
46 - */
47 - void tearDown();
48 -
49 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.demo;
17 -
18 -import com.fasterxml.jackson.databind.JsonNode;
19 -import com.fasterxml.jackson.databind.ObjectMapper;
20 -import com.fasterxml.jackson.databind.node.ObjectNode;
21 -import com.google.common.base.Predicate;
22 -import com.google.common.base.Stopwatch;
23 -import com.google.common.collect.FluentIterable;
24 -import com.google.common.collect.Lists;
25 -import com.google.common.collect.Sets;
26 -import com.google.common.util.concurrent.ThreadFactoryBuilder;
27 -import org.apache.commons.lang.math.RandomUtils;
28 -import org.apache.felix.scr.annotations.Activate;
29 -import org.apache.felix.scr.annotations.Component;
30 -import org.apache.felix.scr.annotations.Deactivate;
31 -import org.apache.felix.scr.annotations.Reference;
32 -import org.apache.felix.scr.annotations.ReferenceCardinality;
33 -import org.apache.felix.scr.annotations.Service;
34 -import org.onlab.packet.MacAddress;
35 -import org.onosproject.cluster.ClusterService;
36 -import org.onosproject.cluster.ControllerNode;
37 -import org.onosproject.cluster.NodeId;
38 -import org.onosproject.core.ApplicationId;
39 -import org.onosproject.core.CoreService;
40 -import org.onosproject.mastership.MastershipService;
41 -import org.onosproject.net.Device;
42 -import org.onosproject.net.Host;
43 -import org.onosproject.net.HostId;
44 -import org.onosproject.net.MastershipRole;
45 -import org.onosproject.net.PortNumber;
46 -import org.onosproject.net.device.DeviceService;
47 -import org.onosproject.net.flow.DefaultFlowRule;
48 -import org.onosproject.net.flow.DefaultTrafficSelector;
49 -import org.onosproject.net.flow.DefaultTrafficTreatment;
50 -import org.onosproject.net.flow.FlowRuleOperations;
51 -import org.onosproject.net.flow.FlowRuleOperationsContext;
52 -import org.onosproject.net.flow.FlowRuleService;
53 -import org.onosproject.net.flow.TrafficSelector;
54 -import org.onosproject.net.flow.TrafficTreatment;
55 -import org.onosproject.net.host.HostService;
56 -import org.onosproject.net.intent.Constraint;
57 -import org.onosproject.net.intent.HostToHostIntent;
58 -import org.onosproject.net.intent.Intent;
59 -import org.onosproject.net.intent.IntentService;
60 -import org.slf4j.Logger;
61 -
62 -import java.util.Collection;
63 -import java.util.Collections;
64 -import java.util.HashSet;
65 -import java.util.Iterator;
66 -import java.util.LinkedList;
67 -import java.util.List;
68 -import java.util.Objects;
69 -import java.util.Optional;
70 -import java.util.Random;
71 -import java.util.Set;
72 -import java.util.concurrent.Callable;
73 -import java.util.concurrent.CountDownLatch;
74 -import java.util.concurrent.ExecutionException;
75 -import java.util.concurrent.ExecutorService;
76 -import java.util.concurrent.Executors;
77 -import java.util.concurrent.Future;
78 -import java.util.concurrent.TimeUnit;
79 -import java.util.concurrent.TimeoutException;
80 -
81 -import static org.slf4j.LoggerFactory.getLogger;
82 -
83 -/**
84 - * Application to set up demos.
85 - */
86 -@Component(immediate = true)
87 -@Service
88 -public class DemoInstaller implements DemoAPI {
89 -
90 - private final Logger log = getLogger(getClass());
91 -
92 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
93 - protected CoreService coreService;
94 -
95 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
96 - protected IntentService intentService;
97 -
98 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
99 - protected HostService hostService;
100 -
101 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
102 - protected MastershipService mastershipService;
103 -
104 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
105 - protected ClusterService clusterService;
106 -
107 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
108 - protected DeviceService deviceService;
109 -
110 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
111 - protected FlowRuleService flowService;
112 -
113 - private ExecutorService worker;
114 -
115 - private ExecutorService installWorker;
116 -
117 - private ApplicationId appId;
118 -
119 - private final Set<Intent> existingIntents = new HashSet<>();
120 - private RandomInstaller randomInstaller;
121 -
122 - private ObjectMapper mapper = new ObjectMapper();
123 -
124 -
125 -
126 - @Activate
127 - public void activate() {
128 - String nodeId = clusterService.getLocalNode().ip().toString();
129 - appId = coreService.registerApplication("org.onosproject.demo.installer."
130 - + nodeId);
131 - worker = Executors.newFixedThreadPool(1,
132 - new ThreadFactoryBuilder()
133 - .setNameFormat("demo-app-worker")
134 - .build());
135 - log.info("Started with Application ID {}", appId.id());
136 - }
137 -
138 - @Deactivate
139 - public void deactivate() {
140 - shutdownAndAwaitTermination(worker);
141 - if (installWorker != null && !installWorker.isShutdown()) {
142 - shutdownAndAwaitTermination(installWorker);
143 - }
144 - log.info("Stopped");
145 - }
146 -
147 - @Override
148 - public JsonNode flowTest(Optional<JsonNode> params) {
149 - int flowsPerDevice = 1000;
150 - int neighbours = 0;
151 - boolean remove = true;
152 - if (params.isPresent()) {
153 - flowsPerDevice = params.get().get("flowsPerDevice").asInt();
154 - neighbours = params.get().get("neighbours").asInt();
155 - remove = params.get().get("remove").asBoolean();
156 - }
157 -
158 - Future<JsonNode> future = worker.submit(new FlowTest(flowsPerDevice, neighbours, remove));
159 -
160 - try {
161 - return future.get(10, TimeUnit.SECONDS);
162 - } catch (InterruptedException | ExecutionException | TimeoutException e) {
163 - ObjectNode node = mapper.createObjectNode();
164 - node.put("Error", e.getMessage());
165 - return node;
166 - }
167 - }
168 -
169 - @Override
170 - public void setup(InstallType type, Optional<JsonNode> runParams) {
171 - switch (type) {
172 - case MESH:
173 - log.debug("Installing mesh intents");
174 - worker.execute(new MeshInstaller());
175 - break;
176 - case RANDOM:
177 - //check that we do not have a random installer running
178 - if (installWorker == null || installWorker.isShutdown()) {
179 - installWorker = Executors.newFixedThreadPool(1,
180 - new ThreadFactoryBuilder()
181 - .setNameFormat("random-worker")
182 - .build());
183 - log.debug("Installing random sequence of intents");
184 - randomInstaller = new RandomInstaller(runParams);
185 - installWorker.execute(randomInstaller);
186 - } else {
187 - log.warn("Random installer is already running");
188 - }
189 - break;
190 - default:
191 - throw new IllegalArgumentException("What is it you want exactly?");
192 - }
193 - }
194 -
195 - @Override
196 - public void tearDown() {
197 - worker.submit(new UnInstaller());
198 - }
199 -
200 -
201 - /**
202 - * Simply installs a mesh of intents from all the hosts existing in the network.
203 - */
204 - private class MeshInstaller implements Runnable {
205 -
206 - @Override
207 - public void run() {
208 - TrafficSelector selector = DefaultTrafficSelector.emptySelector();
209 - TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
210 - List<Constraint> constraint = Lists.newArrayList();
211 - List<Host> hosts = Lists.newArrayList(hostService.getHosts());
212 - while (!hosts.isEmpty()) {
213 - Host src = hosts.remove(0);
214 - for (Host dst : hosts) {
215 - HostToHostIntent intent = new HostToHostIntent(appId, src.id(), dst.id(),
216 - selector, treatment,
217 - constraint,
218 - Intent.DEFAULT_INTENT_PRIORITY);
219 - existingIntents.add(intent);
220 - intentService.submit(intent);
221 - }
222 - }
223 - }
224 - }
225 -
226 - /**
227 - * Randomly installs and withdraws intents.
228 - */
229 - private class RandomInstaller implements Runnable {
230 -
231 - private final boolean isLocal;
232 - private final Set<Host> hosts;
233 -
234 - private final Random random = new Random(System.currentTimeMillis());
235 -
236 - private Set<HostPair> uninstalledOrWithdrawn;
237 - private Set<HostPair> installed;
238 -
239 - private CountDownLatch latch;
240 -
241 - //used to wait on a batch to be processed.
242 - private static final int ITERATIONMAX = 50000000;
243 -
244 -
245 - public RandomInstaller(Optional<JsonNode> runParams) {
246 - /*
247 - Check if we have params and honour them. Otherwise
248 - set defaults to processing only local stuff and
249 - all local hosts.
250 - */
251 - if (runParams.isPresent()) {
252 - JsonNode node = runParams.get();
253 - isLocal = node.get("local").asBoolean();
254 - hosts = node.get("hosts") == null ? Sets.newHashSet(hostService.getHosts()) :
255 - constructHostIds(node.get("hosts").elements());
256 - } else {
257 - isLocal = true;
258 - hosts = Sets.newHashSet(hostService.getHosts());
259 - }
260 -
261 - //construct list of intents.
262 - installed = Sets.newHashSet();
263 - if (isLocal) {
264 - uninstalledOrWithdrawn = buildPairs(pruneHostsByMasterShip());
265 - } else {
266 - uninstalledOrWithdrawn = buildPairs(hosts);
267 - }
268 -
269 - }
270 -
271 - private Set<Host> constructHostIds(Iterator<JsonNode> elements) {
272 - Set<Host> hostIds = Sets.newHashSet();
273 - JsonNode n;
274 - while (elements.hasNext()) {
275 - n = elements.next();
276 - hostIds.add(hostService.getHost(HostId.hostId(n.textValue())));
277 - }
278 - return hostIds;
279 - }
280 -
281 - @Override
282 - public void run() {
283 - if (!installWorker.isShutdown()) {
284 - randomize();
285 - latch = new CountDownLatch(1);
286 - try {
287 - trackIntents();
288 - } catch (InterruptedException e) {
289 - shutdown();
290 - }
291 - }
292 -
293 - }
294 -
295 -
296 - /**
297 - * Check whether the previously submitted batch is in progress
298 - * and if yes submit the next one. If things hang, wait for at
299 - * most 5 seconds and bail.
300 - * @throws InterruptedException if the thread go interupted
301 - */
302 - private void trackIntents() throws InterruptedException {
303 - //FIXME
304 - // TODO generate keys for each set of intents to allow manager to throttle
305 - // TODO may also look into the store to see how many operations are pending
306 -
307 - //if everything is good proceed.
308 - if (!installWorker.isShutdown()) {
309 - installWorker.execute(this);
310 - }
311 -
312 - }
313 -
314 - public void shutdown() {
315 - log.warn("Shutting down random installer!");
316 - cleanUp();
317 - }
318 -
319 -
320 - /**
321 - * Shuffle the uninstalled and installed list (separately) and select
322 - * a random number of them and install or uninstall them respectively.
323 - */
324 - private void randomize() {
325 - List<HostPair> hostList = new LinkedList<>(uninstalledOrWithdrawn);
326 - Collections.shuffle(hostList);
327 - List<HostPair> toInstall = hostList.subList(0,
328 - random.nextInt(hostList.size() - 1));
329 - List<HostPair> toRemove;
330 - if (!installed.isEmpty()) {
331 - hostList = new LinkedList<>(installed);
332 - Collections.shuffle(hostList);
333 - toRemove = hostList.subList(0,
334 - random.nextInt(hostList.size() - 1));
335 - uninstallIntents(toRemove);
336 - }
337 - installIntents(toInstall);
338 -
339 - }
340 -
341 - private void installIntents(List<HostPair> toInstall) {
342 - for (HostPair pair : toInstall) {
343 - installed.add(pair);
344 - uninstalledOrWithdrawn.remove(pair);
345 - intentService.submit(pair.h2hIntent());
346 - }
347 - }
348 -
349 - private void uninstallIntents(Collection<HostPair> toRemove) {
350 - for (HostPair pair : toRemove) {
351 - installed.remove(pair);
352 - uninstalledOrWithdrawn.add(pair);
353 - intentService.withdraw(pair.h2hIntent());
354 - }
355 - }
356 -
357 - /**
358 - * Take everything and remove it all.
359 - */
360 - private void cleanUp() {
361 - List<HostPair> allPairs = Lists.newArrayList(installed);
362 - allPairs.addAll(uninstalledOrWithdrawn);
363 - for (HostPair pair : allPairs) {
364 - intentService.withdraw(pair.h2hIntent());
365 - }
366 - }
367 -
368 -
369 - private Set<HostPair> buildPairs(Set<Host> hosts) {
370 - Set<HostPair> pairs = Sets.newHashSet();
371 - Iterator<Host> it = Sets.newHashSet(hosts).iterator();
372 - while (it.hasNext()) {
373 - Host src = it.next();
374 - it.remove();
375 - for (Host dst : hosts) {
376 - pairs.add(new HostPair(src, dst));
377 - }
378 - }
379 - return pairs;
380 - }
381 -
382 - private Set<Host> pruneHostsByMasterShip() {
383 - return FluentIterable.from(hosts)
384 - .filter(hasLocalMaster())
385 - .toSet();
386 -
387 - }
388 -
389 - private Predicate<? super Host> hasLocalMaster() {
390 - return new Predicate<Host>() {
391 - @Override
392 - public boolean apply(Host host) {
393 - return mastershipService.getLocalRole(
394 - host.location().deviceId()).equals(MastershipRole.MASTER);
395 - }
396 - };
397 - }
398 -
399 -
400 - /**
401 - * Simple class representing a pair of hosts and precomputes the associated
402 - * h2h intent.
403 - */
404 - private class HostPair {
405 -
406 - private final Host src;
407 - private final Host dst;
408 -
409 - private final TrafficSelector selector = DefaultTrafficSelector.emptySelector();
410 - private final TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
411 - private final List<Constraint> constraint = Lists.newArrayList();
412 - private final HostToHostIntent intent;
413 -
414 - public HostPair(Host src, Host dst) {
415 - this.src = src;
416 - this.dst = dst;
417 - this.intent = new HostToHostIntent(appId, src.id(), dst.id(),
418 - selector, treatment, constraint,
419 - Intent.DEFAULT_INTENT_PRIORITY);
420 - }
421 -
422 - public HostToHostIntent h2hIntent() {
423 - return intent;
424 - }
425 -
426 - @Override
427 - public boolean equals(Object o) {
428 - if (this == o) {
429 - return true;
430 - }
431 - if (o == null || getClass() != o.getClass()) {
432 - return false;
433 - }
434 -
435 - HostPair hostPair = (HostPair) o;
436 -
437 - return Objects.equals(src, hostPair.src) &&
438 - Objects.equals(dst, hostPair.dst);
439 -
440 - }
441 -
442 - @Override
443 - public int hashCode() {
444 - return Objects.hash(src, dst);
445 - }
446 -
447 -
448 - }
449 -
450 - }
451 -
452 - /**
453 - * Remove anything that is running and clear it all out.
454 - */
455 - private class UnInstaller implements Runnable {
456 - @Override
457 - public void run() {
458 - if (!existingIntents.isEmpty()) {
459 - clearExistingIntents();
460 - }
461 -
462 - if (installWorker != null && !installWorker.isShutdown()) {
463 - shutdownAndAwaitTermination(installWorker);
464 - randomInstaller.shutdown();
465 - }
466 - }
467 -
468 - private void clearExistingIntents() {
469 - for (Intent i : existingIntents) {
470 - intentService.withdraw(i);
471 - }
472 - existingIntents.clear();
473 - }
474 - }
475 -
476 - /**
477 - * Shutdown a pool cleanly if possible.
478 - *
479 - * @param pool an executorService
480 - */
481 - private void shutdownAndAwaitTermination(ExecutorService pool) {
482 - pool.shutdown(); // Disable new tasks from being submitted
483 - try {
484 - // Wait a while for existing tasks to terminate
485 - if (!pool.awaitTermination(10, TimeUnit.SECONDS)) {
486 - pool.shutdownNow(); // Cancel currently executing tasks
487 - // Wait a while for tasks to respond to being cancelled
488 - if (!pool.awaitTermination(10, TimeUnit.SECONDS)) {
489 - log.error("Pool did not terminate");
490 - }
491 - }
492 - } catch (Exception ie) {
493 - // (Re-)Cancel if current thread also interrupted
494 - pool.shutdownNow();
495 - // Preserve interrupt status
496 - Thread.currentThread().interrupt();
497 - }
498 - }
499 -
500 - private class FlowTest implements Callable<JsonNode> {
501 - private final int flowPerDevice;
502 - private final int neighbours;
503 - private final boolean remove;
504 - private FlowRuleOperations.Builder adds;
505 - private FlowRuleOperations.Builder removes;
506 -
507 - public FlowTest(int flowsPerDevice, int neighbours, boolean remove) {
508 - this.flowPerDevice = flowsPerDevice;
509 - this.neighbours = neighbours;
510 - this.remove = remove;
511 - prepareInstallation();
512 - }
513 -
514 - private void prepareInstallation() {
515 - Set<ControllerNode> instances = Sets.newHashSet(clusterService.getNodes());
516 - instances.remove(clusterService.getLocalNode());
517 - Set<NodeId> acceptableNodes = Sets.newHashSet();
518 - if (neighbours >= instances.size()) {
519 - instances.forEach(instance -> acceptableNodes.add(instance.id()));
520 - } else {
521 - Iterator<ControllerNode> nodes = instances.iterator();
522 - for (int i = neighbours; i > 0; i--) {
523 - acceptableNodes.add(nodes.next().id());
524 - }
525 - }
526 - acceptableNodes.add(clusterService.getLocalNode().id());
527 -
528 - Set<Device> devices = Sets.newHashSet();
529 - for (Device dev : deviceService.getDevices()) {
530 - if (acceptableNodes.contains(
531 - mastershipService.getMasterFor(dev.id()))) {
532 - devices.add(dev);
533 - }
534 - }
535 -
536 - TrafficTreatment treatment = DefaultTrafficTreatment.builder()
537 - .setOutput(PortNumber.portNumber(RandomUtils.nextInt())).build();
538 - TrafficSelector.Builder sbuilder;
539 - FlowRuleOperations.Builder rules = FlowRuleOperations.builder();
540 - FlowRuleOperations.Builder remove = FlowRuleOperations.builder();
541 -
542 - for (Device d : devices) {
543 - for (int i = 0; i < this.flowPerDevice; i++) {
544 - sbuilder = DefaultTrafficSelector.builder();
545 -
546 - sbuilder.matchEthSrc(MacAddress.valueOf(RandomUtils.nextInt() * i))
547 - .matchEthDst(MacAddress.valueOf((Integer.MAX_VALUE - i) * RandomUtils.nextInt()));
548 -
549 -
550 - int randomPriority = RandomUtils.nextInt();
551 - DefaultFlowRule f = new DefaultFlowRule(d.id(), sbuilder.build(), treatment,
552 - randomPriority, appId, 10, false);
553 - rules.add(f);
554 - remove.remove(f);
555 -
556 - }
557 - }
558 -
559 - this.adds = rules;
560 - this.removes = remove;
561 - }
562 -
563 - @Override
564 - public JsonNode call() throws Exception {
565 - ObjectNode node = mapper.createObjectNode();
566 - CountDownLatch latch = new CountDownLatch(1);
567 - flowService.apply(adds.build(new FlowRuleOperationsContext() {
568 -
569 - private final Stopwatch timer = Stopwatch.createStarted();
570 -
571 - @Override
572 - public void onSuccess(FlowRuleOperations ops) {
573 -
574 - long elapsed = timer.elapsed(TimeUnit.MILLISECONDS);
575 - node.put("elapsed", elapsed);
576 -
577 -
578 - latch.countDown();
579 - }
580 - }));
581 -
582 - latch.await(10, TimeUnit.SECONDS);
583 - if (this.remove) {
584 - flowService.apply(removes.build());
585 - }
586 - return node;
587 - }
588 - }
589 -}
590 -
591 -
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.demo;
17 -
18 -import com.fasterxml.jackson.databind.JsonNode;
19 -import com.fasterxml.jackson.databind.ObjectMapper;
20 -import org.onlab.rest.BaseResource;
21 -
22 -import javax.ws.rs.Consumes;
23 -import javax.ws.rs.GET;
24 -import javax.ws.rs.POST;
25 -import javax.ws.rs.Path;
26 -import javax.ws.rs.Produces;
27 -import javax.ws.rs.core.MediaType;
28 -import javax.ws.rs.core.Response;
29 -import java.io.IOException;
30 -import java.io.InputStream;
31 -import java.util.Optional;
32 -
33 -/**
34 - * Rest API for demos.
35 - */
36 -@Path("intents")
37 -public class DemoResource extends BaseResource {
38 -
39 -
40 -
41 - @POST
42 - @Path("flowTest")
43 - @Consumes(MediaType.APPLICATION_JSON)
44 - @Produces(MediaType.APPLICATION_JSON)
45 - public Response flowTest(InputStream input) throws IOException {
46 - ObjectMapper mapper = new ObjectMapper();
47 - JsonNode cfg = mapper.readTree(input);
48 - DemoAPI demo = get(DemoAPI.class);
49 - return Response.ok(demo.flowTest(Optional.ofNullable(cfg)).toString()).build();
50 - }
51 -
52 - @POST
53 - @Path("setup")
54 - @Consumes(MediaType.APPLICATION_JSON)
55 - @Produces(MediaType.APPLICATION_JSON)
56 - public Response setup(InputStream input) throws IOException {
57 - ObjectMapper mapper = new ObjectMapper();
58 - JsonNode cfg = mapper.readTree(input);
59 - if (!cfg.has("type")) {
60 - return Response.status(Response.Status.BAD_REQUEST)
61 - .entity("Expected type field containing either mesh or random.").build();
62 - }
63 -
64 -
65 - DemoAPI.InstallType type = DemoAPI.InstallType.valueOf(
66 - cfg.get("type").asText().toUpperCase());
67 - DemoAPI demo = get(DemoAPI.class);
68 - demo.setup(type, Optional.ofNullable(cfg.get("runParams")));
69 -
70 - return Response.ok(mapper.createObjectNode().toString()).build();
71 - }
72 -
73 - @GET
74 - @Path("teardown")
75 - @Produces(MediaType.APPLICATION_JSON)
76 - public Response tearDown() throws IOException {
77 - ObjectMapper mapper = new ObjectMapper();
78 - DemoAPI demo = get(DemoAPI.class);
79 - demo.tearDown();
80 - return Response.ok(mapper.createObjectNode().toString()).build();
81 - }
82 -
83 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -
17 -/**
18 - * Demo applications live here.
19 - */
20 -package org.onosproject.demo;
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2014 Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
18 - xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
19 - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
20 - id="ONOS" version="2.5">
21 - <display-name>ONOS DEMO APP API v1.0</display-name>
22 -
23 - <servlet>
24 - <servlet-name>JAX-RS Service</servlet-name>
25 - <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
26 - <init-param>
27 - <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
28 - <param-value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value>
29 - </init-param>
30 - <init-param>
31 - <param-name>com.sun.jersey.config.property.classnames</param-name>
32 - <param-value>
33 - org.onosproject.demo.DemoResource
34 - </param-value>
35 - </init-param>
36 - <load-on-startup>1</load-on-startup>
37 - </servlet>
38 -
39 - <servlet-mapping>
40 - <servlet-name>JAX-RS Service</servlet-name>
41 - <url-pattern>/*</url-pattern>
42 - </servlet-mapping>
43 -
44 -</web-app>
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2014 Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -
18 -<project xmlns="http://maven.apache.org/POM/4.0.0"
19 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
21 - <modelVersion>4.0.0</modelVersion>
22 -
23 - <parent>
24 - <groupId>org.onosproject</groupId>
25 - <artifactId>onos-apps</artifactId>
26 - <version>1.2.0-SNAPSHOT</version>
27 - <relativePath>../pom.xml</relativePath>
28 - </parent>
29 -
30 - <artifactId>onos-app-election</artifactId>
31 - <packaging>bundle</packaging>
32 -
33 - <description>ONOS app leadership election test</description>
34 -
35 - <dependencies>
36 -
37 - <dependency>
38 - <groupId>org.onosproject</groupId>
39 - <artifactId>onos-api</artifactId>
40 - <version>${project.version}</version>
41 - <scope>test</scope>
42 - <classifier>tests</classifier>
43 - </dependency>
44 -
45 - <dependency>
46 - <groupId>org.onosproject</groupId>
47 - <artifactId>onos-cli</artifactId>
48 - <version>${project.version}</version>
49 - </dependency>
50 -
51 - <dependency>
52 - <groupId>org.osgi</groupId>
53 - <artifactId>org.osgi.core</artifactId>
54 - </dependency>
55 - <dependency>
56 - <groupId>org.apache.karaf.shell</groupId>
57 - <artifactId>org.apache.karaf.shell.console</artifactId>
58 - </dependency>
59 -
60 - </dependencies>
61 -
62 -</project>
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.election;
17 -
18 -import static org.slf4j.LoggerFactory.getLogger;
19 -
20 -import org.apache.felix.scr.annotations.Activate;
21 -import org.apache.felix.scr.annotations.Component;
22 -import org.apache.felix.scr.annotations.Deactivate;
23 -import org.apache.felix.scr.annotations.Reference;
24 -import org.apache.felix.scr.annotations.ReferenceCardinality;
25 -import org.onosproject.cluster.ClusterService;
26 -import org.onosproject.core.CoreService;
27 -import org.onosproject.cluster.ControllerNode;
28 -import org.onosproject.cluster.LeadershipEvent;
29 -import org.onosproject.cluster.LeadershipEventListener;
30 -import org.onosproject.cluster.LeadershipService;
31 -import org.onosproject.core.ApplicationId;
32 -
33 -import org.slf4j.Logger;
34 -
35 -
36 -/**
37 - * Simple application to test leadership election.
38 - */
39 -@Component(immediate = true)
40 -public class ElectionTest {
41 -
42 - private final Logger log = getLogger(getClass());
43 -
44 - private static final String ELECTION_APP = "org.onosproject.election";
45 - private ApplicationId appId;
46 -
47 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
48 - protected ClusterService clusterService;
49 -
50 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
51 - protected CoreService coreService;
52 -
53 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
54 - protected LeadershipService leadershipService;
55 -
56 - private LeadershipEventListener leadershipEventListener =
57 - new InnerLeadershipEventListener();
58 -
59 - private ControllerNode localControllerNode;
60 -
61 -
62 - @Activate
63 - protected void activate() {
64 - log.info("Election-test app started");
65 -
66 - appId = coreService.registerApplication(ELECTION_APP);
67 -
68 - localControllerNode = clusterService.getLocalNode();
69 -
70 - leadershipService.addListener(leadershipEventListener);
71 - leadershipService.runForLeadership(appId.name());
72 - }
73 -
74 - @Deactivate
75 - protected void deactivate() {
76 -
77 - leadershipService.withdraw(appId.name());
78 - leadershipService.removeListener(leadershipEventListener);
79 -
80 - log.info("Election-test app Stopped");
81 - }
82 -
83 - /**
84 - * A listener for Leadership Events.
85 - */
86 - private class InnerLeadershipEventListener
87 - implements LeadershipEventListener {
88 -
89 - @Override
90 - public void event(LeadershipEvent event) {
91 -
92 -
93 - if (!event.subject().topic().equals(appId.name())) {
94 - return; // Not our topic: ignore
95 - }
96 -
97 - //only log what pertains to us
98 - log.debug("Leadership Event: time = {} type = {} event = {}",
99 - event.time(), event.type(), event);
100 -
101 - if (!event.subject().leader().equals(
102 - localControllerNode.id())) {
103 - return; // The event is not about this instance: ignore
104 - }
105 -
106 - switch (event.type()) {
107 - case LEADER_ELECTED:
108 - log.info("Election-test app leader elected");
109 - break;
110 - case LEADER_BOOTED:
111 - log.info("Election-test app lost election");
112 - break;
113 - case LEADER_REELECTED:
114 - log.debug("Election-test app was re-elected");
115 - break;
116 - default:
117 - break;
118 - }
119 - }
120 - }
121 -
122 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.election.cli;
17 -
18 -import org.onosproject.cluster.NodeId;
19 -import org.apache.karaf.shell.commands.Command;
20 -import org.onosproject.cli.AbstractShellCommand;
21 -import org.onosproject.cluster.LeadershipService;
22 -
23 -/**
24 - * CLI command to get the current leader for the Election test application.
25 - */
26 -@Command(scope = "onos", name = "election-test-leader",
27 - description = "Get the current leader for the Election test application")
28 -public class ElectionTestLeaderCommand extends AbstractShellCommand {
29 -
30 - private NodeId leader;
31 - private static final String ELECTION_APP = "org.onosproject.election";
32 -
33 - @Override
34 - protected void execute() {
35 - LeadershipService service = get(LeadershipService.class);
36 -
37 - //print the current leader
38 - leader = service.getLeader(ELECTION_APP);
39 - printLeader(leader);
40 - }
41 -
42 - /**
43 - * Prints the leader.
44 - *
45 - * @param leader the leader to print
46 - */
47 - private void printLeader(NodeId leader) {
48 - if (leader != null) {
49 - print("The current leader for the Election app is %s.", leader);
50 - } else {
51 - print("There is currently no leader elected for the Election app");
52 - }
53 - }
54 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.election.cli;
17 -
18 -import org.apache.karaf.shell.commands.Command;
19 -import org.onosproject.cli.AbstractShellCommand;
20 -import org.onosproject.cluster.LeadershipService;
21 -
22 -/**
23 - * CLI command to run for leadership of the Election test application.
24 - */
25 -@Command(scope = "onos", name = "election-test-run",
26 - description = "Run for leader of the Election test application")
27 -public class ElectionTestRunCommand extends AbstractShellCommand {
28 -
29 - private static final String ELECTION_APP = "org.onosproject.election";
30 -
31 - @Override
32 - protected void execute() {
33 - LeadershipService service = get(LeadershipService.class);
34 -
35 - service.runForLeadership(ELECTION_APP);
36 - //print the current leader
37 - print("Entering leadership elections for the Election app.");
38 - }
39 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.election.cli;
17 -
18 -import org.apache.karaf.shell.commands.Command;
19 -import org.onosproject.cli.AbstractShellCommand;
20 -import org.onosproject.cluster.LeadershipService;
21 -
22 -/**
23 - * CLI command to withdraw the local node from leadership election for
24 - * the Election test application.
25 - */
26 -@Command(scope = "onos", name = "election-test-withdraw",
27 - description = "Withdraw node from leadership election for the Election test application")
28 -public class ElectionTestWithdrawCommand extends AbstractShellCommand {
29 -
30 - private static final String ELECTION_APP = "org.onosproject.election";
31 -
32 - @Override
33 - protected void execute() {
34 - LeadershipService service = get(LeadershipService.class);
35 -
36 - service.withdraw(ELECTION_APP);
37 - //print the current leader
38 - print("Withdrawing from leadership elections for the Election app.");
39 - }
40 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -
17 -/**
18 - * Election test command-line handlers.
19 - */
20 -package org.onosproject.election.cli;
...\ No newline at end of file ...\ No newline at end of file
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -
17 -/**
18 - * Sample application for use in various experiments.
19 - */
20 -package org.onosproject.election;
1 -<!--
2 - ~ Copyright 2014 Open Networking Laboratory
3 - ~
4 - ~ Licensed under the Apache License, Version 2.0 (the "License");
5 - ~ you may not use this file except in compliance with the License.
6 - ~ You may obtain a copy of the License at
7 - ~
8 - ~ http://www.apache.org/licenses/LICENSE-2.0
9 - ~
10 - ~ Unless required by applicable law or agreed to in writing, software
11 - ~ distributed under the License is distributed on an "AS IS" BASIS,
12 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - ~ See the License for the specific language governing permissions and
14 - ~ limitations under the License.
15 - -->
16 -<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
17 -
18 - <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
19 - <command>
20 - <action class="org.onosproject.election.cli.ElectionTestLeaderCommand"/>
21 - </command>
22 - <command>
23 - <action class="org.onosproject.election.cli.ElectionTestRunCommand"/>
24 - </command>
25 - <command>
26 - <action class="org.onosproject.election.cli.ElectionTestWithdrawCommand"/>
27 - </command>
28 - </command-bundle>
29 -
30 -</blueprint>
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2014 Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -<project xmlns="http://maven.apache.org/POM/4.0.0"
18 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
20 - <modelVersion>4.0.0</modelVersion>
21 -
22 - <parent>
23 - <groupId>org.onosproject</groupId>
24 - <artifactId>onos-apps</artifactId>
25 - <version>1.1.0-SNAPSHOT</version>
26 - <relativePath>../pom.xml</relativePath>
27 - </parent>
28 -
29 - <artifactId>onos-app-foo</artifactId>
30 - <packaging>bundle</packaging>
31 -
32 - <description>ONOS application for miscellaneous experiments</description>
33 -
34 - <dependencies>
35 - <dependency>
36 - <groupId>org.onosproject</groupId>
37 - <artifactId>onos-cli</artifactId>
38 - <version>${project.version}</version>
39 - </dependency>
40 - <dependency>
41 - <groupId>org.onosproject</groupId>
42 - <artifactId>onlab-osgi</artifactId>
43 - <version>${project.version}</version>
44 - </dependency>
45 - <dependency>
46 - <groupId>org.onosproject</groupId>
47 - <artifactId>onlab-nio</artifactId>
48 - <version>${project.version}</version>
49 - </dependency>
50 - <dependency>
51 - <groupId>org.onosproject</groupId>
52 - <artifactId>onlab-netty</artifactId>
53 - <version>${project.version}</version>
54 - </dependency>
55 - <dependency>
56 - <groupId>org.apache.karaf.shell</groupId>
57 - <artifactId>org.apache.karaf.shell.console</artifactId>
58 - </dependency>
59 - <dependency>
60 - <groupId>org.onosproject</groupId>
61 - <artifactId>onlab-misc</artifactId>
62 - </dependency>
63 - <dependency>
64 - <groupId>com.google.guava</groupId>
65 - <artifactId>guava</artifactId>
66 - </dependency>
67 - <dependency>
68 - <groupId>org.osgi</groupId>
69 - <artifactId>org.osgi.core</artifactId>
70 - </dependency>
71 - </dependencies>
72 -</project>
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.foo;
17 -
18 -import static java.util.concurrent.Executors.newScheduledThreadPool;
19 -import static org.onlab.util.Tools.namedThreads;
20 -import static org.slf4j.LoggerFactory.getLogger;
21 -
22 -import java.nio.ByteBuffer;
23 -import java.util.concurrent.ScheduledExecutorService;
24 -//import java.util.concurrent.TimeUnit;
25 -
26 -
27 -
28 -import org.apache.felix.scr.annotations.Activate;
29 -import org.apache.felix.scr.annotations.Component;
30 -import org.apache.felix.scr.annotations.Deactivate;
31 -import org.apache.felix.scr.annotations.Reference;
32 -import org.apache.felix.scr.annotations.ReferenceCardinality;
33 -import org.onosproject.cluster.ClusterEvent;
34 -import org.onosproject.cluster.ClusterEventListener;
35 -import org.onosproject.cluster.ClusterService;
36 -import org.onosproject.cluster.NodeId;
37 -import org.onosproject.mastership.MastershipEvent;
38 -import org.onosproject.mastership.MastershipListener;
39 -import org.onosproject.mastership.MastershipService;
40 -import org.onosproject.net.device.DeviceEvent;
41 -import org.onosproject.net.device.DeviceListener;
42 -import org.onosproject.net.device.DeviceService;
43 -import org.onosproject.net.intent.IntentEvent;
44 -import org.onosproject.net.intent.IntentListener;
45 -import org.onosproject.net.intent.IntentService;
46 -import org.onosproject.store.service.DatabaseAdminService;
47 -import org.onosproject.store.service.DatabaseException;
48 -import org.onosproject.store.service.DatabaseService;
49 -import org.onosproject.store.service.Lock;
50 -import org.onosproject.store.service.LockService;
51 -import org.onosproject.store.service.VersionedValue;
52 -import org.slf4j.Logger;
53 -
54 -/**
55 - * Playground app component.
56 - */
57 -@Component(immediate = true)
58 -public class FooComponent {
59 -
60 - private final Logger log = getLogger(getClass());
61 -
62 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
63 - protected ClusterService clusterService;
64 -
65 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
66 - protected DeviceService deviceService;
67 -
68 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
69 - protected IntentService intentService;
70 -
71 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
72 - protected MastershipService mastershipService;
73 -
74 - @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY)
75 - protected DatabaseAdminService dbAdminService;
76 -
77 - @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY)
78 - protected DatabaseService dbService;
79 -
80 - @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY)
81 - protected LockService lockService;
82 -
83 - private final ClusterEventListener clusterListener = new InnerClusterListener();
84 - private final DeviceListener deviceListener = new InnerDeviceListener();
85 - private final IntentListener intentListener = new InnerIntentListener();
86 - private final MastershipListener mastershipListener = new InnerMastershipListener();
87 -
88 - private ScheduledExecutorService executor;
89 -
90 - @Activate
91 - public void activate() {
92 - executor = newScheduledThreadPool(4, namedThreads("foo-executor-%d"));
93 -
94 - clusterService.addListener(clusterListener);
95 - deviceService.addListener(deviceListener);
96 - intentService.addListener(intentListener);
97 - mastershipService.addListener(mastershipListener);
98 -
99 - if (dbService == null || dbAdminService == null) {
100 - log.info("Couldn't find DB service");
101 - } else {
102 - log.info("Found DB service");
103 - //longIncrementor();
104 - //lockUnlock();
105 - //executor.scheduleAtFixedRate(new LongIncrementor(), 1, 10, TimeUnit.SECONDS);
106 - //executor.scheduleAtFixedRate(new LongIncrementor(), 1, 10, TimeUnit.SECONDS);
107 - }
108 - log.info("Started");
109 - }
110 -
111 - @Deactivate
112 - public void deactivate() {
113 - executor.shutdown();
114 - clusterService.removeListener(clusterListener);
115 - deviceService.removeListener(deviceListener);
116 - intentService.removeListener(intentListener);
117 - mastershipService.removeListener(mastershipListener);
118 - log.info("Stopped");
119 - }
120 -
121 - private class InnerClusterListener implements ClusterEventListener {
122 - @Override
123 - public void event(ClusterEvent event) {
124 - log.info("WOOOOT! {}", event);
125 - }
126 - }
127 -
128 - private class InnerDeviceListener implements DeviceListener {
129 - @Override
130 - public void event(DeviceEvent event) {
131 - log.info("YEEEEHAAAAW! {}", event);
132 - }
133 - }
134 -
135 - private class InnerIntentListener implements IntentListener {
136 - @Override
137 - public void event(IntentEvent event) {
138 - String message;
139 - if (event.type() == IntentEvent.Type.INSTALL_REQ) {
140 - message = "WOW! It looks like someone has some intentions: {}";
141 - } else if (event.type() == IntentEvent.Type.INSTALLED) {
142 - message = "AWESOME! So far things are going great: {}";
143 - } else if (event.type() == IntentEvent.Type.WITHDRAWN) {
144 - message = "HMMM! Ambitions are fading apparently: {}";
145 - } else {
146 - message = "CRAP!!! Things are not turning out as intended: {}";
147 - }
148 - log.info(message, event.subject());
149 - }
150 - }
151 -
152 - private class InnerMastershipListener implements MastershipListener {
153 - @Override
154 - public void event(MastershipEvent event) {
155 - final NodeId myId = clusterService.getLocalNode().id();
156 - if (myId.equals(event.roleInfo().master())) {
157 - log.info("I have control/I wish you luck {}", event);
158 - } else {
159 - log.info("you have control {}", event);
160 - }
161 - }
162 - }
163 -
164 - private void lockUnlock() throws InterruptedException {
165 - try {
166 - final String locksTable = "onos-locks";
167 -
168 - if (!dbAdminService.listTables().contains(locksTable)) {
169 - dbAdminService.createTable(locksTable, 10000);
170 - }
171 - Lock lock = lockService.create("foo-bar");
172 - log.info("Requesting lock");
173 - lock.lock(10000);
174 - //try {
175 - //Thread.sleep(5000);
176 - //} catch (InterruptedException e) {
177 - //e.printStackTrace();
178 - //}
179 - log.info("Acquired Lock");
180 - log.info("Do I have the lock: {} ", lock.isLocked());
181 - //lock.unlock();
182 - log.info("Do I have the lock: {} ", lock.isLocked());
183 - } finally {
184 - log.info("Done");
185 - }
186 - }
187 -
188 - private void longIncrementor() {
189 - try {
190 - final String someTable = "admin";
191 - final String someKey = "long";
192 -
193 - if (!dbAdminService.listTables().contains(someTable)) {
194 - dbAdminService.createTable(someTable);
195 - }
196 -
197 - VersionedValue vv = dbService.get(someTable, someKey);
198 - if (vv == null) {
199 - ByteBuffer zero = ByteBuffer.allocate(Long.BYTES).putLong(0);
200 - if (dbService.putIfAbsent(someTable, someKey, zero.array())) {
201 - log.info("Wrote initial value");
202 - vv = dbService.get(someTable, someKey);
203 - } else {
204 - log.info("Concurrent write detected.");
205 - // concurrent write detected, read and fall through
206 - vv = dbService.get(someTable, someKey);
207 - if (vv == null) {
208 - log.error("Shouldn't reach here");
209 - }
210 - }
211 - }
212 - int retry = 1;
213 -
214 - do {
215 - if (vv == null) {
216 - log.error("Shouldn't reach here - value is null");
217 - break;
218 - }
219 - ByteBuffer prev = ByteBuffer.wrap(vv.value());
220 - long next = prev.getLong() + 1;
221 - byte[] newValue = ByteBuffer.allocate(Long.BYTES).putLong(next).array();
222 - if (dbService.putIfVersionMatches(someTable, someKey, newValue, vv.version())) {
223 - log.info("Write success. New value: {}", next);
224 - break;
225 - } else {
226 - log.info("Write failed retrying.....{}", retry);
227 - vv = dbService.get(someTable, someKey);
228 - if (vv == null) {
229 - log.error("Shouldn't reach here");
230 - }
231 - }
232 - } while (retry++ < 5);
233 - } catch (DatabaseException e) {
234 - log.debug("DB Exception thrown {}", e.getMessage());
235 - } catch (Exception e) {
236 - log.error("Exception thrown", e);
237 - }
238 - }
239 -
240 - private final class LongIncrementor implements Runnable {
241 -
242 - @Override
243 - public void run() {
244 - longIncrementor();
245 - }
246 -
247 - }
248 -}
249 -
250 -
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.foo;
17 -
18 -import com.google.common.collect.Lists;
19 -import org.onlab.nio.IOLoop;
20 -import org.onlab.nio.MessageStream;
21 -import org.onlab.util.Counter;
22 -import org.slf4j.Logger;
23 -import org.slf4j.LoggerFactory;
24 -
25 -import java.io.IOException;
26 -import java.net.InetAddress;
27 -import java.net.InetSocketAddress;
28 -import java.net.SocketAddress;
29 -import java.nio.channels.ByteChannel;
30 -import java.nio.channels.SelectionKey;
31 -import java.nio.channels.SocketChannel;
32 -import java.text.DecimalFormat;
33 -import java.util.ArrayList;
34 -import java.util.List;
35 -import java.util.concurrent.ExecutionException;
36 -import java.util.concurrent.ExecutorService;
37 -import java.util.concurrent.Executors;
38 -import java.util.concurrent.FutureTask;
39 -import java.util.concurrent.Semaphore;
40 -import java.util.concurrent.TimeUnit;
41 -import java.util.concurrent.TimeoutException;
42 -
43 -import static java.lang.String.format;
44 -import static java.lang.System.nanoTime;
45 -import static java.lang.System.out;
46 -import static org.onosproject.foo.IOLoopTestServer.PORT;
47 -import static org.onlab.util.Tools.delay;
48 -import static org.onlab.util.Tools.namedThreads;
49 -
50 -/**
51 - * Auxiliary test fixture to measure speed of NIO-based channels.
52 - */
53 -public class IOLoopTestClient {
54 -
55 - private static Logger log = LoggerFactory.getLogger(IOLoopTestClient.class);
56 -
57 - private final InetAddress ip;
58 - private final int port;
59 - private final int msgCount;
60 - private final int msgLength;
61 -
62 - private final List<CustomIOLoop> iloops = new ArrayList<>();
63 - private final ExecutorService ipool;
64 - private final ExecutorService wpool;
65 -
66 - Counter messages;
67 - Counter bytes;
68 - long latencyTotal = 0;
69 - long latencyCount = 0;
70 -
71 -
72 - /**
73 - * Main entry point to launch the client.
74 - *
75 - * @param args command-line arguments
76 - * @throws java.io.IOException if unable to connect to server
77 - * @throws InterruptedException if latch wait gets interrupted
78 - * @throws java.util.concurrent.ExecutionException if wait gets interrupted
79 - * @throws java.util.concurrent.TimeoutException if timeout occurred while waiting for completion
80 - */
81 - public static void main(String[] args)
82 - throws IOException, InterruptedException, ExecutionException, TimeoutException {
83 - startStandalone(args);
84 -
85 - System.exit(0);
86 - }
87 -
88 - /*
89 - * Starts a standalone IO loop test client.
90 - *
91 - * @param args command-line arguments
92 - */
93 - public static void startStandalone(String[] args)
94 - throws IOException, InterruptedException, ExecutionException, TimeoutException {
95 - InetAddress ip = InetAddress.getByName(args.length > 0 ? args[0] : "127.0.0.1");
96 - int wc = args.length > 1 ? Integer.parseInt(args[1]) : 6;
97 - int mc = args.length > 2 ? Integer.parseInt(args[2]) : 50 * 1000000;
98 - int ml = args.length > 3 ? Integer.parseInt(args[3]) : 128;
99 - int to = args.length > 4 ? Integer.parseInt(args[4]) : 60;
100 -
101 - log.info("Setting up client with {} workers sending {} {}-byte messages to {} server... ",
102 - wc, mc, ml, ip);
103 - IOLoopTestClient client = new IOLoopTestClient(ip, wc, mc, ml, PORT);
104 -
105 - client.start();
106 - delay(500);
107 -
108 - client.await(to);
109 - client.report();
110 - }
111 -
112 - /**
113 - * Creates a speed client.
114 - *
115 - * @param ip ip address of server
116 - * @param wc worker count
117 - * @param mc message count to send per client
118 - * @param ml message length in bytes
119 - * @param port socket port
120 - * @throws java.io.IOException if unable to create IO loops
121 - */
122 - public IOLoopTestClient(InetAddress ip, int wc, int mc, int ml, int port) throws IOException {
123 - this.ip = ip;
124 - this.port = port;
125 - this.msgCount = mc;
126 - this.msgLength = ml;
127 - this.wpool = Executors.newFixedThreadPool(wc, namedThreads("worker"));
128 - this.ipool = Executors.newFixedThreadPool(wc, namedThreads("io-loop"));
129 -
130 - for (int i = 0; i < wc; i++) {
131 - iloops.add(new CustomIOLoop());
132 - }
133 - }
134 -
135 - /**
136 - * Starts the client workers.
137 - *
138 - * @throws java.io.IOException if unable to open connection
139 - */
140 - public void start() throws IOException {
141 - messages = new Counter();
142 - bytes = new Counter();
143 -
144 - // First start up all the IO loops
145 - for (CustomIOLoop l : iloops) {
146 - ipool.execute(l);
147 - }
148 -
149 - // Wait for all of them to get going
150 - for (CustomIOLoop l : iloops) {
151 - l.awaitStart(1000);
152 - }
153 -
154 - // ... and Next open all connections; one-per-loop
155 - for (CustomIOLoop l : iloops) {
156 - openConnection(l);
157 - }
158 - }
159 -
160 -
161 - /**
162 - * Initiates open connection request and registers the pending socket
163 - * channel with the given IO loop.
164 - *
165 - * @param loop loop with which the channel should be registered
166 - * @throws java.io.IOException if the socket could not be open or connected
167 - */
168 - private void openConnection(CustomIOLoop loop) throws IOException {
169 - SocketAddress sa = new InetSocketAddress(ip, port);
170 - SocketChannel ch = SocketChannel.open();
171 - ch.configureBlocking(false);
172 - loop.connectStream(ch);
173 - ch.connect(sa);
174 - }
175 -
176 -
177 - /**
178 - * Waits for the client workers to complete.
179 - *
180 - * @param secs timeout in seconds
181 - * @throws java.util.concurrent.ExecutionException if execution failed
182 - * @throws InterruptedException if interrupt occurred while waiting
183 - * @throws java.util.concurrent.TimeoutException if timeout occurred
184 - */
185 - public void await(int secs) throws InterruptedException,
186 - ExecutionException, TimeoutException {
187 - for (CustomIOLoop l : iloops) {
188 - if (l.worker.task != null) {
189 - l.worker.task.get(secs, TimeUnit.SECONDS);
190 - latencyTotal += l.latencyTotal;
191 - latencyCount += l.latencyCount;
192 - }
193 - }
194 - messages.freeze();
195 - bytes.freeze();
196 - }
197 -
198 - /**
199 - * Reports on the accumulated throughput and latency.
200 - */
201 - public void report() {
202 - DecimalFormat f = new DecimalFormat("#,##0");
203 - out.println(format("Client: %s messages; %s bytes; %s mps; %s MBs; %s ns latency",
204 - f.format(messages.total()), f.format(bytes.total()),
205 - f.format(messages.throughput()),
206 - f.format(bytes.throughput() / (1024 * msgLength)),
207 - f.format(latencyTotal / latencyCount)));
208 - }
209 -
210 -
211 - // Loop for transfer of fixed-length messages
212 - private class CustomIOLoop extends IOLoop<TestMessage, TestMessageStream> {
213 -
214 - Worker worker = new Worker();
215 - long latencyTotal = 0;
216 - long latencyCount = 0;
217 -
218 -
219 - public CustomIOLoop() throws IOException {
220 - super(500);
221 - }
222 -
223 -
224 - @Override
225 - protected TestMessageStream createStream(ByteChannel channel) {
226 - return new TestMessageStream(msgLength, channel, this);
227 - }
228 -
229 - @Override
230 - protected synchronized void removeStream(MessageStream<TestMessage> stream) {
231 - super.removeStream(stream);
232 -
233 - messages.add(stream.messagesIn().total());
234 - bytes.add(stream.bytesIn().total());
235 - stream.messagesOut().reset();
236 - stream.bytesOut().reset();
237 - }
238 -
239 - @Override
240 - protected void processMessages(List<TestMessage> messages,
241 - MessageStream<TestMessage> stream) {
242 - for (TestMessage message : messages) {
243 - // TODO: summarize latency data better
244 - latencyTotal += nanoTime() - message.requestorTime();
245 - latencyCount++;
246 - }
247 - worker.release(messages.size());
248 - }
249 -
250 - @Override
251 - protected void connect(SelectionKey key) throws IOException {
252 - super.connect(key);
253 - TestMessageStream b = (TestMessageStream) key.attachment();
254 - Worker w = ((CustomIOLoop) b.loop()).worker;
255 - w.pump(b);
256 - }
257 -
258 - }
259 -
260 - /**
261 - * Auxiliary worker to connect and pump batched messages using blocking I/O.
262 - */
263 - private class Worker implements Runnable {
264 -
265 - private static final int BATCH_SIZE = 10;
266 - private static final int PERMITS = 2 * BATCH_SIZE;
267 -
268 - private TestMessageStream stream;
269 - private FutureTask<Worker> task;
270 -
271 - // Stuff to throttle pump
272 - private final Semaphore semaphore = new Semaphore(PERMITS);
273 - private int msgWritten;
274 -
275 - void pump(TestMessageStream stream) {
276 - this.stream = stream;
277 - task = new FutureTask<>(this, this);
278 - wpool.execute(task);
279 - }
280 -
281 - @Override
282 - public void run() {
283 - try {
284 - log.info("Worker started...");
285 -
286 - while (msgWritten < msgCount) {
287 - int size = Math.min(BATCH_SIZE, msgCount - msgWritten);
288 - writeBatch(size);
289 - msgWritten += size;
290 - }
291 -
292 - // Now try to get all the permits back before sending poison pill
293 - semaphore.acquireUninterruptibly(PERMITS);
294 - stream.close();
295 -
296 - log.info("Worker done...");
297 -
298 - } catch (IOException e) {
299 - log.error("Worker unable to perform I/O", e);
300 - }
301 - }
302 -
303 -
304 - private void writeBatch(int size) throws IOException {
305 - // Build a batch of messages
306 - List<TestMessage> batch = Lists.newArrayListWithCapacity(size);
307 - for (int i = 0; i < size; i++) {
308 - batch.add(new TestMessage(msgLength, nanoTime(), 0,
309 - stream.padding()));
310 - }
311 - acquire(size);
312 - stream.write(batch);
313 - }
314 -
315 -
316 - // Release permits based on the specified number of message credits
317 - private void release(int permits) {
318 - semaphore.release(permits);
319 - }
320 -
321 - // Acquire permit for a single batch
322 - private void acquire(int permits) {
323 - semaphore.acquireUninterruptibly(permits);
324 - }
325 -
326 - }
327 -
328 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.foo;
17 -
18 -import com.google.common.collect.Lists;
19 -import org.onlab.nio.AcceptorLoop;
20 -import org.onlab.nio.IOLoop;
21 -import org.onlab.nio.MessageStream;
22 -import org.onlab.util.Counter;
23 -import org.slf4j.Logger;
24 -import org.slf4j.LoggerFactory;
25 -
26 -import java.io.IOException;
27 -import java.net.InetAddress;
28 -import java.net.InetSocketAddress;
29 -import java.net.Socket;
30 -import java.net.SocketAddress;
31 -import java.nio.channels.ByteChannel;
32 -import java.nio.channels.ServerSocketChannel;
33 -import java.nio.channels.SocketChannel;
34 -import java.text.DecimalFormat;
35 -import java.util.ArrayList;
36 -import java.util.List;
37 -import java.util.concurrent.ExecutorService;
38 -import java.util.concurrent.Executors;
39 -
40 -import static java.lang.String.format;
41 -import static java.lang.System.nanoTime;
42 -import static java.lang.System.out;
43 -import static org.onlab.util.Tools.delay;
44 -import static org.onlab.util.Tools.namedThreads;
45 -
46 -/**
47 - * Auxiliary test fixture to measure speed of NIO-based channels.
48 - */
49 -public class IOLoopTestServer {
50 -
51 - private static Logger log = LoggerFactory.getLogger(IOLoopTestServer.class);
52 -
53 - private static final int PRUNE_FREQUENCY = 1000;
54 -
55 - static final int PORT = 9876;
56 - static final long TIMEOUT = 1000;
57 -
58 - static final boolean SO_NO_DELAY = false;
59 - static final int SO_SEND_BUFFER_SIZE = 128 * 1024;
60 - static final int SO_RCV_BUFFER_SIZE = 128 * 1024;
61 -
62 - static final DecimalFormat FORMAT = new DecimalFormat("#,##0");
63 -
64 - private final AcceptorLoop aloop;
65 - private final ExecutorService apool = Executors.newSingleThreadExecutor(namedThreads("accept"));
66 -
67 - private final List<CustomIOLoop> iloops = new ArrayList<>();
68 - private final ExecutorService ipool;
69 -
70 - private final int workerCount;
71 - private final int msgLength;
72 - private int lastWorker = -1;
73 -
74 - Counter messages;
75 - Counter bytes;
76 -
77 - /**
78 - * Main entry point to launch the server.
79 - *
80 - * @param args command-line arguments
81 - * @throws java.io.IOException if unable to crate IO loops
82 - */
83 - public static void main(String[] args) throws IOException {
84 - startStandalone(args);
85 - System.exit(0);
86 - }
87 -
88 - /*
89 - * Starts a standalone IO loop test server.
90 - *
91 - * @param args command-line arguments
92 - */
93 - public static void startStandalone(String[] args) throws IOException {
94 - InetAddress ip = InetAddress.getByName(args.length > 0 ? args[0] : "127.0.0.1");
95 - int wc = args.length > 1 ? Integer.parseInt(args[1]) : 6;
96 - int ml = args.length > 2 ? Integer.parseInt(args[2]) : 128;
97 -
98 - log.info("Setting up the server with {} workers, {} byte messages on {}... ",
99 - wc, ml, ip);
100 - IOLoopTestServer server = new IOLoopTestServer(ip, wc, ml, PORT);
101 - server.start();
102 -
103 - // Start pruning clients and keep going until their number goes to 0.
104 - int remaining = -1;
105 - while (remaining == -1 || remaining > 0) {
106 - delay(PRUNE_FREQUENCY);
107 - int r = server.prune();
108 - remaining = remaining == -1 && r == 0 ? remaining : r;
109 - }
110 - server.stop();
111 - }
112 -
113 - /**
114 - * Creates a speed server.
115 - *
116 - * @param ip optional ip of the adapter where to bind
117 - * @param wc worker count
118 - * @param ml message length in bytes
119 - * @param port listen port
120 - * @throws java.io.IOException if unable to create IO loops
121 - */
122 - public IOLoopTestServer(InetAddress ip, int wc, int ml, int port) throws IOException {
123 - this.workerCount = wc;
124 - this.msgLength = ml;
125 - this.ipool = Executors.newFixedThreadPool(workerCount, namedThreads("io-loop"));
126 -
127 - this.aloop = new CustomAcceptLoop(new InetSocketAddress(ip, port));
128 - for (int i = 0; i < workerCount; i++) {
129 - iloops.add(new CustomIOLoop());
130 - }
131 - }
132 -
133 - /**
134 - * Start the server IO loops and kicks off throughput tracking.
135 - */
136 - public void start() {
137 - messages = new Counter();
138 - bytes = new Counter();
139 -
140 - for (CustomIOLoop l : iloops) {
141 - ipool.execute(l);
142 - }
143 - apool.execute(aloop);
144 -
145 - for (CustomIOLoop l : iloops) {
146 - l.awaitStart(TIMEOUT);
147 - }
148 - aloop.awaitStart(TIMEOUT);
149 - }
150 -
151 - /**
152 - * Stop the server IO loops and freezes throughput tracking.
153 - */
154 - public void stop() {
155 - aloop.shutdown();
156 - for (CustomIOLoop l : iloops) {
157 - l.shutdown();
158 - }
159 -
160 - for (CustomIOLoop l : iloops) {
161 - l.awaitStop(TIMEOUT);
162 - }
163 - aloop.awaitStop(TIMEOUT);
164 -
165 - messages.freeze();
166 - bytes.freeze();
167 - }
168 -
169 - /**
170 - * Reports on the accumulated throughput and latency.
171 - */
172 - public void report() {
173 - DecimalFormat f = new DecimalFormat("#,##0");
174 - out.println(format("Server: %s messages; %s bytes; %s mps; %s MBs",
175 - f.format(messages.total()), f.format(bytes.total()),
176 - f.format(messages.throughput()),
177 - f.format(bytes.throughput() / (1024 * msgLength))));
178 - }
179 -
180 - /**
181 - * Prunes the IO loops of stale message buffers.
182 - *
183 - * @return number of remaining IO loops among all workers.
184 - */
185 - public int prune() {
186 - int count = 0;
187 - for (CustomIOLoop l : iloops) {
188 - count += l.pruneStaleStreams();
189 - }
190 - return count;
191 - }
192 -
193 - // Get the next worker to which a client should be assigned
194 - private synchronized CustomIOLoop nextWorker() {
195 - lastWorker = (lastWorker + 1) % workerCount;
196 - return iloops.get(lastWorker);
197 - }
198 -
199 - // Loop for transfer of fixed-length messages
200 - private class CustomIOLoop extends IOLoop<TestMessage, TestMessageStream> {
201 -
202 - public CustomIOLoop() throws IOException {
203 - super(500);
204 - }
205 -
206 - @Override
207 - protected TestMessageStream createStream(ByteChannel channel) {
208 - return new TestMessageStream(msgLength, channel, this);
209 - }
210 -
211 - @Override
212 - protected void removeStream(MessageStream<TestMessage> stream) {
213 - super.removeStream(stream);
214 - messages.add(stream.messagesIn().total());
215 - bytes.add(stream.bytesIn().total());
216 - }
217 -
218 - @Override
219 - protected void processMessages(List<TestMessage> messages,
220 - MessageStream<TestMessage> stream) {
221 - try {
222 - stream.write(createResponses(messages));
223 - } catch (IOException e) {
224 - log.error("Unable to echo messages", e);
225 - }
226 - }
227 -
228 - private List<TestMessage> createResponses(List<TestMessage> messages) {
229 - List<TestMessage> responses = Lists.newArrayListWithCapacity(messages.size());
230 - for (TestMessage message : messages) {
231 - responses.add(new TestMessage(message.length(), message.requestorTime(),
232 - nanoTime(), message.padding()));
233 - }
234 - return responses;
235 - }
236 - }
237 -
238 - // Loop for accepting client connections
239 - private class CustomAcceptLoop extends AcceptorLoop {
240 -
241 - public CustomAcceptLoop(SocketAddress address) throws IOException {
242 - super(500, address);
243 - }
244 -
245 - @Override
246 - protected void acceptConnection(ServerSocketChannel channel) throws IOException {
247 - SocketChannel sc = channel.accept();
248 - sc.configureBlocking(false);
249 -
250 - Socket so = sc.socket();
251 - so.setTcpNoDelay(SO_NO_DELAY);
252 - so.setReceiveBufferSize(SO_RCV_BUFFER_SIZE);
253 - so.setSendBufferSize(SO_SEND_BUFFER_SIZE);
254 -
255 - nextWorker().acceptStream(sc);
256 - log.info("Connected client");
257 - }
258 - }
259 -
260 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.foo;
17 -
18 -import java.io.IOException;
19 -
20 -import org.onlab.netty.Message;
21 -import org.onlab.netty.MessageHandler;
22 -
23 -
24 -/**
25 - * Message handler that echos the message back to the sender.
26 - */
27 -public class NettyEchoHandler implements MessageHandler {
28 -
29 - @Override
30 - public void handle(Message message) throws IOException {
31 - message.respond(message.payload());
32 - }
33 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.foo;
17 -
18 -import org.onlab.netty.Message;
19 -import org.onlab.netty.MessageHandler;
20 -import org.slf4j.Logger;
21 -import org.slf4j.LoggerFactory;
22 -
23 -/**
24 - * A MessageHandler that simply logs the information.
25 - */
26 -public class NettyNothingHandler implements MessageHandler {
27 -
28 - private final Logger log = LoggerFactory.getLogger(getClass());
29 -
30 - @Override
31 - public void handle(Message message) {
32 - // Do nothing
33 - }
34 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.foo;
17 -
18 -import static java.lang.Thread.sleep;
19 -
20 -import java.io.IOException;
21 -import java.util.concurrent.ExecutionException;
22 -import java.util.concurrent.Future;
23 -import java.util.concurrent.TimeUnit;
24 -import java.util.concurrent.TimeoutException;
25 -
26 -import org.onlab.metrics.MetricsComponent;
27 -import org.onlab.metrics.MetricsFeature;
28 -import org.onlab.metrics.MetricsManager;
29 -import org.onlab.netty.Endpoint;
30 -import org.onlab.netty.NettyMessagingService;
31 -import org.slf4j.Logger;
32 -import org.slf4j.LoggerFactory;
33 -
34 -import com.codahale.metrics.Timer;
35 -
36 -/**
37 - * The Simple netty client test.
38 - */
39 -// FIXME: Should be move out to test or app
40 -public final class SimpleNettyClient {
41 -
42 -private static Logger log = LoggerFactory.getLogger(SimpleNettyClient.class);
43 -
44 - static NettyMessagingService messaging;
45 - static MetricsManager metrics;
46 -
47 - private SimpleNettyClient() {
48 - }
49 -
50 - /**
51 - * The entry point of application.
52 - *
53 - * @param args the input arguments
54 - * @throws IOException the iO exception
55 - * @throws InterruptedException the interrupted exception
56 - * @throws ExecutionException the execution exception
57 - * @throws TimeoutException the timeout exception
58 - */
59 - public static void main(String[] args)
60 - throws IOException, InterruptedException, ExecutionException,
61 - TimeoutException {
62 - try {
63 - startStandalone(args);
64 - } catch (Exception e) {
65 - e.printStackTrace();
66 - }
67 -
68 - System.exit(0);
69 - }
70 -
71 - /**
72 - * Start standalone.
73 - *
74 - * @param args the args
75 - * @throws Exception the exception
76 - */
77 - public static void startStandalone(String[] args) throws Exception {
78 - String host = args.length > 0 ? args[0] : "localhost";
79 - int port = args.length > 1 ? Integer.parseInt(args[1]) : 8081;
80 - int warmup = args.length > 2 ? Integer.parseInt(args[2]) : 1000;
81 - int iterations = args.length > 3 ? Integer.parseInt(args[3]) : 50 * 100000;
82 - messaging = new TestNettyMessagingService(9081);
83 - metrics = new MetricsManager();
84 - Endpoint endpoint = new Endpoint(host, port);
85 - messaging.activate();
86 - MetricsFeature feature = new MetricsFeature("latency");
87 - MetricsComponent component = metrics.registerComponent("NettyMessaging");
88 - log.info("connecting " + host + ":" + port + " warmup:" + warmup + " iterations:" + iterations);
89 -
90 - for (int i = 0; i < warmup; i++) {
91 - messaging.sendAsync(endpoint, "simple", "Hello World".getBytes());
92 - Future<byte[]> responseFuture = messaging
93 - .sendAndReceive(endpoint, "echo",
94 - "Hello World".getBytes());
95 - responseFuture.get(100000, TimeUnit.MILLISECONDS);
96 - }
97 -
98 - log.info("measuring round-trip send & receive");
99 - Timer sendAndReceiveTimer = metrics.createTimer(component, feature, "SendAndReceive");
100 - int timeouts = 0;
101 -
102 - for (int i = 0; i < iterations; i++) {
103 - Future<byte[]> responseFuture;
104 - Timer.Context context = sendAndReceiveTimer.time();
105 - try {
106 - responseFuture = messaging
107 - .sendAndReceive(endpoint, "echo",
108 - "Hello World".getBytes());
109 - responseFuture.get(10000, TimeUnit.MILLISECONDS);
110 - } catch (TimeoutException e) {
111 - timeouts++;
112 - log.info("timeout:" + timeouts + " at iteration:" + i);
113 - } finally {
114 - context.stop();
115 - }
116 - // System.out.println("Got back:" + new String(response.get(2, TimeUnit.SECONDS)));
117 - }
118 -
119 - //sleep(1000);
120 - log.info("measuring async sender");
121 - Timer sendAsyncTimer = metrics.createTimer(component, feature, "AsyncSender");
122 -
123 - for (int i = 0; i < iterations; i++) {
124 - Timer.Context context = sendAsyncTimer.time();
125 - messaging.sendAsync(endpoint, "simple", "Hello World".getBytes());
126 - context.stop();
127 - }
128 - sleep(10000);
129 - }
130 -
131 - public static void stop() {
132 - try {
133 - messaging.deactivate();
134 - } catch (Exception e) {
135 - log.info("Unable to stop client %s", e);
136 - }
137 - }
138 -
139 - /**
140 - * The type Test netty messaging service.
141 - */
142 - public static class TestNettyMessagingService extends NettyMessagingService {
143 - /**
144 - * Instantiates a new Test netty messaging service.
145 - *
146 - * @param port the port
147 - * @throws Exception the exception
148 - */
149 - public TestNettyMessagingService(int port) throws Exception {
150 - super(port);
151 - }
152 - }
153 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.foo;
17 -
18 -import static org.onosproject.foo.SimpleNettyClient.startStandalone;
19 -import static org.onosproject.foo.SimpleNettyClient.stop;
20 -
21 -import org.apache.karaf.shell.commands.Argument;
22 -import org.apache.karaf.shell.commands.Command;
23 -import org.onosproject.cli.AbstractShellCommand;
24 -
25 -/**
26 - * Test Netty client performance.
27 - */
28 -@Command(scope = "onos", name = "simple-netty-client",
29 - description = "Starts simple Netty client")
30 -public class SimpleNettyClientCommand extends AbstractShellCommand {
31 -
32 - //FIXME: replace these arguments with proper ones needed for the test.
33 - @Argument(index = 0, name = "hostname", description = "Server Hostname",
34 - required = false, multiValued = false)
35 - String hostname = "localhost";
36 -
37 - @Argument(index = 1, name = "port", description = "Port",
38 - required = false, multiValued = false)
39 - String port = "8081";
40 -
41 - @Argument(index = 2, name = "warmupCount", description = "Warm-up count",
42 - required = false, multiValued = false)
43 - String warmupCount = "1000";
44 -
45 - @Argument(index = 3, name = "messageCount", description = "Message count",
46 - required = false, multiValued = false)
47 - String messageCount = "1000000";
48 -
49 - @Override
50 - protected void execute() {
51 - try {
52 - startStandalone(new String[]{hostname, port, warmupCount, messageCount});
53 - } catch (Exception e) {
54 - error("Unable to start client %s", e);
55 - }
56 - stop();
57 - }
58 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.foo;
17 -
18 -import org.onlab.netty.NettyMessagingService;
19 -import org.slf4j.Logger;
20 -import org.slf4j.LoggerFactory;
21 -
22 -/**
23 - * Test to measure Messaging performance.
24 - */
25 - public final class SimpleNettyServer {
26 - private static Logger log = LoggerFactory.getLogger(SimpleNettyServer.class);
27 -
28 - private SimpleNettyServer() {}
29 -
30 - /**
31 - * The entry point of application.
32 - *
33 - * @param args the input arguments
34 - * @throws Exception the exception
35 - */
36 - public static void main(String... args) throws Exception {
37 - startStandalone(args);
38 - System.exit(0);
39 - }
40 -
41 - /**
42 - * Start standalone server.
43 - *
44 - * @param args the args
45 - * @throws Exception the exception
46 - */
47 - public static void startStandalone(String[] args) throws Exception {
48 - int port = args.length > 0 ? Integer.parseInt(args[0]) : 8081;
49 - NettyMessagingService server = new NettyMessagingService(port);
50 - server.activate();
51 - server.registerHandler("simple", new NettyNothingHandler());
52 - server.registerHandler("echo", new NettyEchoHandler());
53 - log.info("Netty Server server on port " + port);
54 - }
55 - }
56 -
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.foo;
17 -
18 -import static org.onosproject.foo.SimpleNettyServer.startStandalone;
19 -
20 -import org.apache.karaf.shell.commands.Argument;
21 -import org.apache.karaf.shell.commands.Command;
22 -import org.onosproject.cli.AbstractShellCommand;
23 -
24 -/**
25 - * Starts the Simple Netty server.
26 - */
27 -@Command(scope = "onos", name = "simple-netty-server",
28 - description = "Starts simple Netty server")
29 -public class SimpleNettyServerCommand extends AbstractShellCommand {
30 -
31 - //FIXME: Replace these with parameters for
32 - @Argument(index = 0, name = "port", description = "listen port",
33 - required = false, multiValued = false)
34 - String port = "8081";
35 -
36 - @Override
37 - protected void execute() {
38 - try {
39 - startStandalone(new String[]{port});
40 - } catch (Exception e) {
41 - error("Unable to start server %s", e);
42 - }
43 - }
44 -
45 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.foo;
17 -
18 -import org.apache.karaf.shell.commands.Argument;
19 -import org.apache.karaf.shell.commands.Command;
20 -import org.onosproject.cli.AbstractShellCommand;
21 -
22 -import static org.onosproject.foo.IOLoopTestClient.startStandalone;
23 -
24 -/**
25 - * Starts the test IO loop client.
26 - */
27 -@Command(scope = "onos", name = "test-io-client",
28 - description = "Starts the test IO loop client")
29 -public class TestIOClientCommand extends AbstractShellCommand {
30 -
31 - @Argument(index = 0, name = "serverIp", description = "Server IP address",
32 - required = false, multiValued = false)
33 - String serverIp = "127.0.0.1";
34 -
35 - @Argument(index = 1, name = "workers", description = "IO workers",
36 - required = false, multiValued = false)
37 - String workers = "6";
38 -
39 - @Argument(index = 2, name = "messageCount", description = "Message count",
40 - required = false, multiValued = false)
41 - String messageCount = "1000000";
42 -
43 - @Argument(index = 3, name = "messageLength", description = "Message length (bytes)",
44 - required = false, multiValued = false)
45 - String messageLength = "128";
46 -
47 - @Argument(index = 4, name = "timeoutSecs", description = "Test timeout (seconds)",
48 - required = false, multiValued = false)
49 - String timeoutSecs = "60";
50 -
51 - @Override
52 - protected void execute() {
53 - try {
54 - startStandalone(new String[]{serverIp, workers, messageCount, messageLength, timeoutSecs});
55 - } catch (Exception e) {
56 - error("Unable to start client %s", e);
57 - }
58 - }
59 -
60 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.foo;
17 -
18 -import org.apache.karaf.shell.commands.Argument;
19 -import org.apache.karaf.shell.commands.Command;
20 -import org.onosproject.cli.AbstractShellCommand;
21 -
22 -import static org.onosproject.foo.IOLoopTestServer.startStandalone;
23 -
24 -/**
25 - * Starts the test IO loop server.
26 - */
27 -@Command(scope = "onos", name = "test-io-server",
28 - description = "Starts the test IO loop server")
29 -public class TestIOServerCommand extends AbstractShellCommand {
30 -
31 - @Argument(index = 0, name = "serverIp", description = "Server IP address",
32 - required = false, multiValued = false)
33 - String serverIp = "127.0.0.1";
34 -
35 - @Argument(index = 1, name = "workers", description = "IO workers",
36 - required = false, multiValued = false)
37 - String workers = "6";
38 -
39 - @Argument(index = 2, name = "messageLength", description = "Message length (bytes)",
40 - required = false, multiValued = false)
41 - String messageLength = "128";
42 -
43 - @Override
44 - protected void execute() {
45 - try {
46 - startStandalone(new String[]{serverIp, workers, messageLength});
47 - } catch (Exception e) {
48 - error("Unable to start server %s", e);
49 - }
50 - }
51 -
52 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.foo;
17 -
18 -import org.onlab.nio.AbstractMessage;
19 -
20 -import static com.google.common.base.Preconditions.checkNotNull;
21 -
22 -/**
23 - * Test message for measuring rate and round-trip latency.
24 - */
25 -public class TestMessage extends AbstractMessage {
26 -
27 - private final byte[] padding;
28 -
29 - private final long requestorTime;
30 - private final long responderTime;
31 -
32 - /**
33 - * Creates a new message with the specified data.
34 - *
35 - * @param length message length
36 - * @param requestorTime requester time
37 - * @param responderTime responder time
38 - * @param padding message padding
39 - */
40 - TestMessage(int length, long requestorTime, long responderTime, byte[] padding) {
41 - this.length = length;
42 - this.requestorTime = requestorTime;
43 - this.responderTime = responderTime;
44 - this.padding = checkNotNull(padding, "Padding cannot be null");
45 - }
46 -
47 - public long requestorTime() {
48 - return requestorTime;
49 - }
50 -
51 - public long responderTime() {
52 - return responderTime;
53 - }
54 -
55 - public byte[] padding() {
56 - return padding;
57 - }
58 -
59 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.foo;
17 -
18 -import org.onlab.nio.IOLoop;
19 -import org.onlab.nio.MessageStream;
20 -
21 -import java.nio.ByteBuffer;
22 -import java.nio.channels.ByteChannel;
23 -
24 -import static com.google.common.base.Preconditions.checkArgument;
25 -import static com.google.common.base.Preconditions.checkState;
26 -
27 -/**
28 - * Fixed-length message transfer buffer.
29 - */
30 -public class TestMessageStream extends MessageStream<TestMessage> {
31 -
32 - private static final String E_WRONG_LEN = "Illegal message length: ";
33 - private static final long START_TAG = 0xfeedcafedeaddeedL;
34 - private static final long END_TAG = 0xbeadcafedeaddeedL;
35 - private static final int META_LENGTH = 40;
36 -
37 - private final int length;
38 - private boolean isStrict = true;
39 -
40 - public TestMessageStream(int length, ByteChannel ch, IOLoop<TestMessage, ?> loop) {
41 - super(loop, ch, 64 * 1024, 500);
42 - checkArgument(length >= META_LENGTH, "Length must be greater than header length of 40");
43 - this.length = length;
44 - }
45 -
46 - void setNonStrict() {
47 - isStrict = false;
48 - }
49 -
50 - @Override
51 - protected TestMessage read(ByteBuffer rb) {
52 - if (rb.remaining() < length) {
53 - return null;
54 - }
55 -
56 - long startTag = rb.getLong();
57 - if (isStrict) {
58 - checkState(startTag == START_TAG, "Incorrect message start");
59 - }
60 -
61 - long size = rb.getLong();
62 - long requestorTime = rb.getLong();
63 - long responderTime = rb.getLong();
64 - byte[] padding = padding();
65 - rb.get(padding);
66 -
67 - long endTag = rb.getLong();
68 - if (isStrict) {
69 - checkState(endTag == END_TAG, "Incorrect message end");
70 - }
71 -
72 - return new TestMessage((int) size, requestorTime, responderTime, padding);
73 - }
74 -
75 - @Override
76 - protected void write(TestMessage message, ByteBuffer wb) {
77 - if (message.length() != length) {
78 - throw new IllegalArgumentException(E_WRONG_LEN + message.length());
79 - }
80 -
81 - wb.putLong(START_TAG);
82 - wb.putLong(message.length());
83 - wb.putLong(message.requestorTime());
84 - wb.putLong(message.responderTime());
85 - wb.put(message.padding(), 0, length - META_LENGTH);
86 - wb.putLong(END_TAG);
87 - }
88 -
89 - public byte[] padding() {
90 - return new byte[length - META_LENGTH];
91 - }
92 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -
17 -/**
18 - * Sample application for use in various experiments.
19 - */
20 -package org.onosproject.foo;
1 -<!--
2 - ~ Copyright 2014 Open Networking Laboratory
3 - ~
4 - ~ Licensed under the Apache License, Version 2.0 (the "License");
5 - ~ you may not use this file except in compliance with the License.
6 - ~ You may obtain a copy of the License at
7 - ~
8 - ~ http://www.apache.org/licenses/LICENSE-2.0
9 - ~
10 - ~ Unless required by applicable law or agreed to in writing, software
11 - ~ distributed under the License is distributed on an "AS IS" BASIS,
12 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - ~ See the License for the specific language governing permissions and
14 - ~ limitations under the License.
15 - -->
16 -<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
17 -
18 - <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
19 - <command>
20 - <action class="org.onosproject.foo.TestIOClientCommand"/>
21 - </command>
22 - <command>
23 - <action class="org.onosproject.foo.TestIOServerCommand"/>
24 - </command>
25 - <command>
26 - <action class="org.onosproject.foo.SimpleNettyServerCommand"/>
27 - </command>
28 - <command>
29 - <action class="org.onosproject.foo.SimpleNettyClientCommand"/>
30 - </command>
31 - </command-bundle>
32 -
33 -</blueprint>
1 -#
2 -# Copyright 2014 Open Networking Laboratory
3 -#
4 -# Licensed under the Apache License, Version 2.0 (the "License");
5 -# you may not use this file except in compliance with the License.
6 -# You may obtain a copy of the License at
7 -#
8 -# http://www.apache.org/licenses/LICENSE-2.0
9 -#
10 -# Unless required by applicable law or agreed to in writing, software
11 -# distributed under the License is distributed on an "AS IS" BASIS,
12 -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 -# See the License for the specific language governing permissions and
14 -# limitations under the License.
15 -#
16 -livetribe.slp.da.expired.services.purge.period=60
17 -livetribe.slp.sa.client.connect.address=127.0.0.1
18 -livetribe.slp.sa.client.factory=org.livetribe.slp.sa.StandardServiceAgentClient$Factory
19 -livetribe.slp.sa.factory=org.livetribe.slp.sa.StandardServiceAgent$Factory
20 -livetribe.slp.sa.service.renewal.enabled=true
21 -livetribe.slp.sa.unicast.prefer.tcp=false
22 -livetribe.slp.tcp.connector.factory=org.livetribe.slp.spi.net.SocketTCPConnector$Factory
23 -livetribe.slp.tcp.connector.server.factory=org.livetribe.slp.spi.net.SocketTCPConnectorServer$Factory
24 -livetribe.slp.tcp.message.max.length=4096
25 -livetribe.slp.tcp.read.timeout=300000
26 -livetribe.slp.ua.client.factory=org.livetribe.slp.ua.StandardUserAgentClient$Factory
27 -livetribe.slp.ua.factory=org.livetribe.slp.ua.StandardUserAgent$Factory
28 -livetribe.slp.ua.unicast.prefer.tcp=false
29 -livetribe.slp.udp.connector.factory=org.livetribe.slp.spi.net.SocketUDPConnector$Factory
30 -livetribe.slp.udp.connector.server.factory=org.livetribe.slp.spi.net.SocketUDPConnectorServer$Factory
31 -net.slp.DAAddresses=
32 -net.slp.DAAttributes=
33 -net.slp.DAHeartBeat=10800
34 -net.slp.MTU=1400
35 -net.slp.SAAttributes=
36 -net.slp.broadcastAddress=255.255.255.255
37 -net.slp.datagramTimeouts=150,250,400
38 -net.slp.interfaces=0.0.0.0
39 -net.slp.isBroadcastOnly=false
40 -net.slp.locale=en
41 -net.slp.multicastAddress=239.255.255.253
42 -net.slp.multicastMaximumWait=15000
43 -net.slp.multicastTTL=255
44 -net.slp.multicastTimeouts=150,250,400,600,1000
45 -net.slp.notificationPort=1847
46 -net.slp.port=427
47 -net.slp.useScopes=default
48 -
49 -org.onlab.cluster.name = TV-ONOS
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2015 Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -<app name="org.onosproject.app.ifwd" origin="ON.Lab" version="1.1.0"
18 - features="onos-app-ifwd">
19 - <description>ONOS Reactive forwarding application using intent subsystem (experimental)</description>
20 -</app>
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2014 Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -<project xmlns="http://maven.apache.org/POM/4.0.0"
18 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
20 - <modelVersion>4.0.0</modelVersion>
21 -
22 - <parent>
23 - <groupId>org.onosproject</groupId>
24 - <artifactId>onos-apps</artifactId>
25 - <version>1.2.0-SNAPSHOT</version>
26 - <relativePath>../pom.xml</relativePath>
27 - </parent>
28 -
29 - <artifactId>onos-app-ifwd</artifactId>
30 - <packaging>bundle</packaging>
31 -
32 - <description>ONOS simple reactive forwarding app that uses intent service</description>
33 -
34 -</project>
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.ifwd;
17 -
18 -import static org.slf4j.LoggerFactory.getLogger;
19 -
20 -import org.apache.felix.scr.annotations.Activate;
21 -import org.apache.felix.scr.annotations.Component;
22 -import org.apache.felix.scr.annotations.Deactivate;
23 -import org.apache.felix.scr.annotations.Reference;
24 -import org.apache.felix.scr.annotations.ReferenceCardinality;
25 -import org.onlab.packet.Ethernet;
26 -import org.onosproject.core.ApplicationId;
27 -import org.onosproject.core.CoreService;
28 -import org.onosproject.net.Host;
29 -import org.onosproject.net.HostId;
30 -import org.onosproject.net.PortNumber;
31 -import org.onosproject.net.flow.DefaultTrafficSelector;
32 -import org.onosproject.net.flow.DefaultTrafficTreatment;
33 -import org.onosproject.net.flow.FlowRuleService;
34 -import org.onosproject.net.flow.TrafficSelector;
35 -import org.onosproject.net.flow.TrafficTreatment;
36 -import org.onosproject.net.host.HostService;
37 -import org.onosproject.net.intent.HostToHostIntent;
38 -import org.onosproject.net.intent.IntentService;
39 -import org.onosproject.net.packet.DefaultOutboundPacket;
40 -import org.onosproject.net.packet.InboundPacket;
41 -import org.onosproject.net.packet.OutboundPacket;
42 -import org.onosproject.net.packet.PacketContext;
43 -import org.onosproject.net.packet.PacketPriority;
44 -import org.onosproject.net.packet.PacketProcessor;
45 -import org.onosproject.net.packet.PacketService;
46 -import org.onosproject.net.topology.TopologyService;
47 -import org.slf4j.Logger;
48 -
49 -/**
50 - * WORK-IN-PROGRESS: Sample reactive forwarding application using intent framework.
51 - */
52 -@Component(immediate = true)
53 -public class IntentReactiveForwarding {
54 -
55 - private final Logger log = getLogger(getClass());
56 -
57 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
58 - protected CoreService coreService;
59 -
60 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
61 - protected TopologyService topologyService;
62 -
63 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
64 - protected PacketService packetService;
65 -
66 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
67 - protected IntentService intentService;
68 -
69 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
70 - protected HostService hostService;
71 -
72 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
73 - protected FlowRuleService flowRuleService;
74 -
75 - private ReactivePacketProcessor processor = new ReactivePacketProcessor();
76 - private ApplicationId appId;
77 -
78 - @Activate
79 - public void activate() {
80 - appId = coreService.registerApplication("org.onosproject.ifwd");
81 -
82 - packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 2);
83 -
84 - TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
85 - selector.matchEthType(Ethernet.TYPE_IPV4);
86 - packetService.requestPackets(selector.build(), PacketPriority.REACTIVE, appId);
87 -
88 - log.info("Started");
89 - }
90 -
91 - @Deactivate
92 - public void deactivate() {
93 - packetService.removeProcessor(processor);
94 - processor = null;
95 - log.info("Stopped");
96 - }
97 -
98 - /**
99 - * Packet processor responsible for forwarding packets along their paths.
100 - */
101 - private class ReactivePacketProcessor implements PacketProcessor {
102 -
103 - @Override
104 - public void process(PacketContext context) {
105 - // Stop processing if the packet has been handled, since we
106 - // can't do any more to it.
107 - if (context.isHandled()) {
108 - return;
109 - }
110 -
111 - InboundPacket pkt = context.inPacket();
112 - Ethernet ethPkt = pkt.parsed();
113 -
114 - if (ethPkt == null) {
115 - return;
116 - }
117 -
118 - HostId srcId = HostId.hostId(ethPkt.getSourceMAC());
119 - HostId dstId = HostId.hostId(ethPkt.getDestinationMAC());
120 -
121 - // Do we know who this is for? If not, flood and bail.
122 - Host dst = hostService.getHost(dstId);
123 - if (dst == null) {
124 - flood(context);
125 - return;
126 - }
127 -
128 - // Otherwise forward and be done with it.
129 - setUpConnectivity(context, srcId, dstId);
130 - forwardPacketToDst(context, dst);
131 - }
132 - }
133 -
134 - // Floods the specified packet if permissible.
135 - private void flood(PacketContext context) {
136 - if (topologyService.isBroadcastPoint(topologyService.currentTopology(),
137 - context.inPacket().receivedFrom())) {
138 - packetOut(context, PortNumber.FLOOD);
139 - } else {
140 - context.block();
141 - }
142 - }
143 -
144 - // Sends a packet out the specified port.
145 - private void packetOut(PacketContext context, PortNumber portNumber) {
146 - context.treatmentBuilder().setOutput(portNumber);
147 - context.send();
148 - }
149 -
150 - private void forwardPacketToDst(PacketContext context, Host dst) {
151 - TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(dst.location().port()).build();
152 - OutboundPacket packet = new DefaultOutboundPacket(dst.location().deviceId(),
153 - treatment, context.inPacket().unparsed());
154 - packetService.emit(packet);
155 - log.info("sending packet: {}", packet);
156 - }
157 -
158 - // Install a rule forwarding the packet to the specified port.
159 - private void setUpConnectivity(PacketContext context, HostId srcId, HostId dstId) {
160 - TrafficSelector selector = DefaultTrafficSelector.emptySelector();
161 - TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
162 -
163 - HostToHostIntent intent = new HostToHostIntent(appId, srcId, dstId,
164 - selector, treatment);
165 -
166 - intentService.submit(intent);
167 - }
168 -
169 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -
17 -/**
18 - * Sample application that provides simple form of reactive forwarding
19 - * using the intent service.
20 - */
21 -package org.onosproject.ifwd;
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2015 Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -<project xmlns="http://maven.apache.org/POM/4.0.0"
18 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
20 - <modelVersion>4.0.0</modelVersion>
21 -
22 - <parent>
23 - <groupId>org.onosproject</groupId>
24 - <artifactId>onos-apps</artifactId>
25 - <version>1.2.0-SNAPSHOT</version>
26 - <relativePath>../pom.xml</relativePath>
27 - </parent>
28 -
29 - <artifactId>onos-app-intent-perf</artifactId>
30 - <packaging>bundle</packaging>
31 -
32 - <description>ONOS intent perf app bundle</description>
33 -
34 - <dependencies>
35 - <dependency>
36 - <groupId>org.apache.karaf.shell</groupId>
37 - <artifactId>org.apache.karaf.shell.console</artifactId>
38 - </dependency>
39 -
40 - <dependency>
41 - <groupId>org.onosproject</groupId>
42 - <artifactId>onos-cli</artifactId>
43 - <version>${project.version}</version>
44 - </dependency>
45 - <dependency>
46 - <groupId>org.osgi</groupId>
47 - <artifactId>org.osgi.compendium</artifactId>
48 - </dependency>
49 - <!-- Required for javadoc generation -->
50 - <dependency>
51 - <groupId>org.osgi</groupId>
52 - <artifactId>org.osgi.core</artifactId>
53 - </dependency>
54 - </dependencies>
55 -
56 - <build>
57 - <plugins>
58 - <plugin>
59 - <groupId>org.apache.maven.plugins</groupId>
60 - <artifactId>maven-assembly-plugin</artifactId>
61 - <version>2.5.3</version>
62 - <configuration>
63 - <descriptor>src/assembly/bin.xml</descriptor>
64 - </configuration>
65 - <executions>
66 - <execution>
67 - <phase>package</phase>
68 - <goals>
69 - <goal>single</goal>
70 - </goals>
71 - </execution>
72 - </executions>
73 - </plugin>
74 - </plugins>
75 - </build>
76 -</project>
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2015 Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -<app name="org.onosproject.intentperf" origin="ON.Lab" version="1.1.0"
18 - features="onos-app-intent-perf">
19 - <description>Intent performance application</description>
20 -</app>
...\ No newline at end of file ...\ No newline at end of file
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2015 Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -<assembly
18 - xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
19 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20 - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
21 - <formats>
22 - <format>zip</format>
23 - </formats>
24 - <id>onos</id>
25 - <includeBaseDirectory>false</includeBaseDirectory>
26 - <files>
27 - <file>
28 - <source>src/assembly/app.xml</source>
29 - <destName>app.xml</destName>
30 - </file>
31 - <file>
32 - <source>target/${project.artifactId}-${project.version}.jar</source>
33 - <destName>m2/org/onosproject/${project.artifactId}/${project.version}/${project.artifactId}-${project.version}.jar</destName>
34 - </file>
35 - </files>
36 -</assembly>
...\ No newline at end of file ...\ No newline at end of file
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.intentperf;
17 -
18 -import com.google.common.collect.ImmutableList;
19 -import org.apache.felix.scr.annotations.Activate;
20 -import org.apache.felix.scr.annotations.Component;
21 -import org.apache.felix.scr.annotations.Deactivate;
22 -import org.apache.felix.scr.annotations.Reference;
23 -import org.apache.felix.scr.annotations.ReferenceCardinality;
24 -import org.apache.felix.scr.annotations.Service;
25 -import org.onosproject.cluster.ClusterService;
26 -import org.onosproject.cluster.ControllerNode;
27 -import org.onosproject.cluster.NodeId;
28 -import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
29 -import org.onosproject.store.cluster.messaging.ClusterMessage;
30 -import org.onosproject.store.cluster.messaging.ClusterMessageHandler;
31 -import org.onosproject.store.cluster.messaging.MessageSubject;
32 -import org.slf4j.Logger;
33 -
34 -import java.util.ArrayList;
35 -import java.util.Arrays;
36 -import java.util.HashMap;
37 -import java.util.LinkedList;
38 -import java.util.List;
39 -import java.util.Map;
40 -import java.util.concurrent.ExecutorService;
41 -import java.util.concurrent.Executors;
42 -
43 -import static org.onlab.util.Tools.groupedThreads;
44 -import static org.slf4j.LoggerFactory.getLogger;
45 -
46 -/**
47 - * Collects and distributes performance samples.
48 - */
49 -@Component(immediate = true)
50 -@Service(value = IntentPerfCollector.class)
51 -public class IntentPerfCollector {
52 -
53 - private static final long SAMPLE_TIME_WINDOW_MS = 5_000;
54 - private final Logger log = getLogger(getClass());
55 -
56 - private static final int MAX_SAMPLES = 1_000;
57 -
58 - private final List<Sample> samples = new LinkedList<>();
59 -
60 - private static final MessageSubject SAMPLE = new MessageSubject("intent-perf-sample");
61 -
62 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
63 - protected ClusterCommunicationService communicationService;
64 -
65 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
66 - protected ClusterService clusterService;
67 -
68 - @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY)
69 - protected IntentPerfUi ui;
70 -
71 - // Auxiliary structures used to accrue data for normalized time interval
72 - // across all nodes.
73 - private long newestTime;
74 - private Sample overall;
75 - private Sample current;
76 -
77 - private ControllerNode[] nodes;
78 - private Map<NodeId, Integer> nodeToIndex;
79 -
80 - private NodeId nodeId;
81 - private ExecutorService messageHandlingExecutor;
82 -
83 - @Activate
84 - public void activate() {
85 - nodeId = clusterService.getLocalNode().id();
86 -
87 - // TODO: replace with shared executor
88 - messageHandlingExecutor = Executors.newSingleThreadExecutor(
89 - groupedThreads("onos/perf", "message-handler"));
90 -
91 - communicationService.addSubscriber(SAMPLE, new InternalSampleCollector(),
92 - messageHandlingExecutor);
93 -
94 - nodes = clusterService.getNodes().toArray(new ControllerNode[]{});
95 - Arrays.sort(nodes, (a, b) -> a.id().toString().compareTo(b.id().toString()));
96 -
97 - nodeToIndex = new HashMap<>();
98 - for (int i = 0; i < nodes.length; i++) {
99 - nodeToIndex.put(nodes[i].id(), i);
100 - }
101 -
102 - clearSamples();
103 - log.info("Started");
104 - }
105 -
106 - @Deactivate
107 - public void deactivate() {
108 - messageHandlingExecutor.shutdown();
109 - communicationService.removeSubscriber(SAMPLE);
110 - log.info("Stopped");
111 - }
112 -
113 - /**
114 - * Clears all previously accumulated data.
115 - */
116 - public void clearSamples() {
117 - newestTime = 0;
118 - overall = new Sample(0, nodes.length);
119 - current = new Sample(0, nodes.length);
120 - samples.clear();
121 - }
122 -
123 -
124 - /**
125 - * Records a sample point of data about intent operation rate.
126 - *
127 - * @param overallRate overall rate
128 - * @param currentRate current rate
129 - */
130 - public void recordSample(double overallRate, double currentRate) {
131 - long now = System.currentTimeMillis();
132 - addSample(now, nodeId, overallRate, currentRate);
133 - broadcastSample(now, nodeId, overallRate, currentRate);
134 - }
135 -
136 - /**
137 - * Returns set of node ids as headers.
138 - *
139 - * @return node id headers
140 - */
141 - public List<String> getSampleHeaders() {
142 - List<String> headers = new ArrayList<>();
143 - for (ControllerNode node : nodes) {
144 - headers.add(node.id().toString());
145 - }
146 - return headers;
147 - }
148 -
149 - /**
150 - * Returns set of all accumulated samples normalized to the local set of
151 - * samples.
152 - *
153 - * @return accumulated samples
154 - */
155 - public synchronized List<Sample> getSamples() {
156 - return ImmutableList.copyOf(samples);
157 - }
158 -
159 - /**
160 - * Returns overall throughput performance for each of the cluster nodes.
161 - *
162 - * @return overall intent throughput
163 - */
164 - public synchronized Sample getOverall() {
165 - return overall;
166 - }
167 -
168 - // Records a new sample to our collection of samples
169 - private synchronized void addSample(long time, NodeId nodeId,
170 - double overallRate, double currentRate) {
171 - Sample fullSample = createCurrentSampleIfNeeded(time);
172 - setSampleData(current, nodeId, currentRate);
173 - setSampleData(overall, nodeId, overallRate);
174 - pruneSamplesIfNeeded();
175 -
176 - if (fullSample != null && ui != null) {
177 - ui.reportSample(fullSample);
178 - }
179 - }
180 -
181 - private Sample createCurrentSampleIfNeeded(long time) {
182 - Sample oldSample = time - newestTime > SAMPLE_TIME_WINDOW_MS || current.isComplete() ? current : null;
183 - if (oldSample != null) {
184 - newestTime = time;
185 - current = new Sample(time, nodes.length);
186 - if (oldSample.time > 0) {
187 - samples.add(oldSample);
188 - }
189 - }
190 - return oldSample;
191 - }
192 -
193 - private void setSampleData(Sample sample, NodeId nodeId, double data) {
194 - Integer index = nodeToIndex.get(nodeId);
195 - if (index != null) {
196 - sample.data[index] = data;
197 - }
198 - }
199 -
200 - private void pruneSamplesIfNeeded() {
201 - if (samples.size() > MAX_SAMPLES) {
202 - samples.remove(0);
203 - }
204 - }
205 -
206 - // Performance data sample.
207 - static class Sample {
208 - final long time;
209 - final double[] data;
210 -
211 - public Sample(long time, int nodeCount) {
212 - this.time = time;
213 - this.data = new double[nodeCount];
214 - Arrays.fill(data, -1);
215 - }
216 -
217 - public boolean isComplete() {
218 - for (int i = 0; i < data.length; i++) {
219 - if (data[i] < 0) {
220 - return false;
221 - }
222 - }
223 - return true;
224 - }
225 - }
226 -
227 - private void broadcastSample(long time, NodeId nodeId, double overallRate, double currentRate) {
228 - String data = String.format("%d|%f|%f", time, overallRate, currentRate);
229 - communicationService.broadcast(new ClusterMessage(nodeId, SAMPLE, data.getBytes()));
230 - }
231 -
232 - private class InternalSampleCollector implements ClusterMessageHandler {
233 - @Override
234 - public void handle(ClusterMessage message) {
235 - String[] fields = new String(message.payload()).split("\\|");
236 - log.debug("Received sample from {}: {}", message.sender(), fields);
237 - addSample(Long.parseLong(fields[0]), message.sender(),
238 - Double.parseDouble(fields[1]), Double.parseDouble(fields[2]));
239 - }
240 - }
241 -}
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.intentperf;
17 -
18 -import com.google.common.collect.ArrayListMultimap;
19 -import com.google.common.collect.Lists;
20 -import com.google.common.collect.Maps;
21 -import com.google.common.collect.Multimap;
22 -import com.google.common.collect.Sets;
23 -import org.apache.commons.lang.math.RandomUtils;
24 -import org.apache.felix.scr.annotations.Activate;
25 -import org.apache.felix.scr.annotations.Component;
26 -import org.apache.felix.scr.annotations.Deactivate;
27 -import org.apache.felix.scr.annotations.Modified;
28 -import org.apache.felix.scr.annotations.Property;
29 -import org.apache.felix.scr.annotations.Reference;
30 -import org.apache.felix.scr.annotations.ReferenceCardinality;
31 -import org.apache.felix.scr.annotations.Service;
32 -import org.onlab.packet.MacAddress;
33 -import org.onlab.util.Counter;
34 -import org.onosproject.cfg.ComponentConfigService;
35 -import org.onosproject.cluster.ClusterService;
36 -import org.onosproject.cluster.ControllerNode;
37 -import org.onosproject.cluster.NodeId;
38 -import org.onosproject.core.ApplicationId;
39 -import org.onosproject.core.CoreService;
40 -import org.onosproject.mastership.MastershipService;
41 -import org.onosproject.net.ConnectPoint;
42 -import org.onosproject.net.Device;
43 -import org.onosproject.net.PortNumber;
44 -import org.onosproject.net.device.DeviceService;
45 -import org.onosproject.net.flow.DefaultTrafficSelector;
46 -import org.onosproject.net.flow.DefaultTrafficTreatment;
47 -import org.onosproject.net.flow.TrafficSelector;
48 -import org.onosproject.net.flow.TrafficTreatment;
49 -import org.onosproject.net.intent.Intent;
50 -import org.onosproject.net.intent.IntentEvent;
51 -import org.onosproject.net.intent.IntentListener;
52 -import org.onosproject.net.intent.IntentService;
53 -import org.onosproject.net.intent.Key;
54 -import org.onosproject.net.intent.PartitionService;
55 -import org.onosproject.net.intent.PointToPointIntent;
56 -import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
57 -import org.onosproject.store.cluster.messaging.ClusterMessage;
58 -import org.onosproject.store.cluster.messaging.ClusterMessageHandler;
59 -import org.onosproject.store.cluster.messaging.MessageSubject;
60 -import org.osgi.service.component.ComponentContext;
61 -import org.slf4j.Logger;
62 -
63 -import java.util.ArrayList;
64 -import java.util.Collections;
65 -import java.util.Dictionary;
66 -import java.util.List;
67 -import java.util.Map;
68 -import java.util.Set;
69 -import java.util.Timer;
70 -import java.util.TimerTask;
71 -import java.util.concurrent.ExecutorService;
72 -import java.util.concurrent.Executors;
73 -import java.util.concurrent.TimeUnit;
74 -import java.util.stream.Collectors;
75 -
76 -import static com.google.common.base.Preconditions.checkState;
77 -import static com.google.common.base.Strings.isNullOrEmpty;
78 -import static java.lang.String.format;
79 -import static java.lang.System.currentTimeMillis;
80 -import static org.apache.felix.scr.annotations.ReferenceCardinality.MANDATORY_UNARY;
81 -import static org.onlab.util.Tools.*;
82 -import static org.onosproject.net.intent.IntentEvent.Type.*;
83 -import static org.slf4j.LoggerFactory.getLogger;
84 -
85 -/**
86 - * Application to test sustained intent throughput.
87 - */
88 -@Component(immediate = true)
89 -@Service(value = IntentPerfInstaller.class)
90 -public class IntentPerfInstaller {
91 -
92 - private final Logger log = getLogger(getClass());
93 -
94 - private static final int DEFAULT_NUM_WORKERS = 1;
95 -
96 - private static final int DEFAULT_NUM_KEYS = 40000;
97 - private static final int DEFAULT_GOAL_CYCLE_PERIOD = 1000; //ms
98 -
99 - private static final int DEFAULT_NUM_NEIGHBORS = 0;
100 -
101 - private static final int START_DELAY = 5_000; // ms
102 - private static final int REPORT_PERIOD = 5_000; //ms
103 -
104 - private static final String START = "start";
105 - private static final String STOP = "stop";
106 - private static final MessageSubject CONTROL = new MessageSubject("intent-perf-ctl");
107 -
108 - //FIXME add path length
109 -
110 - @Property(name = "numKeys", intValue = DEFAULT_NUM_KEYS,
111 - label = "Number of keys (i.e. unique intents) to generate per instance")
112 - private int numKeys = DEFAULT_NUM_KEYS;
113 -
114 - //TODO implement numWorkers property
115 -// @Property(name = "numThreads", intValue = DEFAULT_NUM_WORKERS,
116 -// label = "Number of installer threads per instance")
117 -// private int numWokers = DEFAULT_NUM_WORKERS;
118 -
119 - @Property(name = "cyclePeriod", intValue = DEFAULT_GOAL_CYCLE_PERIOD,
120 - label = "Goal for cycle period (in ms)")
121 - private int cyclePeriod = DEFAULT_GOAL_CYCLE_PERIOD;
122 -
123 - @Property(name = "numNeighbors", intValue = DEFAULT_NUM_NEIGHBORS,
124 - label = "Number of neighbors to generate intents for")
125 - private int numNeighbors = DEFAULT_NUM_NEIGHBORS;
126 -
127 - @Reference(cardinality = MANDATORY_UNARY)
128 - protected CoreService coreService;
129 -
130 - @Reference(cardinality = MANDATORY_UNARY)
131 - protected IntentService intentService;
132 -
133 - @Reference(cardinality = MANDATORY_UNARY)
134 - protected ClusterService clusterService;
135 -
136 - @Reference(cardinality = MANDATORY_UNARY)
137 - protected DeviceService deviceService;
138 -
139 - @Reference(cardinality = MANDATORY_UNARY)
140 - protected MastershipService mastershipService;
141 -
142 - @Reference(cardinality = MANDATORY_UNARY)
143 - protected PartitionService partitionService;
144 -
145 - @Reference(cardinality = MANDATORY_UNARY)
146 - protected ComponentConfigService configService;
147 -
148 - @Reference(cardinality = MANDATORY_UNARY)
149 - protected IntentPerfCollector sampleCollector;
150 -
151 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
152 - protected ClusterCommunicationService communicationService;
153 -
154 - private ExecutorService messageHandlingExecutor;
155 -
156 - private ExecutorService workers;
157 - private ApplicationId appId;
158 - private Listener listener;
159 - private boolean stopped;
160 -
161 - private Timer reportTimer;
162 -
163 - // FIXME this variable isn't shared properly between multiple worker threads
164 - private int lastKey = 0;
165 -
166 - private IntentPerfUi perfUi;
167 - private NodeId nodeId;
168 - private TimerTask reporterTask;
169 -
170 - @Activate
171 - public void activate(ComponentContext context) {
172 - configService.registerProperties(getClass());
173 -
174 - nodeId = clusterService.getLocalNode().id();
175 - appId = coreService.registerApplication("org.onosproject.intentperf." + nodeId.toString());
176 -
177 - // TODO: replace with shared timer
178 - reportTimer = new Timer("onos-intent-perf-reporter");
179 - workers = Executors.newFixedThreadPool(DEFAULT_NUM_WORKERS, groupedThreads("onos/intent-perf", "worker-%d"));
180 -
181 - // disable flow backups for testing
182 - configService.setProperty("org.onosproject.store.flow.impl.DistributedFlowRuleStore",
183 - "backupEnabled", "false");
184 -
185 - // TODO: replace with shared executor
186 - messageHandlingExecutor = Executors.newSingleThreadExecutor(
187 - groupedThreads("onos/perf", "command-handler"));
188 -
189 - communicationService.addSubscriber(CONTROL, new InternalControl(),
190 - messageHandlingExecutor);
191 -
192 - listener = new Listener();
193 - intentService.addListener(listener);
194 -
195 - // TODO: investigate why this seems to be necessary for configs to get picked up on initial activation
196 - modify(context);
197 - }
198 -
199 - @Deactivate
200 - public void deactivate() {
201 - stopTestRun();
202 -
203 - configService.unregisterProperties(getClass(), false);
204 - messageHandlingExecutor.shutdown();
205 - communicationService.removeSubscriber(CONTROL);
206 -
207 - if (listener != null) {
208 - reportTimer.cancel();
209 - intentService.removeListener(listener);
210 - listener = null;
211 - reportTimer = null;
212 - }
213 - }
214 -
215 - @Modified
216 - public void modify(ComponentContext context) {
217 - if (context == null) {
218 - logConfig("Reconfigured");
219 - return;
220 - }
221 -
222 - Dictionary<?, ?> properties = context.getProperties();
223 - int newNumKeys, newCyclePeriod, newNumNeighbors;
224 - try {
225 - String s = get(properties, "numKeys");
226 - newNumKeys = isNullOrEmpty(s) ? numKeys : Integer.parseInt(s.trim());
227 -
228 - s = get(properties, "cyclePeriod");
229 - newCyclePeriod = isNullOrEmpty(s) ? cyclePeriod : Integer.parseInt(s.trim());
230 -
231 - s = get(properties, "numNeighbors");
232 - newNumNeighbors = isNullOrEmpty(s) ? numNeighbors : Integer.parseInt(s.trim());
233 -
234 - } catch (NumberFormatException | ClassCastException e) {
235 - log.warn("Malformed configuration detected; using defaults", e);
236 - newNumKeys = DEFAULT_NUM_KEYS;
237 - newCyclePeriod = DEFAULT_GOAL_CYCLE_PERIOD;
238 - newNumNeighbors = DEFAULT_NUM_NEIGHBORS;
239 - }
240 -
241 - if (newNumKeys != numKeys || newCyclePeriod != cyclePeriod || newNumNeighbors != numNeighbors) {
242 - numKeys = newNumKeys;
243 - cyclePeriod = newCyclePeriod;
244 - numNeighbors = newNumNeighbors;
245 - logConfig("Reconfigured");
246 - }
247 - }
248 -
249 - public void start() {
250 - communicationService.broadcast(new ClusterMessage(nodeId, CONTROL, START.getBytes()));
251 - startTestRun();
252 - }
253 -
254 - public void stop() {
255 - communicationService.broadcast(new ClusterMessage(nodeId, CONTROL, STOP.getBytes()));
256 - stopTestRun();
257 - }
258 -
259 - private void logConfig(String prefix) {
260 - log.info("{} with appId {}; numKeys = {}; cyclePeriod = {} ms; numNeighbors={}",
261 - prefix, appId.id(), numKeys, cyclePeriod, numNeighbors);
262 - }
263 -
264 - private void startTestRun() {
265 - sampleCollector.clearSamples();
266 -
267 - // adjust numNeighbors and generate list of neighbors
268 - numNeighbors = Math.min(clusterService.getNodes().size() - 1, numNeighbors);
269 -
270 - // Schedule reporter task on report period boundary
271 - reporterTask = new ReporterTask();
272 - reportTimer.scheduleAtFixedRate(reporterTask,
273 - REPORT_PERIOD - currentTimeMillis() % REPORT_PERIOD,
274 - REPORT_PERIOD);
275 -
276 - // Submit workers
277 - stopped = false;
278 - for (int i = 0; i < DEFAULT_NUM_WORKERS; i++) {
279 - workers.submit(new Submitter(createIntents(numKeys, /*FIXME*/ 2, lastKey)));
280 - }
281 - log.info("Started test run");
282 - }
283 -
284 - private void stopTestRun() {
285 - stopped = true;
286 - if (reporterTask != null) {
287 - reporterTask.cancel();
288 - reporterTask = null;
289 - }
290 -
291 - try {
292 - workers.awaitTermination(5 * cyclePeriod, TimeUnit.MILLISECONDS);
293 - } catch (InterruptedException e) {
294 - log.warn("Failed to stop worker", e);
295 - }
296 - log.info("Stopped test run");
297 - }
298 -
299 - private List<NodeId> getNeighbors() {
300 - List<NodeId> nodes = clusterService.getNodes().stream()
301 - .map(ControllerNode::id)
302 - .collect(Collectors.toCollection(ArrayList::new));
303 - // sort neighbors by id
304 - Collections.sort(nodes, (node1, node2) ->
305 - node1.toString().compareTo(node2.toString()));
306 - // rotate the local node to index 0
307 - Collections.rotate(nodes, -1 * nodes.indexOf(clusterService.getLocalNode().id()));
308 - log.debug("neighbors (raw): {}", nodes); //TODO remove
309 - // generate the sub-list that will contain local node and selected neighbors
310 - nodes = nodes.subList(0, numNeighbors + 1);
311 - log.debug("neighbors: {}", nodes); //TODO remove
312 - return nodes;
313 - }
314 -
315 - private Intent createIntent(Key key, long mac, NodeId node, Multimap<NodeId, Device> devices) {
316 - // choose a random device for which this node is master
317 - List<Device> deviceList = devices.get(node).stream().collect(Collectors.toList());
318 - Device device = deviceList.get(RandomUtils.nextInt(deviceList.size()));
319 -
320 - //FIXME we currently ignore the path length and always use the same device
321 - TrafficSelector selector = DefaultTrafficSelector.builder()
322 - .matchEthDst(MacAddress.valueOf(mac)).build();
323 - TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
324 - ConnectPoint ingress = new ConnectPoint(device.id(), PortNumber.portNumber(1));
325 - ConnectPoint egress = new ConnectPoint(device.id(), PortNumber.portNumber(2));
326 -
327 - return PointToPointIntent.builder()
328 - .appId(appId)
329 - .key(key)
330 - .selector(selector)
331 - .treatment(treatment)
332 - .ingressPoint(ingress)
333 - .egressPoint(egress)
334 - .build();
335 -
336 - }
337 -
338 - /**
339 - * Creates a specified number of intents for testing purposes.
340 - *
341 - * @param numberOfKeys number of intents
342 - * @param pathLength path depth
343 - * @param firstKey first key to attempt
344 - * @return set of intents
345 - */
346 - private Set<Intent> createIntents(int numberOfKeys, int pathLength, int firstKey) {
347 - List<NodeId> neighbors = getNeighbors();
348 -
349 - Multimap<NodeId, Device> devices = ArrayListMultimap.create();
350 - deviceService.getAvailableDevices()
351 - .forEach(device -> devices.put(mastershipService.getMasterFor(device.id()), device));
352 -
353 - // ensure that we have at least one device per neighbor
354 - neighbors.forEach(node -> checkState(devices.get(node).size() > 0,
355 - "There are no devices for {}", node));
356 -
357 - // TODO pull this outside so that createIntent can use it
358 - // prefix based on node id for keys generated on this instance
359 - long keyPrefix = ((long) clusterService.getLocalNode().ip().getIp4Address().toInt()) << 32;
360 -
361 - int maxKeysPerNode = (int) Math.ceil((double) numberOfKeys / neighbors.size());
362 - Multimap<NodeId, Intent> intents = ArrayListMultimap.create();
363 -
364 - for (int count = 0, k = firstKey; count < numberOfKeys; k++) {
365 - Key key = Key.of(keyPrefix + k, appId);
366 -
367 - NodeId leader = partitionService.getLeader(key);
368 - if (!neighbors.contains(leader) || intents.get(leader).size() >= maxKeysPerNode) {
369 - // Bail if we are not sending to this node or we have enough for this node
370 - continue;
371 - }
372 - intents.put(leader, createIntent(key, keyPrefix + k, leader, devices));
373 -
374 - // Bump up the counter and remember this as the last key used.
375 - count++;
376 - lastKey = k;
377 - if (count % 1000 == 0) {
378 - log.info("Building intents... {} (attempt: {})", count, lastKey);
379 - }
380 - }
381 - checkState(intents.values().size() == numberOfKeys,
382 - "Generated wrong number of intents");
383 - log.info("Created {} intents", numberOfKeys);
384 - intents.keySet().forEach(node -> log.info("\t{}\t{}", node, intents.get(node).size()));
385 -
386 - return Sets.newHashSet(intents.values());
387 - }
388 -
389 - // Submits intent operations.
390 - final class Submitter implements Runnable {
391 -
392 - private long lastDuration;
393 - private int lastCount;
394 -
395 - private Set<Intent> intents = Sets.newHashSet();
396 - private Set<Intent> submitted = Sets.newHashSet();
397 - private Set<Intent> withdrawn = Sets.newHashSet();
398 -
399 - private Submitter(Set<Intent> intents) {
400 - this.intents = intents;
401 - lastCount = numKeys / 4;
402 - lastDuration = 1_000; // 1 second
403 - }
404 -
405 - @Override
406 - public void run() {
407 - prime();
408 - while (!stopped) {
409 - try {
410 - cycle();
411 - } catch (Exception e) {
412 - log.warn("Exception during cycle", e);
413 - }
414 - }
415 - clear();
416 - }
417 -
418 - private Iterable<Intent> subset(Set<Intent> intents) {
419 - List<Intent> subset = Lists.newArrayList(intents);
420 - Collections.shuffle(subset);
421 - return subset.subList(0, lastCount);
422 - }
423 -
424 - // Submits the specified intent.
425 - private void submit(Intent intent) {
426 - intentService.submit(intent);
427 - submitted.add(intent);
428 - withdrawn.remove(intent); //TODO could check result here...
429 - }
430 -
431 - // Withdraws the specified intent.
432 - private void withdraw(Intent intent) {
433 - intentService.withdraw(intent);
434 - withdrawn.add(intent);
435 - submitted.remove(intent); //TODO could check result here...
436 - }
437 -
438 - // Primes the cycle.
439 - private void prime() {
440 - int i = 0;
441 - withdrawn.addAll(intents);
442 - for (Intent intent : intents) {
443 - submit(intent);
444 - // only submit half of the intents to start
445 - if (i++ >= intents.size() / 2) {
446 - break;
447 - }
448 - }
449 - }
450 -
451 - private void clear() {
452 - submitted.forEach(this::withdraw);
453 - }
454 -
455 - // Runs a single operation cycle.
456 - private void cycle() {
457 - //TODO consider running without rate adjustment
458 - adjustRates();
459 -
460 - long start = currentTimeMillis();
461 - subset(submitted).forEach(this::withdraw);
462 - subset(withdrawn).forEach(this::submit);
463 - long delta = currentTimeMillis() - start;
464 -
465 - if (delta > cyclePeriod * 3 || delta < 0) {
466 - log.warn("Cycle took {} ms", delta);
467 - }
468 -
469 - int difference = cyclePeriod - (int) delta;
470 - if (difference > 0) {
471 - delay(difference);
472 - }
473 -
474 - lastDuration = delta;
475 - }
476 -
477 - int cycleCount = 0;
478 -
479 - private void adjustRates() {
480 -
481 - int addDelta = Math.max(1000 - cycleCount, 10);
482 - double multRatio = Math.min(0.8 + cycleCount * 0.0002, 0.995);
483 -
484 - //FIXME need to iron out the rate adjustment
485 - //FIXME we should taper the adjustments over time
486 - //FIXME don't just use the lastDuration, take an average
487 - if (++cycleCount % 5 == 0) { //TODO: maybe use a timer (we should do this every 5-10 sec)
488 - if (listener.requestThroughput() - listener.processedThroughput() <= 2000 && //was 500
489 - lastDuration <= cyclePeriod) {
490 - lastCount = Math.min(lastCount + addDelta, intents.size() / 2);
491 - } else {
492 - lastCount *= multRatio;
493 - }
494 - log.info("last count: {}, last duration: {} ms (sub: {} vs inst: {})",
495 - lastCount, lastDuration, listener.requestThroughput(), listener.processedThroughput());
496 - }
497 -
498 - }
499 - }
500 -
501 - // Event listener to monitor throughput.
502 - final class Listener implements IntentListener {
503 -
504 - private final Counter runningTotal = new Counter();
505 - private volatile Map<IntentEvent.Type, Counter> counters;
506 -
507 - private volatile double processedThroughput = 0;
508 - private volatile double requestThroughput = 0;
509 -
510 - public Listener() {
511 - counters = initCounters();
512 - }
513 -
514 - private Map<IntentEvent.Type, Counter> initCounters() {
515 - Map<IntentEvent.Type, Counter> map = Maps.newHashMap();
516 - for (IntentEvent.Type type : IntentEvent.Type.values()) {
517 - map.put(type, new Counter());
518 - }
519 - return map;
520 - }
521 -
522 - public double processedThroughput() {
523 - return processedThroughput;
524 - }
525 -
526 - public double requestThroughput() {
527 - return requestThroughput;
528 - }
529 -
530 - @Override
531 - public void event(IntentEvent event) {
532 - if (event.subject().appId().equals(appId)) {
533 - counters.get(event.type()).add(1);
534 - }
535 - }
536 -
537 - public void report() {
538 - Map<IntentEvent.Type, Counter> reportCounters = counters;
539 - counters = initCounters();
540 -
541 - // update running total and latest throughput
542 - Counter installed = reportCounters.get(INSTALLED);
543 - Counter withdrawn = reportCounters.get(WITHDRAWN);
544 - processedThroughput = installed.throughput() + withdrawn.throughput();
545 - runningTotal.add(installed.total() + withdrawn.total());
546 -
547 - Counter installReq = reportCounters.get(INSTALL_REQ);
548 - Counter withdrawReq = reportCounters.get(WITHDRAW_REQ);
549 - requestThroughput = installReq.throughput() + withdrawReq.throughput();
550 -
551 - // build the string to report
552 - StringBuilder stringBuilder = new StringBuilder();
553 - for (IntentEvent.Type type : IntentEvent.Type.values()) {
554 - Counter counter = reportCounters.get(type);
555 - stringBuilder.append(format("%s=%.2f;", type, counter.throughput()));
556 - }
557 - log.info("Throughput: OVERALL={}; CURRENT={}; {}",
558 - format("%.2f", runningTotal.throughput()),
559 - format("%.2f", processedThroughput),
560 - stringBuilder);
561 -
562 - sampleCollector.recordSample(runningTotal.throughput(),
563 - processedThroughput);
564 - }
565 - }
566 -
567 - private class InternalControl implements ClusterMessageHandler {
568 - @Override
569 - public void handle(ClusterMessage message) {
570 - String cmd = new String(message.payload());
571 - log.info("Received command {}", cmd);
572 - if (cmd.equals(START)) {
573 - startTestRun();
574 - } else {
575 - stopTestRun();
576 - }
577 - }
578 - }
579 -
580 - private class ReporterTask extends TimerTask {
581 - @Override
582 - public void run() {
583 - //adjustRates(); // FIXME we currently adjust rates in the cycle thread
584 - listener.report();
585 - }
586 - }
587 -
588 -}
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.intentperf;
17 -
18 -import org.apache.karaf.shell.commands.Command;
19 -import org.apache.karaf.shell.commands.Option;
20 -import org.onosproject.cli.AbstractShellCommand;
21 -import org.onosproject.intentperf.IntentPerfCollector.Sample;
22 -
23 -import java.text.SimpleDateFormat;
24 -import java.util.Date;
25 -import java.util.List;
26 -
27 -/**
28 - * Displays accumulated performance metrics.
29 - */
30 -@Command(scope = "onos", name = "intent-perf",
31 - description = "Displays accumulated performance metrics")
32 -public class IntentPerfListCommand extends AbstractShellCommand {
33 -
34 - @Option(name = "-s", aliases = "--summary", description = "Output just summary",
35 - required = false, multiValued = false)
36 - private boolean summary = false;
37 -
38 - @Override
39 - protected void execute() {
40 - if (summary) {
41 - printSummary();
42 - } else {
43 - printSamples();
44 - }
45 - }
46 -
47 - private void printSummary() {
48 - IntentPerfCollector collector = get(IntentPerfCollector.class);
49 - List<String> headers = collector.getSampleHeaders();
50 - Sample overall = collector.getOverall();
51 - double total = 0;
52 - print("%12s: %14s", "Node ID", "Overall Rate");
53 - for (int i = 0; i < overall.data.length; i++) {
54 - if (overall.data[i] >= 0) {
55 - print("%12s: %14.2f", headers.get(i), overall.data[i]);
56 - total += overall.data[i];
57 - } else {
58 - print("%12s: %14s", headers.get(i), " ");
59 - }
60 - }
61 - print("%12s: %14.2f", "total", total);
62 - }
63 -
64 - private void printSamples() {
65 - IntentPerfCollector collector = get(IntentPerfCollector.class);
66 - List<String> headers = collector.getSampleHeaders();
67 - List<Sample> samples = collector.getSamples();
68 -
69 - System.out.print(String.format("%10s ", "Time"));
70 - for (String header : headers) {
71 - System.out.print(String.format("%12s ", header));
72 - }
73 - System.out.println(String.format("%12s", "Total"));
74 -
75 - SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
76 - for (Sample sample : samples) {
77 - double total = 0;
78 - System.out.print(String.format("%10s ", sdf.format(new Date(sample.time))));
79 - for (int i = 0; i < sample.data.length; i++) {
80 - if (sample.data[i] >= 0) {
81 - System.out.print(String.format("%12.2f ", sample.data[i]));
82 - total += sample.data[i];
83 - } else {
84 - System.out.print(String.format("%12s ", " "));
85 - }
86 - }
87 - System.out.println(String.format("%12.2f", total));
88 - }
89 - }
90 -
91 -}
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.intentperf;
17 -
18 -import org.apache.karaf.shell.commands.Command;
19 -import org.onosproject.cli.AbstractShellCommand;
20 -
21 -/**
22 - * Starts intent performance test run.
23 - */
24 -@Command(scope = "onos", name = "intent-perf-start",
25 - description = "Starts intent performance test run")
26 -public class IntentPerfStartCommand extends AbstractShellCommand {
27 -
28 - @Override
29 - protected void execute() {
30 - get(IntentPerfInstaller.class).start();
31 - }
32 -
33 -}
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.intentperf;
17 -
18 -import org.apache.karaf.shell.commands.Command;
19 -import org.onosproject.cli.AbstractShellCommand;
20 -
21 -/**
22 - * Stops intent performance test run.
23 - */
24 -@Command(scope = "onos", name = "intent-perf-stop",
25 - description = "Stops intent performance test run")
26 -public class IntentPerfStopCommand extends AbstractShellCommand {
27 -
28 - @Override
29 - protected void execute() {
30 - get(IntentPerfInstaller.class).stop();
31 - }
32 -
33 -}
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.intentperf;
17 -
18 -import com.fasterxml.jackson.databind.node.ObjectNode;
19 -import com.google.common.collect.ImmutableList;
20 -import com.google.common.collect.ImmutableSet;
21 -import org.apache.felix.scr.annotations.Activate;
22 -import org.apache.felix.scr.annotations.Component;
23 -import org.apache.felix.scr.annotations.Deactivate;
24 -import org.apache.felix.scr.annotations.Reference;
25 -import org.apache.felix.scr.annotations.ReferenceCardinality;
26 -import org.onlab.osgi.ServiceDirectory;
27 -import org.onosproject.intentperf.IntentPerfCollector.Sample;
28 -import org.onosproject.ui.UiConnection;
29 -import org.onosproject.ui.UiExtension;
30 -import org.onosproject.ui.UiExtensionService;
31 -import org.onosproject.ui.UiMessageHandler;
32 -import org.onosproject.ui.UiView;
33 -
34 -import java.util.Collection;
35 -import java.util.HashSet;
36 -import java.util.List;
37 -import java.util.Set;
38 -
39 -import static java.util.Collections.synchronizedSet;
40 -
41 -/**
42 - * Mechanism to stream data to the GUI.
43 - */
44 -@Component(immediate = true, enabled = false)
45 -public class IntentPerfUi {
46 -
47 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
48 - protected UiExtensionService uiExtensionService;
49 -
50 - private final Set<StreamingControl> handlers = synchronizedSet(new HashSet<>());
51 -
52 - private List<UiView> views = ImmutableList.of(new UiView("intentPerf", "Intent Performance"));
53 - private UiExtension uiExtension = new UiExtension(views, this::newHandlers,
54 - getClass().getClassLoader());
55 -
56 - @Activate
57 - protected void activate() {
58 - uiExtensionService.register(uiExtension);
59 - }
60 -
61 - @Deactivate
62 - protected void deactivate() {
63 - uiExtensionService.unregister(uiExtension);
64 - }
65 -
66 - /**
67 - * Reports a single sample of performance data.
68 - *
69 - * @param sample performance sample
70 - */
71 - public void reportSample(Sample sample) {
72 - synchronized (handlers) {
73 - handlers.forEach(h -> h.send(sample));
74 - }
75 - }
76 -
77 - // Creates and returns session specific message handler.
78 - private Collection<UiMessageHandler> newHandlers() {
79 - return ImmutableList.of(new StreamingControl());
80 - }
81 -
82 - // UI Message handlers for turning on/off reporting to a session.
83 - private class StreamingControl extends UiMessageHandler {
84 -
85 - private boolean streamingEnabled = false;
86 -
87 - protected StreamingControl() {
88 - super(ImmutableSet.of("intentPerfStart", "intentPerfStop"));
89 - }
90 -
91 - @Override
92 - public void process(ObjectNode message) {
93 - streamingEnabled = message.path("event").asText("unknown").equals("initPerfStart");
94 - }
95 -
96 - @Override
97 - public void init(UiConnection connection, ServiceDirectory directory) {
98 - super.init(connection, directory);
99 - handlers.add(this);
100 - }
101 -
102 - @Override
103 - public void destroy() {
104 - super.destroy();
105 - handlers.remove(this);
106 - }
107 -
108 - private void send(Sample sample) {
109 - // FIXME: finish this
110 - ObjectNode sn = mapper.createObjectNode()
111 - .put("time", sample.time);
112 - connection().sendMessage("intentPerf", 0, sn);
113 - }
114 - }
115 -
116 -}
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -
17 -/**
18 - * Performance test application that induces steady load on the intent subsystem.
19 - */
20 -package org.onosproject.intentperf;
...\ No newline at end of file ...\ No newline at end of file
1 -<!--
2 - ~ Copyright 2015 Open Networking Laboratory
3 - ~
4 - ~ Licensed under the Apache License, Version 2.0 (the "License");
5 - ~ you may not use this file except in compliance with the License.
6 - ~ You may obtain a copy of the License at
7 - ~
8 - ~ http://www.apache.org/licenses/LICENSE-2.0
9 - ~
10 - ~ Unless required by applicable law or agreed to in writing, software
11 - ~ distributed under the License is distributed on an "AS IS" BASIS,
12 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - ~ See the License for the specific language governing permissions and
14 - ~ limitations under the License.
15 - -->
16 -<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
17 - <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
18 - <command>
19 - <action class="org.onosproject.intentperf.IntentPerfListCommand"/>
20 - </command>
21 - <command>
22 - <action class="org.onosproject.intentperf.IntentPerfStartCommand"/>
23 - </command>
24 - <command>
25 - <action class="org.onosproject.intentperf.IntentPerfStopCommand"/>
26 - </command>
27 - </command-bundle>
28 -</blueprint>
1 -date,value,node
2 -00:55:15,68.38,node1
3 -00:55:15,55.61,node2
4 -00:55:15,74.00,node3
5 -00:55:30,74.20,node1
6 -00:55:30,77.60,node2
7 -00:55:30,74.80,node3
8 -00:55:45,74.60,node1
9 -00:55:45,72.80,node2
10 -00:55:45,77.00,node3
11 -00:56:00,73.60,node1
12 -00:56:00,75.00,node2
13 -00:56:00,76.98,node3
14 -00:56:15,75.82,node1
15 -00:56:15,75.40,node2
16 -00:56:15,76.00,node3
17 -00:56:30,75.60,node1
18 -00:56:30,74.59,node2
19 -00:56:30,74.01,node3
...\ No newline at end of file ...\ No newline at end of file
1 -key,value,date
2 -Group1,37,00:23:00
3 -Group2,12,00:23:00
4 -Group3,46,00:23:00
5 -Group1,32,00:23:05
6 -Group2,19,00:23:05
7 -Group3,42,00:23:05
8 -Group1,45,00:23:10
9 -Group2,16,00:23:10
10 -Group3,44,00:23:10
11 -Group1,24,00:23:15
12 -Group2,52,00:23:15
13 -Group3,64,00:23:15
14 -Group1,34,00:23:20
15 -Group2,62,00:23:20
16 -Group3,74,00:23:20
17 -Group1,34,00:23:25
18 -Group2,62,00:23:25
19 -Group3,74,00:23:25
...\ No newline at end of file ...\ No newline at end of file
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -
17 -/*
18 - ONOS GUI -- Intent Perf View -- CSS file
19 - */
20 -
21 -.light #ov-intentPerf {
22 - color: navy;
23 -}
24 -
25 -.dark #ov-intentPerf {
26 - color: #1e5e6f;
27 -}
28 -
29 -.dark a {
30 - color: #88c;
31 -}
32 -
33 -#ov-intentPerf .msg {
34 - color: darkorange;
35 -}
36 -
37 -.light #ov-intentPerf .msg {
38 - color: darkorange;
39 -}
40 -
41 -.dark #ov-intentPerf .msg {
42 - color: #904e00;
43 -}
44 -
45 -
46 -
47 -.axis path,
48 -.axis line {
49 - fill: none;
50 - stroke: #000;
51 - shape-rendering: crispEdges;
52 -}
53 -
54 -.browser text {
55 - text-anchor: end;
56 -}
1 -<!--
2 - ~ Copyright 2015 Open Networking Laboratory
3 - ~
4 - ~ Licensed under the Apache License, Version 2.0 (the "License");
5 - ~ you may not use this file except in compliance with the License.
6 - ~ You may obtain a copy of the License at
7 - ~
8 - ~ http://www.apache.org/licenses/LICENSE-2.0
9 - ~
10 - ~ Unless required by applicable law or agreed to in writing, software
11 - ~ distributed under the License is distributed on an "AS IS" BASIS,
12 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - ~ See the License for the specific language governing permissions and
14 - ~ limitations under the License.
15 - -->
16 -
17 -<!-- Intent Performance partial HTML -->
18 -<div id="ov-sample">
19 - <h2> Intent Performance View </h2>
20 -
21 - <span class="msg">{{ ctrl.message }}</span>
22 -
23 - <div id="intent-perf-chart"></div>
24 -</div>
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -
17 -/*
18 - ONOS GUI -- Intent Performance View Module
19 - */
20 -(function () {
21 - 'use strict';
22 -
23 - // injected refs
24 - var $log, tbs, flash;
25 -
26 - function start() {
27 - //var format = d3.time.format("%m/%d/%y");
28 - var format = d3.time.format("%H:%M:%S");
29 - var samples = [];
30 -
31 - var margin = {top: 20, right: 30, bottom: 30, left: 40},
32 - width = 960 - margin.left - margin.right,
33 - height = 500 - margin.top - margin.bottom;
34 -
35 - var x = d3.time.scale()
36 - .range([0, width]);
37 -
38 - var y = d3.scale.linear()
39 - .range([height, 0]);
40 -
41 - var z = d3.scale.category20c();
42 -
43 - var xAxis = d3.svg.axis()
44 - .scale(x)
45 - .orient("bottom")
46 - .ticks(d3.time.seconds);
47 -
48 - var yAxis = d3.svg.axis()
49 - .scale(y)
50 - .orient("left");
51 -
52 - var stack = d3.layout.stack()
53 - .offset("zero")
54 - .values(function(d) { return d.values; })
55 - .x(function(d) { return d.date; })
56 - .y(function(d) { return d.value; });
57 -
58 - var nest = d3.nest()
59 - .key(function(d) { return d.key; });
60 -
61 - var area = d3.svg.area()
62 - .interpolate("cardinal")
63 - .x(function(d) { return x(d.date); })
64 - .y0(function(d) { return y(d.y0); })
65 - .y1(function(d) { return y(d.y0 + d.y); });
66 -
67 - var svg = d3.select("body").append("svg")
68 - .attr("width", width + margin.left + margin.right)
69 - .attr("height", height + margin.top + margin.bottom)
70 - .append("g")
71 - .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
72 -
73 - svg.append("g")
74 - .attr("class", "x axis")
75 - .attr("transform", "translate(0," + height + ")")
76 - .call(xAxis);
77 -
78 - svg.append("g")
79 - .attr("class", "y axis")
80 - .call(yAxis);
81 -
82 - function fetchData() {
83 - d3.csv("app/view/intentPerf/data.csv", function (data) {
84 - samples = data;
85 - updateGraph();
86 - });
87 - }
88 -
89 - function updateGraph() {
90 - samples.forEach(function(d) {
91 - d.date = format.parse(d.date);
92 - d.value = +d.value;
93 - });
94 -
95 - var layers = stack(nest.entries(samples));
96 -
97 - x.domain(d3.extent(samples, function(d) { return d.date; }));
98 - y.domain([0, d3.max(samples, function(d) { return d.y0 + d.y; })]);
99 -
100 - svg.selectAll(".layer")
101 - .data(layers)
102 - .enter().append("path")
103 - .attr("class", "layer")
104 - .attr("d", function(d) { return area(d.values); })
105 - .style("fill", function(d, i) { return z(i); });
106 -
107 - svg.select(".x")
108 - .attr("transform", "translate(0," + height + ")")
109 - .call(xAxis);
110 -
111 - svg.select(".y")
112 - .call(yAxis);
113 -
114 - console.log('tick');
115 - }
116 - }
117 -
118 - start();
119 -
120 - // define the controller
121 -
122 - angular.module('ovIntentPerf', ['onosUtil'])
123 - .controller('OvIntentPerfCtrl',
124 - ['$scope', '$log', 'ToolbarService', 'FlashService',
125 -
126 - function ($scope, _$log_, _tbs_, _flash_) {
127 - var self = this
128 -
129 - $log = _$log_;
130 - tbs = _tbs_;
131 - flash = _flash_;
132 -
133 - self.message = 'Hey there dudes!';
134 - start();
135 -
136 - // Clean up on destroyed scope
137 - $scope.$on('$destroy', function () {
138 - });
139 -
140 - $log.log('OvIntentPerfCtrl has been created');
141 - }]);
142 -}());
1 -<link rel="stylesheet" href="app/view/intentPerf/intentPerf.css">
1 -<!DOCTYPE html>
2 -<!--
3 - ~ Copyright 2014 Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -<html>
18 -<head>
19 - <title>Dev View</title>
20 - <script src="tp/d3.min.js"></script>
21 - <script src="tp/jquery-2.1.1.min.js"></script>
22 -
23 - <link rel="stylesheet" href="app/view/intentPerf/intentPerf.css">
24 -</head>
25 -<body>
26 -<div id="intent-perf-chart" style="width: 1024px; height: 800px"></div>
27 -<script src="app/view/intentPerf/intentPerf.js"></script>
28 -</body>
29 -</html>
...\ No newline at end of file ...\ No newline at end of file
1 -<script src="app/view/intentPerf/intentPerf.js"></script>
...@@ -32,24 +32,17 @@ ...@@ -32,24 +32,17 @@
32 <description>ONOS sample applications</description> 32 <description>ONOS sample applications</description>
33 33
34 <modules> 34 <modules>
35 - <module>tvue</module>
36 <module>fwd</module> 35 <module>fwd</module>
37 - <module>ifwd</module>
38 <module>mobility</module> 36 <module>mobility</module>
39 <module>proxyarp</module> 37 <module>proxyarp</module>
40 <module>config</module> 38 <module>config</module>
41 <module>sdnip</module> 39 <module>sdnip</module>
42 - <module>calendar</module>
43 <module>optical</module> 40 <module>optical</module>
44 <module>metrics</module> 41 <module>metrics</module>
45 <module>oecfg</module> 42 <module>oecfg</module>
46 - <module>demo</module>
47 - <module>election</module>
48 <module>routing</module> 43 <module>routing</module>
49 <module>routing-api</module> 44 <module>routing-api</module>
50 <module>bgprouter</module> 45 <module>bgprouter</module>
51 - <module>intent-perf</module>
52 - <module>database-perf</module>
53 </modules> 46 </modules>
54 47
55 <properties> 48 <properties>
......
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2015 Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -<app name="org.onosproject.app.tvue" origin="ON.Lab" version="1.1.0"
18 - features="onos-app-tvue">
19 - <description>Early prototype GUI (deprecated)</description>
20 -</app>
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2014 Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -<project xmlns="http://maven.apache.org/POM/4.0.0"
18 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
20 - <modelVersion>4.0.0</modelVersion>
21 -
22 - <parent>
23 - <groupId>org.onosproject</groupId>
24 - <artifactId>onos-apps</artifactId>
25 - <version>1.2.0-SNAPSHOT</version>
26 - <relativePath>../pom.xml</relativePath>
27 - </parent>
28 -
29 - <artifactId>onos-app-tvue</artifactId>
30 - <packaging>bundle</packaging>
31 -
32 - <description>ONOS simple topology viewer</description>
33 -
34 - <properties>
35 - <web.context>/onos/tvue</web.context>
36 - </properties>
37 -
38 - <dependencies>
39 - <dependency>
40 - <groupId>org.onosproject</groupId>
41 - <artifactId>onlab-rest</artifactId>
42 - <version>${project.version}</version>
43 - </dependency>
44 -
45 - <dependency>
46 - <groupId>com.sun.jersey</groupId>
47 - <artifactId>jersey-servlet</artifactId>
48 - </dependency>
49 - <dependency>
50 - <groupId>com.sun.jersey.jersey-test-framework</groupId>
51 - <artifactId>jersey-test-framework-core</artifactId>
52 - <version>1.18.1</version>
53 - <scope>test</scope>
54 - </dependency>
55 - <dependency>
56 - <groupId>com.sun.jersey.jersey-test-framework</groupId>
57 - <artifactId>jersey-test-framework-grizzly2</artifactId>
58 - <version>1.18.1</version>
59 - <scope>test</scope>
60 - </dependency>
61 -
62 - <dependency>
63 - <groupId>com.fasterxml.jackson.core</groupId>
64 - <artifactId>jackson-databind</artifactId>
65 - </dependency>
66 -
67 - <dependency>
68 - <groupId>com.fasterxml.jackson.core</groupId>
69 - <artifactId>jackson-annotations</artifactId>
70 - </dependency>
71 -
72 - <dependency>
73 - <groupId>org.osgi</groupId>
74 - <artifactId>org.osgi.core</artifactId>
75 - </dependency>
76 - </dependencies>
77 -
78 - <build>
79 - <plugins>
80 - <plugin>
81 - <groupId>org.apache.felix</groupId>
82 - <artifactId>maven-bundle-plugin</artifactId>
83 - <extensions>true</extensions>
84 - <configuration>
85 - <instructions>
86 - <_wab>src/main/webapp/</_wab>
87 - <Bundle-SymbolicName>
88 - ${project.groupId}.${project.artifactId}
89 - </Bundle-SymbolicName>
90 - <Import-Package>
91 - org.osgi.framework,
92 - javax.ws.rs,javax.ws.rs.core,
93 - com.sun.jersey.api.core,
94 - com.sun.jersey.spi.container.servlet,
95 - com.sun.jersey.server.impl.container.servlet,
96 - com.fasterxml.jackson.databind,
97 - com.fasterxml.jackson.databind.node,
98 - org.onlab.packet.*,
99 - org.onlab.rest.*,
100 - org.onosproject.*
101 - </Import-Package>
102 - <Web-ContextPath>${web.context}</Web-ContextPath>
103 - </instructions>
104 - </configuration>
105 - </plugin>
106 - </plugins>
107 - </build>
108 -
109 -</project>
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.tvue;
17 -
18 -import com.fasterxml.jackson.databind.ObjectMapper;
19 -import com.fasterxml.jackson.databind.node.ArrayNode;
20 -import com.fasterxml.jackson.databind.node.ObjectNode;
21 -import org.onosproject.net.ConnectPoint;
22 -import org.onosproject.net.ElementId;
23 -import org.onosproject.net.Host;
24 -import org.onosproject.net.Link;
25 -import org.onosproject.net.Path;
26 -import org.onosproject.net.device.DeviceService;
27 -import org.onosproject.net.host.HostService;
28 -import org.onosproject.net.link.LinkService;
29 -import org.onosproject.net.topology.PathService;
30 -import org.onosproject.net.topology.Topology;
31 -import org.onosproject.net.topology.TopologyGraph;
32 -import org.onosproject.net.topology.TopologyService;
33 -import org.onosproject.net.topology.TopologyVertex;
34 -import org.onlab.packet.IpAddress;
35 -import org.onlab.rest.BaseResource;
36 -
37 -import javax.ws.rs.GET;
38 -import javax.ws.rs.PathParam;
39 -import javax.ws.rs.Produces;
40 -import javax.ws.rs.core.Response;
41 -import java.util.HashMap;
42 -import java.util.HashSet;
43 -import java.util.Map;
44 -import java.util.Set;
45 -
46 -import static org.onosproject.net.DeviceId.deviceId;
47 -import static org.onosproject.net.HostId.hostId;
48 -import static org.onosproject.net.PortNumber.portNumber;
49 -
50 -/**
51 - * Topology viewer resource.
52 - */
53 -@javax.ws.rs.Path("topology")
54 -public class TopologyResource extends BaseResource {
55 -
56 - @javax.ws.rs.Path("/graph")
57 - @GET
58 - @Produces("application/json")
59 - public Response graph() {
60 - ObjectMapper mapper = new ObjectMapper();
61 -
62 - // Fetch the services we'll be using.
63 - DeviceService deviceService = get(DeviceService.class);
64 - HostService hostService = get(HostService.class);
65 - TopologyService topologyService = get(TopologyService.class);
66 -
67 - // Fetch the current topology and its graph that we'll use to render.
68 - Topology topo = topologyService.currentTopology();
69 - TopologyGraph graph = topologyService.getGraph(topo);
70 -
71 - // Build all interior vertexes, i.e. no end-station hosts yet
72 - ArrayNode vertexesNode = mapper.createArrayNode();
73 - for (TopologyVertex vertex : graph.getVertexes()) {
74 - vertexesNode.add(json(mapper, vertex.deviceId(), 2,
75 - vertex.deviceId().uri().getSchemeSpecificPart(),
76 - deviceService.isAvailable(vertex.deviceId())));
77 - }
78 -
79 - // Now scan all links and count number of them between the same devices
80 - // using a normalized link key.
81 - Map<String, AggLink> linkRecords = aggregateLinks();
82 -
83 - // Now build all interior edges using the aggregated links.
84 - ArrayNode edgesNode = mapper.createArrayNode();
85 - for (AggLink lr : linkRecords.values()) {
86 - edgesNode.add(json(mapper, lr.links.size(), lr.link.src(), lr.link.dst()));
87 - }
88 -
89 - // Merge the exterior and interior vertexes and inject host links as
90 - // the exterior edges.
91 - for (Host host : hostService.getHosts()) {
92 - Set<IpAddress> ipAddresses = host.ipAddresses();
93 - IpAddress ipAddress = ipAddresses.isEmpty() ? null : ipAddresses.iterator().next();
94 - String label = ipAddress != null ? ipAddress.toString() : host.mac().toString();
95 - vertexesNode.add(json(mapper, host.id(), 3, label, true));
96 - edgesNode.add(json(mapper, 1, host.location(), new ConnectPoint(host.id(), portNumber(-1))));
97 - }
98 -
99 - // Now put the vertexes and edges into a root node and ship them off
100 - ObjectNode rootNode = mapper.createObjectNode();
101 - rootNode.set("vertexes", vertexesNode);
102 - rootNode.set("edges", edgesNode);
103 - return Response.ok(rootNode.toString()).build();
104 - }
105 -
106 -
107 - /**
108 - * Returns a JSON array of all paths between the specified hosts.
109 - *
110 - * @param src source host id
111 - * @param dst target host id
112 - * @return JSON array of paths
113 - */
114 - @javax.ws.rs.Path("/paths/{src}/{dst}")
115 - @GET
116 - @Produces("application/json")
117 - public Response paths(@PathParam("src") String src, @PathParam("dst") String dst) {
118 - ObjectMapper mapper = new ObjectMapper();
119 - PathService pathService = get(PathService.class);
120 - Set<Path> paths = pathService.getPaths(elementId(src), elementId(dst));
121 -
122 - ArrayNode pathsNode = mapper.createArrayNode();
123 - for (Path path : paths) {
124 - pathsNode.add(json(mapper, path));
125 - }
126 -
127 - // Now put the vertexes and edges into a root node and ship them off
128 - ObjectNode rootNode = mapper.createObjectNode();
129 - rootNode.set("paths", pathsNode);
130 - return Response.ok(rootNode.toString()).build();
131 - }
132 -
133 - // Creates either device ID or host ID as appropriate.
134 - private ElementId elementId(String id) {
135 - return id.startsWith("nic:") ? hostId(id) : deviceId(id);
136 - }
137 -
138 - // Scan all links and counts number of them between the same devices
139 - // using a normalized link key.
140 - private Map<String, AggLink> aggregateLinks() {
141 - Map<String, AggLink> aggLinks = new HashMap<>();
142 - LinkService linkService = get(LinkService.class);
143 - for (Link link : linkService.getLinks()) {
144 - String key = key(link);
145 - AggLink lr = aggLinks.get(key);
146 - if (lr == null) {
147 - lr = new AggLink(key);
148 - aggLinks.put(key, lr);
149 - }
150 - lr.addLink(link);
151 - }
152 - return aggLinks;
153 - }
154 -
155 - // Produces JSON for a graph vertex.
156 - private ObjectNode json(ObjectMapper mapper, ElementId id, int group,
157 - String label, boolean isOnline) {
158 - return mapper.createObjectNode()
159 - .put("name", id.toString())
160 - .put("label", label)
161 - .put("group", group)
162 - .put("online", isOnline);
163 - }
164 -
165 - // Produces JSON for a graph edge.
166 - private ObjectNode json(ObjectMapper mapper, int count,
167 - ConnectPoint src, ConnectPoint dst) {
168 - return json(mapper, count, id(src), id(dst));
169 - }
170 -
171 - // Produces JSON for a graph edge.
172 - private ObjectNode json(ObjectMapper mapper, int count, String src, String dst) {
173 - return mapper.createObjectNode()
174 - .put("source", src).put("target", dst).put("value", count);
175 - }
176 -
177 - // Produces JSON representation of a network path.
178 - private ArrayNode json(ObjectMapper mapper, Path path) {
179 - ArrayNode pathNode = mapper.createArrayNode();
180 - for (Link link : path.links()) {
181 - ObjectNode linkNode = mapper.createObjectNode()
182 - .put("src", id(link.src()))
183 - .put("dst", id(link.dst()));
184 - pathNode.add(linkNode);
185 - }
186 - return pathNode;
187 - }
188 -
189 -
190 - // Aggregate link of all links between the same devices regardless of
191 - // their direction.
192 - private class AggLink {
193 - Link link; // representative links
194 -
195 - final String key;
196 - final Set<Link> links = new HashSet<>();
197 -
198 - AggLink(String key) {
199 - this.key = key;
200 - }
201 -
202 - void addLink(Link link) {
203 - links.add(link);
204 - if (this.link == null) {
205 - this.link = link;
206 - }
207 - }
208 - }
209 -
210 - // Returns a canonical key for the specified link.
211 - static String key(Link link) {
212 - String s = id(link.src());
213 - String d = id(link.dst());
214 - return s.compareTo(d) > 0 ? d + s : s + d;
215 - }
216 -
217 - // Returns a formatted string for the element associated with the given
218 - // connection point.
219 - private static String id(ConnectPoint cp) {
220 - return cp.elementId().toString();
221 - }
222 -
223 -}
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -
17 -/**
18 - * Sample topology viewer application.
19 - */
20 -package org.onosproject.tvue;
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2014 Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
18 - xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
19 - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
20 - id="ONOS" version="2.5">
21 - <display-name>ONOS GUI</display-name>
22 -
23 - <welcome-file-list>
24 - <welcome-file>index.html</welcome-file>
25 - </welcome-file-list>
26 -
27 - <servlet>
28 - <servlet-name>JAX-RS Service</servlet-name>
29 - <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
30 - <init-param>
31 - <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
32 - <param-value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value>
33 - </init-param>
34 - <init-param>
35 - <!--param-name>com.sun.jersey.config.property.packages</param-name>
36 - <param-value>org.onosproject.tvue</param-value-->
37 - <param-name>com.sun.jersey.config.property.classnames</param-name>
38 - <param-value>org.onosproject.tvue.TopologyResource</param-value>
39 - </init-param>
40 - <load-on-startup>10</load-on-startup>
41 - </servlet>
42 -
43 - <servlet-mapping>
44 - <servlet-name>JAX-RS Service</servlet-name>
45 - <url-pattern>/rs/*</url-pattern>
46 - </servlet-mapping>
47 -
48 -</web-app>
1 -<!DOCTYPE html>
2 -<!--
3 - ~ Copyright 2014 Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -<html>
18 -<head>
19 - <title>Topology Viewer</title>
20 - <script src="libs/d3.v3.min.js"></script>
21 - <script src="libs/jquery-1.11.1.min.js"></script>
22 - <style>
23 - .link {
24 - }
25 -
26 - .node {
27 - stroke-width: 3px;
28 - }
29 -
30 - .textClass {
31 - stroke: #323232;
32 - font-family: "Lucida Grande", "Droid Sans", Arial, Helvetica, sans-serif;
33 - font-weight: normal;
34 - stroke-width: .5;
35 - font-size: 14px;
36 - }
37 - </style>
38 -</head>
39 -<body>
40 - <script>
41 - // Adapted from sample code @ ericcoopey’s block #6c602d7cb14b25c179a4
42 - // by Thomas Vachuska
43 -
44 - var graph,
45 - topo = {vertexes:{}, edges:{}},
46 - paths = [],
47 - currentPath = 0;
48 -
49 - // Set up the canvas
50 - var w = 2048,
51 - h = 2048;
52 -
53 - // Allocate colors predictably
54 - var color = d3.scale.category10(),
55 - deviceColor = color(2),
56 - sourceColor = color(0),
57 - targetColor = color(1),
58 - dummy1Color = color(9),
59 - dummy2Color = color(8),
60 - dummy3Color = color(7),
61 - dummy4Color = color(6),
62 - offlineColor = color(5),
63 - dummy5Color = color(4),
64 - hostColor = color(3);
65 -
66 - var selectedNode,
67 - sourceNode,
68 - targetNode,
69 - pathRequested;
70 -
71 -
72 - function fillColor(d) {
73 - return ((targetNode && targetNode.id == d.id) ? targetColor :
74 - ((sourceNode && sourceNode.id == d.id) ? sourceColor :
75 - d.online ? color(d.group) : offlineColor));
76 - }
77 -
78 - function strokeColor(d) {
79 - return selectedNode && d.id == selectedNode.id ? "#f00" : "#aaa";
80 - }
81 -
82 - function linkColor(d) {
83 - if (!paths || paths.length == 0) {
84 - return "#666";
85 - }
86 -
87 - var path = paths[currentPath];
88 - if (path) {
89 - for (var i = 0, n = path.length; i < n; i++) {
90 - var link = path[i];
91 - if ((link.src == d.source.id || link.dst == d.source.id) &&
92 - (link.dst == d.target.id || link.src == d.target.id)) {
93 - return "#f00";
94 - }
95 - }
96 - }
97 - return "#666";
98 - }
99 -
100 - function linkKey(link) {
101 - return link.source.id + "-" + link.target.id;
102 -
103 - };
104 -
105 - function toggleNode(node) {
106 - pathRequested = false;
107 - return selectedNode && selectedNode != node ? selectedNode : null;
108 -
109 - };
110 -
111 - function refreshPaths() {
112 - d3.selectAll("line").attr("stroke", linkColor);
113 - }
114 -
115 - function fetchPaths() {
116 - if (!pathRequested && sourceNode && targetNode) {
117 - pathRequested = true;
118 - d3.json("rs/topology/paths/" + sourceNode.id + "/" + targetNode.id, function(error, data) {
119 - currentPath = 0;
120 - paths = data.paths;
121 - refreshPaths();
122 - });
123 - }
124 - }
125 -
126 - function resetSelections() {
127 - selectedNode = null;
128 - sourceNode = null;
129 - targetNode = null;
130 - paths = [];
131 - currentPath = 0;
132 - refreshPaths();
133 - d3.selectAll(".nodeStrokeClass").attr("stroke", strokeColor);
134 - }
135 -
136 - function nextPath() {
137 - currentPath = paths && currentPath < paths.length - 1 ? currentPath + 1 : 0
138 - console.log("Showing path: " + currentPath);
139 - refreshPaths();
140 - }
141 -
142 - function dblclick(d) {
143 - d3.select(this).classed("fixed", d.fixed = false);
144 - }
145 -
146 - function dragstart(d) {
147 - // d3.select(this).classed("fixed", d.fixed = true);
148 - }
149 -
150 -
151 - function topoGraph() {
152 - // Add and remove elements on the graph object
153 - this.addNode = function (vertex, stamp) {
154 - var node = topo.vertexes[vertex.name];
155 - if (node) {
156 - var oldState = node.online;
157 - node.online = vertex.online;
158 - node.stamp = stamp;
159 - if (oldState != node.online) {
160 - update();
161 - return true;
162 - }
163 - return false;
164 - }
165 - node = {"id": vertex.name, "label": vertex.label,
166 - "group": vertex.group, "online": vertex.online, "stamp": stamp};
167 - nodes.push(node);
168 - topo.vertexes[vertex.name] = node;
169 - update();
170 - return true;
171 - };
172 -
173 - this.addLink = function (edge, stamp) {
174 - var key = edge.source + "-" + edge.target;
175 - var link = topo.edges[key];
176 - if (link) {
177 - var oldValue = link.value;
178 - link.value = edge.value;
179 - link.stamp = stamp;
180 - if (oldValue != link.value) {
181 - update();
182 - return true;
183 - }
184 - return false;
185 - }
186 - link = {"source": findNode(edge.source), "target": findNode(edge.target),
187 - "value": edge.value, "stamp": stamp};
188 - links.push(link);
189 - topo.edges[key] = link;
190 - update();
191 - return true;
192 - };
193 -
194 - this.prune = function (stamp) {
195 - var linksChanged = pruneArray(links, stamp, topo.edges, linkKey);
196 - var nodesChanged = pruneArray(nodes, stamp, topo.vertexes,
197 - function(node) { return node.id; });
198 - if (linksChanged || nodesChanged) {
199 - update();
200 - return true;
201 - }
202 - return false;
203 - };
204 -
205 - var pruneArray = function(array, stamp, map, key) {
206 - var changed = false;
207 - for (var i = 0; i < array.length; i++) {
208 - if (array[i].stamp < stamp) {
209 - changed = true;
210 - map[key(array[i])] = null;
211 - array.splice(i, 1);
212 - i--;
213 - }
214 - }
215 - return changed;
216 - };
217 -
218 - var findNode = function (id) {
219 - for (var i in nodes) {
220 - if (nodes[i]["id"] === id) return nodes[i];
221 - }
222 - };
223 -
224 - var force = d3.layout.force();
225 -
226 - var drag = force.drag()
227 - .on("dragstart", dragstart);
228 -
229 - var nodes = force.nodes(),
230 - links = force.links();
231 -
232 - var vis = d3.select("body")
233 - .append("svg:svg")
234 - .attr("width", w)
235 - .attr("height", h)
236 - .attr("id", "svg")
237 - .attr("pointer-events", "all")
238 - .attr("viewBox", "0 0 " + w + " " + h)
239 - .attr("perserveAspectRatio", "xMinYMid")
240 - .append('svg:g');
241 -
242 - d3.select("body")
243 - .on("keydown", function(d) {
244 - console.log(d3.event.keyCode);
245 - if (d3.event.keyCode == 27) {
246 - resetSelections();
247 - } else if (d3.event.keyCode == 83) {
248 - sourceNode = toggleNode(sourceNode);
249 - } else if (d3.event.keyCode == 68) {
250 - targetNode = toggleNode(targetNode);
251 - } else if (d3.event.keyCode == 65) {
252 - var aux = sourceNode;
253 - sourceNode = targetNode;
254 - targetNode = aux;
255 - } else if (d3.event.keyCode == 70) {
256 - nextPath();
257 - } else if (d3.event.keyCode == 67 && selectedNode) {
258 - selectedNode.fixed = !selectedNode.fixed;
259 - }
260 -
261 - d3.selectAll(".nodeStrokeClass").attr("fill", fillColor);
262 - fetchPaths();
263 - });
264 -
265 -
266 - var update = function () {
267 - var link = vis.selectAll("line")
268 - .data(links, linkKey);
269 -
270 - link.enter().append("line")
271 - .attr("id", linkKey)
272 - .attr("class", "link")
273 - .attr("stroke-width", function (d) { return d.value; })
274 - .attr("stroke", linkColor);
275 - link.append("title").text(function (d) { return d.id; });
276 - link.exit().remove();
277 -
278 - var node = vis.selectAll("g.node")
279 - .data(nodes, function (d) { return d.id; })
280 - .on("click", function(d) {
281 - selectedNode = d;
282 - d3.selectAll(".nodeStrokeClass").attr("stroke", strokeColor);
283 - });
284 -
285 - var nodeEnter = node.enter().append("g")
286 - .attr("class", "node")
287 - .on("dblclick", dblclick)
288 - .call(force.drag);
289 -
290 - nodeEnter.append("svg:circle")
291 - .attr("r", function(d) { return 28 / 2; })
292 - .attr("id", function (d) { return "n-" + d.id.replace(/[.:]/g, ""); })
293 - .attr("class", "nodeStrokeClass")
294 - .attr("fill", fillColor)
295 - .attr("stroke", strokeColor);
296 -
297 - nodeEnter.append("image")
298 - .attr("xlink:href", function(d) { return d.group == 2 ? "images/switch.png" : "images/server.png"; })
299 - .attr("x", -12)
300 - .attr("y", -12)
301 - .attr("width", 24)
302 - .attr("height", 24);
303 -
304 - nodeEnter.append("svg:text")
305 - .attr("class", "textClass")
306 - .attr("x", 20)
307 - .attr("y", ".31em")
308 - .text(function (d) { return d.label; });
309 -
310 - node.exit().remove();
311 -
312 - d3.selectAll("nodeStrokeClass").attr("stroke", strokeColor);
313 -
314 - force.on("tick", function () {
315 - node.attr("transform", function (d) {
316 - return "translate(" + d.x + "," + d.y + ")";
317 - });
318 -
319 - link.attr("x1", function (d) { return d.source.x; })
320 - .attr("y1", function (d) { return d.source.y; })
321 - .attr("x2", function (d) { return d.target.x; })
322 - .attr("y2", function (d) { return d.target.y; });
323 - });
324 -
325 - // Restart the force layout.
326 - force
327 - .gravity(0.3)
328 - .charge(-15000)
329 - .friction(0.1)
330 - .linkDistance(function(d) { return d.value * 30; })
331 - .linkStrength(function(d) { return d.value * 0.6; })
332 - .size([w, h])
333 - .start();
334 - };
335 -
336 - // Make it all go
337 - update();
338 - }
339 -
340 - function drawGraph() {
341 - graph = new topoGraph("#svgdiv");
342 - bringNodesToFront();
343 - }
344 -
345 - function bringNodesToFront() {
346 - $(".nodeStrokeClass").each(function( index ) {
347 - var gnode = this.parentNode;
348 - gnode.parentNode.appendChild(gnode);
349 - });
350 - }
351 -
352 - function addNodes() {
353 - d3.select("svg")
354 - .remove();
355 - drawGraph();
356 - }
357 -
358 - function fetchData() {
359 - var stamp = new Date().getTime();
360 - d3.json("rs/topology/graph", function(error, data) {
361 - var changed = false;
362 - data.vertexes.forEach(function(vertex) { changed = graph.addNode(vertex, stamp) || changed; });
363 - data.edges.forEach(function(edge) { changed = graph.addLink(edge, stamp) || changed; });
364 -
365 - changed = graph.prune(stamp) || changed;
366 - if (changed) {
367 - bringNodesToFront();
368 - // Update node and links styles
369 - d3.selectAll(".nodeStrokeClass").attr("fill", fillColor);
370 - d3.selectAll(".line").attr("stroke-width", function (d) { return d.value; })
371 - }
372 -
373 - setTimeout(fetchData, 1000);
374 - });
375 - };
376 -
377 - drawGraph();
378 - setTimeout(fetchData, 500);
379 -
380 - </script>
381 -</body>
382 -</html>
...\ No newline at end of file ...\ No newline at end of file
This diff could not be displayed because it is too large.
1 -/*
2 - * Copyright 2014 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -
17 -/*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
18 -!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.1",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b=a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+O+"))|)"+M+"*\\]",Q=":("+N+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+P+")*)|.*)\\)|)",R=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),S=new RegExp("^"+M+"*,"+M+"*"),T=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),V=new RegExp(Q),W=new RegExp("^"+O+"$"),X={ID:new RegExp("^#("+N+")"),CLASS:new RegExp("^\\.("+N+")"),TAG:new RegExp("^("+N.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+Q),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+L+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{I.apply(F=J.call(v.childNodes),v.childNodes),F[v.childNodes.length].nodeType}catch(eb){I={apply:F.length?function(a,b){H.apply(a,J.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],!a||"string"!=typeof a)return d;if(1!==(k=b.nodeType)&&9!==k)return[];if(p&&!e){if(f=_.exec(a))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return I.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return I.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=9===k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+qb(o[l]);w=ab.test(a)&&ob(b.parentNode)||b,x=o.join(",")}if(x)try{return I.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function gb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function hb(a){return a[u]=!0,a}function ib(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function jb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function kb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||D)-(~a.sourceIndex||D);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function lb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function nb(a){return hb(function(b){return b=+b,hb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function ob(a){return a&&typeof a.getElementsByTagName!==C&&a}c=fb.support={},f=fb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fb.setDocument=function(a){var b,e=a?a.ownerDocument||a:v,g=e.defaultView;return e!==n&&9===e.nodeType&&e.documentElement?(n=e,o=e.documentElement,p=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){m()},!1):g.attachEvent&&g.attachEvent("onunload",function(){m()})),c.attributes=ib(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ib(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(e.getElementsByClassName)&&ib(function(a){return a.innerHTML="<div class='a'></div><div class='a i'></div>",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=ib(function(a){return o.appendChild(a).id=u,!e.getElementsByName||!e.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==C&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c=typeof a.getAttributeNode!==C&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==C?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==C&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(e.querySelectorAll))&&(ib(function(a){a.innerHTML="<select msallowclip=''><option selected=''></option></select>",a.querySelectorAll("[msallowclip^='']").length&&q.push("[*^$]="+M+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+M+"*(?:value|"+L+")"),a.querySelectorAll(":checked").length||q.push(":checked")}),ib(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+M+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ib(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",Q)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===v&&t(v,a)?-1:b===e||b.ownerDocument===v&&t(v,b)?1:k?K.call(k,a)-K.call(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],i=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:k?K.call(k,a)-K.call(k,b):0;if(f===g)return kb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?kb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},e):n},fb.matches=function(a,b){return fb(a,null,null,b)},fb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fb(b,n,null,[a]).length>0},fb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&E.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fb.selectors={cacheLength:50,createPseudo:hb,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+M+")"+a+"("+M+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==C&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?hb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=K.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:hb(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?hb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:hb(function(a){return function(b){return fb(a,b).length>0}}),contains:hb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:hb(function(a){return W.test(a||"")||fb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:nb(function(){return[0]}),last:nb(function(a,b){return[b-1]}),eq:nb(function(a,b,c){return[0>c?c+b:c]}),even:nb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:nb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:nb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:nb(function(a,b,c){for(var d=0>c?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=lb(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=mb(b);function pb(){}pb.prototype=d.filters=d.pseudos,d.setFilters=new pb,g=fb.tokenize=function(a,b){var c,e,f,g,h,i,j,k=z[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){(!c||(e=S.exec(h)))&&(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=T.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(R," ")}),h=h.slice(c.length));for(g in d.filter)!(e=X[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?fb.error(a):z(a,i).slice(0)};function qb(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function rb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function sb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function tb(a,b,c){for(var d=0,e=b.length;e>d;d++)fb(a,b[d],c);return c}function ub(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function vb(a,b,c,d,e,f){return d&&!d[u]&&(d=vb(d)),e&&!e[u]&&(e=vb(e,f)),hb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||tb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ub(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ub(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?K.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ub(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):I.apply(g,r)})}function wb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=rb(function(a){return a===b},h,!0),l=rb(function(a){return K.call(b,a)>-1},h,!0),m=[function(a,c,d){return!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>i;i++)if(c=d.relative[a[i].type])m=[rb(sb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return vb(i>1&&sb(m),i>1&&qb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&wb(a.slice(i,e)),f>e&&wb(a=a.slice(e)),f>e&&qb(a))}m.push(c)}return sb(m)}function xb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=G.call(i));s=ub(s)}I.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&fb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?hb(f):f}return h=fb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xb(e,d)),f.selector=a}return f},i=fb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&ob(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qb(j),!a)return I.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&ob(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ib(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ib(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||jb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ib(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||jb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ib(function(a){return null==a.getAttribute("disabled")})||jb(L,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fb}(a);m.find=s,m.expr=s.selectors,m.expr[":"]=m.expr.pseudos,m.unique=s.uniqueSort,m.text=s.getText,m.isXMLDoc=s.isXML,m.contains=s.contains;var t=m.expr.match.needsContext,u=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/^.[^:#\[\.,]*$/;function w(a,b,c){if(m.isFunction(b))return m.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return m.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(v.test(b))return m.filter(b,a,c);b=m.filter(b,a)}return m.grep(a,function(a){return m.inArray(a,b)>=0!==c})}m.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?m.find.matchesSelector(d,a)?[d]:[]:m.find.matches(a,m.grep(b,function(a){return 1===a.nodeType}))},m.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(m(a).filter(function(){for(b=0;e>b;b++)if(m.contains(d[b],this))return!0}));for(b=0;e>b;b++)m.find(a,d[b],c);return c=this.pushStack(e>1?m.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(w(this,a||[],!1))},not:function(a){return this.pushStack(w(this,a||[],!0))},is:function(a){return!!w(this,"string"==typeof a&&t.test(a)?m(a):a||[],!1).length}});var x,y=a.document,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=m.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||x).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof m?b[0]:b,m.merge(this,m.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:y,!0)),u.test(c[1])&&m.isPlainObject(b))for(c in b)m.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=y.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return x.find(a);this.length=1,this[0]=d}return this.context=y,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):m.isFunction(a)?"undefined"!=typeof x.ready?x.ready(a):a(m):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),m.makeArray(a,this))};A.prototype=m.fn,x=m(y);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};m.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!m(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),m.fn.extend({has:function(a){var b,c=m(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(m.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=t.test(a)||"string"!=typeof a?m(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&m.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?m.unique(f):f)},index:function(a){return a?"string"==typeof a?m.inArray(this[0],m(a)):m.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(m.unique(m.merge(this.get(),m(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}m.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return m.dir(a,"parentNode")},parentsUntil:function(a,b,c){return m.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return m.dir(a,"nextSibling")},prevAll:function(a){return m.dir(a,"previousSibling")},nextUntil:function(a,b,c){return m.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return m.dir(a,"previousSibling",c)},siblings:function(a){return m.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return m.sibling(a.firstChild)},contents:function(a){return m.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:m.merge([],a.childNodes)}},function(a,b){m.fn[a]=function(c,d){var e=m.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=m.filter(d,e)),this.length>1&&(C[a]||(e=m.unique(e)),B.test(a)&&(e=e.reverse())),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return m.each(a.match(E)||[],function(a,c){b[c]=!0}),b}m.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):m.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){m.each(b,function(b,c){var d=m.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&m.each(arguments,function(a,c){var d;while((d=m.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?m.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},m.extend({Deferred:function(a){var b=[["resolve","done",m.Callbacks("once memory"),"resolved"],["reject","fail",m.Callbacks("once memory"),"rejected"],["notify","progress",m.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return m.Deferred(function(c){m.each(b,function(b,f){var g=m.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&m.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?m.extend(a,d):d}},e={};return d.pipe=d.then,m.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&m.isFunction(a.promise)?e:0,g=1===f?a:m.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&m.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;m.fn.ready=function(a){return m.ready.promise().done(a),this},m.extend({isReady:!1,readyWait:1,holdReady:function(a){a?m.readyWait++:m.ready(!0)},ready:function(a){if(a===!0?!--m.readyWait:!m.isReady){if(!y.body)return setTimeout(m.ready);m.isReady=!0,a!==!0&&--m.readyWait>0||(H.resolveWith(y,[m]),m.fn.triggerHandler&&(m(y).triggerHandler("ready"),m(y).off("ready")))}}});function I(){y.addEventListener?(y.removeEventListener("DOMContentLoaded",J,!1),a.removeEventListener("load",J,!1)):(y.detachEvent("onreadystatechange",J),a.detachEvent("onload",J))}function J(){(y.addEventListener||"load"===event.type||"complete"===y.readyState)&&(I(),m.ready())}m.ready.promise=function(b){if(!H)if(H=m.Deferred(),"complete"===y.readyState)setTimeout(m.ready);else if(y.addEventListener)y.addEventListener("DOMContentLoaded",J,!1),a.addEventListener("load",J,!1);else{y.attachEvent("onreadystatechange",J),a.attachEvent("onload",J);var c=!1;try{c=null==a.frameElement&&y.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!m.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}I(),m.ready()}}()}return H.promise(b)};var K="undefined",L;for(L in m(k))break;k.ownLast="0"!==L,k.inlineBlockNeedsLayout=!1,m(function(){var a,b,c,d;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",k.inlineBlockNeedsLayout=a=3===b.offsetWidth,a&&(c.style.zoom=1)),c.removeChild(d))}),function(){var a=y.createElement("div");if(null==k.deleteExpando){k.deleteExpando=!0;try{delete a.test}catch(b){k.deleteExpando=!1}}a=null}(),m.acceptData=function(a){var b=m.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var M=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,N=/([A-Z])/g;function O(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(N,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:M.test(c)?m.parseJSON(c):c}catch(e){}m.data(a,b,c)}else c=void 0}return c}function P(a){var b;for(b in a)if(("data"!==b||!m.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h;
19 -if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?m.queue(this[0],a):void 0===b?this:this.each(function(){var c=m.queue(this,a,b);m._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&m.dequeue(this,a)})},dequeue:function(a){return this.each(function(){m.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=m.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=m._data(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var S=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=["Top","Right","Bottom","Left"],U=function(a,b){return a=b||a,"none"===m.css(a,"display")||!m.contains(a.ownerDocument,a)},V=m.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===m.type(c)){e=!0;for(h in c)m.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,m.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(m(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav></:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="<input type='radio' checked='checked' name='t'/>",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function ab(){return!0}function bb(){return!1}function cb(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=m.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof m===K||a&&m.event.triggered===a.type?void 0:m.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(E)||[""],h=b.length;while(h--)f=_.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=m.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=m.event.special[o]||{},l=m.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&m.expr.match.needsContext.test(e),namespace:p.join(".")},i),(n=g[o])||(n=g[o]=[],n.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?n.splice(n.delegateCount++,0,l):n.push(l),m.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m.hasData(a)&&m._data(a);if(r&&(k=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=_.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=m.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,n=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=n.length;while(f--)g=n[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(n.splice(f,1),g.selector&&n.delegateCount--,l.remove&&l.remove.call(a,g));i&&!n.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||m.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)m.event.remove(a,o+b[j],c,d,!0);m.isEmptyObject(k)&&(delete r.handle,m._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,o=[d||y],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||y,3!==d.nodeType&&8!==d.nodeType&&!$.test(p+m.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[m.expando]?b:new m.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:m.makeArray(c,[b]),k=m.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!m.isWindow(d)){for(i=k.delegateType||p,$.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||y)&&o.push(l.defaultView||l.parentWindow||a)}n=0;while((h=o[n++])&&!b.isPropagationStopped())b.type=n>1?i:k.bindType||p,f=(m._data(h,"events")||{})[b.type]&&m._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&m.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&m.acceptData(d)&&g&&d[p]&&!m.isWindow(d)){l=d[g],l&&(d[g]=null),m.event.triggered=p;try{d[p]()}catch(r){}m.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=m.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(m._data(this,"events")||{})[a.type]||[],k=m.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=m.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((m.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?m(c,this).index(i)>=0:m.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h<b.length&&g.push({elem:this,handlers:b.slice(h)}),g},fix:function(a){if(a[m.expando])return a;var b,c,d,e=a.type,f=a,g=this.fixHooks[e];g||(this.fixHooks[e]=g=Z.test(e)?this.mouseHooks:Y.test(e)?this.keyHooks:{}),d=g.props?this.props.concat(g.props):this.props,a=new m.Event(f),b=d.length;while(b--)c=d[b],a[c]=f[c];return a.target||(a.target=f.srcElement||y),3===a.target.nodeType&&(a.target=a.target.parentNode),a.metaKey=!!a.metaKey,g.filter?g.filter(a,f):a},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return null==a.which&&(a.which=null!=b.charCode?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,b){var c,d,e,f=b.button,g=b.fromElement;return null==a.pageX&&null!=b.clientX&&(d=a.target.ownerDocument||y,e=d.documentElement,c=d.body,a.pageX=b.clientX+(e&&e.scrollLeft||c&&c.scrollLeft||0)-(e&&e.clientLeft||c&&c.clientLeft||0),a.pageY=b.clientY+(e&&e.scrollTop||c&&c.scrollTop||0)-(e&&e.clientTop||c&&c.clientTop||0)),!a.relatedTarget&&g&&(a.relatedTarget=g===a.target?b.toElement:g),a.which||void 0===f||(a.which=1&f?1:2&f?3:4&f?2:0),a}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==cb()&&this.focus)try{return this.focus(),!1}catch(a){}},delegateType:"focusin"},blur:{trigger:function(){return this===cb()&&this.blur?(this.blur(),!1):void 0},delegateType:"focusout"},click:{trigger:function(){return m.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):void 0},_default:function(a){return m.nodeName(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&a.originalEvent&&(a.originalEvent.returnValue=a.result)}}},simulate:function(a,b,c,d){var e=m.extend(new m.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?m.event.trigger(e,null,b):m.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},m.removeEvent=y.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){var d="on"+b;a.detachEvent&&(typeof a[d]===K&&(a[d]=null),a.detachEvent(d,c))},m.Event=function(a,b){return this instanceof m.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.returnValue===!1?ab:bb):this.type=a,b&&m.extend(this,b),this.timeStamp=a&&a.timeStamp||m.now(),void(this[m.expando]=!0)):new m.Event(a,b)},m.Event.prototype={isDefaultPrevented:bb,isPropagationStopped:bb,isImmediatePropagationStopped:bb,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=ab,a&&(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=ab,a&&(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){var a=this.originalEvent;this.isImmediatePropagationStopped=ab,a&&a.stopImmediatePropagation&&a.stopImmediatePropagation(),this.stopPropagation()}},m.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(a,b){m.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return(!e||e!==d&&!m.contains(d,e))&&(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),k.submitBubbles||(m.event.special.submit={setup:function(){return m.nodeName(this,"form")?!1:void m.event.add(this,"click._submit keypress._submit",function(a){var b=a.target,c=m.nodeName(b,"input")||m.nodeName(b,"button")?b.form:void 0;c&&!m._data(c,"submitBubbles")&&(m.event.add(c,"submit._submit",function(a){a._submit_bubble=!0}),m._data(c,"submitBubbles",!0))})},postDispatch:function(a){a._submit_bubble&&(delete a._submit_bubble,this.parentNode&&!a.isTrigger&&m.event.simulate("submit",this.parentNode,a,!0))},teardown:function(){return m.nodeName(this,"form")?!1:void m.event.remove(this,"._submit")}}),k.changeBubbles||(m.event.special.change={setup:function(){return X.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(m.event.add(this,"propertychange._change",function(a){"checked"===a.originalEvent.propertyName&&(this._just_changed=!0)}),m.event.add(this,"click._change",function(a){this._just_changed&&!a.isTrigger&&(this._just_changed=!1),m.event.simulate("change",this,a,!0)})),!1):void m.event.add(this,"beforeactivate._change",function(a){var b=a.target;X.test(b.nodeName)&&!m._data(b,"changeBubbles")&&(m.event.add(b,"change._change",function(a){!this.parentNode||a.isSimulated||a.isTrigger||m.event.simulate("change",this.parentNode,a,!0)}),m._data(b,"changeBubbles",!0))})},handle:function(a){var b=a.target;return this!==b||a.isSimulated||a.isTrigger||"radio"!==b.type&&"checkbox"!==b.type?a.handleObj.handler.apply(this,arguments):void 0},teardown:function(){return m.event.remove(this,"._change"),!X.test(this.nodeName)}}),k.focusinBubbles||m.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){m.event.simulate(b,a.target,m.event.fix(a),!0)};m.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=m._data(d,b);e||d.addEventListener(a,c,!0),m._data(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=m._data(d,b)-1;e?m._data(d,b,e):(d.removeEventListener(a,c,!0),m._removeData(d,b))}}}),m.fn.extend({on:function(a,b,c,d,e){var f,g;if("object"==typeof a){"string"!=typeof b&&(c=c||b,b=void 0);for(f in a)this.on(f,b,c,a[f],e);return this}if(null==c&&null==d?(d=b,c=b=void 0):null==d&&("string"==typeof b?(d=c,c=void 0):(d=c,c=b,b=void 0)),d===!1)d=bb;else if(!d)return this;return 1===e&&(g=d,d=function(a){return m().off(a),g.apply(this,arguments)},d.guid=g.guid||(g.guid=m.guid++)),this.each(function(){m.event.add(this,a,d,c,b)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,m(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return(b===!1||"function"==typeof b)&&(c=b,b=void 0),c===!1&&(c=bb),this.each(function(){m.event.remove(this,a,c,b)})},trigger:function(a,b){return this.each(function(){m.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];return c?m.event.trigger(a,b,c,!0):void 0}});function db(a){var b=eb.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}var eb="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",fb=/ jQuery\d+="(?:null|\d+)"/g,gb=new RegExp("<(?:"+eb+")[\\s/>]","i"),hb=/^\s+/,ib=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,jb=/<([\w:]+)/,kb=/<tbody/i,lb=/<|&#?\w+;/,mb=/<(?:script|style|link)/i,nb=/checked\s*(?:[^=]|=\s*.checked.)/i,ob=/^$|\/(?:java|ecma)script/i,pb=/^true\/(.*)/,qb=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,rb={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:k.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},sb=db(y),tb=sb.appendChild(y.createElement("div"));rb.optgroup=rb.option,rb.tbody=rb.tfoot=rb.colgroup=rb.caption=rb.thead,rb.th=rb.td;function ub(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==K?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==K?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||m.nodeName(d,b)?f.push(d):m.merge(f,ub(d,b));return void 0===b||b&&m.nodeName(a,b)?m.merge([a],f):f}function vb(a){W.test(a.type)&&(a.defaultChecked=a.checked)}function wb(a,b){return m.nodeName(a,"table")&&m.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function xb(a){return a.type=(null!==m.find.attr(a,"type"))+"/"+a.type,a}function yb(a){var b=pb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function zb(a,b){for(var c,d=0;null!=(c=a[d]);d++)m._data(c,"globalEval",!b||m._data(b[d],"globalEval"))}function Ab(a,b){if(1===b.nodeType&&m.hasData(a)){var c,d,e,f=m._data(a),g=m._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)m.event.add(b,c,h[c][d])}g.data&&(g.data=m.extend({},g.data))}}function Bb(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!k.noCloneEvent&&b[m.expando]){e=m._data(b);for(d in e.events)m.removeEvent(b,d,e.handle);b.removeAttribute(m.expando)}"script"===c&&b.text!==a.text?(xb(b).text=a.text,yb(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),k.html5Clone&&a.innerHTML&&!m.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&W.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}m.extend({clone:function(a,b,c){var d,e,f,g,h,i=m.contains(a.ownerDocument,a);if(k.html5Clone||m.isXMLDoc(a)||!gb.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(tb.innerHTML=a.outerHTML,tb.removeChild(f=tb.firstChild)),!(k.noCloneEvent&&k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||m.isXMLDoc(a)))for(d=ub(f),h=ub(a),g=0;null!=(e=h[g]);++g)d[g]&&Bb(e,d[g]);if(b)if(c)for(h=h||ub(a),d=d||ub(f),g=0;null!=(e=h[g]);g++)Ab(e,d[g]);else Ab(a,f);return d=ub(f,"script"),d.length>0&&zb(d,!i&&ub(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,l,n=a.length,o=db(b),p=[],q=0;n>q;q++)if(f=a[q],f||0===f)if("object"===m.type(f))m.merge(p,f.nodeType?[f]:f);else if(lb.test(f)){h=h||o.appendChild(b.createElement("div")),i=(jb.exec(f)||["",""])[1].toLowerCase(),l=rb[i]||rb._default,h.innerHTML=l[1]+f.replace(ib,"<$1></$2>")+l[2],e=l[0];while(e--)h=h.lastChild;if(!k.leadingWhitespace&&hb.test(f)&&p.push(b.createTextNode(hb.exec(f)[0])),!k.tbody){f="table"!==i||kb.test(f)?"<table>"!==l[1]||kb.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)m.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}m.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),k.appendChecked||m.grep(ub(p,"input"),vb),q=0;while(f=p[q++])if((!d||-1===m.inArray(f,d))&&(g=m.contains(f.ownerDocument,f),h=ub(o.appendChild(f),"script"),g&&zb(h),c)){e=0;while(f=h[e++])ob.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=m.expando,j=m.cache,l=k.deleteExpando,n=m.event.special;null!=(d=a[h]);h++)if((b||m.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)n[e]?m.event.remove(d,e):m.removeEvent(d,e,g.handle);j[f]&&(delete j[f],l?delete d[i]:typeof d.removeAttribute!==K?d.removeAttribute(i):d[i]=null,c.push(f))}}}),m.fn.extend({text:function(a){return V(this,function(a){return void 0===a?m.text(this):this.empty().append((this[0]&&this[0].ownerDocument||y).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?m.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||m.cleanData(ub(c)),c.parentNode&&(b&&m.contains(c.ownerDocument,c)&&zb(ub(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&m.cleanData(ub(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&m.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return m.clone(this,a,b)})},html:function(a){return V(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(fb,""):void 0;if(!("string"!=typeof a||mb.test(a)||!k.htmlSerialize&&gb.test(a)||!k.leadingWhitespace&&hb.test(a)||rb[(jb.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(ib,"<$1></$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(m.cleanData(ub(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,m.cleanData(ub(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,n=this,o=l-1,p=a[0],q=m.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&nb.test(p))return this.each(function(c){var d=n.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(i=m.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=m.map(ub(i,"script"),xb),f=g.length;l>j;j++)d=i,j!==o&&(d=m.clone(d,!0,!0),f&&m.merge(g,ub(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,m.map(g,yb),j=0;f>j;j++)d=g[j],ob.test(d.type||"")&&!m._data(d,"globalEval")&&m.contains(h,d)&&(d.src?m._evalUrl&&m._evalUrl(d.src):m.globalEval((d.text||d.textContent||d.innerHTML||"").replace(qb,"")));i=c=null}return this}}),m.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){m.fn[a]=function(a){for(var c,d=0,e=[],g=m(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),m(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Cb,Db={};function Eb(b,c){var d,e=m(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:m.css(e[0],"display");return e.detach(),f}function Fb(a){var b=y,c=Db[a];return c||(c=Eb(a,b),"none"!==c&&c||(Cb=(Cb||m("<iframe frameborder='0' width='0' height='0'/>")).appendTo(b.documentElement),b=(Cb[0].contentWindow||Cb[0].contentDocument).document,b.write(),b.close(),c=Eb(a,b),Cb.detach()),Db[a]=c),c}!function(){var a;k.shrinkWrapBlocks=function(){if(null!=a)return a;a=!1;var b,c,d;return c=y.getElementsByTagName("body")[0],c&&c.style?(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:1px;width:1px;zoom:1",b.appendChild(y.createElement("div")).style.width="5px",a=3!==b.offsetWidth),c.removeChild(d),a):void 0}}();var Gb=/^margin/,Hb=new RegExp("^("+S+")(?!px)[a-z%]+$","i"),Ib,Jb,Kb=/^(top|right|bottom|left)$/;a.getComputedStyle?(Ib=function(a){return a.ownerDocument.defaultView.getComputedStyle(a,null)},Jb=function(a,b,c){var d,e,f,g,h=a.style;return c=c||Ib(a),g=c?c.getPropertyValue(b)||c[b]:void 0,c&&(""!==g||m.contains(a.ownerDocument,a)||(g=m.style(a,b)),Hb.test(g)&&Gb.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0===g?g:g+""}):y.documentElement.currentStyle&&(Ib=function(a){return a.currentStyle},Jb=function(a,b,c){var d,e,f,g,h=a.style;return c=c||Ib(a),g=c?c[b]:void 0,null==g&&h&&h[b]&&(g=h[b]),Hb.test(g)&&!Kb.test(b)&&(d=h.left,e=a.runtimeStyle,f=e&&e.left,f&&(e.left=a.currentStyle.left),h.left="fontSize"===b?"1em":g,g=h.pixelLeft+"px",h.left=d,f&&(e.left=f)),void 0===g?g:g+""||"auto"});function Lb(a,b){return{get:function(){var c=a();if(null!=c)return c?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d,e,f,g,h;if(b=y.createElement("div"),b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",d=b.getElementsByTagName("a")[0],c=d&&d.style){c.cssText="float:left;opacity:.5",k.opacity="0.5"===c.opacity,k.cssFloat=!!c.cssFloat,b.style.backgroundClip="content-box",b.cloneNode(!0).style.backgroundClip="",k.clearCloneStyle="content-box"===b.style.backgroundClip,k.boxSizing=""===c.boxSizing||""===c.MozBoxSizing||""===c.WebkitBoxSizing,m.extend(k,{reliableHiddenOffsets:function(){return null==g&&i(),g},boxSizingReliable:function(){return null==f&&i(),f},pixelPosition:function(){return null==e&&i(),e},reliableMarginRight:function(){return null==h&&i(),h}});function i(){var b,c,d,i;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),b.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute",e=f=!1,h=!0,a.getComputedStyle&&(e="1%"!==(a.getComputedStyle(b,null)||{}).top,f="4px"===(a.getComputedStyle(b,null)||{width:"4px"}).width,i=b.appendChild(y.createElement("div")),i.style.cssText=b.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",i.style.marginRight=i.style.width="0",b.style.width="1px",h=!parseFloat((a.getComputedStyle(i,null)||{}).marginRight)),b.innerHTML="<table><tr><td></td><td>t</td></tr></table>",i=b.getElementsByTagName("td"),i[0].style.cssText="margin:0;border:0;padding:0;display:none",g=0===i[0].offsetHeight,g&&(i[0].style.display="",i[1].style.display="none",g=0===i[0].offsetHeight),c.removeChild(d))}}}(),m.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var Mb=/alpha\([^)]*\)/i,Nb=/opacity\s*=\s*([^)]*)/,Ob=/^(none|table(?!-c[ea]).+)/,Pb=new RegExp("^("+S+")(.*)$","i"),Qb=new RegExp("^([+-])=("+S+")","i"),Rb={position:"absolute",visibility:"hidden",display:"block"},Sb={letterSpacing:"0",fontWeight:"400"},Tb=["Webkit","O","Moz","ms"];function Ub(a,b){if(b in a)return b;var c=b.charAt(0).toUpperCase()+b.slice(1),d=b,e=Tb.length;while(e--)if(b=Tb[e]+c,b in a)return b;return d}function Vb(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=m._data(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&U(d)&&(f[g]=m._data(d,"olddisplay",Fb(d.nodeName)))):(e=U(d),(c&&"none"!==c||!e)&&m._data(d,"olddisplay",e?c:m.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}function Wb(a,b,c){var d=Pb.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Xb(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=m.css(a,c+T[f],!0,e)),d?("content"===c&&(g-=m.css(a,"padding"+T[f],!0,e)),"margin"!==c&&(g-=m.css(a,"border"+T[f]+"Width",!0,e))):(g+=m.css(a,"padding"+T[f],!0,e),"padding"!==c&&(g+=m.css(a,"border"+T[f]+"Width",!0,e)));return g}function Yb(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=Ib(a),g=k.boxSizing&&"border-box"===m.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=Jb(a,b,f),(0>e||null==e)&&(e=a.style[b]),Hb.test(e))return e;d=g&&(k.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Xb(a,b,c||(g?"border":"content"),d,f)+"px"}m.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=Jb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":k.cssFloat?"cssFloat":"styleFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=m.camelCase(b),i=a.style;if(b=m.cssProps[h]||(m.cssProps[h]=Ub(i,h)),g=m.cssHooks[b]||m.cssHooks[h],void 0===c)return g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b];if(f=typeof c,"string"===f&&(e=Qb.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(m.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||m.cssNumber[h]||(c+="px"),k.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),!(g&&"set"in g&&void 0===(c=g.set(a,c,d)))))try{i[b]=c}catch(j){}}},css:function(a,b,c,d){var e,f,g,h=m.camelCase(b);return b=m.cssProps[h]||(m.cssProps[h]=Ub(a.style,h)),g=m.cssHooks[b]||m.cssHooks[h],g&&"get"in g&&(f=g.get(a,!0,c)),void 0===f&&(f=Jb(a,b,d)),"normal"===f&&b in Sb&&(f=Sb[b]),""===c||c?(e=parseFloat(f),c===!0||m.isNumeric(e)?e||0:f):f}}),m.each(["height","width"],function(a,b){m.cssHooks[b]={get:function(a,c,d){return c?Ob.test(m.css(a,"display"))&&0===a.offsetWidth?m.swap(a,Rb,function(){return Yb(a,b,d)}):Yb(a,b,d):void 0},set:function(a,c,d){var e=d&&Ib(a);return Wb(a,c,d?Xb(a,b,d,k.boxSizing&&"border-box"===m.css(a,"boxSizing",!1,e),e):0)}}}),k.opacity||(m.cssHooks.opacity={get:function(a,b){return Nb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=m.isNumeric(b)?"alpha(opacity="+100*b+")":"",f=d&&d.filter||c.filter||"";c.zoom=1,(b>=1||""===b)&&""===m.trim(f.replace(Mb,""))&&c.removeAttribute&&(c.removeAttribute("filter"),""===b||d&&!d.filter)||(c.filter=Mb.test(f)?f.replace(Mb,e):f+" "+e)}}),m.cssHooks.marginRight=Lb(k.reliableMarginRight,function(a,b){return b?m.swap(a,{display:"inline-block"},Jb,[a,"marginRight"]):void 0}),m.each({margin:"",padding:"",border:"Width"},function(a,b){m.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+T[d]+b]=f[d]||f[d-2]||f[0];return e}},Gb.test(a)||(m.cssHooks[a+b].set=Wb)}),m.fn.extend({css:function(a,b){return V(this,function(a,b,c){var d,e,f={},g=0;if(m.isArray(b)){for(d=Ib(a),e=b.length;e>g;g++)f[b[g]]=m.css(a,b[g],!1,d);return f}return void 0!==c?m.style(a,b,c):m.css(a,b)},a,b,arguments.length>1)},show:function(){return Vb(this,!0)},hide:function(){return Vb(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){U(this)?m(this).show():m(this).hide()})}});function Zb(a,b,c,d,e){return new Zb.prototype.init(a,b,c,d,e)}m.Tween=Zb,Zb.prototype={constructor:Zb,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(m.cssNumber[c]?"":"px")
20 -},cur:function(){var a=Zb.propHooks[this.prop];return a&&a.get?a.get(this):Zb.propHooks._default.get(this)},run:function(a){var b,c=Zb.propHooks[this.prop];return this.pos=b=this.options.duration?m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Zb.propHooks._default.set(this),this}},Zb.prototype.init.prototype=Zb.prototype,Zb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=m.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){m.fx.step[a.prop]?m.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[m.cssProps[a.prop]]||m.cssHooks[a.prop])?m.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Zb.propHooks.scrollTop=Zb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},m.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},m.fx=Zb.prototype.init,m.fx.step={};var $b,_b,ac=/^(?:toggle|show|hide)$/,bc=new RegExp("^(?:([+-])=|)("+S+")([a-z%]*)$","i"),cc=/queueHooks$/,dc=[ic],ec={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=bc.exec(b),f=e&&e[3]||(m.cssNumber[a]?"":"px"),g=(m.cssNumber[a]||"px"!==f&&+d)&&bc.exec(m.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,m.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function fc(){return setTimeout(function(){$b=void 0}),$b=m.now()}function gc(a,b){var c,d={height:a},e=0;for(b=b?1:0;4>e;e+=2-b)c=T[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function hc(a,b,c){for(var d,e=(ec[b]||[]).concat(ec["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function ic(a,b,c){var d,e,f,g,h,i,j,l,n=this,o={},p=a.style,q=a.nodeType&&U(a),r=m._data(a,"fxshow");c.queue||(h=m._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,n.always(function(){n.always(function(){h.unqueued--,m.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[p.overflow,p.overflowX,p.overflowY],j=m.css(a,"display"),l="none"===j?m._data(a,"olddisplay")||Fb(a.nodeName):j,"inline"===l&&"none"===m.css(a,"float")&&(k.inlineBlockNeedsLayout&&"inline"!==Fb(a.nodeName)?p.zoom=1:p.display="inline-block")),c.overflow&&(p.overflow="hidden",k.shrinkWrapBlocks()||n.always(function(){p.overflow=c.overflow[0],p.overflowX=c.overflow[1],p.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],ac.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(q?"hide":"show")){if("show"!==e||!r||void 0===r[d])continue;q=!0}o[d]=r&&r[d]||m.style(a,d)}else j=void 0;if(m.isEmptyObject(o))"inline"===("none"===j?Fb(a.nodeName):j)&&(p.display=j);else{r?"hidden"in r&&(q=r.hidden):r=m._data(a,"fxshow",{}),f&&(r.hidden=!q),q?m(a).show():n.done(function(){m(a).hide()}),n.done(function(){var b;m._removeData(a,"fxshow");for(b in o)m.style(a,b,o[b])});for(d in o)g=hc(q?r[d]:0,d,n),d in r||(r[d]=g.start,q&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function jc(a,b){var c,d,e,f,g;for(c in a)if(d=m.camelCase(c),e=b[d],f=a[c],m.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=m.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function kc(a,b,c){var d,e,f=0,g=dc.length,h=m.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=$b||fc(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:m.extend({},b),opts:m.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:$b||fc(),duration:c.duration,tweens:[],createTween:function(b,c){var d=m.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(jc(k,j.opts.specialEasing);g>f;f++)if(d=dc[f].call(j,a,k,j.opts))return d;return m.map(k,hc,j),m.isFunction(j.opts.start)&&j.opts.start.call(a,j),m.fx.timer(m.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}m.Animation=m.extend(kc,{tweener:function(a,b){m.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],ec[c]=ec[c]||[],ec[c].unshift(b)},prefilter:function(a,b){b?dc.unshift(a):dc.push(a)}}),m.speed=function(a,b,c){var d=a&&"object"==typeof a?m.extend({},a):{complete:c||!c&&b||m.isFunction(a)&&a,duration:a,easing:c&&b||b&&!m.isFunction(b)&&b};return d.duration=m.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in m.fx.speeds?m.fx.speeds[d.duration]:m.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){m.isFunction(d.old)&&d.old.call(this),d.queue&&m.dequeue(this,d.queue)},d},m.fn.extend({fadeTo:function(a,b,c,d){return this.filter(U).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=m.isEmptyObject(a),f=m.speed(b,c,d),g=function(){var b=kc(this,m.extend({},a),f);(e||m._data(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=m.timers,g=m._data(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&cc.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&m.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=m._data(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=m.timers,g=d?d.length:0;for(c.finish=!0,m.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),m.each(["toggle","show","hide"],function(a,b){var c=m.fn[b];m.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(gc(b,!0),a,d,e)}}),m.each({slideDown:gc("show"),slideUp:gc("hide"),slideToggle:gc("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){m.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),m.timers=[],m.fx.tick=function(){var a,b=m.timers,c=0;for($b=m.now();c<b.length;c++)a=b[c],a()||b[c]!==a||b.splice(c--,1);b.length||m.fx.stop(),$b=void 0},m.fx.timer=function(a){m.timers.push(a),a()?m.fx.start():m.timers.pop()},m.fx.interval=13,m.fx.start=function(){_b||(_b=setInterval(m.fx.tick,m.fx.interval))},m.fx.stop=function(){clearInterval(_b),_b=null},m.fx.speeds={slow:600,fast:200,_default:400},m.fn.delay=function(a,b){return a=m.fx?m.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},function(){var a,b,c,d,e;b=y.createElement("div"),b.setAttribute("className","t"),b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",d=b.getElementsByTagName("a")[0],c=y.createElement("select"),e=c.appendChild(y.createElement("option")),a=b.getElementsByTagName("input")[0],d.style.cssText="top:1px",k.getSetAttribute="t"!==b.className,k.style=/top/.test(d.getAttribute("style")),k.hrefNormalized="/a"===d.getAttribute("href"),k.checkOn=!!a.value,k.optSelected=e.selected,k.enctype=!!y.createElement("form").enctype,c.disabled=!0,k.optDisabled=!e.disabled,a=y.createElement("input"),a.setAttribute("value",""),k.input=""===a.getAttribute("value"),a.value="t",a.setAttribute("type","radio"),k.radioValue="t"===a.value}();var lc=/\r/g;m.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=m.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,m(this).val()):a,null==e?e="":"number"==typeof e?e+="":m.isArray(e)&&(e=m.map(e,function(a){return null==a?"":a+""})),b=m.valHooks[this.type]||m.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=m.valHooks[e.type]||m.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(lc,""):null==c?"":c)}}}),m.extend({valHooks:{option:{get:function(a){var b=m.find.attr(a,"value");return null!=b?b:m.trim(m.text(a))}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(k.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&m.nodeName(c.parentNode,"optgroup"))){if(b=m(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=m.makeArray(b),g=e.length;while(g--)if(d=e[g],m.inArray(m.valHooks.option.get(d),f)>=0)try{d.selected=c=!0}catch(h){d.scrollHeight}else d.selected=!1;return c||(a.selectedIndex=-1),e}}}}),m.each(["radio","checkbox"],function(){m.valHooks[this]={set:function(a,b){return m.isArray(b)?a.checked=m.inArray(m(a).val(),b)>=0:void 0}},k.checkOn||(m.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var mc,nc,oc=m.expr.attrHandle,pc=/^(?:checked|selected)$/i,qc=k.getSetAttribute,rc=k.input;m.fn.extend({attr:function(a,b){return V(this,m.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){m.removeAttr(this,a)})}}),m.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===K?m.prop(a,b,c):(1===f&&m.isXMLDoc(a)||(b=b.toLowerCase(),d=m.attrHooks[b]||(m.expr.match.bool.test(b)?nc:mc)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=m.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void m.removeAttr(a,b))},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=m.propFix[c]||c,m.expr.match.bool.test(c)?rc&&qc||!pc.test(c)?a[d]=!1:a[m.camelCase("default-"+c)]=a[d]=!1:m.attr(a,c,""),a.removeAttribute(qc?c:d)},attrHooks:{type:{set:function(a,b){if(!k.radioValue&&"radio"===b&&m.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),nc={set:function(a,b,c){return b===!1?m.removeAttr(a,c):rc&&qc||!pc.test(c)?a.setAttribute(!qc&&m.propFix[c]||c,c):a[m.camelCase("default-"+c)]=a[c]=!0,c}},m.each(m.expr.match.bool.source.match(/\w+/g),function(a,b){var c=oc[b]||m.find.attr;oc[b]=rc&&qc||!pc.test(b)?function(a,b,d){var e,f;return d||(f=oc[b],oc[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,oc[b]=f),e}:function(a,b,c){return c?void 0:a[m.camelCase("default-"+b)]?b.toLowerCase():null}}),rc&&qc||(m.attrHooks.value={set:function(a,b,c){return m.nodeName(a,"input")?void(a.defaultValue=b):mc&&mc.set(a,b,c)}}),qc||(mc={set:function(a,b,c){var d=a.getAttributeNode(c);return d||a.setAttributeNode(d=a.ownerDocument.createAttribute(c)),d.value=b+="","value"===c||b===a.getAttribute(c)?b:void 0}},oc.id=oc.name=oc.coords=function(a,b,c){var d;return c?void 0:(d=a.getAttributeNode(b))&&""!==d.value?d.value:null},m.valHooks.button={get:function(a,b){var c=a.getAttributeNode(b);return c&&c.specified?c.value:void 0},set:mc.set},m.attrHooks.contenteditable={set:function(a,b,c){mc.set(a,""===b?!1:b,c)}},m.each(["width","height"],function(a,b){m.attrHooks[b]={set:function(a,c){return""===c?(a.setAttribute(b,"auto"),c):void 0}}})),k.style||(m.attrHooks.style={get:function(a){return a.style.cssText||void 0},set:function(a,b){return a.style.cssText=b+""}});var sc=/^(?:input|select|textarea|button|object)$/i,tc=/^(?:a|area)$/i;m.fn.extend({prop:function(a,b){return V(this,m.prop,a,b,arguments.length>1)},removeProp:function(a){return a=m.propFix[a]||a,this.each(function(){try{this[a]=void 0,delete this[a]}catch(b){}})}}),m.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!m.isXMLDoc(a),f&&(b=m.propFix[b]||b,e=m.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=m.find.attr(a,"tabindex");return b?parseInt(b,10):sc.test(a.nodeName)||tc.test(a.nodeName)&&a.href?0:-1}}}}),k.hrefNormalized||m.each(["href","src"],function(a,b){m.propHooks[b]={get:function(a){return a.getAttribute(b,4)}}}),k.optSelected||(m.propHooks.selected={get:function(a){var b=a.parentNode;return b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex),null}}),m.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){m.propFix[this.toLowerCase()]=this}),k.enctype||(m.propFix.enctype="encoding");var uc=/[\t\r\n\f]/g;m.fn.extend({addClass:function(a){var b,c,d,e,f,g,h=0,i=this.length,j="string"==typeof a&&a;if(m.isFunction(a))return this.each(function(b){m(this).addClass(a.call(this,b,this.className))});if(j)for(b=(a||"").match(E)||[];i>h;h++)if(c=this[h],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(uc," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=m.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0,i=this.length,j=0===arguments.length||"string"==typeof a&&a;if(m.isFunction(a))return this.each(function(b){m(this).removeClass(a.call(this,b,this.className))});if(j)for(b=(a||"").match(E)||[];i>h;h++)if(c=this[h],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(uc," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?m.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(m.isFunction(a)?function(c){m(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=m(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===K||"boolean"===c)&&(this.className&&m._data(this,"__className__",this.className),this.className=this.className||a===!1?"":m._data(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(uc," ").indexOf(b)>=0)return!0;return!1}}),m.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){m.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),m.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var vc=m.now(),wc=/\?/,xc=/(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;m.parseJSON=function(b){if(a.JSON&&a.JSON.parse)return a.JSON.parse(b+"");var c,d=null,e=m.trim(b+"");return e&&!m.trim(e.replace(xc,function(a,b,e,f){return c&&b&&(d=0),0===d?a:(c=e||b,d+=!f-!e,"")}))?Function("return "+e)():m.error("Invalid JSON: "+b)},m.parseXML=function(b){var c,d;if(!b||"string"!=typeof b)return null;try{a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b))}catch(e){c=void 0}return c&&c.documentElement&&!c.getElementsByTagName("parsererror").length||m.error("Invalid XML: "+b),c};var yc,zc,Ac=/#.*$/,Bc=/([?&])_=[^&]*/,Cc=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Dc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Ec=/^(?:GET|HEAD)$/,Fc=/^\/\//,Gc=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,Hc={},Ic={},Jc="*/".concat("*");try{zc=location.href}catch(Kc){zc=y.createElement("a"),zc.href="",zc=zc.href}yc=Gc.exec(zc.toLowerCase())||[];function Lc(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(m.isFunction(c))while(d=f[e++])"+"===d.charAt(0)?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function Mc(a,b,c,d){var e={},f=a===Ic;function g(h){var i;return e[h]=!0,m.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function Nc(a,b){var c,d,e=m.ajaxSettings.flatOptions||{};for(d in b)void 0!==b[d]&&((e[d]?a:c||(c={}))[d]=b[d]);return c&&m.extend(!0,a,c),a}function Oc(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===e&&(e=a.mimeType||b.getResponseHeader("Content-Type"));if(e)for(g in h)if(h[g]&&h[g].test(e)){i.unshift(g);break}if(i[0]in c)f=i[0];else{for(g in c){if(!i[0]||a.converters[g+" "+i[0]]){f=g;break}d||(d=g)}f=f||d}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function Pc(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}m.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:zc,type:"GET",isLocal:Dc.test(yc[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Jc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":m.parseJSON,"text xml":m.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?Nc(Nc(a,m.ajaxSettings),b):Nc(m.ajaxSettings,a)},ajaxPrefilter:Lc(Hc),ajaxTransport:Lc(Ic),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=m.ajaxSetup({},b),l=k.context||k,n=k.context&&(l.nodeType||l.jquery)?m(l):m.event,o=m.Deferred(),p=m.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!j){j={};while(b=Cc.exec(f))j[b[1].toLowerCase()]=b[2]}b=j[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?f:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return i&&i.abort(b),x(0,b),this}};if(o.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||zc)+"").replace(Ac,"").replace(Fc,yc[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=m.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(c=Gc.exec(k.url.toLowerCase()),k.crossDomain=!(!c||c[1]===yc[1]&&c[2]===yc[2]&&(c[3]||("http:"===c[1]?"80":"443"))===(yc[3]||("http:"===yc[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=m.param(k.data,k.traditional)),Mc(Hc,k,b,v),2===t)return v;h=k.global,h&&0===m.active++&&m.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!Ec.test(k.type),e=k.url,k.hasContent||(k.data&&(e=k.url+=(wc.test(e)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=Bc.test(e)?e.replace(Bc,"$1_="+vc++):e+(wc.test(e)?"&":"?")+"_="+vc++)),k.ifModified&&(m.lastModified[e]&&v.setRequestHeader("If-Modified-Since",m.lastModified[e]),m.etag[e]&&v.setRequestHeader("If-None-Match",m.etag[e])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+Jc+"; q=0.01":""):k.accepts["*"]);for(d in k.headers)v.setRequestHeader(d,k.headers[d]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(d in{success:1,error:1,complete:1})v[d](k[d]);if(i=Mc(Ic,k,b,v)){v.readyState=1,h&&n.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,i.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,c,d){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),i=void 0,f=d||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,c&&(u=Oc(k,v,c)),u=Pc(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(m.lastModified[e]=w),w=v.getResponseHeader("etag"),w&&(m.etag[e]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?o.resolveWith(l,[r,x,v]):o.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,h&&n.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),h&&(n.trigger("ajaxComplete",[v,k]),--m.active||m.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return m.get(a,b,c,"json")},getScript:function(a,b){return m.get(a,void 0,b,"script")}}),m.each(["get","post"],function(a,b){m[b]=function(a,c,d,e){return m.isFunction(c)&&(e=e||d,d=c,c=void 0),m.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),m.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){m.fn[b]=function(a){return this.on(b,a)}}),m._evalUrl=function(a){return m.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},m.fn.extend({wrapAll:function(a){if(m.isFunction(a))return this.each(function(b){m(this).wrapAll(a.call(this,b))});if(this[0]){var b=m(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&1===a.firstChild.nodeType)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return this.each(m.isFunction(a)?function(b){m(this).wrapInner(a.call(this,b))}:function(){var b=m(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=m.isFunction(a);return this.each(function(c){m(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){m.nodeName(this,"body")||m(this).replaceWith(this.childNodes)}).end()}}),m.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0||!k.reliableHiddenOffsets()&&"none"===(a.style&&a.style.display||m.css(a,"display"))},m.expr.filters.visible=function(a){return!m.expr.filters.hidden(a)};var Qc=/%20/g,Rc=/\[\]$/,Sc=/\r?\n/g,Tc=/^(?:submit|button|image|reset|file)$/i,Uc=/^(?:input|select|textarea|keygen)/i;function Vc(a,b,c,d){var e;if(m.isArray(b))m.each(b,function(b,e){c||Rc.test(a)?d(a,e):Vc(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==m.type(b))d(a,b);else for(e in b)Vc(a+"["+e+"]",b[e],c,d)}m.param=function(a,b){var c,d=[],e=function(a,b){b=m.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=m.ajaxSettings&&m.ajaxSettings.traditional),m.isArray(a)||a.jquery&&!m.isPlainObject(a))m.each(a,function(){e(this.name,this.value)});else for(c in a)Vc(c,a[c],b,e);return d.join("&").replace(Qc,"+")},m.fn.extend({serialize:function(){return m.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=m.prop(this,"elements");return a?m.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!m(this).is(":disabled")&&Uc.test(this.nodeName)&&!Tc.test(a)&&(this.checked||!W.test(a))}).map(function(a,b){var c=m(this).val();return null==c?null:m.isArray(c)?m.map(c,function(a){return{name:b.name,value:a.replace(Sc,"\r\n")}}):{name:b.name,value:c.replace(Sc,"\r\n")}}).get()}}),m.ajaxSettings.xhr=void 0!==a.ActiveXObject?function(){return!this.isLocal&&/^(get|post|head|put|delete|options)$/i.test(this.type)&&Zc()||$c()}:Zc;var Wc=0,Xc={},Yc=m.ajaxSettings.xhr();a.ActiveXObject&&m(a).on("unload",function(){for(var a in Xc)Xc[a](void 0,!0)}),k.cors=!!Yc&&"withCredentials"in Yc,Yc=k.ajax=!!Yc,Yc&&m.ajaxTransport(function(a){if(!a.crossDomain||k.cors){var b;return{send:function(c,d){var e,f=a.xhr(),g=++Wc;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)void 0!==c[e]&&f.setRequestHeader(e,c[e]+"");f.send(a.hasContent&&a.data||null),b=function(c,e){var h,i,j;if(b&&(e||4===f.readyState))if(delete Xc[g],b=void 0,f.onreadystatechange=m.noop,e)4!==f.readyState&&f.abort();else{j={},h=f.status,"string"==typeof f.responseText&&(j.text=f.responseText);try{i=f.statusText}catch(k){i=""}h||!a.isLocal||a.crossDomain?1223===h&&(h=204):h=j.text?200:404}j&&d(h,i,j,f.getAllResponseHeaders())},a.async?4===f.readyState?setTimeout(b):f.onreadystatechange=Xc[g]=b:b()},abort:function(){b&&b(void 0,!0)}}}});function Zc(){try{return new a.XMLHttpRequest}catch(b){}}function $c(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}m.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return m.globalEval(a),a}}}),m.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),m.ajaxTransport("script",function(a){if(a.crossDomain){var b,c=y.head||m("head")[0]||y.documentElement;return{send:function(d,e){b=y.createElement("script"),b.async=!0,a.scriptCharset&&(b.charset=a.scriptCharset),b.src=a.url,b.onload=b.onreadystatechange=function(a,c){(c||!b.readyState||/loaded|complete/.test(b.readyState))&&(b.onload=b.onreadystatechange=null,b.parentNode&&b.parentNode.removeChild(b),b=null,c||e(200,"success"))},c.insertBefore(b,c.firstChild)},abort:function(){b&&b.onload(void 0,!0)}}}});var _c=[],ad=/(=)\?(?=&|$)|\?\?/;m.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=_c.pop()||m.expando+"_"+vc++;return this[a]=!0,a}}),m.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(ad.test(b.url)?"url":"string"==typeof b.data&&!(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&ad.test(b.data)&&"data");return h||"jsonp"===b.dataTypes[0]?(e=b.jsonpCallback=m.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(ad,"$1"+e):b.jsonp!==!1&&(b.url+=(wc.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||m.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,_c.push(e)),g&&m.isFunction(f)&&f(g[0]),g=f=void 0}),"script"):void 0}),m.parseHTML=function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||y;var d=u.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=m.buildFragment([a],b,e),e&&e.length&&m(e).remove(),m.merge([],d.childNodes))};var bd=m.fn.load;m.fn.load=function(a,b,c){if("string"!=typeof a&&bd)return bd.apply(this,arguments);var d,e,f,g=this,h=a.indexOf(" ");return h>=0&&(d=m.trim(a.slice(h,a.length)),a=a.slice(0,h)),m.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(f="POST"),g.length>0&&m.ajax({url:a,type:f,dataType:"html",data:b}).done(function(a){e=arguments,g.html(d?m("<div>").append(m.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,e||[a.responseText,b,a])}),this},m.expr.filters.animated=function(a){return m.grep(m.timers,function(b){return a===b.elem}).length};var cd=a.document.documentElement;function dd(a){return m.isWindow(a)?a:9===a.nodeType?a.defaultView||a.parentWindow:!1}m.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=m.css(a,"position"),l=m(a),n={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=m.css(a,"top"),i=m.css(a,"left"),j=("absolute"===k||"fixed"===k)&&m.inArray("auto",[f,i])>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),m.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(n.top=b.top-h.top+g),null!=b.left&&(n.left=b.left-h.left+e),"using"in b?b.using.call(a,n):l.css(n)}},m.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){m.offset.setOffset(this,a,b)});var b,c,d={top:0,left:0},e=this[0],f=e&&e.ownerDocument;if(f)return b=f.documentElement,m.contains(b,e)?(typeof e.getBoundingClientRect!==K&&(d=e.getBoundingClientRect()),c=dd(f),{top:d.top+(c.pageYOffset||b.scrollTop)-(b.clientTop||0),left:d.left+(c.pageXOffset||b.scrollLeft)-(b.clientLeft||0)}):d},position:function(){if(this[0]){var a,b,c={top:0,left:0},d=this[0];return"fixed"===m.css(d,"position")?b=d.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),m.nodeName(a[0],"html")||(c=a.offset()),c.top+=m.css(a[0],"borderTopWidth",!0),c.left+=m.css(a[0],"borderLeftWidth",!0)),{top:b.top-c.top-m.css(d,"marginTop",!0),left:b.left-c.left-m.css(d,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||cd;while(a&&!m.nodeName(a,"html")&&"static"===m.css(a,"position"))a=a.offsetParent;return a||cd})}}),m.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,b){var c=/Y/.test(b);m.fn[a]=function(d){return V(this,function(a,d,e){var f=dd(a);return void 0===e?f?b in f?f[b]:f.document.documentElement[d]:a[d]:void(f?f.scrollTo(c?m(f).scrollLeft():e,c?e:m(f).scrollTop()):a[d]=e)},a,d,arguments.length,null)}}),m.each(["top","left"],function(a,b){m.cssHooks[b]=Lb(k.pixelPosition,function(a,c){return c?(c=Jb(a,b),Hb.test(c)?m(a).position()[b]+"px":c):void 0})}),m.each({Height:"height",Width:"width"},function(a,b){m.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){m.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return V(this,function(b,c,d){var e;return m.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?m.css(b,c,g):m.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),m.fn.size=function(){return this.length},m.fn.andSelf=m.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return m});var ed=a.jQuery,fd=a.$;return m.noConflict=function(b){return a.$===m&&(a.$=fd),b&&a.jQuery===m&&(a.jQuery=ed),m},typeof b===K&&(a.jQuery=a.$=m),m});