@Override public void registerGroup(String groupName) { ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(combinedClassLoader); registerGroup(new Group(groupName)); } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } }
@Override public void registerGroup(String groupName) { ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(combinedClassLoader); registerGroup(new Group(groupName)); } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } }
@Override public Map<String, Group> listGroups() { ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { Map<String, Group> res = new HashMap<String, Group>(); Thread.currentThread().setContextClassLoader(combinedClassLoader); Map<Node, Set<String>> nodes = getClusterGroups(); Set<String> groups = convertStringToSet((String) localConfig.get(Configurations.GROUPS_KEY)); groups.add(Configurations.DEFAULT_GROUP_NAME); for (String groupName : groups) { Group group = new Group(groupName); res.put(groupName, group); for (Map.Entry<Node, Set<String>> entry : nodes.entrySet()) { if (entry.getValue().contains(groupName)) { group.getNodes().add(entry.getKey()); } } } return res; } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } }
@Override public Map<String, Group> listGroups() { ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { Map<String, Group> res = new HashMap<String, Group>(); Thread.currentThread().setContextClassLoader(combinedClassLoader); Map<Node, Set<String>> nodes = getClusterGroups(); Set<String> groups = convertStringToSet((String) localConfig.get(Configurations.GROUPS_KEY)); groups.add(Configurations.DEFAULT_GROUP_NAME); for (String groupName : groups) { Group group = new Group(groupName); res.put(groupName, group); for (Map.Entry<Node, Set<String>> entry : nodes.entrySet()) { if (entry.getValue().contains(groupName)) { group.getNodes().add(entry.getKey()); } } } return res; } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } }
@Override public Group createGroup(String groupName) { ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(combinedClassLoader); Map<String, Group> listGroups = listGroups(); Group group = listGroups.get(groupName); if (group == null) { group = new Group(groupName); try { Configuration configuration = getConfigurationForGroups(); if (configuration != null) { Dictionary<String, Object> properties = configuration.getProperties(); if (properties != null && !properties.isEmpty()) { properties = copyGroupConfiguration(Configurations.DEFAULT_GROUP_NAME + '.', groupName + '.', properties); Set<String> groups = convertStringToSet((String) properties.get(Configurations.GROUPS_KEY)); groups.add(groupName); properties.put(Configurations.GROUPS_KEY, convertSetToString(groups)); updateConfiguration(configuration, properties); } } } catch (IOException e) { LOGGER.error("CELLAR HAZELCAST: failed to update cluster group configuration", e); } } return group; } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } }
@Override public Group createGroup(String groupName) { ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(combinedClassLoader); Map<String, Group> listGroups = listGroups(); Group group = listGroups.get(groupName); if (group == null) { group = new Group(groupName); try { Configuration configuration = getConfigurationForGroups(); if (configuration != null) { Dictionary<String, Object> properties = configuration.getProperties(); if (properties != null && !properties.isEmpty()) { properties = copyGroupConfiguration(Configurations.DEFAULT_GROUP_NAME + '.', groupName + '.', properties); Set<String> groups = convertStringToSet((String) properties.get(Configurations.GROUPS_KEY)); groups.add(groupName); properties.put(Configurations.GROUPS_KEY, convertSetToString(groups)); updateConfiguration(configuration, properties); } } } catch (IOException e) { LOGGER.error("CELLAR HAZELCAST: failed to update cluster group configuration", e); } } return group; } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } }