Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 | */ |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 16 | package org.onlab.onos.store.intent.impl; |
| 17 | |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 18 | import com.codahale.metrics.Timer; |
| 19 | import com.codahale.metrics.Timer.Context; |
Yuta HIGUCHI | c8f3026 | 2014-11-20 19:14:42 -0800 | [diff] [blame] | 20 | import com.google.common.base.Verify; |
Thomas Vachuska | b97cf28 | 2014-10-20 23:31:12 -0700 | [diff] [blame] | 21 | import com.google.common.collect.ImmutableSet; |
Yuta HIGUCHI | 10a31c3 | 2014-10-28 14:42:06 -0700 | [diff] [blame] | 22 | |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 23 | import org.apache.felix.scr.annotations.Activate; |
| 24 | import org.apache.felix.scr.annotations.Component; |
| 25 | import org.apache.felix.scr.annotations.Deactivate; |
Yuta HIGUCHI | 4490a73 | 2014-11-18 20:20:30 -0800 | [diff] [blame] | 26 | import org.apache.felix.scr.annotations.Reference; |
| 27 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 28 | import org.apache.felix.scr.annotations.Service; |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 29 | import org.onlab.metrics.MetricsService; |
| 30 | import org.onlab.onos.core.MetricsHelper; |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 31 | import org.onlab.onos.net.intent.Intent; |
| 32 | import org.onlab.onos.net.intent.IntentEvent; |
| 33 | import org.onlab.onos.net.intent.IntentId; |
| 34 | import org.onlab.onos.net.intent.IntentState; |
| 35 | import org.onlab.onos.net.intent.IntentStore; |
| 36 | import org.onlab.onos.net.intent.IntentStoreDelegate; |
Yuta HIGUCHI | 4490a73 | 2014-11-18 20:20:30 -0800 | [diff] [blame] | 37 | import org.onlab.onos.store.AbstractStore; |
Yuta HIGUCHI | 2befc66 | 2014-10-30 15:57:49 -0700 | [diff] [blame] | 38 | import org.onlab.onos.store.serializers.KryoNamespaces; |
| 39 | import org.onlab.onos.store.serializers.KryoSerializer; |
Yuta HIGUCHI | 4490a73 | 2014-11-18 20:20:30 -0800 | [diff] [blame] | 40 | import org.onlab.onos.store.serializers.StoreSerializer; |
| 41 | import org.onlab.onos.store.service.DatabaseAdminService; |
| 42 | import org.onlab.onos.store.service.DatabaseService; |
| 43 | import org.onlab.onos.store.service.impl.CMap; |
Yuta HIGUCHI | 2befc66 | 2014-10-30 15:57:49 -0700 | [diff] [blame] | 44 | import org.onlab.util.KryoNamespace; |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 45 | import org.slf4j.Logger; |
| 46 | |
Yuta HIGUCHI | 9a2e18a | 2014-11-18 16:41:58 -0800 | [diff] [blame] | 47 | import java.util.EnumSet; |
Thomas Vachuska | b97cf28 | 2014-10-20 23:31:12 -0700 | [diff] [blame] | 48 | import java.util.List; |
| 49 | import java.util.Map; |
Yuta HIGUCHI | 9a2e18a | 2014-11-18 16:41:58 -0800 | [diff] [blame] | 50 | import java.util.Set; |
Thomas Vachuska | b97cf28 | 2014-10-20 23:31:12 -0700 | [diff] [blame] | 51 | import java.util.concurrent.ConcurrentHashMap; |
| 52 | |
| 53 | import static org.onlab.onos.net.intent.IntentState.*; |
| 54 | import static org.slf4j.LoggerFactory.getLogger; |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 55 | import static org.onlab.metrics.MetricsUtil.*; |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 56 | |
Yuta HIGUCHI | c8f3026 | 2014-11-20 19:14:42 -0800 | [diff] [blame] | 57 | @Component(immediate = true, enabled = true) |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 58 | @Service |
| 59 | public class DistributedIntentStore |
Yuta HIGUCHI | 4490a73 | 2014-11-18 20:20:30 -0800 | [diff] [blame] | 60 | extends AbstractStore<IntentEvent, IntentStoreDelegate> |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 61 | implements IntentStore, MetricsHelper { |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 62 | |
Yuta HIGUCHI | 9a2e18a | 2014-11-18 16:41:58 -0800 | [diff] [blame] | 63 | /** Valid parking state, which can transition to INSTALLED. */ |
Yuta HIGUCHI | 89a7f47 | 2014-11-21 14:50:24 -0800 | [diff] [blame] | 64 | private static final Set<IntentState> PRE_INSTALLED = EnumSet.of(SUBMITTED, INSTALLED, FAILED); |
Yuta HIGUCHI | 9a2e18a | 2014-11-18 16:41:58 -0800 | [diff] [blame] | 65 | |
| 66 | /** Valid parking state, which can transition to WITHDRAWN. */ |
| 67 | private static final Set<IntentState> PRE_WITHDRAWN = EnumSet.of(INSTALLED, FAILED); |
| 68 | |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 69 | private final Logger log = getLogger(getClass()); |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 70 | |
Yuta HIGUCHI | 10a31c3 | 2014-10-28 14:42:06 -0700 | [diff] [blame] | 71 | // Assumption: IntentId will not have synonyms |
Yuta HIGUCHI | 4490a73 | 2014-11-18 20:20:30 -0800 | [diff] [blame] | 72 | private CMap<IntentId, Intent> intents; |
| 73 | private CMap<IntentId, IntentState> states; |
Yuta HIGUCHI | 10a31c3 | 2014-10-28 14:42:06 -0700 | [diff] [blame] | 74 | |
Yuta HIGUCHI | 4490a73 | 2014-11-18 20:20:30 -0800 | [diff] [blame] | 75 | // TODO left behind transient state issue: ONOS-103 |
Yuta HIGUCHI | 10a31c3 | 2014-10-28 14:42:06 -0700 | [diff] [blame] | 76 | // Map to store instance local intermediate state transition |
| 77 | private transient Map<IntentId, IntentState> transientStates = new ConcurrentHashMap<>(); |
| 78 | |
Yuta HIGUCHI | 4490a73 | 2014-11-18 20:20:30 -0800 | [diff] [blame] | 79 | private CMap<IntentId, List<Intent>> installable; |
Yuta HIGUCHI | 10a31c3 | 2014-10-28 14:42:06 -0700 | [diff] [blame] | 80 | |
Yuta HIGUCHI | 4490a73 | 2014-11-18 20:20:30 -0800 | [diff] [blame] | 81 | private StoreSerializer serializer; |
| 82 | |
| 83 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 84 | protected DatabaseAdminService dbAdminService; |
| 85 | |
| 86 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 87 | protected DatabaseService dbService; |
| 88 | |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 89 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 90 | protected MetricsService metricsService; |
| 91 | |
Yuta HIGUCHI | c8f3026 | 2014-11-20 19:14:42 -0800 | [diff] [blame] | 92 | // TODO make this configurable |
| 93 | private boolean onlyLogTransitionError = true; |
| 94 | |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 95 | private Timer createIntentTimer; |
| 96 | private Timer removeIntentTimer; |
| 97 | private Timer setInstallableIntentsTimer; |
| 98 | private Timer getInstallableIntentsTimer; |
| 99 | private Timer removeInstalledIntentsTimer; |
| 100 | private Timer setStateTimer; |
| 101 | private Timer getIntentCountTimer; |
| 102 | private Timer getIntentsTimer; |
| 103 | private Timer getIntentTimer; |
| 104 | private Timer getIntentStateTimer; |
| 105 | |
| 106 | |
| 107 | private Timer createResponseTimer(String methodName) { |
| 108 | return createTimer("IntentStore", methodName, "responseTime"); |
| 109 | } |
| 110 | |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 111 | @Activate |
| 112 | public void activate() { |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 113 | createIntentTimer = createResponseTimer("createIntent"); |
| 114 | removeIntentTimer = createResponseTimer("removeIntent"); |
| 115 | setInstallableIntentsTimer = createResponseTimer("setInstallableIntents"); |
| 116 | getInstallableIntentsTimer = createResponseTimer("getInstallableIntents"); |
| 117 | removeInstalledIntentsTimer = createResponseTimer("removeInstalledIntents"); |
| 118 | setStateTimer = createResponseTimer("setState"); |
| 119 | getIntentCountTimer = createResponseTimer("getIntentCount"); |
| 120 | getIntentsTimer = createResponseTimer("getIntents"); |
| 121 | getIntentTimer = createResponseTimer("getIntent"); |
| 122 | getIntentStateTimer = createResponseTimer("getIntentState"); |
| 123 | |
Yuta HIGUCHI | 71fa493 | 2014-10-28 22:27:49 -0700 | [diff] [blame] | 124 | // FIXME: We need a way to add serializer for intents which has been plugged-in. |
Yuta HIGUCHI | 2befc66 | 2014-10-30 15:57:49 -0700 | [diff] [blame] | 125 | // As a short term workaround, relax Kryo config to |
| 126 | // registrationRequired=false |
Yuta HIGUCHI | 4490a73 | 2014-11-18 20:20:30 -0800 | [diff] [blame] | 127 | serializer = new KryoSerializer() { |
Yuta HIGUCHI | 2befc66 | 2014-10-30 15:57:49 -0700 | [diff] [blame] | 128 | |
| 129 | @Override |
| 130 | protected void setupKryoPool() { |
| 131 | serializerPool = KryoNamespace.newBuilder() |
| 132 | .setRegistrationRequired(false) |
| 133 | .register(KryoNamespaces.API) |
Yuta HIGUCHI | 91768e3 | 2014-11-22 05:06:35 -0800 | [diff] [blame] | 134 | .nextId(KryoNamespaces.BEGIN_USER_CUSTOM_ID) |
| 135 | .build(); |
Yuta HIGUCHI | 2befc66 | 2014-10-30 15:57:49 -0700 | [diff] [blame] | 136 | } |
Yuta HIGUCHI | 2befc66 | 2014-10-30 15:57:49 -0700 | [diff] [blame] | 137 | }; |
Yuta HIGUCHI | 10a31c3 | 2014-10-28 14:42:06 -0700 | [diff] [blame] | 138 | |
Yuta HIGUCHI | 4490a73 | 2014-11-18 20:20:30 -0800 | [diff] [blame] | 139 | intents = new CMap<>(dbAdminService, dbService, "intents", serializer); |
Yuta HIGUCHI | 10a31c3 | 2014-10-28 14:42:06 -0700 | [diff] [blame] | 140 | |
Yuta HIGUCHI | 4490a73 | 2014-11-18 20:20:30 -0800 | [diff] [blame] | 141 | states = new CMap<>(dbAdminService, dbService, "intent-states", serializer); |
Yuta HIGUCHI | 10a31c3 | 2014-10-28 14:42:06 -0700 | [diff] [blame] | 142 | |
| 143 | transientStates.clear(); |
| 144 | |
Yuta HIGUCHI | 4490a73 | 2014-11-18 20:20:30 -0800 | [diff] [blame] | 145 | installable = new CMap<>(dbAdminService, dbService, "installable-intents", serializer); |
Yuta HIGUCHI | 10a31c3 | 2014-10-28 14:42:06 -0700 | [diff] [blame] | 146 | |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 147 | log.info("Started"); |
| 148 | } |
| 149 | |
| 150 | @Deactivate |
| 151 | public void deactivate() { |
| 152 | log.info("Stopped"); |
| 153 | } |
| 154 | |
| 155 | @Override |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 156 | public MetricsService metricsService() { |
| 157 | return metricsService; |
| 158 | } |
| 159 | |
| 160 | @Override |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 161 | public IntentEvent createIntent(Intent intent) { |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 162 | Context timer = startTimer(createIntentTimer); |
| 163 | try { |
| 164 | boolean absent = intents.putIfAbsent(intent.id(), intent); |
| 165 | if (!absent) { |
| 166 | // duplicate, ignore |
| 167 | return null; |
| 168 | } else { |
| 169 | return this.setState(intent, IntentState.SUBMITTED); |
| 170 | } |
| 171 | } finally { |
| 172 | stopTimer(timer); |
Yuta HIGUCHI | 10a31c3 | 2014-10-28 14:42:06 -0700 | [diff] [blame] | 173 | } |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | @Override |
| 177 | public IntentEvent removeIntent(IntentId intentId) { |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 178 | Context timer = startTimer(removeIntentTimer); |
| 179 | try { |
| 180 | Intent intent = intents.remove(intentId); |
| 181 | installable.remove(intentId); |
| 182 | if (intent == null) { |
| 183 | // was already removed |
| 184 | return null; |
| 185 | } |
| 186 | IntentEvent event = this.setState(intent, WITHDRAWN); |
| 187 | states.remove(intentId); |
| 188 | transientStates.remove(intentId); |
| 189 | // TODO: Should we callremoveInstalledIntents if this Intent was |
| 190 | return event; |
| 191 | } finally { |
| 192 | stopTimer(timer); |
Yuta HIGUCHI | 10a31c3 | 2014-10-28 14:42:06 -0700 | [diff] [blame] | 193 | } |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | @Override |
| 197 | public long getIntentCount() { |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 198 | Context timer = startTimer(getIntentCountTimer); |
| 199 | try { |
| 200 | return intents.size(); |
| 201 | } finally { |
| 202 | stopTimer(timer); |
| 203 | } |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | @Override |
| 207 | public Iterable<Intent> getIntents() { |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 208 | Context timer = startTimer(getIntentsTimer); |
| 209 | try { |
| 210 | return ImmutableSet.copyOf(intents.values()); |
| 211 | } finally { |
| 212 | stopTimer(timer); |
| 213 | } |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | @Override |
| 217 | public Intent getIntent(IntentId intentId) { |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 218 | Context timer = startTimer(getIntentTimer); |
| 219 | try { |
| 220 | return intents.get(intentId); |
| 221 | } finally { |
| 222 | stopTimer(timer); |
| 223 | } |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | @Override |
| 227 | public IntentState getIntentState(IntentId id) { |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 228 | Context timer = startTimer(getIntentStateTimer); |
| 229 | try { |
| 230 | final IntentState localState = transientStates.get(id); |
| 231 | if (localState != null) { |
| 232 | return localState; |
| 233 | } |
| 234 | return states.get(id); |
| 235 | } finally { |
| 236 | stopTimer(timer); |
Yuta HIGUCHI | 10a31c3 | 2014-10-28 14:42:06 -0700 | [diff] [blame] | 237 | } |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 238 | } |
| 239 | |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 240 | // FIXME temporary workaround until we fix our state machine |
Yuta HIGUCHI | c8f3026 | 2014-11-20 19:14:42 -0800 | [diff] [blame] | 241 | private void verify(boolean expression, String errorMessageTemplate, Object... errorMessageArgs) { |
| 242 | if (onlyLogTransitionError) { |
| 243 | if (!expression) { |
| 244 | log.error(errorMessageTemplate.replace("%s", "{}"), errorMessageArgs); |
| 245 | } |
| 246 | } else { |
| 247 | Verify.verify(expression, errorMessageTemplate, errorMessageArgs); |
| 248 | } |
| 249 | } |
Yuta HIGUCHI | 9a2e18a | 2014-11-18 16:41:58 -0800 | [diff] [blame] | 250 | |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 251 | @Override |
| 252 | public IntentEvent setState(Intent intent, IntentState state) { |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 253 | Context timer = startTimer(setStateTimer); |
| 254 | try { |
| 255 | final IntentId id = intent.id(); |
| 256 | IntentEvent.Type evtType = null; |
| 257 | final IntentState prevParking; |
| 258 | boolean transitionedToParking = true; |
| 259 | boolean updated; |
Pavlin Radoslavov | c8ccbd9 | 2014-10-22 09:59:37 -0700 | [diff] [blame] | 260 | |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 261 | // parking state transition |
| 262 | switch (state) { |
| 263 | case SUBMITTED: |
| 264 | prevParking = states.get(id); |
| 265 | if (prevParking == null) { |
| 266 | updated = states.putIfAbsent(id, SUBMITTED); |
| 267 | verify(updated, "Conditional replace %s => %s failed", prevParking, SUBMITTED); |
| 268 | } else { |
| 269 | verify(prevParking == WITHDRAWN, |
| 270 | "Illegal state transition attempted from %s to SUBMITTED", |
| 271 | prevParking); |
| 272 | updated = states.replace(id, prevParking, SUBMITTED); |
| 273 | verify(updated, "Conditional replace %s => %s failed", prevParking, SUBMITTED); |
| 274 | } |
| 275 | evtType = IntentEvent.Type.SUBMITTED; |
| 276 | break; |
| 277 | |
| 278 | case INSTALLED: |
| 279 | prevParking = states.get(id); |
| 280 | verify(PRE_INSTALLED.contains(prevParking), |
| 281 | "Illegal state transition attempted from %s to INSTALLED", |
| 282 | prevParking); |
| 283 | updated = states.replace(id, prevParking, INSTALLED); |
| 284 | verify(updated, "Conditional replace %s => %s failed", prevParking, INSTALLED); |
| 285 | evtType = IntentEvent.Type.INSTALLED; |
| 286 | break; |
| 287 | |
| 288 | case FAILED: |
| 289 | prevParking = states.get(id); |
| 290 | updated = states.replace(id, prevParking, FAILED); |
| 291 | verify(updated, "Conditional replace %s => %s failed", prevParking, FAILED); |
| 292 | evtType = IntentEvent.Type.FAILED; |
| 293 | break; |
| 294 | |
| 295 | case WITHDRAWN: |
| 296 | prevParking = states.get(id); |
| 297 | verify(PRE_WITHDRAWN.contains(prevParking), |
| 298 | "Illegal state transition attempted from %s to WITHDRAWN", |
| 299 | prevParking); |
| 300 | updated = states.replace(id, prevParking, WITHDRAWN); |
| 301 | verify(updated, "Conditional replace %s => %s failed", prevParking, WITHDRAWN); |
| 302 | evtType = IntentEvent.Type.WITHDRAWN; |
| 303 | break; |
| 304 | |
| 305 | default: |
| 306 | transitionedToParking = false; |
| 307 | prevParking = null; |
| 308 | break; |
Yuta HIGUCHI | 89a7f47 | 2014-11-21 14:50:24 -0800 | [diff] [blame] | 309 | } |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 310 | if (transitionedToParking) { |
| 311 | log.debug("Parking State change: {} {}=>{}", id, prevParking, state); |
| 312 | // remove instance local state |
| 313 | transientStates.remove(id); |
| 314 | } else { |
| 315 | // Update instance local state, which includes non-parking state transition |
| 316 | final IntentState prevTransient = transientStates.put(id, state); |
| 317 | log.debug("Transient State change: {} {}=>{}", id, prevTransient, state); |
| 318 | } |
Yuta HIGUCHI | 4490a73 | 2014-11-18 20:20:30 -0800 | [diff] [blame] | 319 | |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 320 | if (evtType == null) { |
| 321 | return null; |
| 322 | } |
| 323 | return new IntentEvent(evtType, intent); |
| 324 | } finally { |
| 325 | stopTimer(timer); |
Pavlin Radoslavov | c8ccbd9 | 2014-10-22 09:59:37 -0700 | [diff] [blame] | 326 | } |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | @Override |
Yuta HIGUCHI | 10a31c3 | 2014-10-28 14:42:06 -0700 | [diff] [blame] | 330 | public void setInstallableIntents(IntentId intentId, List<Intent> result) { |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 331 | Context timer = startTimer(setInstallableIntentsTimer); |
| 332 | try { |
| 333 | installable.put(intentId, result); |
| 334 | } finally { |
| 335 | stopTimer(timer); |
| 336 | } |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | @Override |
Thomas Vachuska | b97cf28 | 2014-10-20 23:31:12 -0700 | [diff] [blame] | 340 | public List<Intent> getInstallableIntents(IntentId intentId) { |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 341 | Context timer = startTimer(getInstallableIntentsTimer); |
| 342 | try { |
| 343 | return installable.get(intentId); |
| 344 | } finally { |
| 345 | stopTimer(timer); |
| 346 | } |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | @Override |
| 350 | public void removeInstalledIntents(IntentId intentId) { |
Yuta HIGUCHI | e367fb9 | 2014-11-24 22:26:58 -0800 | [diff] [blame^] | 351 | Context timer = startTimer(removeInstalledIntentsTimer); |
| 352 | try { |
| 353 | installable.remove(intentId); |
| 354 | } finally { |
| 355 | stopTimer(timer); |
| 356 | } |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 357 | } |
Yuta HIGUCHI | 406a565 | 2014-10-20 22:18:16 -0700 | [diff] [blame] | 358 | } |