tom | 9ccd781 | 2014-08-25 22:43:19 -0700 | [diff] [blame^] | 1 | package org.onlab.onos.of.controller.impl; |
alshabib | 1f44e8e | 2014-08-14 15:19:57 -0700 | [diff] [blame] | 2 | |
| 3 | import org.projectfloodlight.openflow.protocol.OFControllerRole; |
| 4 | |
| 5 | /** |
| 6 | * The role of the controller as it pertains to a particular switch. |
| 7 | * Note that this definition of the role enum is different from the |
| 8 | * OF1.3 definition. It is maintained here to be backward compatible to |
| 9 | * earlier versions of the controller code. This enum is translated |
| 10 | * to the OF1.3 enum, before role messages are sent to the switch. |
| 11 | * See sendRoleRequestMessage method in OFSwitchImpl |
| 12 | */ |
| 13 | public enum Role { |
| 14 | EQUAL(OFControllerRole.ROLE_EQUAL), |
| 15 | MASTER(OFControllerRole.ROLE_MASTER), |
| 16 | SLAVE(OFControllerRole.ROLE_SLAVE); |
| 17 | |
| 18 | private Role(OFControllerRole nxRole) { |
| 19 | nxRole.ordinal(); |
| 20 | } |
| 21 | /* |
| 22 | private static Map<Integer,Role> nxRoleToEnum |
| 23 | = new HashMap<Integer,Role>(); |
| 24 | static { |
| 25 | for(Role r: Role.values()) |
| 26 | nxRoleToEnum.put(r.toNxRole(), r); |
| 27 | } |
| 28 | public int toNxRole() { |
| 29 | return nxRole; |
| 30 | } |
| 31 | // Return the enum representing the given nxRole or null if no |
| 32 | // such role exists |
| 33 | public static Role fromNxRole(int nxRole) { |
| 34 | return nxRoleToEnum.get(nxRole); |
| 35 | }*/ |
| 36 | } |