blob: 954f66b9718ec3dfd258dfac4815d543dea705ac [file] [log] [blame]
yoonseon94672112017-01-31 13:46:21 -08001/*
2 * Copyright 2017-present Open Networking Foundation
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
17package org.onosproject.incubator.net.virtual;
18
19import org.onosproject.net.DeviceId;
20import org.onosproject.net.meter.Meter;
21import org.onosproject.net.meter.MeterEvent;
22import org.onosproject.net.meter.MeterFailReason;
23import org.onosproject.net.meter.MeterFeatures;
24import org.onosproject.net.meter.MeterFeaturesKey;
25import org.onosproject.net.meter.MeterKey;
26import org.onosproject.net.meter.MeterOperation;
27import org.onosproject.net.meter.MeterStoreDelegate;
28import org.onosproject.net.meter.MeterStoreResult;
29
30import java.util.Collection;
31import java.util.concurrent.CompletableFuture;
32
33public interface VirtualNetworkMeterStore
34 extends VirtualStore<MeterEvent, MeterStoreDelegate> {
35
36 /**
37 * Adds a meter to the store.
38 *
39 * @param networkId a virtual network identifier
40 * @param meter a meter
41 * @return a future indicating the result of the store operation
42 */
43 CompletableFuture<MeterStoreResult> storeMeter(NetworkId networkId, Meter meter);
44
45 /**
46 * Deletes a meter from the store.
47 *
48 * @param networkId a virtual network identifier
49 * @param meter a meter
50 * @return a future indicating the result of the store operation
51 */
52 CompletableFuture<MeterStoreResult> deleteMeter(NetworkId networkId, Meter meter);
53
54
55 /**
56 * Adds the meter features to the store.
57 *
58 * @param networkId a virtual network identifier
59 * @param meterfeatures the meter features
60 * @return the result of the store operation
61 */
62 MeterStoreResult storeMeterFeatures(NetworkId networkId, MeterFeatures meterfeatures);
63
64 /**
65 * Deletes the meter features from the store.
66 *
67 * @param networkId a virtual network identifier
68 * @param deviceId the device id
69 * @return a future indicating the result of the store operation
70 */
71 MeterStoreResult deleteMeterFeatures(NetworkId networkId, DeviceId deviceId);
72
73
74 /**
75 * Updates a meter whose meter id is the same as the passed meter.
76 *
77 * @param networkId a virtual network identifier
78 * @param meter a new meter
79 * @return a future indicating the result of the store operation
80 */
81 CompletableFuture<MeterStoreResult> updateMeter(NetworkId networkId, Meter meter);
82
83 /**
84 * Updates a given meter's state with the provided state.
85 *
86 * @param networkId a virtual network identifier
87 * @param meter a meter
88 */
89 void updateMeterState(NetworkId networkId, Meter meter);
90
91 /**
92 * Obtains a meter matching the given meter key.
93 *
94 * @param networkId a virtual network identifier
95 * @param key a meter key
96 * @return a meter
97 */
98 Meter getMeter(NetworkId networkId, MeterKey key);
99
100 /**
101 * Returns all meters stored in the store.
102 *
103 * @param networkId a virtual network identifier
104 * @return a collection of meters
105 */
106 Collection<Meter> getAllMeters(NetworkId networkId);
107
108 /**
109 * Update the store by deleting the failed meter.
110 * Notifies the delegate that the meter failed to allow it
111 * to nofity the app.
112 *
113 * @param networkId a virtual network identifier
114 * @param op a failed meter operation
115 * @param reason a failure reason
116 */
117 void failedMeter(NetworkId networkId, MeterOperation op, MeterFailReason reason);
118
119 /**
120 * Delete this meter immediately.
121 *
122 * @param networkId a virtual network identifier
123 * @param m a meter
124 */
125 void deleteMeterNow(NetworkId networkId, Meter m);
126
127 /**
128 * Retrieve maximum meters available for the device.
129 *
130 * @param networkId a virtual network identifier
131 * @param key the meter features key
132 * @return the maximum number of meters supported by the device
133 */
134 long getMaxMeters(NetworkId networkId, MeterFeaturesKey key);
135}