Committed by
Gerrit Code Review
ONOS-894 : Implemented GroupProvider
Change-Id: I2755abd433921a420ad545fcf6fef61e90a8b89f
Showing
7 changed files
with
149 additions
and
1 deletions
... | @@ -149,7 +149,7 @@ | ... | @@ -149,7 +149,7 @@ |
149 | <bundle>mvn:org.onosproject/onos-of-provider-device/@ONOS-VERSION</bundle> | 149 | <bundle>mvn:org.onosproject/onos-of-provider-device/@ONOS-VERSION</bundle> |
150 | <bundle>mvn:org.onosproject/onos-of-provider-packet/@ONOS-VERSION</bundle> | 150 | <bundle>mvn:org.onosproject/onos-of-provider-packet/@ONOS-VERSION</bundle> |
151 | <bundle>mvn:org.onosproject/onos-of-provider-flow/@ONOS-VERSION</bundle> | 151 | <bundle>mvn:org.onosproject/onos-of-provider-flow/@ONOS-VERSION</bundle> |
152 | - | 152 | + <bundle>mvn:org.onosproject/onos-of-provider-group/@ONOS-VERSION</bundle> |
153 | </feature> | 153 | </feature> |
154 | 154 | ||
155 | <feature name="onos-app-tvue" version="@FEATURE-VERSION" | 155 | <feature name="onos-app-tvue" version="@FEATURE-VERSION" | ... | ... |
providers/openflow/group/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-of-providers</artifactId> | ||
25 | + <version>1.1.0-SNAPSHOT</version> | ||
26 | + <relativePath>../pom.xml</relativePath> | ||
27 | + </parent> | ||
28 | + | ||
29 | + <artifactId>onos-of-provider-group</artifactId> | ||
30 | + <packaging>bundle</packaging> | ||
31 | + | ||
32 | + <description>ONOS OpenFlow protocol group provider</description> | ||
33 | + | ||
34 | +</project> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
This diff is collapsed. Click to expand it.
providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupModBuilder.java
0 → 100644
This diff is collapsed. Click to expand it.
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 | +package org.onosproject.provider.of.group.impl; | ||
18 | + | ||
19 | +import org.jboss.netty.util.HashedWheelTimer; | ||
20 | +import org.jboss.netty.util.Timeout; | ||
21 | +import org.jboss.netty.util.TimerTask; | ||
22 | +import org.onlab.util.Timer; | ||
23 | +import org.onosproject.openflow.controller.OpenFlowSwitch; | ||
24 | +import org.onosproject.openflow.controller.RoleState; | ||
25 | +import org.projectfloodlight.openflow.protocol.OFGroupDescStatsRequest; | ||
26 | +import org.projectfloodlight.openflow.protocol.OFGroupStatsRequest; | ||
27 | +import org.projectfloodlight.openflow.types.OFGroup; | ||
28 | +import org.slf4j.Logger; | ||
29 | + | ||
30 | +import java.util.concurrent.TimeUnit; | ||
31 | +import java.util.concurrent.atomic.AtomicLong; | ||
32 | + | ||
33 | +import static org.slf4j.LoggerFactory.getLogger; | ||
34 | + | ||
35 | +/* | ||
36 | + * Sends Group Stats Request and collect the group statistics with a time interval. | ||
37 | + */ | ||
38 | +public class GroupStatsCollector implements TimerTask { | ||
39 | + | ||
40 | + private final HashedWheelTimer timer = Timer.getTimer(); | ||
41 | + private final OpenFlowSwitch sw; | ||
42 | + private final Logger log = getLogger(getClass()); | ||
43 | + private final int refreshInterval; | ||
44 | + | ||
45 | + private Timeout timeout; | ||
46 | + private final AtomicLong xidCounter = new AtomicLong(1); | ||
47 | + | ||
48 | + private boolean stopTimer = false; | ||
49 | + | ||
50 | + /** | ||
51 | + * Creates a GroupStatsCollector object. | ||
52 | + * | ||
53 | + * @param sw Open Flow switch | ||
54 | + * @param interval time interval for collecting group statistic | ||
55 | + */ | ||
56 | + public GroupStatsCollector(OpenFlowSwitch sw, int interval) { | ||
57 | + this.sw = sw; | ||
58 | + this.refreshInterval = interval; | ||
59 | + } | ||
60 | + | ||
61 | + @Override | ||
62 | + public void run(Timeout timeout) throws Exception { | ||
63 | + log.trace("Collecting stats for {}", sw.getStringId()); | ||
64 | + | ||
65 | + sendGroupStatistic(); | ||
66 | + | ||
67 | + if (!this.stopTimer) { | ||
68 | + log.trace("Scheduling stats collection in {} seconds for {}", | ||
69 | + this.refreshInterval, this.sw.getStringId()); | ||
70 | + timeout.getTimer().newTimeout(this, refreshInterval, | ||
71 | + TimeUnit.SECONDS); | ||
72 | + } | ||
73 | + } | ||
74 | + | ||
75 | + private void sendGroupStatistic() { | ||
76 | + if (log.isTraceEnabled()) { | ||
77 | + log.trace("sendGroupStatistics {}:{}", sw.getStringId(), sw.getRole()); | ||
78 | + } | ||
79 | + if (sw.getRole() != RoleState.MASTER) { | ||
80 | + return; | ||
81 | + } | ||
82 | + Long statsXid = xidCounter.getAndAdd(2); | ||
83 | + OFGroupStatsRequest statsRequest = sw.factory().buildGroupStatsRequest() | ||
84 | + .setGroup(OFGroup.ALL) | ||
85 | + .setXid(statsXid) | ||
86 | + .build(); | ||
87 | + sw.sendMsg(statsRequest); | ||
88 | + | ||
89 | + Long descXid = statsXid + 1; | ||
90 | + OFGroupDescStatsRequest descStatsRequest = | ||
91 | + sw.factory().buildGroupDescStatsRequest() | ||
92 | + .setXid(descXid) | ||
93 | + .build(); | ||
94 | + sw.sendMsg(descStatsRequest); | ||
95 | + } | ||
96 | + | ||
97 | + /** | ||
98 | + * Starts the collector. | ||
99 | + */ | ||
100 | + public void start() { | ||
101 | + log.info("Staring Group Stats collection thread for {}", sw.getStringId()); | ||
102 | + timeout = timer.newTimeout(this, 1, TimeUnit.SECONDS); | ||
103 | + } | ||
104 | + | ||
105 | + /** | ||
106 | + * Stops the collector. | ||
107 | + */ | ||
108 | + public void stop() { | ||
109 | + log.info("Stopping Group Stats collection thread for {}", sw.getStringId()); | ||
110 | + this.stopTimer = true; | ||
111 | + timeout.cancel(); | ||
112 | + } | ||
113 | +} |
This diff is collapsed. Click to expand it.
... | @@ -37,6 +37,7 @@ | ... | @@ -37,6 +37,7 @@ |
37 | <module>host</module> | 37 | <module>host</module> |
38 | <module>packet</module> | 38 | <module>packet</module> |
39 | <module>flow</module> | 39 | <module>flow</module> |
40 | + <module>group</module> | ||
40 | </modules> | 41 | </modules> |
41 | 42 | ||
42 | <dependencies> | 43 | <dependencies> | ... | ... |
-
Please register or login to post a comment