MCPcopy Create free account
hub / github.com/apache/solr / NodeRoles

Method NodeRoles

solr/core/src/java/org/apache/solr/core/NodeRoles.java:37–61  ·  view source on GitHub ↗
(String rolesString)

Source from the content-addressed store, hash-verified

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;

Callers

nothing calls this directly

Calls 10

isNullOrEmptyMethod · 0.95
splitSmartMethod · 0.95
getRoleMethod · 0.95
supportedModesMethod · 0.95
modeWhenRoleIsAbsentMethod · 0.95
getMethod · 0.65
putMethod · 0.65
containsMethod · 0.45
valuesMethod · 0.45
containsKeyMethod · 0.45

Tested by

no test coverage detected