blob: 7f9e18a445233c634a459eb6b2e58a41c1e34fcf [file] [log] [blame]
Ray Milkey18b44ac2014-08-22 08:29:47 -07001package net.onrc.onos.core.matchaction;
2
3import net.onrc.onos.core.util.Dpid;
4
Ray Milkeya313cde2014-09-05 09:02:52 -07005/**
6 * The result of applying a MatchAction operation to a switch.
7 */
Ray Milkey18b44ac2014-08-22 08:29:47 -07008public class SwitchResult {
9 private Dpid sw;
10 private Status status;
11 private MatchActionOperationsId matchSetId;
12
Ray Milkeya313cde2014-09-05 09:02:52 -070013 /**
14 * Status of the switch operation.
15 */
Brian O'Connor0efc9062014-09-02 14:47:28 -070016 public enum Status {
Ray Milkeya313cde2014-09-05 09:02:52 -070017 /** Installation of the MatchAction was successful. */
Ray Milkey18b44ac2014-08-22 08:29:47 -070018 SUCCESS,
Ray Milkeya313cde2014-09-05 09:02:52 -070019
20 /** Installation of the MatchAction failed. */
Ray Milkey18b44ac2014-08-22 08:29:47 -070021 FAILURE,
Ray Milkeya313cde2014-09-05 09:02:52 -070022
23 /** No status has been assigned. */
Ray Milkey18b44ac2014-08-22 08:29:47 -070024 UNKNOWN
25 }
26
Ray Milkeya313cde2014-09-05 09:02:52 -070027 /**
28 * Creates a new SwitchResult object.
29 *
30 * @param match identifier for MatchActionsOperations that was requested
31 * @param sw Dpid of the switch that the operations were applied to
32 */
Ray Milkey18b44ac2014-08-22 08:29:47 -070033 protected SwitchResult(MatchActionOperationsId match, Dpid sw) {
34 this.sw = sw;
35 this.status = Status.UNKNOWN;
36 this.matchSetId = match;
37 }
38
Brian O'Connor0efc9062014-09-02 14:47:28 -070039 /**
40 * no-arg constructor for Kryo.
41 */
42 protected SwitchResult() {
Ray Milkeya313cde2014-09-05 09:02:52 -070043 // Needed for Kryo
Brian O'Connor0efc9062014-09-02 14:47:28 -070044 }
45
Ray Milkeya313cde2014-09-05 09:02:52 -070046 /**
47 * Sets the status of the SwitchResult.
48 *
49 * @param newStatus new status
50 */
Ray Milkey18b44ac2014-08-22 08:29:47 -070051 protected void setStatus(Status newStatus) {
52 this.status = newStatus;
53 }
54
Ray Milkeya313cde2014-09-05 09:02:52 -070055 /**
56 * Gets the status of the SwitchResult.
57 *
58 * @return status
59 */
Ray Milkey18b44ac2014-08-22 08:29:47 -070060 protected Status getStatus() {
61 return this.status;
62 }
63
Ray Milkeya313cde2014-09-05 09:02:52 -070064 /**
65 * Gets the identifier for the set of operations that was requested.
66 *
67 * @return MatchActionOperationsId of the requested set of operations
68 */
Ray Milkey18b44ac2014-08-22 08:29:47 -070069 protected MatchActionOperationsId getMatchActionOperationsId() {
70 return this.matchSetId;
71 }
72
Ray Milkeya313cde2014-09-05 09:02:52 -070073 /**
74 * Gets the identifier for the switch that was requested.
75 *
76 * @return Dpid of the requested switch
77 */
Ray Milkey18b44ac2014-08-22 08:29:47 -070078 protected Dpid getSwitch() {
79 return this.sw;
80 }
81}