public Map<String, String> getConfiguration(String pid) { return delegate.getConfiguration(pid); }
/** * Get a long profile info string */ public static String getProfileInfo(Profile profile) { IllegalArgumentAssertion.assertNotNull(profile, "profile"); StringBuilder builder = new StringBuilder("Profile[ver=" + profile.getVersion() + ",id=" + profile.getId() + "]"); builder.append("\nAttributes"); Map<String, String> attributes = new TreeMap<>(profile.getAttributes()); for (Entry<String, String> entry : attributes.entrySet()) { builder.append("\n " + entry.getKey() + " = " + entry.getValue()); } builder.append("\nConfigurations"); for (String pid : new TreeSet<>(profile.getConfigurations().keySet())) { builder.append("\n " + pid); Map<String, String> config = new TreeMap<>(profile.getConfiguration(pid)); for (Entry<String, String> citem : config.entrySet()) { builder.append("\n " + citem.getKey() + " = " + citem.getValue()); } } builder.append("\nFiles"); for (String fileKey : new TreeSet<>(profile.getFileConfigurations().keySet())) { if (!fileKey.endsWith(Profile.PROPERTIES_SUFFIX)) { builder.append("\n " + fileKey); } } return builder.toString(); }
Map<String, String> profileConfig = overlay.getConfiguration(filePid); if (profileConfig != null) { overlayConfig.putAll(profileConfig);
public Map<String, String> getConfiguration(String pid) { return delegate.getConfiguration(pid); }
/** * Get a long profile info string */ public static String getProfileInfo(Profile profile) { IllegalArgumentAssertion.assertNotNull(profile, "profile"); StringBuilder builder = new StringBuilder("Profile[ver=" + profile.getVersion() + ",id=" + profile.getId() + "]"); builder.append("\nAttributes"); Map<String, String> attributes = new TreeMap<>(profile.getAttributes()); for (Entry<String, String> entry : attributes.entrySet()) { builder.append("\n " + entry.getKey() + " = " + entry.getValue()); } builder.append("\nConfigurations"); for (String pid : new TreeSet<>(profile.getConfigurations().keySet())) { builder.append("\n " + pid); Map<String, String> config = new TreeMap<>(profile.getConfiguration(pid)); for (Entry<String, String> citem : config.entrySet()) { builder.append("\n " + citem.getKey() + " = " + citem.getValue()); } } builder.append("\nFiles"); for (String fileKey : new TreeSet<>(profile.getFileConfigurations().keySet())) { if (!fileKey.endsWith(Profile.PROPERTIES_SUFFIX)) { builder.append("\n " + fileKey); } } return builder.toString(); }
Map<String, String> profileConfig = overlay.getConfiguration(filePid); if (profileConfig != null) { overlayConfig.putAll(profileConfig);
static List<String> getContainerConfigList(Profile p, ConfigListType type) { try { Map<String, String> containerProps = p.getConfiguration(Constants.AGENT_PID); List<String> rc = new ArrayList<String>(); String prefix = type + "."; for (Map.Entry<String, String> e : containerProps.entrySet()) { if ((e.getKey()).startsWith(prefix)) { rc.add(e.getValue()); } } return rc; } catch (Exception e) { throw FabricException.launderThrowable(e); } }
for (String pid : leftOnlyPids) { builder.append("\n " + pid); Map<String, String> config = new TreeMap<>(leftProfile.getConfiguration(pid)); for (Entry<String, String> citem : config.entrySet()) { builder.append("\n " + citem.getKey() + " = " + citem.getValue()); for (String pid : rightOnlyPids) { builder.append("\n " + pid); Map<String, String> config = new TreeMap<>(rightProfile.getConfiguration(pid)); for (Entry<String, String> citem : config.entrySet()) { builder.append("\n " + citem.getKey() + " = " + citem.getValue()); Map<String, String> leftConfig = leftProfile.getConfiguration(pid); Map<String, String> rightConfig = rightProfile.getConfiguration(pid); if (!leftConfig.equals(rightConfig)) { builder.append("\n " + pid + ": " + Maps.difference(leftConfig, rightConfig));
public static boolean agentConfigurationEquals(FabricService fabricService, Profile thisProfile, Profile otherProfile) { ProfileService profileService = fabricService.adapt(ProfileService.class); Profile thisOverlay = profileService.getOverlayProfile(thisProfile); Profile otherOverlay = profileService.getOverlayProfile(otherProfile); return thisOverlay.getConfiguration(Constants.AGENT_PID).equals(otherOverlay.getConfiguration(Constants.AGENT_PID)); }
for (String pid : leftOnlyPids) { builder.append("\n " + pid); Map<String, String> config = new TreeMap<>(leftProfile.getConfiguration(pid)); for (Entry<String, String> citem : config.entrySet()) { builder.append("\n " + citem.getKey() + " = " + citem.getValue()); for (String pid : rightOnlyPids) { builder.append("\n " + pid); Map<String, String> config = new TreeMap<>(rightProfile.getConfiguration(pid)); for (Entry<String, String> citem : config.entrySet()) { builder.append("\n " + citem.getKey() + " = " + citem.getValue()); Map<String, String> leftConfig = leftProfile.getConfiguration(pid); Map<String, String> rightConfig = rightProfile.getConfiguration(pid); if (!leftConfig.equals(rightConfig)) { builder.append("\n " + pid + ": " + Maps.difference(leftConfig, rightConfig));
public static boolean agentConfigurationEquals(FabricService fabricService, Profile thisProfile, Profile otherProfile) { ProfileService profileService = fabricService.adapt(ProfileService.class); Profile thisOverlay = profileService.getOverlayProfile(thisProfile); Profile otherOverlay = profileService.getOverlayProfile(otherProfile); return thisOverlay.getConfiguration(Constants.AGENT_PID).equals(otherOverlay.getConfiguration(Constants.AGENT_PID)); }
private static String substituteFromProfile(FabricService fabricService, Map<String, Map<String, String>> configs, String pid, String key) { Map<String, String> configuration = configs.get(pid); if (configuration != null && configuration.containsKey(key)) { return configuration.get(key); } else { // lets default to the current container if a version doesn't exist in a different profile Profile overlayProfile = fabricService.getCurrentContainer().getOverlayProfile(); Profile effectiveProfile = Profiles.getEffectiveProfile(fabricService, overlayProfile); configuration = effectiveProfile.getConfiguration(pid); if (configuration != null && configuration.containsKey(key)) { return configuration.get(key); } else { return EMPTY; } } }
@Override public Map<String, String> getProfileProperties(String versionId, String profileId, String pid) { Map<String, String> answer = null; Version version = profileService.getVersion(versionId); if (version != null) { Profile profile = version.getRequiredProfile(profileId); if (profile != null) { answer = profile.getConfiguration(pid); } } return answer; }
@Override public String getConfigurationValue(String versionId, String profileId, String pid, String key) { assertValid(); Profile pr = profileService.get().getRequiredProfile(versionId, profileId); Map<String, String> config = pr.getConfiguration(pid); if (config == null) { return null; } return config.get(key); }
@Override public Map<String, String> getOverlayProfileProperties(String versionId, String profileId, String pid) { Map<String, String> answer = null; Version version = profileService.getVersion(versionId); if (version != null) { Profile profile = version.getRequiredProfile(profileId); if (profile != null) { Profile overlayProfile = profileService.getOverlayProfile(profile); answer = overlayProfile.getConfiguration(pid); } } return answer; }
@Override public String getEnvironment() { assertValid(); String answer = runtimeProperties.get().getProperty(SystemProperties.FABRIC_ENVIRONMENT); if (answer == null) { // in case we've not updated the system properties in the JVM based on the profile // e.g. when adding/removing profiles Container currentContainer = getCurrentContainer(); if (currentContainer != null) { Map<String, String> systemProperties = currentContainer.getOverlayProfile().getConfiguration(Constants.SYSTEM_PROPERTIES_PID); answer = systemProperties.get(SystemProperties.FABRIC_ENVIRONMENT); } // lets store the effective profile for later on if (answer != null) { System.setProperty(SystemProperties.FABRIC_PROFILE_ENVIRONMENT, answer); } } return answer; }
public static Map<String, String> getOverlayConfiguration(FabricService fabricService, Iterable<String> profileIds, String versionId, String pid, String environment) { Map<String, String> overlayConfig = new HashMap<String, String>(); ProfileService profileService = fabricService.adapt(ProfileService.class); // this should only be null in test cases if (profileService != null) { Version version = null; if (versionId == null) { version = fabricService.getRequiredDefaultVersion(); } else { version = profileService.getRequiredVersion(versionId); } if (profileIds != null) { for (String profileId : profileIds) { Profile profile = version.getRequiredProfile(profileId); Profile overlay = profileService.getOverlayProfile(profile); Map<String, String> profileConfig = overlay.getConfiguration(pid); if (profileConfig != null) { overlayConfig.putAll(profileConfig); } } } } return overlayConfig; }
public static Map<String, String> getOverlayConfiguration(FabricService fabricService, Iterable<String> profileIds, String versionId, String pid, String environment) { Map<String, String> overlayConfig = new HashMap<String, String>(); ProfileService profileService = fabricService.adapt(ProfileService.class); // this should only be null in test cases if (profileService != null) { Version version = null; if (versionId == null) { version = fabricService.getRequiredDefaultVersion(); } else { version = profileService.getRequiredVersion(versionId); } if (profileIds != null) { for (String profileId : profileIds) { Profile profile = version.getRequiredProfile(profileId); Profile overlay = profileService.getOverlayProfile(profile); Map<String, String> profileConfig = overlay.getConfiguration(pid); if (profileConfig != null) { overlayConfig.putAll(profileConfig); } } } } return overlayConfig; }
Profile profile = defaultVersion.getRequiredProfile("default"); if (profile != null) { Map<String, String> zookeeperConfig = profile.getConfiguration(Constants.ZOOKEEPER_CLIENT_PID); if (zookeeperConfig != null) { zooKeeperUrl = getSubstitutedData(curator.get(), zookeeperConfig.get(name));
if (!Strings.isEmpty(webContextPath)) { Map<String, String> contextPathConfig = new HashMap<>(); Map<String, String> oldValue = profile.getConfiguration(Constants.WEB_CONTEXT_PATHS_PID); if (oldValue != null) { contextPathConfig.putAll(oldValue);