2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. 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
8 package org.opendaylight.genius.mdsalutil;
10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
11 import java.math.BigInteger;
12 import java.util.List;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.immutables.value.Value.Default;
15 import org.immutables.value.Value.Immutable;
16 import org.opendaylight.genius.infra.OpenDaylightImmutableStyle;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
24 @OpenDaylightImmutableStyle
25 public abstract class FlowEntity extends AbstractSwitchEntity {
27 // This is required as it will cause the code generation by @Immutable.org to implement Builder,
28 // which is required Xtend sources can use the XtendBuilderExtensions.operator_doubleGreaterThan
29 public abstract static class Builder implements org.opendaylight.yangtools.concepts.Builder<FlowEntity> {
33 // This was done because MDSALManager has this hard-coded like this, upon MDSALManager.installFlow()
35 public BigInteger getCookie() {
36 return new BigInteger("0110000", 16);
39 public abstract String getFlowId();
41 public abstract @Nullable String getFlowName();
44 // Confusing to have methods getHardTimeOut() and ActionLearn.getHardTimeout()
45 @SuppressFBWarnings("NM_CONFUSING")
46 public int getHardTimeOut() {
51 // Confusing to have methods getIdleTimeOut() and ActionLearn.getIdleTimeout()
52 @SuppressFBWarnings("NM_CONFUSING")
53 public int getIdleTimeOut() {
57 public abstract List<InstructionInfo> getInstructionInfoList();
59 public abstract List<MatchInfoBase> getMatchInfoList();
62 public int getPriority() {
67 public boolean getSendFlowRemFlag() {
72 public boolean getStrictFlag() {
76 public abstract short getTableId();
78 public FlowBuilder getFlowBuilder() {
79 FlowBuilder flowBuilder = new FlowBuilder();
81 flowBuilder.withKey(new FlowKey(new FlowId(getFlowId())));
83 flowBuilder.setTableId(getTableId());
84 flowBuilder.setPriority(getPriority());
85 flowBuilder.setFlowName(getFlowName());
86 flowBuilder.setIdleTimeout(getIdleTimeOut());
87 flowBuilder.setHardTimeout(getHardTimeOut());
88 flowBuilder.setCookie(new FlowCookie(getCookie()));
89 flowBuilder.setMatch(MDSALUtil.buildMatches(getMatchInfoList()));
90 flowBuilder.setInstructions(MDSALUtil.buildInstructions(getInstructionInfoList()));
92 flowBuilder.setStrict(getStrictFlag());
93 // TODO flowBuilder.setResyncFlag(getResyncFlag());
94 if (getSendFlowRemFlag()) {
95 flowBuilder.setFlags(new FlowModFlags(false, false, false, false, true));
98 flowBuilder.setBarrier(false);
99 flowBuilder.setInstallHw(true);