diff --git a/apps/pi-demo/ecmp/src/main/java/org/onosproject/pi/demo/app/ecmp/EcmpFabricApp.java b/apps/pi-demo/ecmp/src/main/java/org/onosproject/pi/demo/app/ecmp/EcmpFabricApp.java index bb15afc846..2bad3e9e59 100644 --- a/apps/pi-demo/ecmp/src/main/java/org/onosproject/pi/demo/app/ecmp/EcmpFabricApp.java +++ b/apps/pi-demo/ecmp/src/main/java/org/onosproject/pi/demo/app/ecmp/EcmpFabricApp.java @@ -40,8 +40,8 @@ import org.onosproject.net.group.GroupBuckets; import org.onosproject.net.group.GroupDescription; import org.onosproject.net.group.GroupKey; import org.onosproject.net.pi.runtime.PiAction; -import org.onosproject.net.pi.runtime.PiActionGroupId; import org.onosproject.net.pi.runtime.PiActionParam; +import org.onosproject.net.pi.runtime.PiActionProfileGroupId; import org.onosproject.net.pi.runtime.PiGroupKey; import org.onosproject.net.pi.runtime.PiTableAction; import org.onosproject.net.topology.DefaultTopologyVertex; @@ -272,7 +272,7 @@ public class EcmpFabricApp extends AbstractUpgradableFabricApp { .build()) .withTreatment( DefaultTrafficTreatment.builder() - .piTableAction(PiActionGroupId.of(groupId)) + .piTableAction(PiActionProfileGroupId.of(groupId)) .build()) .build(); } diff --git a/core/api/src/main/java/org/onosproject/net/flow/instructions/PiInstruction.java b/core/api/src/main/java/org/onosproject/net/flow/instructions/PiInstruction.java index 180a52157a..87542bd4ab 100644 --- a/core/api/src/main/java/org/onosproject/net/flow/instructions/PiInstruction.java +++ b/core/api/src/main/java/org/onosproject/net/flow/instructions/PiInstruction.java @@ -19,8 +19,8 @@ package org.onosproject.net.flow.instructions; import com.google.common.annotations.Beta; import com.google.common.base.Objects; -import org.onosproject.net.pi.runtime.PiActionGroupId; -import org.onosproject.net.pi.runtime.PiActionGroupMemberId; +import org.onosproject.net.pi.runtime.PiActionProfileGroupId; +import org.onosproject.net.pi.runtime.PiActionProfileMemberId; import org.onosproject.net.pi.runtime.PiTableAction; /** @@ -74,10 +74,10 @@ public final class PiInstruction implements Instruction { @Override public String toString() { switch (tableAction.type()) { - case ACTION_GROUP_ID: - return "GROUP:0x" + Integer.toHexString(((PiActionGroupId) tableAction).id()); - case GROUP_MEMBER_ID: - return "GROUP_MEMBER:0x" + Integer.toHexString(((PiActionGroupMemberId) tableAction).id()); + case ACTION_PROFILE_GROUP_ID: + return "GROUP:0x" + Integer.toHexString(((PiActionProfileGroupId) tableAction).id()); + case ACTION_PROFILE_MEMBER_ID: + return "GROUP_MEMBER:0x" + Integer.toHexString(((PiActionProfileMemberId) tableAction).id()); default: return tableAction.toString(); } diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroup.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileGroup.java similarity index 58% rename from core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroup.java rename to core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileGroup.java index a22e039424..96168b9375 100644 --- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroup.java +++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileGroup.java @@ -29,37 +29,38 @@ import java.util.Map; import static com.google.common.base.Preconditions.checkNotNull; /** - * Instance of an action group of a protocol-independent pipeline. + * Instance of an action profile group of a protocol-independent pipeline. */ @Beta -public final class PiActionGroup implements PiEntity { +public final class PiActionProfileGroup implements PiEntity { - private final PiActionGroupId id; - private final ImmutableSet members; - private final PiActionProfileId piActionProfileId; + private final PiActionProfileGroupId id; + private final ImmutableSet members; + private final PiActionProfileId actionProfileId; - private PiActionGroup(PiActionGroupId id, ImmutableSet members, - PiActionProfileId piActionProfileId) { + private PiActionProfileGroup(PiActionProfileGroupId id, + ImmutableSet members, + PiActionProfileId actionProfileId) { this.id = id; this.members = members; - this.piActionProfileId = piActionProfileId; + this.actionProfileId = actionProfileId; } /** - * Returns the identifier of this action group. + * Returns the identifier of this action profile group. * - * @return action group identifier + * @return action profile group identifier */ - public PiActionGroupId id() { + public PiActionProfileGroupId id() { return id; } /** - * Returns the members of this action group. + * Returns the members of this action profile group. * - * @return collection of action members. + * @return collection of action profile members. */ - public Collection members() { + public Collection members() { return members; } @@ -69,7 +70,7 @@ public final class PiActionGroup implements PiEntity { * @return action profile id */ public PiActionProfileId actionProfileId() { - return piActionProfileId; + return actionProfileId; } @Override @@ -77,13 +78,13 @@ public final class PiActionGroup implements PiEntity { if (this == o) { return true; } - if (o == null || !(o instanceof PiActionGroup)) { + if (o == null || !(o instanceof PiActionProfileGroup)) { return false; } - PiActionGroup that = (PiActionGroup) o; + PiActionProfileGroup that = (PiActionProfileGroup) o; return Objects.equal(id, that.id) && Objects.equal(members, that.members) && - Objects.equal(piActionProfileId, that.piActionProfileId); + Objects.equal(actionProfileId, that.actionProfileId); } @Override @@ -96,14 +97,14 @@ public final class PiActionGroup implements PiEntity { return MoreObjects.toStringHelper(this) .add("groupId", id) .add("members", members) - .add("piActionProfileId", piActionProfileId) + .add("piActionProfileId", actionProfileId) .toString(); } /** - * Returns a new builder of action groups. + * Returns a new builder of action profile groups. * - * @return action group builder + * @return action profile group builder */ public static Builder builder() { return new Builder(); @@ -111,16 +112,16 @@ public final class PiActionGroup implements PiEntity { @Override public PiEntityType piEntityType() { - return PiEntityType.GROUP; + return PiEntityType.ACTION_PROFILE_GROUP; } /** - * Builder of action groups. + * Builder of action profile groups. */ public static final class Builder { - private PiActionGroupId id; - private Map members = Maps.newHashMap(); + private PiActionProfileGroupId id; + private Map members = Maps.newHashMap(); private PiActionProfileId piActionProfileId; private Builder() { @@ -128,34 +129,34 @@ public final class PiActionGroup implements PiEntity { } /** - * Sets the identifier of this action group. + * Sets the identifier of this action profile group. * - * @param id action group identifier + * @param id action profile group identifier * @return this */ - public Builder withId(PiActionGroupId id) { + public Builder withId(PiActionProfileGroupId id) { this.id = id; return this; } /** - * Adds one member to this action group. + * Adds one member to this action profile group. * - * @param member action group member + * @param member action profile member * @return this */ - public Builder addMember(PiActionGroupMember member) { + public Builder addMember(PiActionProfileMember member) { members.put(member.id(), member); return this; } /** - * Adds many members to this action group. + * Adds many members to this action profile group. * - * @param members action group members + * @param members action profile members * @return this */ - public Builder addMembers(Collection members) { + public Builder addMembers(Collection members) { members.forEach(this::addMember); return this; } @@ -172,15 +173,15 @@ public final class PiActionGroup implements PiEntity { } /** - * Creates a new action group. + * Creates a new action profile group. * - * @return action group + * @return action profile group */ - public PiActionGroup build() { + public PiActionProfileGroup build() { checkNotNull(id); checkNotNull(piActionProfileId); - return new PiActionGroup(id, ImmutableSet.copyOf(members.values()), - piActionProfileId); + return new PiActionProfileGroup( + id, ImmutableSet.copyOf(members.values()), piActionProfileId); } } } diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupHandle.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileGroupHandle.java similarity index 72% rename from core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupHandle.java rename to core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileGroupHandle.java index 6969714f5e..42ed272771 100644 --- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupHandle.java +++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileGroupHandle.java @@ -23,36 +23,36 @@ import org.onosproject.net.DeviceId; import org.onosproject.net.pi.model.PiActionProfileId; /** - * Global identifier of a PI action group applied to a device, uniquely defined - * by a device ID, action profile ID and group ID. + * Global identifier of a PI action profile group applied to a device, uniquely + * defined by a device ID, action profile ID and group ID. */ @Beta -public final class PiActionGroupHandle extends PiHandle { +public final class PiActionProfileGroupHandle extends PiHandle { private final PiActionProfileId actionProfileId; - private final PiActionGroupId groupId; + private final PiActionProfileGroupId groupId; - private PiActionGroupHandle(DeviceId deviceId, PiActionGroup group) { + private PiActionProfileGroupHandle(DeviceId deviceId, PiActionProfileGroup group) { super(deviceId); actionProfileId = group.actionProfileId(); groupId = group.id(); } /** - * Creates a new handle for the given device ID and PI action group. + * Creates a new handle for the given device ID and PI action profile group. * * @param deviceId device ID - * @param group PI action group - * @return PI action group handle + * @param group PI action profile group + * @return PI action profile group handle */ - public static PiActionGroupHandle of(DeviceId deviceId, - PiActionGroup group) { - return new PiActionGroupHandle(deviceId, group); + public static PiActionProfileGroupHandle of(DeviceId deviceId, + PiActionProfileGroup group) { + return new PiActionProfileGroupHandle(deviceId, group); } @Override public PiEntityType entityType() { - return PiEntityType.GROUP; + return PiEntityType.ACTION_PROFILE_GROUP; } @Override @@ -70,7 +70,7 @@ public final class PiActionGroupHandle extends PiHandle { if (o == null || getClass() != o.getClass()) { return false; } - PiActionGroupHandle that = (PiActionGroupHandle) o; + PiActionProfileGroupHandle that = (PiActionProfileGroupHandle) o; return Objects.equal(deviceId(), that.deviceId()) && Objects.equal(actionProfileId, that.actionProfileId) && diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupId.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileGroupId.java similarity index 57% rename from core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupId.java rename to core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileGroupId.java index b604237baf..206525a598 100644 --- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupId.java +++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileGroupId.java @@ -20,32 +20,34 @@ import com.google.common.annotations.Beta; import org.onlab.util.Identifier; /** - * Identifier of an action group in a protocol-independent pipeline, unique within the scope of an action profile. + * Identifier of an action profile group in a protocol-independent pipeline, + * unique within the scope of an action profile. */ @Beta -public final class PiActionGroupId extends Identifier implements PiTableAction { +public final class PiActionProfileGroupId extends Identifier implements PiTableAction { - private PiActionGroupId(int id) { + private PiActionProfileGroupId(int id) { super(id); } /** - * Returns an action group identifier for the given integer value. + * Returns an action profile group identifier for the given integer value. * * @param id identifier - * @return action group + * @return action profile group */ - public static PiActionGroupId of(int id) { - return new PiActionGroupId(id); + public static PiActionProfileGroupId of(int id) { + return new PiActionProfileGroupId(id); } /* - In P4Runtime, groups can be referenced directly as table actions (i.e. without invoking the selector). - In future we should consider having a more appropriate wrapper class for group IDs, instead of implementing - the PiTableAction interface. + In P4Runtime, groups can be referenced directly as table actions (i.e. + without invoking the selector). In future we should consider having a more + appropriate wrapper class for group IDs, instead of implementing the + PiTableAction interface. */ @Override public Type type() { - return Type.ACTION_GROUP_ID; + return Type.ACTION_PROFILE_GROUP_ID; } } diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupMember.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileMember.java similarity index 76% rename from core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupMember.java rename to core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileMember.java index 690d1186d2..92c35627cf 100644 --- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupMember.java +++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileMember.java @@ -24,24 +24,25 @@ import org.onosproject.net.pi.model.PiActionProfileId; import static com.google.common.base.Preconditions.checkNotNull; /** - * Instance of a member of an action group in a protocol-independent pipeline. + * Instance of a member of an action profile in a protocol-independent pipeline. */ @Beta -public final class PiActionGroupMember implements PiEntity { +public final class PiActionProfileMember implements PiEntity { private final PiActionProfileId actionProfileId; - private final PiActionGroupMemberId id; + private final PiActionProfileMemberId memberId; private final PiAction action; // FIXME: in P4Runtime weight is an attribute of the member reference in a // group. Either remove it from this class or define the containing group // ID. private final int weight; - private PiActionGroupMember( - PiActionProfileId actionProfileId, PiActionGroupMemberId id, - PiAction action, int weight) { + private PiActionProfileMember(PiActionProfileId actionProfileId, + PiActionProfileMemberId memberId, + PiAction action, + int weight) { this.actionProfileId = actionProfileId; - this.id = id; + this.memberId = memberId; this.action = action; this.weight = weight; } @@ -51,8 +52,8 @@ public final class PiActionGroupMember implements PiEntity { * * @return member identifier */ - public PiActionGroupMemberId id() { - return id; + public PiActionProfileMemberId id() { + return memberId; } /** @@ -84,7 +85,7 @@ public final class PiActionGroupMember implements PiEntity { @Override public PiEntityType piEntityType() { - return PiEntityType.GROUP_MEMBER; + return PiEntityType.ACTION_PROFILE_MEMBER; } @Override @@ -92,33 +93,33 @@ public final class PiActionGroupMember implements PiEntity { if (this == o) { return true; } - if (!(o instanceof PiActionGroupMember)) { + if (!(o instanceof PiActionProfileMember)) { return false; } - PiActionGroupMember that = (PiActionGroupMember) o; + PiActionProfileMember that = (PiActionProfileMember) o; return weight == that.weight && Objects.equal(actionProfileId, that.actionProfileId) && - Objects.equal(id, that.id) && + Objects.equal(memberId, that.memberId) && Objects.equal(action, that.action); } @Override public int hashCode() { - return Objects.hashCode(actionProfileId, id, action, weight); + return Objects.hashCode(actionProfileId, memberId, action, weight); } @Override public String toString() { return MoreObjects.toStringHelper(this) .add("actionProfile", actionProfileId) - .add("id", id) + .add("id", memberId) .add("action", action) .add("weight", weight) .toString(); } /** - * Returns a new builder of action group members. + * Returns a new builder of action profile members. * * @return member builder */ @@ -127,12 +128,12 @@ public final class PiActionGroupMember implements PiEntity { } /** - * Builder of action group members. + * Builder of action profile members. */ public static final class Builder { private PiActionProfileId actionProfileId; - private PiActionGroupMemberId id; + private PiActionProfileMemberId id; private PiAction action; private int weight; @@ -157,7 +158,7 @@ public final class PiActionGroupMember implements PiEntity { * @param id member identifier * @return this */ - public Builder withId(PiActionGroupMemberId id) { + public Builder withId(PiActionProfileMemberId id) { this.id = id; return this; } @@ -187,15 +188,15 @@ public final class PiActionGroupMember implements PiEntity { } /** - * Creates a new action group member. + * Creates a new action profile member. * - * @return action group member + * @return action profile member */ - public PiActionGroupMember build() { + public PiActionProfileMember build() { checkNotNull(actionProfileId); checkNotNull(id); checkNotNull(action); - return new PiActionGroupMember(actionProfileId, id, action, weight); + return new PiActionProfileMember(actionProfileId, id, action, weight); } } } diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupMemberHandle.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileMemberHandle.java similarity index 81% rename from core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupMemberHandle.java rename to core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileMemberHandle.java index 9ef8a319c2..8771650607 100644 --- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroupMemberHandle.java +++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileMemberHandle.java @@ -27,14 +27,14 @@ import static com.google.common.base.Preconditions.checkNotNull; * Global identifier of a PI action profile group member, uniquely defined by a * device ID, action profile ID, and member ID. */ -public final class PiActionGroupMemberHandle extends PiHandle { +public final class PiActionProfileMemberHandle extends PiHandle { - private final PiActionGroupMemberId memberId; + private final PiActionProfileMemberId memberId; private final PiActionProfileId actionProfileId; - private PiActionGroupMemberHandle(DeviceId deviceId, + private PiActionProfileMemberHandle(DeviceId deviceId, PiActionProfileId actionProfileId, - PiActionGroupMemberId memberId) { + PiActionProfileMemberId memberId) { super(deviceId); this.actionProfileId = actionProfileId; this.memberId = memberId; @@ -49,11 +49,11 @@ public final class PiActionGroupMemberHandle extends PiHandle implements PiTableAction { +public final class PiActionProfileMemberId extends Identifier + implements PiTableAction { - private PiActionGroupMemberId(int id) { + private PiActionProfileMemberId(int id) { super(id); } /** - * Returns an action group identifier for the given integer value. + * Returns a member identifier for the given integer value. * * @param id identifier - * @return action group + * @return action profile group */ - public static PiActionGroupMemberId of(int id) { - return new PiActionGroupMemberId(id); + public static PiActionProfileMemberId of(int id) { + return new PiActionProfileMemberId(id); } /* - In P4Runtime, group members can be referenced directly as table actions. - In future we should consider having a more appropriate wrapper class for group member IDs, instead of implementing - the PiTableAction interface. + In P4Runtime, action profile members can be referenced directly as table + actions. In future we should consider having a more appropriate wrapper + class for group member IDs, instead of implementing the PiTableAction + interface. */ @Override public Type type() { - return Type.GROUP_MEMBER_ID; + return Type.ACTION_PROFILE_MEMBER_ID; } } diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiEntityType.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiEntityType.java index 0569f99986..4c318302eb 100644 --- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiEntityType.java +++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiEntityType.java @@ -31,12 +31,12 @@ public enum PiEntityType { /** * Action profile group. */ - GROUP, + ACTION_PROFILE_GROUP, /** - * Action profile group member. + * Action profile member. */ - GROUP_MEMBER, + ACTION_PROFILE_MEMBER, /** * Meter config. diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTableAction.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTableAction.java index 7d25e1aa03..284dde608b 100644 --- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTableAction.java +++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTableAction.java @@ -19,8 +19,8 @@ package org.onosproject.net.pi.runtime; import com.google.common.annotations.Beta; /** - * Instance of an action that can be executed as a consequence of a match in a match+action table of a - * protocol-independent pipeline. + * Instance of an action that can be executed as a consequence of a match in a + * match+action table of a protocol-independent pipeline. */ @Beta public interface PiTableAction { @@ -35,14 +35,15 @@ public interface PiTableAction { ACTION, /** - * Executes the action group specified by the given identifier. + * Executes the action profile group specified by the given identifier. */ - ACTION_GROUP_ID, + ACTION_PROFILE_GROUP_ID, /** - * Executes the action member group specified by the given identifier. + * Executes the action profile member specified by the given + * identifier. */ - GROUP_MEMBER_ID + ACTION_PROFILE_MEMBER_ID } /** diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTableEntry.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTableEntry.java index ac73bbef22..b25ada5033 100644 --- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTableEntry.java +++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiTableEntry.java @@ -179,10 +179,10 @@ public final class PiTableEntry implements PiEntity { return "null"; } switch (tableAction.type()) { - case ACTION_GROUP_ID: - return "GROUP:" + ((PiActionGroupId) tableAction).id(); - case GROUP_MEMBER_ID: - return "GROUP_MEMBER:" + ((PiActionGroupMemberId) tableAction).id(); + case ACTION_PROFILE_GROUP_ID: + return "ACT_PROF_GROUP:" + ((PiActionProfileGroupId) tableAction).id(); + case ACTION_PROFILE_MEMBER_ID: + return "ACT_PROF_MEMBER:" + ((PiActionProfileMemberId) tableAction).id(); case ACTION: default: return tableAction.toString(); diff --git a/core/api/src/main/java/org/onosproject/net/pi/service/PiGroupTranslationStore.java b/core/api/src/main/java/org/onosproject/net/pi/service/PiGroupTranslationStore.java index 4fe526a35f..ed76c9e944 100644 --- a/core/api/src/main/java/org/onosproject/net/pi/service/PiGroupTranslationStore.java +++ b/core/api/src/main/java/org/onosproject/net/pi/service/PiGroupTranslationStore.java @@ -18,13 +18,13 @@ package org.onosproject.net.pi.service; import com.google.common.annotations.Beta; import org.onosproject.net.group.Group; -import org.onosproject.net.pi.runtime.PiActionGroup; +import org.onosproject.net.pi.runtime.PiActionProfileGroup; /** * A PI translation store that keeps track of which groups have been - * translated to which PI action groups. + * translated to which PI action profile groups. */ @Beta public interface PiGroupTranslationStore - extends PiTranslationStore { + extends PiTranslationStore { } diff --git a/core/api/src/main/java/org/onosproject/net/pi/service/PiGroupTranslator.java b/core/api/src/main/java/org/onosproject/net/pi/service/PiGroupTranslator.java index d5eb5af7c2..5d7b6b3ce3 100644 --- a/core/api/src/main/java/org/onosproject/net/pi/service/PiGroupTranslator.java +++ b/core/api/src/main/java/org/onosproject/net/pi/service/PiGroupTranslator.java @@ -18,12 +18,12 @@ package org.onosproject.net.pi.service; import com.google.common.annotations.Beta; import org.onosproject.net.group.Group; -import org.onosproject.net.pi.runtime.PiActionGroup; +import org.onosproject.net.pi.runtime.PiActionProfileGroup; /** - * A translator of groups to PI action groups. + * A translator of groups to PI action profile groups. */ @Beta public interface PiGroupTranslator - extends PiTranslator { + extends PiTranslator { } diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupIdTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionProfileGroupIdTest.java similarity index 73% rename from core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupIdTest.java rename to core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionProfileGroupIdTest.java index 4c18f18b1c..cffb9e996a 100644 --- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupIdTest.java +++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionProfileGroupIdTest.java @@ -19,28 +19,27 @@ package org.onosproject.net.pi.runtime; import com.google.common.testing.EqualsTester; import org.junit.Test; - import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; /** - * Unit tests for PiActionGroupId class. + * Unit tests for PiActionProfileGroupId class. */ -public class PiActionGroupIdTest { +public class PiActionProfileGroupIdTest { - final PiActionGroupId piActionGroupId1 = PiActionGroupId.of(10); - final PiActionGroupId sameAsPiActionGroupId1 = PiActionGroupId.of(10); - final PiActionGroupId piActionGroupId2 = PiActionGroupId.of(20); + final PiActionProfileGroupId piActionGroupId1 = PiActionProfileGroupId.of(10); + final PiActionProfileGroupId sameAsPiActionProfileGroupId1 = PiActionProfileGroupId.of(10); + final PiActionProfileGroupId piActionGroupId2 = PiActionProfileGroupId.of(20); /** - * Checks that the PiActionGroupId class is immutable. + * Checks that the PiActionProfileGroupId class is immutable. */ @Test public void testImmutability() { - assertThatClassIsImmutable(PiActionGroupId.class); + assertThatClassIsImmutable(PiActionProfileGroupId.class); } /** @@ -50,19 +49,19 @@ public class PiActionGroupIdTest { public void testEquals() { new EqualsTester() - .addEqualityGroup(piActionGroupId1, sameAsPiActionGroupId1) + .addEqualityGroup(piActionGroupId1, sameAsPiActionProfileGroupId1) .addEqualityGroup(piActionGroupId2) .testEquals(); } /** - * Checks the methods of PiActionGroupId. + * Checks the methods of PiActionProfileGroupId. */ @Test public void testMethods() { assertThat(piActionGroupId1, is(notNullValue())); - assertThat(piActionGroupId1.type(), is(PiTableAction.Type.ACTION_GROUP_ID)); + assertThat(piActionGroupId1.type(), is(PiTableAction.Type.ACTION_PROFILE_GROUP_ID)); assertThat(piActionGroupId1.id(), is(10)); } } diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionProfileGroupTest.java similarity index 68% rename from core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupTest.java rename to core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionProfileGroupTest.java index c3aca5a135..0fecc72a5b 100644 --- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupTest.java +++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionProfileGroupTest.java @@ -35,48 +35,48 @@ import static org.onosproject.net.pi.runtime.PiConstantsTest.DST_ADDR; import static org.onosproject.net.pi.runtime.PiConstantsTest.MOD_NW_DST; /** - * Unit tests for PiActionGroup class. + * Unit tests for PiActionProfileGroup class. */ -public class PiActionGroupTest { +public class PiActionProfileGroupTest { - private final PiActionGroupMemberId piActionGroupMemberId = PiActionGroupMemberId.of(10); + private final PiActionProfileMemberId piActionProfileMemberId = PiActionProfileMemberId.of(10); private final PiAction piAction = PiAction.builder().withId(PiActionId.of(MOD_NW_DST)) .withParameter(new PiActionParam(PiActionParamId.of(DST_ADDR), copyFrom(0x0a010101))) .build(); - private final PiActionGroupMember piActionGroupMember = PiActionGroupMember.builder() + private final PiActionProfileMember piActionProfileMember = PiActionProfileMember.builder() .forActionProfile(ACTION_PROF_ID) - .withId(piActionGroupMemberId) + .withId(piActionProfileMemberId) .withAction(piAction) .withWeight(10) .build(); - private PiActionGroupId piActionGroupId = PiActionGroupId.of(10); - private PiActionGroup piActionGroup1 = PiActionGroup.builder() - .addMember(piActionGroupMember) + private PiActionProfileGroupId piActionGroupId = PiActionProfileGroupId.of(10); + private PiActionProfileGroup piActionGroup1 = PiActionProfileGroup.builder() + .addMember(piActionProfileMember) .withId(piActionGroupId) .withActionProfileId(ACTION_PROF_ID) .build(); - private PiActionGroup sameAsPiActionGroup1 = PiActionGroup.builder() - .addMember(piActionGroupMember) + private PiActionProfileGroup sameAsPiActionProfileGroup1 = PiActionProfileGroup.builder() + .addMember(piActionProfileMember) .withId(piActionGroupId) .withActionProfileId(ACTION_PROF_ID) .build(); - private PiActionGroupId piActionGroupId2 = PiActionGroupId.of(20); - private PiActionGroup piActionGroup2 = PiActionGroup.builder() - .addMember(piActionGroupMember) + private PiActionProfileGroupId piActionGroupId2 = PiActionProfileGroupId.of(20); + private PiActionProfileGroup piActionGroup2 = PiActionProfileGroup.builder() + .addMember(piActionProfileMember) .withId(piActionGroupId2) .withActionProfileId(ACTION_PROF_ID) .build(); /** - * Checks that the PiActionGroup class is immutable. + * Checks that the PiActionProfileGroup class is immutable. */ @Test public void testImmutability() { - assertThatClassIsImmutable(PiActionGroup.class); + assertThatClassIsImmutable(PiActionProfileGroup.class); } /** @@ -86,23 +86,23 @@ public class PiActionGroupTest { public void testEquals() { new EqualsTester() - .addEqualityGroup(piActionGroup1, sameAsPiActionGroup1) + .addEqualityGroup(piActionGroup1, sameAsPiActionProfileGroup1) .addEqualityGroup(piActionGroup2) .testEquals(); } /** - * Checks the methods of PiActionGroup. + * Checks the methods of PiActionProfileGroup. */ @Test public void testMethods() { - Collection piActionGroupMembers = Lists.newArrayList(); + Collection piActionProfileMembers = Lists.newArrayList(); - piActionGroupMembers.add(piActionGroupMember); + piActionProfileMembers.add(piActionProfileMember); assertThat(piActionGroup1, is(notNullValue())); assertThat(piActionGroup1.id(), is(piActionGroupId)); assertThat("Incorrect members value", - CollectionUtils.isEqualCollection(piActionGroup1.members(), piActionGroupMembers)); + CollectionUtils.isEqualCollection(piActionGroup1.members(), piActionProfileMembers)); } } diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupMemberIdTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionProfileMemberIdTest.java similarity index 57% rename from core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupMemberIdTest.java rename to core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionProfileMemberIdTest.java index 008a74e45a..430ce9e181 100644 --- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupMemberIdTest.java +++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionProfileMemberIdTest.java @@ -25,21 +25,21 @@ import static org.hamcrest.Matchers.notNullValue; import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; /** - * Unit tests for PiActionGroupMemberId class. + * Unit tests for PiActionProfileMemberId class. */ -public class PiActionGroupMemberIdTest { +public class PiActionProfileMemberIdTest { - final PiActionGroupMemberId piActionGroupMemberId1 = PiActionGroupMemberId.of(10); - final PiActionGroupMemberId sameAsPiActionGroupMemberId1 = PiActionGroupMemberId.of(10); - final PiActionGroupMemberId piActionGroupMemberId2 = PiActionGroupMemberId.of(20); + final PiActionProfileMemberId piActionProfileMemberId1 = PiActionProfileMemberId.of(10); + final PiActionProfileMemberId sameAsPiActionProfileMemberId1 = PiActionProfileMemberId.of(10); + final PiActionProfileMemberId piActionProfileMemberId2 = PiActionProfileMemberId.of(20); /** - * Checks that the PiActionGroupMemberId class is immutable. + * Checks that the PiActionProfileMemberId class is immutable. */ @Test public void testImmutability() { - assertThatClassIsImmutable(PiActionGroupMemberId.class); + assertThatClassIsImmutable(PiActionProfileMemberId.class); } /** @@ -49,19 +49,19 @@ public class PiActionGroupMemberIdTest { public void testEquals() { new EqualsTester() - .addEqualityGroup(piActionGroupMemberId1, sameAsPiActionGroupMemberId1) - .addEqualityGroup(piActionGroupMemberId2) + .addEqualityGroup(piActionProfileMemberId1, sameAsPiActionProfileMemberId1) + .addEqualityGroup(piActionProfileMemberId2) .testEquals(); } /** - * Checks the methods of PiActionGroupMemberId. + * Checks the methods of PiActionProfileMemberId. */ @Test public void testMethods() { - assertThat(piActionGroupMemberId1, is(notNullValue())); - assertThat(piActionGroupMemberId1.type(), is(PiTableAction.Type.GROUP_MEMBER_ID)); - assertThat(piActionGroupMemberId1.id(), is(10)); + assertThat(piActionProfileMemberId1, is(notNullValue())); + assertThat(piActionProfileMemberId1.type(), is(PiTableAction.Type.ACTION_PROFILE_MEMBER_ID)); + assertThat(piActionProfileMemberId1.id(), is(10)); } } diff --git a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupMemberTest.java b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionProfileMemberTest.java similarity index 65% rename from core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupMemberTest.java rename to core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionProfileMemberTest.java index e84d48f662..317f3220f4 100644 --- a/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionGroupMemberTest.java +++ b/core/api/src/test/java/org/onosproject/net/pi/runtime/PiActionProfileMemberTest.java @@ -31,49 +31,49 @@ import static org.onosproject.net.pi.runtime.PiConstantsTest.DST_ADDR; import static org.onosproject.net.pi.runtime.PiConstantsTest.MOD_NW_DST; /** - * Unit tests for PiActionGroupMember class. + * Unit tests for PiActionProfileMember class. */ -public class PiActionGroupMemberTest { +public class PiActionProfileMemberTest { private final PiActionProfileId actionProfileId1 = PiActionProfileId.of("foo"); private final PiActionProfileId actionProfileId2 = PiActionProfileId.of("bar"); - private final PiActionGroupMemberId piActionGroupMemberId = PiActionGroupMemberId.of(10); + private final PiActionProfileMemberId piActionProfileMemberId = PiActionProfileMemberId.of(10); private final PiAction piAction = PiAction.builder().withId(PiActionId.of(MOD_NW_DST)) .withParameter(new PiActionParam(PiActionParamId.of(DST_ADDR), copyFrom(0x0a010101))) .build(); - private final PiActionGroupMember piActionGroupMember1 = PiActionGroupMember.builder() + private final PiActionProfileMember piActionProfileMember1 = PiActionProfileMember.builder() .forActionProfile(actionProfileId1) - .withId(piActionGroupMemberId) + .withId(piActionProfileMemberId) .withAction(piAction) .withWeight(10) .build(); - private final PiActionGroupMember sameAsPiActionGroupMember1 = PiActionGroupMember.builder() + private final PiActionProfileMember sameAsPiActionProfileMember1 = PiActionProfileMember.builder() .forActionProfile(actionProfileId1) - .withId(piActionGroupMemberId) + .withId(piActionProfileMemberId) .withAction(piAction) .withWeight(10) .build(); - private final PiActionGroupMember piActionGroupMember2 = PiActionGroupMember.builder() + private final PiActionProfileMember piActionProfileMember2 = PiActionProfileMember.builder() .forActionProfile(actionProfileId1) - .withId(piActionGroupMemberId) + .withId(piActionProfileMemberId) .withAction(piAction) .withWeight(20) .build(); - private final PiActionGroupMember piActionGroupMember1ForOtherProfile = PiActionGroupMember.builder() + private final PiActionProfileMember piActionGroupMember1ForOtherProfile = PiActionProfileMember.builder() .forActionProfile(actionProfileId2) - .withId(piActionGroupMemberId) + .withId(piActionProfileMemberId) .withAction(piAction) .withWeight(10) .build(); /** - * Checks that the PiActionGroupMember class is immutable. + * Checks that the PiActionProfileMember class is immutable. */ @Test public void testImmutability() { - assertThatClassIsImmutable(PiActionGroupMember.class); + assertThatClassIsImmutable(PiActionProfileMember.class); } /** @@ -83,21 +83,21 @@ public class PiActionGroupMemberTest { public void testEquals() { new EqualsTester() - .addEqualityGroup(piActionGroupMember1, sameAsPiActionGroupMember1) - .addEqualityGroup(piActionGroupMember2) + .addEqualityGroup(piActionProfileMember1, sameAsPiActionProfileMember1) + .addEqualityGroup(piActionProfileMember2) .addEqualityGroup(piActionGroupMember1ForOtherProfile) .testEquals(); } /** - * Checks the methods of PiActionGroupMember. + * Checks the methods of PiActionProfileMember. */ @Test public void testMethods() { - assertThat(piActionGroupMember1, is(notNullValue())); - assertThat(piActionGroupMember1.weight(), is(10)); - assertThat(piActionGroupMember1.id(), is(piActionGroupMemberId)); - assertThat(piActionGroupMember1.action(), is(piAction)); + assertThat(piActionProfileMember1, is(notNullValue())); + assertThat(piActionProfileMember1.weight(), is(10)); + assertThat(piActionProfileMember1.id(), is(piActionProfileMemberId)); + assertThat(piActionProfileMember1.action(), is(piAction)); } } diff --git a/core/common/src/main/java/org/onosproject/codec/impl/DecodeInstructionCodecHelper.java b/core/common/src/main/java/org/onosproject/codec/impl/DecodeInstructionCodecHelper.java index 6753fae3f7..2730c38a6a 100644 --- a/core/common/src/main/java/org/onosproject/codec/impl/DecodeInstructionCodecHelper.java +++ b/core/common/src/main/java/org/onosproject/codec/impl/DecodeInstructionCodecHelper.java @@ -29,7 +29,6 @@ import org.onlab.packet.VlanId; import org.onlab.util.HexString; import org.onlab.util.ImmutableByteSequence; import org.onosproject.codec.CodecContext; -import org.onosproject.net.flow.ExtensionTreatmentCodec; import org.onosproject.core.GroupId; import org.onosproject.net.ChannelSpacing; import org.onosproject.net.Device; @@ -39,6 +38,7 @@ import org.onosproject.net.OchSignal; import org.onosproject.net.OduSignalId; import org.onosproject.net.PortNumber; import org.onosproject.net.device.DeviceService; +import org.onosproject.net.flow.ExtensionTreatmentCodec; import org.onosproject.net.flow.StatTriggerField; import org.onosproject.net.flow.StatTriggerFlag; import org.onosproject.net.flow.instructions.ExtensionTreatment; @@ -53,9 +53,9 @@ import org.onosproject.net.meter.MeterId; import org.onosproject.net.pi.model.PiActionId; import org.onosproject.net.pi.model.PiActionParamId; import org.onosproject.net.pi.runtime.PiAction; -import org.onosproject.net.pi.runtime.PiActionGroupId; -import org.onosproject.net.pi.runtime.PiActionGroupMemberId; import org.onosproject.net.pi.runtime.PiActionParam; +import org.onosproject.net.pi.runtime.PiActionProfileGroupId; +import org.onosproject.net.pi.runtime.PiActionProfileMemberId; import org.onosproject.net.pi.runtime.PiTableAction; import org.slf4j.Logger; @@ -306,18 +306,18 @@ public final class DecodeInstructionCodecHelper { } return Instructions.piTableAction(builder.withId(piActionId).build()); - } else if (subType.equals(PiTableAction.Type.ACTION_GROUP_ID.name())) { - PiActionGroupId piActionGroupId = PiActionGroupId.of(nullIsIllegal( - json.get(InstructionCodec.PI_ACTION_GROUP_ID), - InstructionCodec.PI_ACTION_GROUP_ID + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt()); + } else if (subType.equals(PiTableAction.Type.ACTION_PROFILE_GROUP_ID.name())) { + PiActionProfileGroupId piActionGroupId = PiActionProfileGroupId.of(nullIsIllegal( + json.get(InstructionCodec.PI_ACTION_PROFILE_GROUP_ID), + InstructionCodec.PI_ACTION_PROFILE_GROUP_ID + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt()); return Instructions.piTableAction(piActionGroupId); - } else if (subType.equals(PiTableAction.Type.GROUP_MEMBER_ID.name())) { - PiActionGroupMemberId piActionGroupMemberId = PiActionGroupMemberId.of(nullIsIllegal( - json.get(InstructionCodec.PI_ACTION_GROUP_MEMBER_ID), - InstructionCodec.PI_ACTION_GROUP_MEMBER_ID + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt()); + } else if (subType.equals(PiTableAction.Type.ACTION_PROFILE_MEMBER_ID.name())) { + PiActionProfileMemberId piActionProfileMemberId = PiActionProfileMemberId.of(nullIsIllegal( + json.get(InstructionCodec.PI_ACTION_PROFILE_MEMBER_ID), + InstructionCodec.PI_ACTION_PROFILE_MEMBER_ID + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt()); - return Instructions.piTableAction(piActionGroupMemberId); + return Instructions.piTableAction(piActionProfileMemberId); } throw new IllegalArgumentException("Protocol-independent Instruction subtype " + subType + " is not supported"); diff --git a/core/common/src/main/java/org/onosproject/codec/impl/EncodeInstructionCodecHelper.java b/core/common/src/main/java/org/onosproject/codec/impl/EncodeInstructionCodecHelper.java index 7e2f2df7ba..0f3c125e2a 100644 --- a/core/common/src/main/java/org/onosproject/codec/impl/EncodeInstructionCodecHelper.java +++ b/core/common/src/main/java/org/onosproject/codec/impl/EncodeInstructionCodecHelper.java @@ -20,12 +20,12 @@ import org.onlab.osgi.DefaultServiceDirectory; import org.onlab.osgi.ServiceDirectory; import org.onlab.util.HexString; import org.onosproject.codec.CodecContext; -import org.onosproject.net.flow.ExtensionTreatmentCodec; import org.onosproject.net.Device; import org.onosproject.net.DeviceId; import org.onosproject.net.OchSignal; import org.onosproject.net.OduSignalId; import org.onosproject.net.device.DeviceService; +import org.onosproject.net.flow.ExtensionTreatmentCodec; import org.onosproject.net.flow.instructions.Instruction; import org.onosproject.net.flow.instructions.Instructions; import org.onosproject.net.flow.instructions.L0ModificationInstruction; @@ -35,9 +35,9 @@ import org.onosproject.net.flow.instructions.L3ModificationInstruction; import org.onosproject.net.flow.instructions.L4ModificationInstruction; import org.onosproject.net.flow.instructions.PiInstruction; import org.onosproject.net.pi.runtime.PiAction; -import org.onosproject.net.pi.runtime.PiActionGroupId; -import org.onosproject.net.pi.runtime.PiActionGroupMemberId; import org.onosproject.net.pi.runtime.PiActionParam; +import org.onosproject.net.pi.runtime.PiActionProfileGroupId; +import org.onosproject.net.pi.runtime.PiActionProfileMemberId; import org.slf4j.Logger; import static org.onlab.util.Tools.toHexWithPrefix; @@ -264,13 +264,13 @@ public final class EncodeInstructionCodecHelper { } result.set(InstructionCodec.PI_ACTION_PARAMS, jsonActionParams); break; - case ACTION_GROUP_ID: - final PiActionGroupId piActionGroupId = (PiActionGroupId) piInstruction.action(); - result.put(InstructionCodec.PI_ACTION_GROUP_ID, piActionGroupId.id()); + case ACTION_PROFILE_GROUP_ID: + final PiActionProfileGroupId groupId = (PiActionProfileGroupId) piInstruction.action(); + result.put(InstructionCodec.PI_ACTION_PROFILE_GROUP_ID, groupId.id()); break; - case GROUP_MEMBER_ID: - final PiActionGroupMemberId piActionGroupMemberId = (PiActionGroupMemberId) piInstruction.action(); - result.put(InstructionCodec.PI_ACTION_GROUP_MEMBER_ID, piActionGroupMemberId.id()); + case ACTION_PROFILE_MEMBER_ID: + final PiActionProfileMemberId memberId = (PiActionProfileMemberId) piInstruction.action(); + result.put(InstructionCodec.PI_ACTION_PROFILE_MEMBER_ID, memberId.id()); break; default: throw new IllegalArgumentException("Cannot convert protocol-independent subtype of" + diff --git a/core/common/src/main/java/org/onosproject/codec/impl/InstructionCodec.java b/core/common/src/main/java/org/onosproject/codec/impl/InstructionCodec.java index 75192a0365..df7ff1c642 100644 --- a/core/common/src/main/java/org/onosproject/codec/impl/InstructionCodec.java +++ b/core/common/src/main/java/org/onosproject/codec/impl/InstructionCodec.java @@ -66,8 +66,8 @@ public final class InstructionCodec extends JsonCodec { static final String STAT_DURATION = "duration"; static final String PI_ACTION_ID = "actionId"; - static final String PI_ACTION_GROUP_ID = "groupId"; - static final String PI_ACTION_GROUP_MEMBER_ID = "memberId"; + static final String PI_ACTION_PROFILE_GROUP_ID = "groupId"; + static final String PI_ACTION_PROFILE_MEMBER_ID = "memberId"; static final String PI_ACTION_PARAMS = "actionParams"; static final String MISSING_MEMBER_MESSAGE = diff --git a/core/common/src/test/java/org/onosproject/codec/impl/InstructionCodecTest.java b/core/common/src/test/java/org/onosproject/codec/impl/InstructionCodecTest.java index 832a420c2f..1647c8ee3f 100644 --- a/core/common/src/test/java/org/onosproject/codec/impl/InstructionCodecTest.java +++ b/core/common/src/test/java/org/onosproject/codec/impl/InstructionCodecTest.java @@ -44,9 +44,9 @@ import org.onosproject.net.flow.instructions.PiInstruction; import org.onosproject.net.pi.model.PiActionId; import org.onosproject.net.pi.model.PiActionParamId; import org.onosproject.net.pi.runtime.PiAction; -import org.onosproject.net.pi.runtime.PiActionGroupId; -import org.onosproject.net.pi.runtime.PiActionGroupMemberId; import org.onosproject.net.pi.runtime.PiActionParam; +import org.onosproject.net.pi.runtime.PiActionProfileGroupId; +import org.onosproject.net.pi.runtime.PiActionProfileMemberId; import org.onosproject.net.pi.runtime.PiTableAction; import java.io.IOException; @@ -264,17 +264,17 @@ public class InstructionCodecTest { instructionCodec.encode(actionInstruction, context); assertThat(actionInstructionJson, matchesInstruction(actionInstruction)); - PiTableAction actionGroupId = PiActionGroupId.of(10); + PiTableAction actionGroupId = PiActionProfileGroupId.of(10); final PiInstruction actionGroupIdInstruction = Instructions.piTableAction(actionGroupId); final ObjectNode actionGroupIdInstructionJson = instructionCodec.encode(actionGroupIdInstruction, context); assertThat(actionGroupIdInstructionJson, matchesInstruction(actionGroupIdInstruction)); - PiTableAction actionGroupMemberId = PiActionGroupMemberId.of(10); - final PiInstruction actionGroupMemberIdInstruction = Instructions.piTableAction(actionGroupMemberId); - final ObjectNode actionGroupMemberIdInstructionJson = - instructionCodec.encode(actionGroupMemberIdInstruction, context); - assertThat(actionGroupMemberIdInstructionJson, matchesInstruction(actionGroupMemberIdInstruction)); + PiTableAction actionProfileMemberId = PiActionProfileMemberId.of(10); + final PiInstruction actionProfileMemberIdInstruction = Instructions.piTableAction(actionProfileMemberId); + final ObjectNode actionProfileMemberIdInstructionJson = + instructionCodec.encode(actionProfileMemberIdInstruction, context); + assertThat(actionProfileMemberIdInstructionJson, matchesInstruction(actionProfileMemberIdInstruction)); } /** @@ -294,17 +294,17 @@ public class InstructionCodecTest { Assert.assertThat(actionParam.id().id(), is("port")); Assert.assertThat(actionParam.value(), is(copyFrom((byte) 0x1))); - Instruction actionGroupIdInstruction = getInstruction("PiActionGroupIdInstruction.json"); + Instruction actionGroupIdInstruction = getInstruction("PiActionProfileGroupIdInstruction.json"); Assert.assertThat(actionInstruction.type(), is(Instruction.Type.PROTOCOL_INDEPENDENT)); PiTableAction actionGroupId = ((PiInstruction) actionGroupIdInstruction).action(); - Assert.assertThat(actionGroupId.type(), is(PiTableAction.Type.ACTION_GROUP_ID)); - Assert.assertThat(((PiActionGroupId) actionGroupId).id(), is(100)); + Assert.assertThat(actionGroupId.type(), is(PiTableAction.Type.ACTION_PROFILE_GROUP_ID)); + Assert.assertThat(((PiActionProfileGroupId) actionGroupId).id(), is(100)); - Instruction actionMemberIdInstruction = getInstruction("PiActionMemberIdInstruction.json"); + Instruction actionMemberIdInstruction = getInstruction("PiActionProfileMemberIdInstruction.json"); Assert.assertThat(actionInstruction.type(), is(Instruction.Type.PROTOCOL_INDEPENDENT)); PiTableAction actionMemberId = ((PiInstruction) actionMemberIdInstruction).action(); - Assert.assertThat(actionMemberId.type(), is(PiTableAction.Type.GROUP_MEMBER_ID)); - Assert.assertThat(((PiActionGroupMemberId) actionMemberId).id(), is(100)); + Assert.assertThat(actionMemberId.type(), is(PiTableAction.Type.ACTION_PROFILE_MEMBER_ID)); + Assert.assertThat(((PiActionProfileMemberId) actionMemberId).id(), is(100)); } /** diff --git a/core/common/src/test/java/org/onosproject/codec/impl/InstructionJsonMatcher.java b/core/common/src/test/java/org/onosproject/codec/impl/InstructionJsonMatcher.java index 9911a4f982..66f8473d23 100644 --- a/core/common/src/test/java/org/onosproject/codec/impl/InstructionJsonMatcher.java +++ b/core/common/src/test/java/org/onosproject/codec/impl/InstructionJsonMatcher.java @@ -37,9 +37,9 @@ import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInst import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction; import org.onosproject.net.flow.instructions.PiInstruction; import org.onosproject.net.pi.runtime.PiAction; -import org.onosproject.net.pi.runtime.PiActionGroupId; -import org.onosproject.net.pi.runtime.PiActionGroupMemberId; import org.onosproject.net.pi.runtime.PiActionParam; +import org.onosproject.net.pi.runtime.PiActionProfileGroupId; +import org.onosproject.net.pi.runtime.PiActionProfileMemberId; import java.util.Collection; import java.util.Objects; @@ -554,19 +554,19 @@ public final class InstructionJsonMatcher extends TypeSafeDiagnosingMatcher + extends AbstractPiTranslatorImpl implements PiGroupTranslator { private InternalGroupTranslator(PiGroupTranslationStore store) { @@ -147,7 +147,7 @@ public class PiTranslationServiceImpl implements PiTranslationService { } @Override - public PiActionGroup translate(Group original, PiPipeconf pipeconf) + public PiActionProfileGroup translate(Group original, PiPipeconf pipeconf) throws PiTranslationException { return PiGroupTranslatorImpl .translate(original, pipeconf, getDevice(original.deviceId())); diff --git a/core/net/src/test/java/org/onosproject/net/pi/impl/PiGroupTranslatorImplTest.java b/core/net/src/test/java/org/onosproject/net/pi/impl/PiGroupTranslatorImplTest.java index 6c86604410..f5b8384e28 100644 --- a/core/net/src/test/java/org/onosproject/net/pi/impl/PiGroupTranslatorImplTest.java +++ b/core/net/src/test/java/org/onosproject/net/pi/impl/PiGroupTranslatorImplTest.java @@ -38,10 +38,10 @@ import org.onosproject.net.group.GroupBuckets; import org.onosproject.net.group.GroupDescription; import org.onosproject.net.pi.model.PiPipeconf; import org.onosproject.net.pi.runtime.PiAction; -import org.onosproject.net.pi.runtime.PiActionGroup; -import org.onosproject.net.pi.runtime.PiActionGroupMember; -import org.onosproject.net.pi.runtime.PiActionGroupMemberId; import org.onosproject.net.pi.runtime.PiActionParam; +import org.onosproject.net.pi.runtime.PiActionProfileGroup; +import org.onosproject.net.pi.runtime.PiActionProfileMember; +import org.onosproject.net.pi.runtime.PiActionProfileMemberId; import org.onosproject.net.pi.runtime.PiGroupKey; import org.onosproject.net.pi.runtime.PiTableAction; import org.onosproject.pipelines.basic.PipeconfLoader; @@ -80,7 +80,7 @@ public class PiGroupTranslatorImplTest { private static final Group SELECT_GROUP = new DefaultGroup(GROUP_ID, SELECT_GROUP_DESC); private static final int DEFAULT_MEMBER_WEIGHT = 1; private static final int BASE_MEM_ID = 65535; - private Collection expectedMembers; + private Collection expectedMembers; private PiPipeconf pipeconf; @@ -102,16 +102,16 @@ public class PiGroupTranslatorImplTest { return DefaultGroupBucket.createSelectGroupBucket(treatment); } - private static PiActionGroupMember outputMember(int portNum) + private static PiActionProfileMember outputMember(int portNum) throws ImmutableByteSequence.ByteSequenceTrimException { PiActionParam param = new PiActionParam(ACT_PRM_PORT_ID, copyFrom(portNum).fit(PORT_BITWIDTH)); PiAction piAction = PiAction.builder() .withId(ACT_SET_EGRESS_PORT_WCMP_ID) .withParameter(param).build(); - return PiActionGroupMember.builder() + return PiActionProfileMember.builder() .forActionProfile(ACT_PRF_WCMP_SELECTOR_ID) .withAction(piAction) - .withId(PiActionGroupMemberId.of(BASE_MEM_ID + portNum)) + .withId(PiActionProfileMemberId.of(BASE_MEM_ID + portNum)) .withWeight(DEFAULT_MEMBER_WEIGHT) .build(); } @@ -122,8 +122,8 @@ public class PiGroupTranslatorImplTest { @Test public void testTranslateGroups() throws Exception { - PiActionGroup piGroup1 = PiGroupTranslatorImpl.translate(SELECT_GROUP, pipeconf, null); - PiActionGroup piGroup2 = PiGroupTranslatorImpl.translate(SELECT_GROUP, pipeconf, null); + PiActionProfileGroup piGroup1 = PiGroupTranslatorImpl.translate(SELECT_GROUP, pipeconf, null); + PiActionProfileGroup piGroup2 = PiGroupTranslatorImpl.translate(SELECT_GROUP, pipeconf, null); new EqualsTester() .addEqualityGroup(piGroup1, piGroup2) @@ -135,7 +135,7 @@ public class PiGroupTranslatorImplTest { piGroup1.actionProfileId(), is(equalTo(ACT_PRF_WCMP_SELECTOR_ID))); // members installed - Collection members = piGroup1.members(); + Collection members = piGroup1.members(); assertThat("The number of group members must be equal", piGroup1.members().size(), is(expectedMembers.size())); assertThat("Group members must be equal", diff --git a/core/store/dist/src/main/java/org/onosproject/store/pi/impl/DistributedPiGroupTranslationStore.java b/core/store/dist/src/main/java/org/onosproject/store/pi/impl/DistributedPiGroupTranslationStore.java index fa62ef1cea..05ef4af60e 100644 --- a/core/store/dist/src/main/java/org/onosproject/store/pi/impl/DistributedPiGroupTranslationStore.java +++ b/core/store/dist/src/main/java/org/onosproject/store/pi/impl/DistributedPiGroupTranslationStore.java @@ -19,7 +19,7 @@ package org.onosproject.store.pi.impl; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Service; import org.onosproject.net.group.Group; -import org.onosproject.net.pi.runtime.PiActionGroup; +import org.onosproject.net.pi.runtime.PiActionProfileGroup; import org.onosproject.net.pi.service.PiGroupTranslationStore; /** @@ -28,7 +28,7 @@ import org.onosproject.net.pi.service.PiGroupTranslationStore; @Component(immediate = true) @Service public class DistributedPiGroupTranslationStore - extends AbstractDistributedPiTranslationStore + extends AbstractDistributedPiTranslationStore implements PiGroupTranslationStore { private static final String MAP_SIMPLE_NAME = "group"; diff --git a/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java b/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java index faaafac481..cf812167ed 100644 --- a/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java +++ b/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java @@ -226,13 +226,13 @@ import org.onosproject.net.pi.model.PiPipeconfId; import org.onosproject.net.pi.model.PiTableId; import org.onosproject.net.pi.model.PiTableType; import org.onosproject.net.pi.runtime.PiAction; -import org.onosproject.net.pi.runtime.PiActionGroup; -import org.onosproject.net.pi.runtime.PiActionGroupHandle; -import org.onosproject.net.pi.runtime.PiActionGroupId; -import org.onosproject.net.pi.runtime.PiActionGroupMember; -import org.onosproject.net.pi.runtime.PiActionGroupMemberHandle; -import org.onosproject.net.pi.runtime.PiActionGroupMemberId; import org.onosproject.net.pi.runtime.PiActionParam; +import org.onosproject.net.pi.runtime.PiActionProfileGroup; +import org.onosproject.net.pi.runtime.PiActionProfileGroupHandle; +import org.onosproject.net.pi.runtime.PiActionProfileGroupId; +import org.onosproject.net.pi.runtime.PiActionProfileMember; +import org.onosproject.net.pi.runtime.PiActionProfileMemberHandle; +import org.onosproject.net.pi.runtime.PiActionProfileMemberId; import org.onosproject.net.pi.runtime.PiControlMetadata; import org.onosproject.net.pi.runtime.PiCounterCell; import org.onosproject.net.pi.runtime.PiCounterCellData; @@ -692,12 +692,12 @@ public final class KryoNamespaces { PiTableType.class, // PI Runtime PiAction.class, - PiActionGroup.class, - PiActionGroupHandle.class, - PiActionGroupId.class, - PiActionGroupMember.class, - PiActionGroupMemberHandle.class, - PiActionGroupMemberId.class, + PiActionProfileGroup.class, + PiActionProfileGroupHandle.class, + PiActionProfileGroupId.class, + PiActionProfileMember.class, + PiActionProfileMemberHandle.class, + PiActionProfileMemberId.class, PiActionParam.class, PiControlMetadata.class, PiCounterCell.class, diff --git a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeActionGroupProgrammable.java b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeActionGroupProgrammable.java index 070207f431..4a48897cc5 100644 --- a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeActionGroupProgrammable.java +++ b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeActionGroupProgrammable.java @@ -23,8 +23,8 @@ import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.common.util.concurrent.Striped; import org.onlab.util.SharedExecutors; +import org.onosproject.drivers.p4runtime.mirror.P4RuntimeActionProfileGroupMirror; import org.onosproject.drivers.p4runtime.mirror.P4RuntimeActionProfileMemberMirror; -import org.onosproject.drivers.p4runtime.mirror.P4RuntimeGroupMirror; import org.onosproject.drivers.p4runtime.mirror.TimedEntry; import org.onosproject.net.DefaultAnnotations; import org.onosproject.net.DeviceId; @@ -40,11 +40,11 @@ import org.onosproject.net.pi.model.PiActionId; import org.onosproject.net.pi.model.PiActionProfileId; import org.onosproject.net.pi.model.PiActionProfileModel; import org.onosproject.net.pi.runtime.PiAction; -import org.onosproject.net.pi.runtime.PiActionGroup; -import org.onosproject.net.pi.runtime.PiActionGroupHandle; -import org.onosproject.net.pi.runtime.PiActionGroupMember; -import org.onosproject.net.pi.runtime.PiActionGroupMemberHandle; -import org.onosproject.net.pi.runtime.PiActionGroupMemberId; +import org.onosproject.net.pi.runtime.PiActionProfileGroup; +import org.onosproject.net.pi.runtime.PiActionProfileGroupHandle; +import org.onosproject.net.pi.runtime.PiActionProfileMember; +import org.onosproject.net.pi.runtime.PiActionProfileMemberHandle; +import org.onosproject.net.pi.runtime.PiActionProfileMemberId; import org.onosproject.net.pi.service.PiGroupTranslator; import org.onosproject.net.pi.service.PiTranslatedEntity; import org.onosproject.net.pi.service.PiTranslationException; @@ -80,7 +80,7 @@ public class P4RuntimeActionGroupProgrammable private static final String MAX_MEM_SIZE = "maxMemSize"; protected GroupStore groupStore; - private P4RuntimeGroupMirror groupMirror; + private P4RuntimeActionProfileGroupMirror groupMirror; private P4RuntimeActionProfileMemberMirror memberMirror; private PiGroupTranslator groupTranslator; @@ -93,7 +93,7 @@ public class P4RuntimeActionGroupProgrammable if (!super.setupBehaviour()) { return false; } - groupMirror = this.handler().get(P4RuntimeGroupMirror.class); + groupMirror = this.handler().get(P4RuntimeActionProfileGroupMirror.class); memberMirror = this.handler().get(P4RuntimeActionProfileMemberMirror.class); groupStore = handler().get(GroupStore.class); groupTranslator = translationService.groupTranslator(); @@ -140,14 +140,14 @@ public class P4RuntimeActionGroupProgrammable .stream() .map(PiActionProfileModel::id) .collect(Collectors.toList()); - final List groupsOnDevice = actionProfileIds.stream() + final List groupsOnDevice = actionProfileIds.stream() .flatMap(this::streamGroupsFromDevice) .collect(Collectors.toList()); - final Set membersOnDevice = actionProfileIds + final Set membersOnDevice = actionProfileIds .stream() .flatMap(actProfId -> getMembersFromDevice(actProfId) .stream() - .map(memberId -> PiActionGroupMemberHandle.of( + .map(memberId -> PiActionProfileMemberHandle.of( deviceId, actProfId, memberId))) .collect(Collectors.toSet()); @@ -160,10 +160,10 @@ public class P4RuntimeActionGroupProgrammable syncMemberMirror(membersOnDevice); final List result = Lists.newArrayList(); - final List inconsistentGroups = Lists.newArrayList(); - final List validGroups = Lists.newArrayList(); + final List inconsistentGroups = Lists.newArrayList(); + final List validGroups = Lists.newArrayList(); - for (PiActionGroup piGroup : groupsOnDevice) { + for (PiActionProfileGroup piGroup : groupsOnDevice) { final Group pdGroup = forgeGroupEntry(piGroup); if (pdGroup == null) { // Entry is on device but unknown to translation service or @@ -178,11 +178,11 @@ public class P4RuntimeActionGroupProgrammable // Trigger clean up of inconsistent groups and members. This will also // remove all members that are not used by any group, and update the // mirror accordingly. - final Set membersToKeep = validGroups.stream() + final Set membersToKeep = validGroups.stream() .flatMap(g -> g.members().stream()) - .map(m -> PiActionGroupMemberHandle.of(deviceId, m)) + .map(m -> PiActionProfileMemberHandle.of(deviceId, m)) .collect(Collectors.toSet()); - final Set inconsistentMembers = Sets.difference( + final Set inconsistentMembers = Sets.difference( membersOnDevice, membersToKeep); SharedExecutors.getSingleThreadExecutor().execute( () -> cleanUpInconsistentGroupsAndMembers( @@ -191,15 +191,15 @@ public class P4RuntimeActionGroupProgrammable return result; } - private void syncGroupMirror(Collection groups) { - Map handleMap = Maps.newHashMap(); - groups.forEach(g -> handleMap.put(PiActionGroupHandle.of(deviceId, g), g)); + private void syncGroupMirror(Collection groups) { + Map handleMap = Maps.newHashMap(); + groups.forEach(g -> handleMap.put(PiActionProfileGroupHandle.of(deviceId, g), g)); groupMirror.sync(deviceId, handleMap); } - private void syncMemberMirror(Collection memberHandles) { - Map handleMap = Maps.newHashMap(); - memberHandles.forEach(handle -> handleMap.put( + private void syncMemberMirror(Collection memberHandles) { + Map handleMap = Maps.newHashMap(); + memberHandles.forEach(handle -> handleMap.put( handle, dummyMember(handle.actionProfileId(), handle.memberId()))); memberMirror.sync(deviceId, handleMap); } @@ -212,8 +212,8 @@ public class P4RuntimeActionGroupProgrammable .collect(Collectors.toList()); } - private void cleanUpInconsistentGroupsAndMembers(Collection groupsToRemove, - Collection membersToRemove) { + private void cleanUpInconsistentGroupsAndMembers(Collection groupsToRemove, + Collection membersToRemove) { if (!groupsToRemove.isEmpty()) { log.warn("Found {} inconsistent action profile groups on {}, removing them...", groupsToRemove.size(), deviceId); @@ -227,33 +227,33 @@ public class P4RuntimeActionGroupProgrammable membersToRemove.size(), deviceId); // FIXME: implement client call to remove members from multiple // action profiles in one shot. - final ListMultimap + final ListMultimap membersByActProfId = ArrayListMultimap.create(); membersToRemove.forEach(m -> membersByActProfId.put( m.actionProfileId(), m.memberId())); membersByActProfId.keySet().forEach(actProfId -> { - List removedMembers = getFutureWithDeadline( + List removedMembers = getFutureWithDeadline( client.removeActionProfileMembers( actProfId, membersByActProfId.get(actProfId), pipeconf), "cleaning up action profile members", Collections.emptyList()); // Update member mirror. removedMembers.stream() - .map(id -> PiActionGroupMemberHandle.of(deviceId, actProfId, id)) + .map(id -> PiActionProfileMemberHandle.of(deviceId, actProfId, id)) .forEach(memberMirror::remove); }); } } - private Stream streamGroupsFromDevice(PiActionProfileId actProfId) { + private Stream streamGroupsFromDevice(PiActionProfileId actProfId) { // TODO: implement P4Runtime client call to read all groups with one call // Good if pipeline has multiple action profiles. - final Collection groups = getFutureWithDeadline( - client.dumpGroups(actProfId, pipeconf), + final Collection groups = getFutureWithDeadline( + client.dumpActionProfileGroups(actProfId, pipeconf), "dumping groups", Collections.emptyList()); return groups.stream(); } - private List getMembersFromDevice(PiActionProfileId actProfId) { + private List getMembersFromDevice(PiActionProfileId actProfId) { // TODO: implement P4Runtime client call to read all members with one call // Good if pipeline has multiple action profiles. return getFutureWithDeadline( @@ -261,11 +261,11 @@ public class P4RuntimeActionGroupProgrammable "dumping action profile ids", Collections.emptyList()); } - private Group forgeGroupEntry(PiActionGroup piGroup) { - final PiActionGroupHandle handle = PiActionGroupHandle.of(deviceId, piGroup); - final Optional> + private Group forgeGroupEntry(PiActionProfileGroup piGroup) { + final PiActionProfileGroupHandle handle = PiActionProfileGroupHandle.of(deviceId, piGroup); + final Optional> translatedEntity = groupTranslator.lookup(handle); - final TimedEntry timedEntry = groupMirror.get(handle); + final TimedEntry timedEntry = groupMirror.get(handle); // Is entry consistent with our state? if (!translatedEntity.isPresent()) { log.warn("Group handle not found in translation store: {}", handle); @@ -292,7 +292,7 @@ public class P4RuntimeActionGroupProgrammable } private void processGroupOperation(Group pdGroup, GroupOperation.Type opType) { - final PiActionGroup piGroup; + final PiActionProfileGroup piGroup; try { piGroup = groupTranslator.translate(pdGroup, pipeconf); } catch (PiTranslationException e) { @@ -305,10 +305,10 @@ public class P4RuntimeActionGroupProgrammable processGroup(piGroup, pdGroup, operation); } - private void processGroup(PiActionGroup groupToApply, + private void processGroup(PiActionProfileGroup groupToApply, Group pdGroup, Operation operation) { - final PiActionGroupHandle handle = PiActionGroupHandle.of(deviceId, groupToApply); + final PiActionProfileGroupHandle handle = PiActionProfileGroupHandle.of(deviceId, groupToApply); STRIPED_LOCKS.get(handle).lock(); try { switch (operation) { @@ -332,7 +332,7 @@ public class P4RuntimeActionGroupProgrammable } } - private boolean applyGroupWithMembersOrNothing(PiActionGroup group, PiActionGroupHandle handle) { + private boolean applyGroupWithMembersOrNothing(PiActionProfileGroup group, PiActionProfileGroupHandle handle) { // First apply members, then group, if fails, delete members. if (!applyAllMembersOrNothing(group.members())) { return false; @@ -344,7 +344,7 @@ public class P4RuntimeActionGroupProgrammable return true; } - private boolean applyGroup(PiActionGroup group, PiActionGroupHandle handle) { + private boolean applyGroup(PiActionProfileGroup group, PiActionProfileGroupHandle handle) { final int currentMemberSize = group.members().size(); if (groupMirror.get(handle) != null) { String maxMemSize = ""; @@ -352,7 +352,7 @@ public class P4RuntimeActionGroupProgrammable groupMirror.annotations(handle).value(MAX_MEM_SIZE) != null) { maxMemSize = groupMirror.annotations(handle).value(MAX_MEM_SIZE); } - if (maxMemSize == "" || currentMemberSize > Integer.parseInt(maxMemSize)) { + if (maxMemSize.equals("") || currentMemberSize > Integer.parseInt(maxMemSize)) { deleteGroup(group, handle); } } @@ -362,7 +362,7 @@ public class P4RuntimeActionGroupProgrammable int currentMaxMemberSize = opType == INSERT ? (currentMemberSize + GROUP_MEMBERS_BUFFER_SIZE) : 0; final boolean success = getFutureWithDeadline( - client.writeActionGroup(group, opType, pipeconf, currentMaxMemberSize), + client.writeActionProfileGroup(group, opType, pipeconf, currentMaxMemberSize), "performing action profile group " + opType, false); if (success) { groupMirror.put(handle, group); @@ -376,9 +376,9 @@ public class P4RuntimeActionGroupProgrammable return success; } - private boolean deleteGroup(PiActionGroup group, PiActionGroupHandle handle) { + private boolean deleteGroup(PiActionProfileGroup group, PiActionProfileGroupHandle handle) { final boolean success = getFutureWithDeadline( - client.writeActionGroup(group, DELETE, pipeconf, 0), + client.writeActionProfileGroup(group, DELETE, pipeconf, 0), "performing action profile group " + DELETE, false); if (success) { groupMirror.remove(handle); @@ -386,8 +386,8 @@ public class P4RuntimeActionGroupProgrammable return success; } - private boolean applyAllMembersOrNothing(Collection members) { - Collection appliedMembers = applyMembers(members); + private boolean applyAllMembersOrNothing(Collection members) { + Collection appliedMembers = applyMembers(members); if (appliedMembers.size() == members.size()) { return true; } else { @@ -396,22 +396,22 @@ public class P4RuntimeActionGroupProgrammable } } - private Collection applyMembers( - Collection members) { + private Collection applyMembers( + Collection members) { return members.stream() .filter(this::applyMember) .collect(Collectors.toList()); } - private boolean applyMember(PiActionGroupMember member) { + private boolean applyMember(PiActionProfileMember member) { // If exists, modify, otherwise insert - final PiActionGroupMemberHandle handle = PiActionGroupMemberHandle.of( + final PiActionProfileMemberHandle handle = PiActionProfileMemberHandle.of( deviceId, member); final P4RuntimeClient.WriteOperationType opType = memberMirror.get(handle) == null ? INSERT : MODIFY; final boolean success = getFutureWithDeadline( - client.writeActionGroupMembers(Collections.singletonList(member), - opType, pipeconf), + client.writeActionProfileMembers(Collections.singletonList(member), + opType, pipeconf), "performing action profile member " + opType, false); if (success) { memberMirror.put(handle, dummyMember(member.actionProfile(), member.id())); @@ -419,16 +419,16 @@ public class P4RuntimeActionGroupProgrammable return success; } - private void deleteMembers(Collection members) { + private void deleteMembers(Collection members) { members.forEach(this::deleteMember); } - private void deleteMember(PiActionGroupMember member) { - final PiActionGroupMemberHandle handle = PiActionGroupMemberHandle.of( + private void deleteMember(PiActionProfileMember member) { + final PiActionProfileMemberHandle handle = PiActionProfileMemberHandle.of( deviceId, member); final boolean success = getFutureWithDeadline( - client.writeActionGroupMembers(Collections.singletonList(member), - DELETE, pipeconf), + client.writeActionProfileMembers(Collections.singletonList(member), + DELETE, pipeconf), "performing action profile member " + DELETE, false); if (success) { memberMirror.remove(handle); @@ -436,15 +436,13 @@ public class P4RuntimeActionGroupProgrammable } // FIXME: this is nasty, we have to rely on a dummy member of the mirror - // because the PiActionGroupMember abstraction is broken, since it includes + // because the PiActionProfileMember abstraction is broken, since it includes // attributes that are not part of a P4Runtime member, e.g. weight. // We should remove weight from the class, and have client methods that - // return the full PiActionGroupMember, not just the IDs. Also the naming - // "ActionGroupMember" is wrong since it makes believe that members can - // exists only inside a group, which is not true. - private PiActionGroupMember dummyMember( - PiActionProfileId actionProfileId, PiActionGroupMemberId memberId) { - return PiActionGroupMember.builder() + // return the full PiActionProfileMember, not just the IDs. + private PiActionProfileMember dummyMember( + PiActionProfileId actionProfileId, PiActionProfileMemberId memberId) { + return PiActionProfileMember.builder() .forActionProfile(actionProfileId) .withId(memberId) .withAction(PiAction.builder() diff --git a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/DistributedP4RuntimeGroupMirror.java b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/DistributedP4RuntimeActionProfileGroupMirror.java similarity index 76% rename from drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/DistributedP4RuntimeGroupMirror.java rename to drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/DistributedP4RuntimeActionProfileGroupMirror.java index 4c963a6d04..13e37a9b60 100644 --- a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/DistributedP4RuntimeGroupMirror.java +++ b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/DistributedP4RuntimeActionProfileGroupMirror.java @@ -19,21 +19,21 @@ package org.onosproject.drivers.p4runtime.mirror; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Service; import org.onlab.util.KryoNamespace; -import org.onosproject.net.pi.runtime.PiActionGroup; -import org.onosproject.net.pi.runtime.PiActionGroupHandle; +import org.onosproject.net.pi.runtime.PiActionProfileGroup; +import org.onosproject.net.pi.runtime.PiActionProfileGroupHandle; import org.onosproject.store.serializers.KryoNamespaces; /** - * Distributed implementation of a P4Runtime group mirror. + * Distributed implementation of a P4Runtime action profile group mirror. */ @Component(immediate = true) @Service -public final class DistributedP4RuntimeGroupMirror +public final class DistributedP4RuntimeActionProfileGroupMirror extends AbstractDistributedP4RuntimeMirror - - implements P4RuntimeGroupMirror { + + implements P4RuntimeActionProfileGroupMirror { - private static final String DIST_MAP_NAME = "onos-p4runtime-group-mirror"; + private static final String DIST_MAP_NAME = "onos-p4runtime-act-prof-group-mirror"; @Override String mapName() { diff --git a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/DistributedP4RuntimeActionProfileMemberMirror.java b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/DistributedP4RuntimeActionProfileMemberMirror.java index 83edba465a..b2bc93c714 100644 --- a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/DistributedP4RuntimeActionProfileMemberMirror.java +++ b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/DistributedP4RuntimeActionProfileMemberMirror.java @@ -19,8 +19,8 @@ package org.onosproject.drivers.p4runtime.mirror; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Service; import org.onlab.util.KryoNamespace; -import org.onosproject.net.pi.runtime.PiActionGroupMember; -import org.onosproject.net.pi.runtime.PiActionGroupMemberHandle; +import org.onosproject.net.pi.runtime.PiActionProfileMember; +import org.onosproject.net.pi.runtime.PiActionProfileMemberHandle; import org.onosproject.store.serializers.KryoNamespaces; /** @@ -30,7 +30,7 @@ import org.onosproject.store.serializers.KryoNamespaces; @Service public class DistributedP4RuntimeActionProfileMemberMirror extends AbstractDistributedP4RuntimeMirror - + implements P4RuntimeActionProfileMemberMirror { private static final String DIST_MAP_NAME = "onos-p4runtime-act-prof-member-mirror"; diff --git a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/P4RuntimeGroupMirror.java b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/P4RuntimeActionProfileGroupMirror.java similarity index 67% rename from drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/P4RuntimeGroupMirror.java rename to drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/P4RuntimeActionProfileGroupMirror.java index f363e714ad..d5ce7ff45e 100644 --- a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/P4RuntimeGroupMirror.java +++ b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/P4RuntimeActionProfileGroupMirror.java @@ -16,12 +16,12 @@ package org.onosproject.drivers.p4runtime.mirror; -import org.onosproject.net.pi.runtime.PiActionGroup; -import org.onosproject.net.pi.runtime.PiActionGroupHandle; +import org.onosproject.net.pi.runtime.PiActionProfileGroup; +import org.onosproject.net.pi.runtime.PiActionProfileGroupHandle; /** - * Mirror of action groups installed on a P4Runtime device. + * Mirror of action profile groups installed on a P4Runtime device. */ -public interface P4RuntimeGroupMirror - extends P4RuntimeMirror { +public interface P4RuntimeActionProfileGroupMirror + extends P4RuntimeMirror { } diff --git a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/P4RuntimeActionProfileMemberMirror.java b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/P4RuntimeActionProfileMemberMirror.java index 8ab1fa09bf..045f283ec9 100644 --- a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/P4RuntimeActionProfileMemberMirror.java +++ b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/mirror/P4RuntimeActionProfileMemberMirror.java @@ -16,12 +16,12 @@ package org.onosproject.drivers.p4runtime.mirror; -import org.onosproject.net.pi.runtime.PiActionGroupMember; -import org.onosproject.net.pi.runtime.PiActionGroupMemberHandle; +import org.onosproject.net.pi.runtime.PiActionProfileMember; +import org.onosproject.net.pi.runtime.PiActionProfileMemberHandle; /** * Mirror of action profile members installed on a P4Runtime device. */ public interface P4RuntimeActionProfileMemberMirror - extends P4RuntimeMirror { + extends P4RuntimeMirror { } diff --git a/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/pipeliner/NextObjectiveTranslator.java b/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/pipeliner/NextObjectiveTranslator.java index 037a95f6bc..3af3c3e0f4 100644 --- a/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/pipeliner/NextObjectiveTranslator.java +++ b/pipelines/fabric/src/main/java/org/onosproject/pipelines/fabric/pipeliner/NextObjectiveTranslator.java @@ -43,8 +43,8 @@ import org.onosproject.net.group.GroupDescription; import org.onosproject.net.group.GroupKey; import org.onosproject.net.pi.model.PiTableId; import org.onosproject.net.pi.runtime.PiAction; -import org.onosproject.net.pi.runtime.PiActionGroupId; import org.onosproject.net.pi.runtime.PiActionParam; +import org.onosproject.net.pi.runtime.PiActionProfileGroupId; import org.onosproject.net.pi.runtime.PiGroupKey; import org.onosproject.pipelines.fabric.FabricCapabilities; import org.onosproject.pipelines.fabric.FabricConstants; @@ -216,7 +216,7 @@ class NextObjectiveTranslator final TrafficSelector selector = nextIdSelector(obj.id()); final TrafficTreatment treatment = DefaultTrafficTreatment.builder() - .piTableAction(PiActionGroupId.of(groupId)) + .piTableAction(PiActionProfileGroupId.of(groupId)) .build(); resultBuilder.addFlowRule(flowRule( diff --git a/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/pipeliner/FabricNextPipelinerTest.java b/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/pipeliner/FabricNextPipelinerTest.java index a56d26bf59..b28074d06e 100644 --- a/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/pipeliner/FabricNextPipelinerTest.java +++ b/pipelines/fabric/src/test/java/org/onosproject/pipelines/fabric/pipeliner/FabricNextPipelinerTest.java @@ -36,8 +36,8 @@ import org.onosproject.net.group.GroupBuckets; import org.onosproject.net.group.GroupDescription; import org.onosproject.net.group.GroupKey; import org.onosproject.net.pi.runtime.PiAction; -import org.onosproject.net.pi.runtime.PiActionGroupId; import org.onosproject.net.pi.runtime.PiActionParam; +import org.onosproject.net.pi.runtime.PiActionProfileGroupId; import org.onosproject.net.pi.runtime.PiGroupKey; import org.onosproject.pipelines.fabric.FabricConstants; @@ -256,7 +256,7 @@ public class FabricNextPipelinerTest extends FabricPipelinerTest { TrafficSelector nextIdSelector = DefaultTrafficSelector.builder() .matchPi(nextIdCriterion) .build(); - PiActionGroupId actionGroupId = PiActionGroupId.of(NEXT_ID_1); + PiActionProfileGroupId actionGroupId = PiActionProfileGroupId.of(NEXT_ID_1); TrafficTreatment treatment = DefaultTrafficTreatment.builder() .piTableAction(actionGroupId) .build(); diff --git a/protocols/p4runtime/api/src/main/java/org/onosproject/p4runtime/api/P4RuntimeClient.java b/protocols/p4runtime/api/src/main/java/org/onosproject/p4runtime/api/P4RuntimeClient.java index 7a08668a57..5d7e93e752 100644 --- a/protocols/p4runtime/api/src/main/java/org/onosproject/p4runtime/api/P4RuntimeClient.java +++ b/protocols/p4runtime/api/src/main/java/org/onosproject/p4runtime/api/P4RuntimeClient.java @@ -23,9 +23,9 @@ import org.onosproject.net.pi.model.PiCounterId; import org.onosproject.net.pi.model.PiMeterId; import org.onosproject.net.pi.model.PiPipeconf; import org.onosproject.net.pi.model.PiTableId; -import org.onosproject.net.pi.runtime.PiActionGroup; -import org.onosproject.net.pi.runtime.PiActionGroupMember; -import org.onosproject.net.pi.runtime.PiActionGroupMemberId; +import org.onosproject.net.pi.runtime.PiActionProfileGroup; +import org.onosproject.net.pi.runtime.PiActionProfileMember; +import org.onosproject.net.pi.runtime.PiActionProfileMemberId; import org.onosproject.net.pi.runtime.PiCounterCell; import org.onosproject.net.pi.runtime.PiCounterCellId; import org.onosproject.net.pi.runtime.PiMeterCellConfig; @@ -185,41 +185,44 @@ public interface P4RuntimeClient extends GrpcClient { Set cellIds, PiPipeconf pipeconf); /** - * Performs the given write operation for the given action group members and - * pipeconf. + * Performs the given write operation for the given action profile members + * and pipeconf. * - * @param members action group members - * @param opType write operation type - * @param pipeconf the pipeconf currently deployed on the device + * @param members action profile members + * @param opType write operation type + * @param pipeconf the pipeconf currently deployed on the device * @return true if the operation was successful, false otherwise */ - CompletableFuture writeActionGroupMembers( - List members, + CompletableFuture writeActionProfileMembers( + List members, WriteOperationType opType, PiPipeconf pipeconf); /** - * Performs the given write operation for the given action group and + * Performs the given write operation for the given action profile group and * pipeconf. * - * @param group the action group - * @param opType write operation type - * @param pipeconf the pipeconf currently deployed on the device - * @param maxMemberSize the maximum number of members that can be added to the group. - * This is meaningful only if it's an INSERT operation, otherwise - * its value should be 0 + * @param group the action profile group + * @param opType write operation type + * @param pipeconf the pipeconf currently deployed on the device + * @param maxMemberSize the maximum number of members that can be added to + * the group. This is meaningful only if it's an INSERT + * operation, otherwise its value should be 0 * @return true if the operation was successful, false otherwise */ - CompletableFuture writeActionGroup( - PiActionGroup group, WriteOperationType opType, PiPipeconf pipeconf, int maxMemberSize); + CompletableFuture writeActionProfileGroup( + PiActionProfileGroup group, + WriteOperationType opType, + PiPipeconf pipeconf, + int maxMemberSize); /** - * Dumps all groups currently installed for the given action profile. + * Dumps all groups currently installed in the given action profile. * * @param actionProfileId the action profile id * @param pipeconf the pipeconf currently deployed on the device * @return completable future of a list of groups */ - CompletableFuture> dumpGroups( + CompletableFuture> dumpActionProfileGroups( PiActionProfileId actionProfileId, PiPipeconf pipeconf); /** @@ -229,7 +232,7 @@ public interface P4RuntimeClient extends GrpcClient { * @param pipeconf pipeconf * @return future of list of action profile member ID */ - CompletableFuture> dumpActionProfileMemberIds( + CompletableFuture> dumpActionProfileMemberIds( PiActionProfileId actionProfileId, PiPipeconf pipeconf); /** @@ -241,9 +244,9 @@ public interface P4RuntimeClient extends GrpcClient { * @param pipeconf pipeconf * @return list of member IDs that were successfully removed from the device */ - CompletableFuture> removeActionProfileMembers( + CompletableFuture> removeActionProfileMembers( PiActionProfileId actionProfileId, - List memberIds, + List memberIds, PiPipeconf pipeconf); /** diff --git a/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/ActionProfileGroupEncoder.java b/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/ActionProfileGroupEncoder.java index cb0735d61c..414a0e67a9 100644 --- a/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/ActionProfileGroupEncoder.java +++ b/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/ActionProfileGroupEncoder.java @@ -19,8 +19,8 @@ package org.onosproject.p4runtime.ctl; import com.google.common.collect.Maps; import org.onosproject.net.pi.model.PiActionProfileId; import org.onosproject.net.pi.model.PiPipeconf; -import org.onosproject.net.pi.runtime.PiActionGroup; -import org.onosproject.net.pi.runtime.PiActionGroupId; +import org.onosproject.net.pi.runtime.PiActionProfileGroup; +import org.onosproject.net.pi.runtime.PiActionProfileGroupId; import p4.config.v1.P4InfoOuterClass; import p4.v1.P4RuntimeOuterClass.ActionProfileGroup; import p4.v1.P4RuntimeOuterClass.ActionProfileGroup.Member; @@ -41,18 +41,18 @@ final class ActionProfileGroupEncoder { } /** - * Encode a PI action group to a action profile group. + * Encode a PI action profile group to a action profile group. * * @param piActionGroup the action profile group * @param pipeconf the pipeconf * @param maxMemberSize the max member size of action group - * @return a action profile group encoded from PI action group + * @return a action profile group encoded from PI action profile group * @throws P4InfoBrowser.NotFoundException if can't find action profile from * P4Info browser * @throws EncodeException if can't find P4Info from * pipeconf */ - static ActionProfileGroup encode(PiActionGroup piActionGroup, PiPipeconf pipeconf, int maxMemberSize) + static ActionProfileGroup encode(PiActionProfileGroup piActionGroup, PiPipeconf pipeconf, int maxMemberSize) throws P4InfoBrowser.NotFoundException, EncodeException { P4InfoBrowser browser = PipeconfHelper.getP4InfoBrowser(pipeconf); @@ -86,26 +86,26 @@ final class ActionProfileGroupEncoder { /** * Decode an action profile group with members information to a PI action - * group. + * profile group. * * @param actionProfileGroup the action profile group * @param members members of the action profile group * @param pipeconf the pipeconf - * @return decoded PI action group + * @return decoded PI action profile group * @throws P4InfoBrowser.NotFoundException if can't find action profile from * P4Info browser * @throws EncodeException if can't find P4Info from * pipeconf */ - static PiActionGroup decode(ActionProfileGroup actionProfileGroup, - Collection members, - PiPipeconf pipeconf) + static PiActionProfileGroup decode(ActionProfileGroup actionProfileGroup, + Collection members, + PiPipeconf pipeconf) throws P4InfoBrowser.NotFoundException, EncodeException { P4InfoBrowser browser = PipeconfHelper.getP4InfoBrowser(pipeconf); if (browser == null) { throw new EncodeException(format("Can't get P4 info browser from pipeconf %s", pipeconf)); } - PiActionGroup.Builder piActionGroupBuilder = PiActionGroup.builder(); + PiActionProfileGroup.Builder piActionGroupBuilder = PiActionProfileGroup.builder(); P4InfoOuterClass.ActionProfile actionProfile = browser.actionProfiles() .getById(actionProfileGroup.getActionProfileId()); @@ -113,14 +113,14 @@ final class ActionProfileGroupEncoder { piActionGroupBuilder .withActionProfileId(piActionProfileId) - .withId(PiActionGroupId.of(actionProfileGroup.getGroupId())); + .withId(PiActionProfileGroupId.of(actionProfileGroup.getGroupId())); Map memberWeights = Maps.newHashMap(); actionProfileGroup.getMembersList().forEach(member -> { int weight = member.getWeight(); if (weight < 1) { // FIXME: currently PI has a bug which will always return weight 0 - // ONOS won't accept group member with weight 0 + // ONOS won't accept group buckets with weight 0 weight = 1; } memberWeights.put(member.getMemberId(), weight); diff --git a/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/ActionProfileMemberEncoder.java b/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/ActionProfileMemberEncoder.java index e78aa97ca2..30dd43c07a 100644 --- a/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/ActionProfileMemberEncoder.java +++ b/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/ActionProfileMemberEncoder.java @@ -18,8 +18,8 @@ package org.onosproject.p4runtime.ctl; import org.onosproject.net.pi.model.PiActionProfileId; import org.onosproject.net.pi.model.PiPipeconf; -import org.onosproject.net.pi.runtime.PiActionGroupMember; -import org.onosproject.net.pi.runtime.PiActionGroupMemberId; +import org.onosproject.net.pi.runtime.PiActionProfileMember; +import org.onosproject.net.pi.runtime.PiActionProfileMemberId; import p4.config.v1.P4InfoOuterClass; import p4.v1.P4RuntimeOuterClass; import p4.v1.P4RuntimeOuterClass.ActionProfileMember; @@ -37,16 +37,16 @@ final class ActionProfileMemberEncoder { } /** - * Encode a PiActionGroupMember to a ActionProfileMember. + * Encode a PiActionProfileMember to a ActionProfileMember. * - * @param member the member to encode - * @param pipeconf the pipeconf, as encode spec + * @param member the member to encode + * @param pipeconf the pipeconf, as encode spec * @return encoded member * @throws P4InfoBrowser.NotFoundException can't find action profile from * P4Info browser * @throws EncodeException can't find P4Info from pipeconf */ - static ActionProfileMember encode(PiActionGroupMember member, + static ActionProfileMember encode(PiActionProfileMember member, PiPipeconf pipeconf) throws P4InfoBrowser.NotFoundException, EncodeException { @@ -77,20 +77,20 @@ final class ActionProfileMemberEncoder { } /** - * Decode an action profile member to PI action group member. + * Decode an action profile member to PI action profile member. * * @param member the action profile member * @param weight the weight of the member * @param pipeconf the pipeconf, as decode spec - * @return decoded PI action group member + * @return decoded PI action profile member * @throws P4InfoBrowser.NotFoundException can't find definition of action * from P4 info * @throws EncodeException can't get P4 info browser from * pipeconf */ - static PiActionGroupMember decode(ActionProfileMember member, - int weight, - PiPipeconf pipeconf) + static PiActionProfileMember decode(ActionProfileMember member, + int weight, + PiPipeconf pipeconf) throws P4InfoBrowser.NotFoundException, EncodeException { P4InfoBrowser browser = PipeconfHelper.getP4InfoBrowser(pipeconf); if (browser == null) { @@ -103,9 +103,9 @@ final class ActionProfileMemberEncoder { .getPreamble() .getName()); - return PiActionGroupMember.builder() + return PiActionProfileMember.builder() .forActionProfile(actionProfileId) - .withId(PiActionGroupMemberId.of(member.getMemberId())) + .withId(PiActionProfileMemberId.of(member.getMemberId())) .withWeight(weight) .withAction(decodeActionMsg(member.getAction(), browser)) .build(); diff --git a/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/P4RuntimeClientImpl.java b/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/P4RuntimeClientImpl.java index d5080ae251..78ea9d917c 100644 --- a/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/P4RuntimeClientImpl.java +++ b/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/P4RuntimeClientImpl.java @@ -38,9 +38,9 @@ import org.onosproject.net.pi.model.PiCounterId; import org.onosproject.net.pi.model.PiMeterId; import org.onosproject.net.pi.model.PiPipeconf; import org.onosproject.net.pi.model.PiTableId; -import org.onosproject.net.pi.runtime.PiActionGroup; -import org.onosproject.net.pi.runtime.PiActionGroupMember; -import org.onosproject.net.pi.runtime.PiActionGroupMemberId; +import org.onosproject.net.pi.runtime.PiActionProfileGroup; +import org.onosproject.net.pi.runtime.PiActionProfileMember; +import org.onosproject.net.pi.runtime.PiActionProfileMemberId; import org.onosproject.net.pi.runtime.PiCounterCell; import org.onosproject.net.pi.runtime.PiCounterCellId; import org.onosproject.net.pi.runtime.PiMeterCellConfig; @@ -218,41 +218,41 @@ final class P4RuntimeClientImpl extends AbstractGrpcClient implements P4RuntimeC } @Override - public CompletableFuture writeActionGroupMembers(List members, + public CompletableFuture writeActionProfileMembers(List members, + WriteOperationType opType, + PiPipeconf pipeconf) { + return supplyInContext(() -> doWriteActionProfileMembers(members, opType, pipeconf), + "writeActionProfileMembers-" + opType.name()); + } + + + @Override + public CompletableFuture writeActionProfileGroup(PiActionProfileGroup group, WriteOperationType opType, - PiPipeconf pipeconf) { - return supplyInContext(() -> doWriteActionGroupMembers(members, opType, pipeconf), - "writeActionGroupMembers-" + opType.name()); - } - - - @Override - public CompletableFuture writeActionGroup(PiActionGroup group, - WriteOperationType opType, - PiPipeconf pipeconf, + PiPipeconf pipeconf, int maxMemberSize) { - return supplyInContext(() -> doWriteActionGroup(group, opType, pipeconf, maxMemberSize), - "writeActionGroup-" + opType.name()); + return supplyInContext(() -> doWriteActionProfileGroup(group, opType, pipeconf, maxMemberSize), + "writeActionProfileGroup-" + opType.name()); } @Override - public CompletableFuture> dumpGroups(PiActionProfileId actionProfileId, - PiPipeconf pipeconf) { + public CompletableFuture> dumpActionProfileGroups( + PiActionProfileId actionProfileId, PiPipeconf pipeconf) { return supplyInContext(() -> doDumpGroups(actionProfileId, pipeconf), - "dumpGroups-" + actionProfileId.id()); + "dumpActionProfileGroups-" + actionProfileId.id()); } @Override - public CompletableFuture> dumpActionProfileMemberIds( + public CompletableFuture> dumpActionProfileMemberIds( PiActionProfileId actionProfileId, PiPipeconf pipeconf) { return supplyInContext(() -> doDumpActionProfileMemberIds(actionProfileId, pipeconf), "dumpActionProfileMemberIds-" + actionProfileId.id()); } @Override - public CompletableFuture> removeActionProfileMembers( + public CompletableFuture> removeActionProfileMembers( PiActionProfileId actionProfileId, - List memberIds, + List memberIds, PiPipeconf pipeconf) { return supplyInContext( () -> doRemoveActionProfileMembers(actionProfileId, memberIds, pipeconf), @@ -667,15 +667,15 @@ final class P4RuntimeClientImpl extends AbstractGrpcClient implements P4RuntimeC return CounterEntryCodec.decodeCounterEntities(entities, pipeconf); } - private boolean doWriteActionGroupMembers(List members, - WriteOperationType opType, PiPipeconf pipeconf) { + private boolean doWriteActionProfileMembers(List members, + WriteOperationType opType, PiPipeconf pipeconf) { final List actionProfileMembers = Lists.newArrayList(); - for (PiActionGroupMember member : members) { + for (PiActionProfileMember member : members) { try { actionProfileMembers.add(ActionProfileMemberEncoder.encode(member, pipeconf)); } catch (EncodeException | P4InfoBrowser.NotFoundException e) { - log.warn("Unable to encode group member, aborting {} operation: {} [{}]", + log.warn("Unable to encode action profile member, aborting {} operation: {} [{}]", opType.name(), e.getMessage(), member.toString()); return false; } @@ -696,10 +696,10 @@ final class P4RuntimeClientImpl extends AbstractGrpcClient implements P4RuntimeC return true; } - return write(updateMsgs, members, opType, "group member"); + return write(updateMsgs, members, opType, "action profile member"); } - private List doDumpGroups(PiActionProfileId piActionProfileId, PiPipeconf pipeconf) { + private List doDumpGroups(PiActionProfileId piActionProfileId, PiPipeconf pipeconf) { log.debug("Dumping groups from action profile {} from {} (pipeconf {})...", piActionProfileId.id(), deviceId, pipeconf.id()); @@ -806,7 +806,7 @@ final class P4RuntimeClientImpl extends AbstractGrpcClient implements P4RuntimeC .map(Map.Entry::getKey) .forEach(gid -> groupIdToMembersMap.put(gid, member))); - log.debug("Retrieved {} group members from action profile {} on {}...", + log.debug("Retrieved {} members from action profile {} on {}...", groupIdToMembersMap.size(), piActionProfileId.id(), deviceId); return groupMsgs.stream() @@ -824,7 +824,7 @@ final class P4RuntimeClientImpl extends AbstractGrpcClient implements P4RuntimeC .collect(Collectors.toList()); } - private List doDumpActionProfileMemberIds( + private List doDumpActionProfileMemberIds( PiActionProfileId actionProfileId, PiPipeconf pipeconf) { final P4InfoBrowser browser = PipeconfHelper.getP4InfoBrowser(pipeconf); @@ -875,13 +875,13 @@ final class P4RuntimeClientImpl extends AbstractGrpcClient implements P4RuntimeC // removing members of other groups. .filter(m -> m.getActionProfileId() == p4ActProfId) .map(ActionProfileMember::getMemberId) - .map(PiActionGroupMemberId::of) + .map(PiActionProfileMemberId::of) .collect(Collectors.toList()); } - private List doRemoveActionProfileMembers( + private List doRemoveActionProfileMembers( PiActionProfileId actionProfileId, - List memberIds, + List memberIds, PiPipeconf pipeconf) { if (memberIds.isEmpty()) { @@ -922,7 +922,8 @@ final class P4RuntimeClientImpl extends AbstractGrpcClient implements P4RuntimeC "action profile members"); } - private boolean doWriteActionGroup(PiActionGroup group, WriteOperationType opType, PiPipeconf pipeconf, + private boolean doWriteActionProfileGroup( + PiActionProfileGroup group, WriteOperationType opType, PiPipeconf pipeconf, int maxMemberSize) { final ActionProfileGroup actionProfileGroup; if (opType == P4RuntimeClient.WriteOperationType.INSERT && maxMemberSize < group.members().size()) { diff --git a/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/TableEntryEncoder.java b/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/TableEntryEncoder.java index 7e2df982f1..3294a6d689 100644 --- a/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/TableEntryEncoder.java +++ b/protocols/p4runtime/ctl/src/main/java/org/onosproject/p4runtime/ctl/TableEntryEncoder.java @@ -26,9 +26,9 @@ import org.onosproject.net.pi.model.PiMatchFieldId; import org.onosproject.net.pi.model.PiPipeconf; import org.onosproject.net.pi.model.PiTableId; import org.onosproject.net.pi.runtime.PiAction; -import org.onosproject.net.pi.runtime.PiActionGroupId; -import org.onosproject.net.pi.runtime.PiActionGroupMemberId; import org.onosproject.net.pi.runtime.PiActionParam; +import org.onosproject.net.pi.runtime.PiActionProfileGroupId; +import org.onosproject.net.pi.runtime.PiActionProfileMemberId; import org.onosproject.net.pi.runtime.PiCounterCellData; import org.onosproject.net.pi.runtime.PiExactFieldMatch; import org.onosproject.net.pi.runtime.PiFieldMatch; @@ -46,7 +46,6 @@ import p4.v1.P4RuntimeOuterClass.FieldMatch; import p4.v1.P4RuntimeOuterClass.TableAction; import p4.v1.P4RuntimeOuterClass.TableEntry; -import java.util.Collection; import java.util.Collections; import java.util.List; @@ -109,7 +108,7 @@ final class TableEntryEncoder { } /** - * Same as {@link #encode(Collection, PiPipeconf)} but encodes only one entry. + * Same as {@link #encode(List, PiPipeconf)} but encodes only one entry. * * @param piTableEntry table entry * @param pipeconf pipeconf @@ -162,7 +161,7 @@ final class TableEntryEncoder { } /** - * Same as {@link #decode(Collection, PiPipeconf)} but decodes only one entry. + * Same as {@link #decode(List, PiPipeconf)} but decodes only one entry. * * @param tableEntryMsg table entry message * @param pipeconf pipeconf @@ -443,13 +442,13 @@ final class TableEntryEncoder { Action theAction = encodePiAction(piAction, browser); tableActionMsgBuilder.setAction(theAction); break; - case ACTION_GROUP_ID: - PiActionGroupId actionGroupId = (PiActionGroupId) piTableAction; + case ACTION_PROFILE_GROUP_ID: + PiActionProfileGroupId actionGroupId = (PiActionProfileGroupId) piTableAction; tableActionMsgBuilder.setActionProfileGroupId(actionGroupId.id()); break; - case GROUP_MEMBER_ID: - PiActionGroupMemberId actionGroupMemberId = (PiActionGroupMemberId) piTableAction; - tableActionMsgBuilder.setActionProfileMemberId(actionGroupMemberId.id()); + case ACTION_PROFILE_MEMBER_ID: + PiActionProfileMemberId actionProfileMemberId = (PiActionProfileMemberId) piTableAction; + tableActionMsgBuilder.setActionProfileMemberId(actionProfileMemberId.id()); break; default: throw new EncodeException( @@ -467,9 +466,9 @@ final class TableEntryEncoder { Action actionMsg = tableActionMsg.getAction(); return decodeActionMsg(actionMsg, browser); case ACTION_PROFILE_GROUP_ID: - return PiActionGroupId.of(tableActionMsg.getActionProfileGroupId()); + return PiActionProfileGroupId.of(tableActionMsg.getActionProfileGroupId()); case ACTION_PROFILE_MEMBER_ID: - return PiActionGroupMemberId.of(tableActionMsg.getActionProfileMemberId()); + return PiActionProfileMemberId.of(tableActionMsg.getActionProfileMemberId()); default: throw new EncodeException( format("Decoding of table action type %s not implemented", typeCase.name())); @@ -524,4 +523,4 @@ final class TableEntryEncoder { static PiCounterCellData decodeCounter(CounterData counterData) { return new PiCounterCellData(counterData.getPacketCount(), counterData.getByteCount()); } -} \ No newline at end of file +} diff --git a/protocols/p4runtime/ctl/src/test/java/org/onosproject/p4runtime/ctl/P4RuntimeGroupTest.java b/protocols/p4runtime/ctl/src/test/java/org/onosproject/p4runtime/ctl/P4RuntimeGroupTest.java index 301d5e1de1..f006c58a8b 100644 --- a/protocols/p4runtime/ctl/src/test/java/org/onosproject/p4runtime/ctl/P4RuntimeGroupTest.java +++ b/protocols/p4runtime/ctl/src/test/java/org/onosproject/p4runtime/ctl/P4RuntimeGroupTest.java @@ -39,11 +39,11 @@ import org.onosproject.net.pi.model.PiPipeconf; import org.onosproject.net.pi.model.PiPipeconfId; import org.onosproject.net.pi.model.PiPipelineModel; import org.onosproject.net.pi.runtime.PiAction; -import org.onosproject.net.pi.runtime.PiActionGroup; -import org.onosproject.net.pi.runtime.PiActionGroupId; -import org.onosproject.net.pi.runtime.PiActionGroupMember; -import org.onosproject.net.pi.runtime.PiActionGroupMemberId; import org.onosproject.net.pi.runtime.PiActionParam; +import org.onosproject.net.pi.runtime.PiActionProfileGroup; +import org.onosproject.net.pi.runtime.PiActionProfileGroupId; +import org.onosproject.net.pi.runtime.PiActionProfileMember; +import org.onosproject.net.pi.runtime.PiActionProfileMemberId; import org.onosproject.p4runtime.api.P4RuntimeClientKey; import p4.v1.P4RuntimeOuterClass.ActionProfileGroup; import p4.v1.P4RuntimeOuterClass.ActionProfileMember; @@ -78,19 +78,19 @@ public class P4RuntimeGroupTest { private static final PiPipeconf PIPECONF = buildPipeconf(); private static final int P4_INFO_ACT_PROF_ID = 285227860; private static final PiActionProfileId ACT_PROF_ID = PiActionProfileId.of("ecmp_selector"); - private static final PiActionGroupId GROUP_ID = PiActionGroupId.of(1); + private static final PiActionProfileGroupId GROUP_ID = PiActionProfileGroupId.of(1); private static final int DEFAULT_MEMBER_WEIGHT = 1; private static final PiActionId EGRESS_PORT_ACTION_ID = PiActionId.of("set_egress_port"); private static final PiActionParamId PORT_PARAM_ID = PiActionParamId.of("port"); private static final int BASE_MEM_ID = 65535; private static final List MEMBER_IDS = ImmutableList.of(65536, 65537, 65538); - private static final List GROUP_MEMBERS = + private static final List GROUP_MEMBERS = Lists.newArrayList( outputMember((short) 1), outputMember((short) 2), outputMember((short) 3) ); - private static final PiActionGroup GROUP = PiActionGroup.builder() + private static final PiActionProfileGroup GROUP = PiActionProfileGroup.builder() .withId(GROUP_ID) .addMembers(GROUP_MEMBERS) .withActionProfileId(ACT_PROF_ID) @@ -110,17 +110,17 @@ public class P4RuntimeGroupTest { private static Server grpcServer; private static ManagedChannel grpcChannel; - private static PiActionGroupMember outputMember(short portNum) { + private static PiActionProfileMember outputMember(short portNum) { PiActionParam param = new PiActionParam(PORT_PARAM_ID, ImmutableByteSequence.copyFrom(portNum)); PiAction piAction = PiAction.builder() .withId(EGRESS_PORT_ACTION_ID) .withParameter(param).build(); - return PiActionGroupMember.builder() + return PiActionProfileMember.builder() .forActionProfile(ACT_PROF_ID) .withAction(piAction) - .withId(PiActionGroupMemberId.of(BASE_MEM_ID + portNum)) + .withId(PiActionProfileMemberId.of(BASE_MEM_ID + portNum)) .withWeight(DEFAULT_MEMBER_WEIGHT) .build(); } @@ -161,9 +161,9 @@ public class P4RuntimeGroupTest { } @Test - public void testInsertPiActionGroup() throws Exception { + public void testInsertPiActionProfileGroup() throws Exception { CompletableFuture complete = p4RuntimeServerImpl.expectRequests(1); - client.writeActionGroup(GROUP, INSERT, PIPECONF, 3); + client.writeActionProfileGroup(GROUP, INSERT, PIPECONF, 3); complete.get(DEFAULT_TIMEOUT_TIME, TimeUnit.SECONDS); WriteRequest result = p4RuntimeServerImpl.getWriteReqs().get(0); assertEquals(1, result.getDeviceId()); @@ -192,7 +192,7 @@ public class P4RuntimeGroupTest { @Test public void testInsertPiActionMembers() throws Exception { CompletableFuture complete = p4RuntimeServerImpl.expectRequests(1); - client.writeActionGroupMembers(GROUP_MEMBERS, INSERT, PIPECONF); + client.writeActionProfileMembers(GROUP_MEMBERS, INSERT, PIPECONF); complete.get(DEFAULT_TIMEOUT_TIME, TimeUnit.SECONDS); WriteRequest result = p4RuntimeServerImpl.getWriteReqs().get(0); assertEquals(1, result.getDeviceId()); @@ -269,12 +269,12 @@ public class P4RuntimeGroupTest { p4RuntimeServerImpl.willReturnReadResult(responses); CompletableFuture complete = p4RuntimeServerImpl.expectRequests(2); - CompletableFuture> groupsComplete = client.dumpGroups(ACT_PROF_ID, PIPECONF); + CompletableFuture> groupsComplete = client.dumpActionProfileGroups(ACT_PROF_ID, PIPECONF); complete.get(DEFAULT_TIMEOUT_TIME, TimeUnit.SECONDS); - Collection groups = groupsComplete.get(DEFAULT_TIMEOUT_TIME, TimeUnit.SECONDS); + Collection groups = groupsComplete.get(DEFAULT_TIMEOUT_TIME, TimeUnit.SECONDS); assertEquals(1, groups.size()); - PiActionGroup piActionGroup = groups.iterator().next(); + PiActionProfileGroup piActionGroup = groups.iterator().next(); assertEquals(ACT_PROF_ID, piActionGroup.actionProfileId()); assertEquals(GROUP_ID, piActionGroup.id()); assertEquals(3, piActionGroup.members().size()); diff --git a/protocols/p4runtime/ctl/src/test/java/org/onosproject/p4runtime/ctl/TableEntryEncoderTest.java b/protocols/p4runtime/ctl/src/test/java/org/onosproject/p4runtime/ctl/TableEntryEncoderTest.java index d9e5f9a75f..278e050b61 100644 --- a/protocols/p4runtime/ctl/src/test/java/org/onosproject/p4runtime/ctl/TableEntryEncoderTest.java +++ b/protocols/p4runtime/ctl/src/test/java/org/onosproject/p4runtime/ctl/TableEntryEncoderTest.java @@ -30,8 +30,8 @@ import org.onosproject.net.pi.model.PiPipeconfId; import org.onosproject.net.pi.model.PiPipelineModel; import org.onosproject.net.pi.model.PiTableId; import org.onosproject.net.pi.runtime.PiAction; -import org.onosproject.net.pi.runtime.PiActionGroupId; import org.onosproject.net.pi.runtime.PiActionParam; +import org.onosproject.net.pi.runtime.PiActionProfileGroupId; import org.onosproject.net.pi.runtime.PiCounterCellData; import org.onosproject.net.pi.runtime.PiExactFieldMatch; import org.onosproject.net.pi.runtime.PiMatchKey; @@ -140,7 +140,7 @@ public class TableEntryEncoderTest { .withMatchKey(PiMatchKey.builder() .addFieldMatch(new PiExactFieldMatch(ecmpGroupFieldId, ofOnes(1))) .build()) - .withAction(PiActionGroupId.of(1)) + .withAction(PiActionProfileGroupId.of(1)) .withPriority(1) .withCookie(2) .withCounterCellData(counterCellData)