Ray Milkey | 18b44ac | 2014-08-22 08:29:47 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.matchaction; |
| 2 | |
| 3 | import net.onrc.onos.core.util.Dpid; |
| 4 | |
Ray Milkey | a313cde | 2014-09-05 09:02:52 -0700 | [diff] [blame] | 5 | /** |
| 6 | * The result of applying a MatchAction operation to a switch. |
| 7 | */ |
Ray Milkey | 18b44ac | 2014-08-22 08:29:47 -0700 | [diff] [blame] | 8 | public class SwitchResult { |
| 9 | private Dpid sw; |
| 10 | private Status status; |
| 11 | private MatchActionOperationsId matchSetId; |
| 12 | |
Ray Milkey | a313cde | 2014-09-05 09:02:52 -0700 | [diff] [blame] | 13 | /** |
| 14 | * Status of the switch operation. |
| 15 | */ |
Brian O'Connor | 0efc906 | 2014-09-02 14:47:28 -0700 | [diff] [blame] | 16 | public enum Status { |
Ray Milkey | a313cde | 2014-09-05 09:02:52 -0700 | [diff] [blame] | 17 | /** Installation of the MatchAction was successful. */ |
Ray Milkey | 18b44ac | 2014-08-22 08:29:47 -0700 | [diff] [blame] | 18 | SUCCESS, |
Ray Milkey | a313cde | 2014-09-05 09:02:52 -0700 | [diff] [blame] | 19 | |
| 20 | /** Installation of the MatchAction failed. */ |
Ray Milkey | 18b44ac | 2014-08-22 08:29:47 -0700 | [diff] [blame] | 21 | FAILURE, |
Ray Milkey | a313cde | 2014-09-05 09:02:52 -0700 | [diff] [blame] | 22 | |
| 23 | /** No status has been assigned. */ |
Ray Milkey | 18b44ac | 2014-08-22 08:29:47 -0700 | [diff] [blame] | 24 | UNKNOWN |
| 25 | } |
| 26 | |
Ray Milkey | a313cde | 2014-09-05 09:02:52 -0700 | [diff] [blame] | 27 | /** |
| 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 Milkey | 18b44ac | 2014-08-22 08:29:47 -0700 | [diff] [blame] | 33 | protected SwitchResult(MatchActionOperationsId match, Dpid sw) { |
| 34 | this.sw = sw; |
| 35 | this.status = Status.UNKNOWN; |
| 36 | this.matchSetId = match; |
| 37 | } |
| 38 | |
Brian O'Connor | 0efc906 | 2014-09-02 14:47:28 -0700 | [diff] [blame] | 39 | /** |
| 40 | * no-arg constructor for Kryo. |
| 41 | */ |
| 42 | protected SwitchResult() { |
Ray Milkey | a313cde | 2014-09-05 09:02:52 -0700 | [diff] [blame] | 43 | // Needed for Kryo |
Brian O'Connor | 0efc906 | 2014-09-02 14:47:28 -0700 | [diff] [blame] | 44 | } |
| 45 | |
Ray Milkey | a313cde | 2014-09-05 09:02:52 -0700 | [diff] [blame] | 46 | /** |
| 47 | * Sets the status of the SwitchResult. |
| 48 | * |
| 49 | * @param newStatus new status |
| 50 | */ |
Ray Milkey | 18b44ac | 2014-08-22 08:29:47 -0700 | [diff] [blame] | 51 | protected void setStatus(Status newStatus) { |
| 52 | this.status = newStatus; |
| 53 | } |
| 54 | |
Ray Milkey | a313cde | 2014-09-05 09:02:52 -0700 | [diff] [blame] | 55 | /** |
| 56 | * Gets the status of the SwitchResult. |
| 57 | * |
| 58 | * @return status |
| 59 | */ |
Ray Milkey | 18b44ac | 2014-08-22 08:29:47 -0700 | [diff] [blame] | 60 | protected Status getStatus() { |
| 61 | return this.status; |
| 62 | } |
| 63 | |
Ray Milkey | a313cde | 2014-09-05 09:02:52 -0700 | [diff] [blame] | 64 | /** |
| 65 | * Gets the identifier for the set of operations that was requested. |
| 66 | * |
| 67 | * @return MatchActionOperationsId of the requested set of operations |
| 68 | */ |
Ray Milkey | 18b44ac | 2014-08-22 08:29:47 -0700 | [diff] [blame] | 69 | protected MatchActionOperationsId getMatchActionOperationsId() { |
| 70 | return this.matchSetId; |
| 71 | } |
| 72 | |
Ray Milkey | a313cde | 2014-09-05 09:02:52 -0700 | [diff] [blame] | 73 | /** |
| 74 | * Gets the identifier for the switch that was requested. |
| 75 | * |
| 76 | * @return Dpid of the requested switch |
| 77 | */ |
Ray Milkey | 18b44ac | 2014-08-22 08:29:47 -0700 | [diff] [blame] | 78 | protected Dpid getSwitch() { |
| 79 | return this.sw; |
| 80 | } |
| 81 | } |