@SuppressWarnings("unchecked") private <K,V> Map<K,V> concat(Map<? extends K,? extends V> map1, Map<? extends K,? extends V> map2) { if (map1 == null || map1.isEmpty()) return (Map<K,V>) map2; if (map2 == null || map2.isEmpty()) return (Map<K,V>) map1; // TODO Not using Immutable builder, because that fails if duplicates in map1 and map2 return MutableMap.<K,V>builder().putAll(map1).putAll(map2).build(); }
protected void runTest(Map<String,?> flags) throws Exception { String tag = getClass().getSimpleName().toLowerCase(); int length = tag.length(); if (length > MAX_TAG_LENGTH) tag = tag.substring(length - MAX_TAG_LENGTH, length); Map<String,?> allFlags = MutableMap.<String,Object>builder() .put("tags", ImmutableList.of(tag)) .putAll(flags) .build(); jcloudsLocation = mgmt.getLocationRegistry().getLocationManaged(LOCATION_SPEC, allFlags); doTest(jcloudsLocation); }
protected void runTest(Map<String,?> flags) throws Exception { String tag = getClass().getSimpleName().toLowerCase(); Map<String,?> allFlags = MutableMap.<String,Object>builder() .put("tags", ImmutableList.of(tag)) .putAll(flags) .build(); jcloudsLocation = mgmt.getLocationRegistry().getLocationManaged(PROVIDER, allFlags); doTest(jcloudsLocation); }
@Override public Map<String, String> getShellEnvironment() { return MutableMap.<String, String>builder() .putAll(super.getShellEnvironment()) .put("LAUNCH_JBOSS_IN_BACKGROUND", "1") .put("RUN", getRunDir()) .build(); }
@Override protected Map<String, ?> customBrooklynProperties() { return MutableMap.<String, Object>builder() .putAll(super.customBrooklynProperties()) .put("brooklyn.external.myprovider", MyExternalConfigSupplier.class.getName()) .put("brooklyn.external.myprovider.mykey", "myval") .put("brooklyn.external.myproviderWithoutMapArg", MyExternalConfigSupplierWithoutMapArg.class.getName()) .build(); }
protected String getCreateUserStatementsFor(Map<ConfigKey<?>,?> config) { BailOutJcloudsLocation jl = BailOutJcloudsLocation.newBailOutJcloudsLocation( managementContext, MutableMap.<ConfigKey<?>, Object>builder() .put(JcloudsLocationConfig.LOGIN_USER, "root").put(JcloudsLocationConfig.LOGIN_USER_PASSWORD, "m0ck") .put(JcloudsLocationConfig.USER, "bob").put(JcloudsLocationConfig.LOGIN_USER_PASSWORD, "b0b") .putAll(config).build()); CreateUserStatements creation = CreateUserStatements.get(jl, null, jl.config().getBag()); return new StatementList(creation.statements()).render(OsFamily.UNIX); }
protected ServerPoolLocation createLocation() { return createLocation(MutableMap.<String, Object>builder() .putAll(getConfig(LOCATION_FLAGS)) .put(DynamicLocation.OWNER.getName(), this) .build()); }
protected void runTest(Map<String,?> flags) throws Exception { Map<String,?> allFlags = MutableMap.<String,Object>builder() .put("tags", ImmutableList.of(getClass().getName())) .put(JcloudsLocationConfig.MACHINE_CREATE_ATTEMPTS.getName(), 1) .putAll(flags) .build(); jcloudsLocation = mgmt.getLocationRegistry().getLocationManaged(getLocationSpec(), allFlags); doTest(jcloudsLocation); }
@Override public Map<String, String> getShellEnvironment() { return MutableMap.<String,String>builder() .putAll(super.getShellEnvironment()) .put("ACTIVEMQ_HOME", getRunDir()) .put("ACTIVEMQ_PIDFILE", getPidFile()) .renameKey("JAVA_OPTS", "ACTIVEMQ_OPTS") .build(); } }
@Override public Map<String, String> getShellEnvironment() { return MutableMap.<String, String>builder() .putAll(super.getShellEnvironment()) .put("QPID_HOME", getRunDir()) .put("QPID_WORK", getRunDir()) .renameKey("JAVA_OPTS", "QPID_OPTS") .build(); } }
/** * Use RMI agent to provide JMX. */ @Override public Map<String, String> getShellEnvironment() { return MutableMap.<String, String>builder() .putAll(super.getShellEnvironment()) .renameKey("JAVA_OPTS", "KAFKA_JMX_OPTS") .build(); }
@Override public Map<String, String> getShellEnvironment() { return MutableMap.<String, String>builder().putAll(super.getShellEnvironment()) .put("PORT", Integer.toString(getHttpPort())) .build(); }
@Test(groups = "Live", dataProvider="cloudAndImageNames") public void testCreatesWindowsVm(String locationSpec, String imageNameRegex, Map<String, ?> additionalConfig) throws Exception { jcloudsLocation = (JcloudsLocation) managementContext.getLocationRegistry().getLocationManaged(locationSpec); JcloudsWinRmMachineLocation machine = obtainWinrmMachine(MutableMap.<String,Object>builder() .putIfAbsent("inboundPorts", ImmutableList.of(5986, 5985, 3389)) .put(JcloudsLocation.IMAGE_NAME_REGEX.getName(), imageNameRegex) .put(JcloudsLocation.USE_JCLOUDS_SSH_INIT.getName(), false) .put(JcloudsLocation.OS_FAMILY_OVERRIDE.getName(), OsFamily.WINDOWS) .putAll(additionalConfig != null ? additionalConfig : ImmutableMap.<String, Object>of()) .build()); assertWinrmable(machine); }
@Override public Map<String,String> getShellEnvironment() { return MutableMap.<String,String>builder() .putAll(super.getShellEnvironment()) .putIfNotNull("CLASSPATH", getClasspath()) .build(); } }
@Test(expectedExceptions=IllegalArgumentException.class, expectedExceptionsMessageRegExp=".*Invalid arguments.*missing argument.*stringParam.*") public void testPrepareArgsFromMapThrowsIfMissing() throws Exception { MutableMap<Object, Object> mapMissingArg = MutableMap.builder() .putAll(argsMap) .remove("stringParam") .build(); EffectorUtils.prepareArgsForEffector(effector, mapMissingArg); }
@Override public Map<String, String> getShellEnvironment() { return MutableMap.<String, String>builder() .putAll(super.getShellEnvironment()) .put("RABBITMQ_HOME", getRunDir()) .put("RABBITMQ_LOG_BASE", getRunDir()) .put("RABBITMQ_NODENAME", getEntity().getId()) .put("RABBITMQ_NODE_PORT", getAmqpPort().toString()) .put("RABBITMQ_PID_FILE", getRunDir()+"/"+getPidFile()) .put("RABBITMQ_CONFIG_FILE", getConfigPath()) .build(); }
@Override public Map<String, String> getShellEnvironment() { return MutableMap.<String, String>builder() .putAll(super.getShellEnvironment()) .put("JETTY_RUN", getRunDir()) .put("JETTY_HOME", getRunDir()) .put("JETTY_LOGS", Os.mergePathsUnix(getRunDir(), "logs")) .put("JETTY_PORT", getHttpPort().toString()) .renameKey("JAVA_OPTS", "JAVA_OPTIONS") .build(); } }
public static Map<String,Object> getBasicAddonSubstitutions(EntityDriver driver, String addon) { return MutableMap.<String,Object>builder() .putAll(getBasicEntitySubstitutions(driver)) .put("addon", addon) .build(); }