@Test public void testCreateRespectsFlagInMap() { TestEntity entity2 = app.createAndManageChild( TestEntity.Spec.newInstance().configure(MutableMap.of("confName", "baz"))); assertEquals(entity2.getConfig(TestEntity.CONF_NAME), "baz"); }
@Test public void testCanSetConfig() { final ExampleJavaPolicy policy = new ExampleJavaPolicy(MutableMap.of("displayName", "myName", "myConfig1", "myVal1")); entity.addPolicy(policy); assertEquals(policy.getName(), "myName"); assertEquals(policy.myConfig1, "myVal1"); }
public Map<String, String> getShellEnvironment() { Map<String, String> orig = super.getShellEnvironment(); return MutableMap.<String, String>builder() .putAll(orig) .put("QPID_HOME", getRunDir()) .put("QPID_WORK", getRunDir()) .put("QPID_OPTS", (orig.containsKey("JAVA_OPTS") ? orig.get("JAVA_OPTS") : "")) .build(); }
@Test public void testCanSetConfig() { entity = new ExampleJavaEntity(MutableMap.of("displayName", "myName", "myConfig1", "myVal1"), app); app.manage(entity); assertEquals(entity.getDisplayName(), "myName"); assertEquals(entity.getConfig(ExampleJavaEntity.MY_CONFIG1), "myVal1"); }
public static BrooklynProperties newDefault() { BrooklynProperties p = new BrooklynProperties().addEnvironmentVars().addSystemProperties(); File f = new File( p.getFirst(MutableMap.of("defaultIfNone", "/"), "user.home", "HOME") + File.separatorChar + ".brooklyn" + File.separatorChar + "brooklyn.properties"); if (f.exists()) p.addFrom(f); return p; }
@Override public void customize() { NetworkUtils.checkPortsValid(MutableMap.of("jmxPort", getJmxPort(), "amqpPort", getAmqpPort())); newScript(CUSTOMIZING) .body .append(format("cp -R %s/{bin,etc,lib} .", getExpandedInstallDir()), "mkdir lib/opt") .execute(); Map runtimeFiles = entity.getConfig(QpidBroker.RUNTIME_FILES); copyResources(runtimeFiles); Map runtimeTemplates = entity.getConfig(QpidBroker.RUNTIME_TEMPLATES); copyTemplates(runtimeTemplates); }
public Map<String, Object> getCustomJavaSystemProperties() { Map<String, Object> props = MutableMap.<String, Object>builder() .put("connector.port", getAmqpPort()) .put("management.enabled", "true") .put("management.jmxport.registryServer", getJmxPort()) .put("management.jmxport.connectorServer", getRmiServerPort()) .put("management.http.enabled", getHttpManagementPort() != null ? "true" : "false") .build(); if (getHttpManagementPort() != null) { props.put("management.http.port", getHttpManagementPort()); } return props; }
/** * AS7 config notes and TODOs: We're using the http management interface on port managementPort * We're not using any JMX. - AS 7 simply doesn't boot with Sun JMX enabled * (https://issues.jboss.org/browse/JBAS-7427) - 7.1 onwards uses Remoting 3, which we haven't * configured We're completely disabling security on the management interface. - In the future we * probably want to use the as7/bin/add-user.sh script using config keys for user and password - * Or we could create our own security realm and use that. We disable the root welcome page, since * we can't deploy our own root otherwise We bind all interfaces to entity.hostname, rather than * 127.0.0.1. */ @Override public void customize() { Map ports = MutableMap.of( "httpPort", getHttpPort(), "managementPort", getManagementPort(), "managementNativePort", getManagementNativePort()); NetworkUtils.checkPortsValid(ports); String hostname = entity.getAttribute(SoftwareProcessEntity.HOSTNAME); Preconditions.checkNotNull( hostname, "AS 7 entity must set hostname otherwise server will only be visible on localhost"); newScript(CUSTOMIZING) .body .append( format( "cp -r %s/jboss-as-%s/%s . || exit $!", getInstallDir(), getVersion(), SERVER_TYPE), format("cd %s/%s/configuration/", getRunDir(), SERVER_TYPE), format("cp standalone.xml %s", CONFIG_FILE), format("sed -i.bk 's/8080/%s/' %s", getHttpPort(), CONFIG_FILE), format("sed -i.bk 's/9990/%s/' %s", getManagementPort(), CONFIG_FILE), format("sed -i.bk 's/9999/%s/' %s", getManagementNativePort(), CONFIG_FILE), format( "sed -i.bk 's/port-offset:0/port-offset:%s/' %s", getPortIncrement(), CONFIG_FILE), format( "sed -i.bk 's/enable-welcome-root=\"true\"/enable-welcome-root=\"false\"/' %s", CONFIG_FILE), // Disable Management security (!) by deleting the security-realm attribute format( "sed -i.bk 's/http-interface security-realm=\"ManagementRealm\"/http-interface/' %s", CONFIG_FILE), // Increase deployment timeout to ten minutes format( "sed -i.bk 's/\\(path=\"deployments\"\\)/\\1 deployment-timeout=\"600\"/' %s", CONFIG_FILE), // Bind interfaces to entity hostname format( "sed -i.bk 's/\\(inet-address value=.*\\)127.0.0.1/\\1%s/' %s", getHostname(), CONFIG_FILE)) .execute(); ((JBoss7Server) entity).deployInitialWars(); }
@Override public void launch() { Map flags = MutableMap.of("usePidFile", false); newScript(flags, LAUNCHING) .body .append( "export LAUNCH_JBOSS_IN_BACKGROUND=true", format("export JBOSS_HOME=%s/jboss-as-%s", getInstallDir(), getVersion()), format("export JBOSS_PIDFILE=%s/%s", getRunDir(), PID_FILENAME), format("%s/jboss-as-%s/bin/%s.sh ", getInstallDir(), getVersion(), SERVER_TYPE) + format("--server-config %s ", CONFIG_FILE) + format("-Djboss.server.base.dir=%s/%s ", getRunDir(), SERVER_TYPE) + format("\"-Djboss.server.base.url=file://%s/%s\" ", getRunDir(), SERVER_TYPE) + "-Djava.net.preferIPv4Stack=true " + "-Djava.net.preferIPv6Addresses=false " + format(" >> %s/console 2>&1 </dev/null &", getRunDir())) .execute(); }
@Test public void testCanSetId() { final ExampleJavaPolicy policy = new ExampleJavaPolicy(MutableMap.of("id", "myid")); entity.addPolicy(policy); assertEquals(policy.getId(), "myid"); }
/** * returns the value of the first key which is defined * * <p>takes the following flags: 'warnIfNone', 'failIfNone' (both taking a boolean (to use default * message) or a string (which is the message)); and 'defaultIfNone' (a default value to return if * there is no such property); defaults to no warning and null response */ @Override public String getFirst(String... keys) { return getFirst(MutableMap.of(), keys); }
public Map<String, Object> getProvisioningFlags(Collection<String> tags) { return MutableMap.<String, Object>of(); }
public SimulatedLocation() { this(MutableMap.<String, Object>of()); }
public ActiveMQDestination(Entity parent) { this(MutableMap.of(), parent); }
public ActiveMQDestination() { this(MutableMap.of(), null); }
@Override public void kill() { Map flags = MutableMap.of("usePidFile", true); newScript(flags, KILLING).execute(); }
@Override public void stop() { Map flags = MutableMap.of("usePidFile", true); newScript(flags, STOPPING).execute(); }
@Override public boolean isRunning() { Map flags = MutableMap.of("usePidFile", true); return newScript(flags, CHECK_RUNNING).execute() == 0; }