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;
46 private boolean flowStatisticsAvailable;
47 private boolean tableStatisticsAvailable;
48 private boolean portStatisticsAvailable;
49 private boolean queueStatisticsAvailable;
51 public DeviceStateImpl(@CheckForNull final FeaturesReply featuresReply, @Nonnull final NodeId nodeId) {
52 Preconditions.checkArgument(featuresReply != null);
53 featuresOutput = new GetFeaturesOutputBuilder(featuresReply).build();
54 this.nodeId = Preconditions.checkNotNull(nodeId);
55 nodeII = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId));
56 version = featuresReply.getVersion();
60 public NodeId getNodeId() {
65 public KeyedInstanceIdentifier<Node, NodeKey> getNodeInstanceIdentifier() {
70 public GetFeaturesOutput getFeatures() {
71 return featuresOutput;
75 public boolean isValid() {
80 public void setValid(final boolean valid) {
85 public short getVersion() {
90 public boolean isMetersAvailable() {
91 return meterIsAvailable;
95 public void setMeterAvailable(boolean available) {
96 meterIsAvailable = available;
100 public boolean isGroupAvailable() {
101 return groupIsAvailable;
105 public void setGroupAvailable(boolean available) {
106 groupIsAvailable = available;
110 public boolean deviceSynchronized() {
111 return deviceSynchronized;
115 public boolean isFlowStatisticsAvailable() {
116 return flowStatisticsAvailable;
120 public void setFlowStatisticsAvailable(final boolean available) {
121 flowStatisticsAvailable = available;
125 public boolean isTableStatisticsAvailable() {
126 return tableStatisticsAvailable;
130 public void setTableStatisticsAvailable(final boolean available) {
131 tableStatisticsAvailable = available;
135 public boolean isPortStatisticsAvailable() {
136 return portStatisticsAvailable;
140 public void setPortStatisticsAvailable(final boolean available) {
141 portStatisticsAvailable = available;
145 public boolean isQueueStatisticsAvailable() {
146 return queueStatisticsAvailable;
150 public void setQueueStatisticsAvailable(final boolean available) {
151 queueStatisticsAvailable = available;
156 public void setDeviceSynchronized(final boolean _deviceSynchronized) {
157 deviceSynchronized = _deviceSynchronized;