2 * Copyright (c) 2015 Cisco Systems, 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.openflowplugin.impl.device;
11 import com.google.common.base.Preconditions;
12 import javax.annotation.CheckForNull;
13 import javax.annotation.Nonnull;
14 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder;
22 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
27 * org.opendaylight.openflowplugin.impl.device
29 * DeviceState is builded from {@link FeaturesReply} and {@link NodeId}. Both values are inside
30 * {@link org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext}
32 * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
34 * Created: Mar 29, 2015
36 class DeviceStateImpl implements DeviceState {
38 private final GetFeaturesOutput featuresOutput;
39 private final NodeId nodeId;
40 private final KeyedInstanceIdentifier<Node, NodeKey> nodeII;
41 private final short version;
42 private boolean valid;
43 private boolean meterIsAvailable;
44 private boolean groupIsAvailable;
45 private boolean deviceSynchronized;
48 public DeviceStateImpl(@CheckForNull final FeaturesReply featuresReply, @Nonnull final NodeId nodeId) {
49 Preconditions.checkArgument(featuresReply != null);
50 featuresOutput = new GetFeaturesOutputBuilder(featuresReply).build();
51 this.nodeId = Preconditions.checkNotNull(nodeId);
52 nodeII = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId));
53 version = featuresReply.getVersion();
57 public NodeId getNodeId() {
62 public KeyedInstanceIdentifier<Node, NodeKey> getNodeInstanceIdentifier() {
67 public GetFeaturesOutput getFeatures() {
68 return featuresOutput;
72 public boolean isValid() {
77 public void setValid(final boolean valid) {
82 public short getVersion() {
87 public boolean isMetersAvailable() {
88 return meterIsAvailable;
92 public void meterIsAvailable() {
93 meterIsAvailable = true;
97 public boolean isGroupAvailable() {
98 return groupIsAvailable;
102 public void groupIsAvailable() {
103 groupIsAvailable = true;
107 public boolean deviceSynchronized() {
108 return deviceSynchronized;
112 public void setDeviceSynchronized(final boolean _deviceSynchronized) {
113 deviceSynchronized = _deviceSynchronized;