Committed by
Gerrit Code Review
Adding test apps as submodule to apps
Moving election and intent-perf there Change-Id: Ia71e98438b33d3a1c5c12b08ae98c32930c4bd81
Showing
29 changed files
with
1412 additions
and
0 deletions
... | @@ -43,6 +43,7 @@ | ... | @@ -43,6 +43,7 @@ |
43 | <module>routing</module> | 43 | <module>routing</module> |
44 | <module>routing-api</module> | 44 | <module>routing-api</module> |
45 | <module>bgprouter</module> | 45 | <module>bgprouter</module> |
46 | + <module>test</module> | ||
46 | </modules> | 47 | </modules> |
47 | 48 | ||
48 | <properties> | 49 | <properties> | ... | ... |
apps/test/election/pom.xml
0 → 100644
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-app-samples</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 | +} |
apps/test/election/src/main/java/org/onosproject/election/cli/ElectionTestLeaderCommand.java
0 → 100644
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 | +} |
apps/test/election/src/main/java/org/onosproject/election/cli/ElectionTestRunCommand.java
0 → 100644
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 | +} |
apps/test/election/src/main/java/org/onosproject/election/cli/ElectionTestWithdrawCommand.java
0 → 100644
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> |
apps/test/intent-perf/pom.xml
0 → 100644
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-app-samples</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> |
apps/test/intent-perf/src/assembly/app.xml
0 → 100644
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.2.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 |
apps/test/intent-perf/src/assembly/bin.xml
0 → 100644
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 | +} |
This diff is collapsed. Click to expand it.
apps/test/intent-perf/src/main/java/org/onosproject/intentperf/IntentPerfListCommand.java
0 → 100644
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 | +} |
apps/test/intent-perf/src/main/java/org/onosproject/intentperf/IntentPerfStartCommand.java
0 → 100644
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 | +} |
apps/test/intent-perf/src/main/java/org/onosproject/intentperf/IntentPerfStopCommand.java
0 → 100644
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> |
apps/test/pom.xml
0 → 100644
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</artifactId> | ||
25 | + <version>1.2.0-SNAPSHOT</version> | ||
26 | + <relativePath>../pom.xml</relativePath> | ||
27 | + </parent> | ||
28 | + | ||
29 | + <artifactId>onos-apps-test</artifactId> | ||
30 | + <packaging>pom</packaging> | ||
31 | + | ||
32 | + <description>ONOS test applications</description> | ||
33 | + | ||
34 | + <modules> | ||
35 | + <module>election</module> | ||
36 | + <module>intent-perf</module> | ||
37 | + </modules> | ||
38 | + | ||
39 | +</project> |
-
Please register or login to post a comment