(String rolesString)
| 35 | private Map<Role, String> nodeRoles; |
| 36 | |
| 37 | public NodeRoles(String rolesString) { |
| 38 | Map<Role, String> roles = new EnumMap<>(Role.class); |
| 39 | if (StrUtils.isNullOrEmpty(rolesString)) { |
| 40 | rolesString = DEFAULT_ROLES_STRING; |
| 41 | } |
| 42 | List<String> rolesList = StrUtils.splitSmart(rolesString, ','); |
| 43 | for (String s : rolesList) { |
| 44 | List<String> roleMode = StrUtils.splitSmart(s, ':'); |
| 45 | Role r = Role.getRole(roleMode.get(0)); |
| 46 | String m = roleMode.get(1); |
| 47 | if (r.supportedModes().contains(m)) { |
| 48 | roles.put(r, m); |
| 49 | } else { |
| 50 | throw new SolrException( |
| 51 | SolrException.ErrorCode.SERVER_ERROR, |
| 52 | "Unknown role mode '" + roleMode.get(1) + "' for role '" + r + "'"); |
| 53 | } |
| 54 | } |
| 55 | for (Role r : Role.values()) { |
| 56 | if (!roles.containsKey(r)) { |
| 57 | roles.put(r, r.modeWhenRoleIsAbsent()); |
| 58 | } |
| 59 | } |
| 60 | nodeRoles = Collections.unmodifiableMap(roles); |
| 61 | } |
| 62 | |
| 63 | public Map<Role, String> getRoles() { |
| 64 | return nodeRoles; |
nothing calls this directly
no test coverage detected