2 * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.nemo.intent.condition;
11 import org.opendaylight.nemo.intent.IntentResolver;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.UserId;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.operation.rev151010.condition.instance.ConditionSegment;
15 import java.util.List;
16 import java.util.TimerTask;
19 * Created by hj on 11/19/15.
20 * TimerTask for one condition.
22 public class ConditionMonitor extends TimerTask {
23 private List<ConditionSegment> conditionSegments;
24 //Handle operation when condition state changed
25 private IntentResolver intentResolver;
26 private boolean preState;
27 private UserId userId;
29 public ConditionMonitor(IntentResolver intentResolver, UserId userId, List<ConditionSegment> conditionSegments) {
30 this.conditionSegments = conditionSegments;
31 this.intentResolver = intentResolver;
33 preState = ConditionDeterminer.isConditionMet(conditionSegments);
38 boolean currentState = ConditionDeterminer.isConditionMet(conditionSegments);
39 if (currentState != preState) {
41 intentResolver.resolveIntent(userId);
42 } catch (Exception e) {
45 preState = currentState;