Committed by
Gerrit Code Review
Add skeletal CPMan manager component interfaces
Change-Id: Ica16e43849dd3bb0b90936a20ef4af477045b376
Showing
12 changed files
with
436 additions
and
0 deletions
| 1 | +/* | ||
| 2 | + * Copyright 2016 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.cpman; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * Abstraction of control message. | ||
| 20 | + */ | ||
| 21 | +public interface ControlMessage { | ||
| 22 | + | ||
| 23 | + enum Type { | ||
| 24 | + INCOMING_PACKET, OUTGOING_PACKET, FLOW_MOD_PACKET, | ||
| 25 | + FLOW_REMOVED_PACKET, REQUEST_PACKET, REPLY_PACKET | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * Returns the control message type. | ||
| 30 | + * | ||
| 31 | + * @return control message type | ||
| 32 | + */ | ||
| 33 | + Type type(); | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * Returns the latest control message load. | ||
| 37 | + * | ||
| 38 | + * @return control message load | ||
| 39 | + */ | ||
| 40 | + long load(); | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * Returns the latest control message rate. | ||
| 44 | + * | ||
| 45 | + * @return control message rate | ||
| 46 | + */ | ||
| 47 | + long rate(); | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * Returns the latest control message packet count. | ||
| 51 | + * | ||
| 52 | + * @return packet count | ||
| 53 | + */ | ||
| 54 | + long count(); | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * Returns the time that this control message stats collected. | ||
| 58 | + * | ||
| 59 | + * @return | ||
| 60 | + */ | ||
| 61 | + long timeStamp(); | ||
| 62 | +} |
| 1 | +/* | ||
| 2 | + * Copyright 2016 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.cpman; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * Default control message implementation. | ||
| 20 | + */ | ||
| 21 | +public class DefaultControlMessage implements ControlMessage { | ||
| 22 | + | ||
| 23 | + private final Type type; | ||
| 24 | + private final long load; | ||
| 25 | + private final long rate; | ||
| 26 | + private final long count; | ||
| 27 | + private final long timeStamp; | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * Generates a control message instance using given type and statistic | ||
| 31 | + * information. | ||
| 32 | + * | ||
| 33 | + * @param type control message type | ||
| 34 | + * @param load control message load | ||
| 35 | + * @param rate control message rate | ||
| 36 | + * @param count control message count | ||
| 37 | + * @param timeStamp time stamp of the control message stats | ||
| 38 | + */ | ||
| 39 | + public DefaultControlMessage(Type type, long load, long rate, | ||
| 40 | + long count, long timeStamp) { | ||
| 41 | + this.type = type; | ||
| 42 | + this.load = load; | ||
| 43 | + this.rate = rate; | ||
| 44 | + this.count = count; | ||
| 45 | + this.timeStamp = timeStamp; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @Override | ||
| 49 | + public Type type() { | ||
| 50 | + return type; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + @Override | ||
| 54 | + public long load() { | ||
| 55 | + return load; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + @Override | ||
| 59 | + public long rate() { | ||
| 60 | + return rate; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + @Override | ||
| 64 | + public long count() { | ||
| 65 | + return count; | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + @Override | ||
| 69 | + public long timeStamp() { | ||
| 70 | + return timeStamp; | ||
| 71 | + } | ||
| 72 | +} |
apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageAdminService.java
0 → 100644
| 1 | +/* | ||
| 2 | + * Copyright 2016 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.cpman.message; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * Service for administering the control message monitoring. | ||
| 20 | + */ | ||
| 21 | +public interface ControlMessageAdminService extends ControlMessageService { | ||
| 22 | +} |
| 1 | +/* | ||
| 2 | + * Copyright 2016 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.cpman.message; | ||
| 17 | + | ||
| 18 | +import org.onosproject.event.AbstractEvent; | ||
| 19 | +import org.onosproject.cpman.ControlMessage; | ||
| 20 | + | ||
| 21 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
| 22 | + | ||
| 23 | +/** | ||
| 24 | + * Describes control message event. | ||
| 25 | + */ | ||
| 26 | +public class ControlMessageEvent | ||
| 27 | + extends AbstractEvent<ControlMessageEvent.Type, ControlMessage> { | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * Type of control message events. | ||
| 31 | + */ | ||
| 32 | + public enum Type { | ||
| 33 | + /** | ||
| 34 | + * signifies that the control message stats has been updated. | ||
| 35 | + */ | ||
| 36 | + STATS_UPDATE | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * Creates an event of given type and the current time. | ||
| 41 | + * | ||
| 42 | + * @param type control message event type | ||
| 43 | + * @param controlMessage event control message subject | ||
| 44 | + */ | ||
| 45 | + public ControlMessageEvent(Type type, ControlMessage controlMessage) { | ||
| 46 | + super(type, controlMessage); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + @Override | ||
| 50 | + public String toString() { | ||
| 51 | + return toStringHelper(this) | ||
| 52 | + .add("type", type()) | ||
| 53 | + .add("subject", subject()) | ||
| 54 | + .toString(); | ||
| 55 | + } | ||
| 56 | +} |
| 1 | +/* | ||
| 2 | + * Copyright 2016 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.cpman.message; | ||
| 17 | + | ||
| 18 | +import org.onosproject.event.EventListener; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * Entity capable of receiving control message related event. | ||
| 22 | + */ | ||
| 23 | +public interface ControlMessageListener extends EventListener<ControlMessageEvent> { | ||
| 24 | + | ||
| 25 | +} |
| 1 | +/* | ||
| 2 | + * Copyright 2016 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.cpman.message; | ||
| 17 | + | ||
| 18 | +import org.onosproject.net.provider.Provider; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * Abstraction of a control message provider. | ||
| 22 | + */ | ||
| 23 | +public interface ControlMessageProvider extends Provider { | ||
| 24 | +} |
apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageProviderRegistry.java
0 → 100644
| 1 | +/* | ||
| 2 | + * Copyright 2016 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.cpman.message; | ||
| 17 | + | ||
| 18 | +import org.onosproject.net.provider.ProviderRegistry; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * Abstraction of a control message provider registry. | ||
| 22 | + */ | ||
| 23 | +public interface ControlMessageProviderRegistry | ||
| 24 | + extends ProviderRegistry<ControlMessageProvider, | ||
| 25 | + ControlMessageProviderService> { | ||
| 26 | +} |
apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageProviderService.java
0 → 100644
| 1 | +/* | ||
| 2 | + * Copyright 2016 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.cpman.message; | ||
| 17 | + | ||
| 18 | +import org.onosproject.cpman.ControlMessage; | ||
| 19 | +import org.onosproject.net.DeviceId; | ||
| 20 | +import org.onosproject.net.provider.ProviderService; | ||
| 21 | + | ||
| 22 | +import java.util.Collection; | ||
| 23 | + | ||
| 24 | +/** | ||
| 25 | + * Service through which control message providers can inject control message | ||
| 26 | + * stats into the core. | ||
| 27 | + */ | ||
| 28 | +public interface ControlMessageProviderService | ||
| 29 | + extends ProviderService<ControlMessageProvider> { | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * Used to notify the core about the control message statistic information. | ||
| 33 | + * | ||
| 34 | + * @param deviceId device identifier | ||
| 35 | + * @param controlMessages a collection of control message stats | ||
| 36 | + */ | ||
| 37 | + void updateStatsInfo(DeviceId deviceId, Collection<ControlMessage> controlMessages); | ||
| 38 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +/* | ||
| 2 | + * Copyright 2016 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.cpman.message; | ||
| 17 | + | ||
| 18 | +import org.onosproject.event.ListenerService; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * Service for obtaining control message statistic information. | ||
| 22 | + */ | ||
| 23 | +public interface ControlMessageService extends ListenerService { | ||
| 24 | +} |
| 1 | +/* | ||
| 2 | + * Copyright 2016 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.cpman.message; | ||
| 17 | + | ||
| 18 | +import org.onosproject.cpman.ControlMessage; | ||
| 19 | +import org.onosproject.net.DeviceId; | ||
| 20 | +import org.onosproject.net.provider.ProviderId; | ||
| 21 | +import org.onosproject.store.Store; | ||
| 22 | + | ||
| 23 | +import java.util.Collection; | ||
| 24 | + | ||
| 25 | +/** | ||
| 26 | + * Manages inventory of control message. | ||
| 27 | + */ | ||
| 28 | +public interface ControlMessageStore | ||
| 29 | + extends Store<ControlMessageEvent, ControlMessageStoreDelegate> { | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * Updates the control message statistics of the specified device. | ||
| 33 | + * | ||
| 34 | + * @param providerId provider identifier | ||
| 35 | + * @param deviceId device identifier | ||
| 36 | + * @param controlMessages a collection of control message stats | ||
| 37 | + * @return ready to send event describing what occurred | ||
| 38 | + */ | ||
| 39 | + ControlMessageEvent updateStatsInfo(ProviderId providerId, | ||
| 40 | + DeviceId deviceId, | ||
| 41 | + Collection<ControlMessage> controlMessages); | ||
| 42 | + | ||
| 43 | +} |
apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageStoreDelegate.java
0 → 100644
| 1 | +/* | ||
| 2 | + * Copyright 2016 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.cpman.message; | ||
| 17 | + | ||
| 18 | +import org.onosproject.store.StoreDelegate; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * Control message store delegate abstraction. | ||
| 22 | + */ | ||
| 23 | +public interface ControlMessageStoreDelegate extends StoreDelegate<ControlMessageEvent> { | ||
| 24 | +} |
| 1 | +/* | ||
| 2 | + * Copyright 2016 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 | + * Service for looking up control message stats. | ||
| 19 | + */ | ||
| 20 | +package org.onosproject.cpman.message; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment