Search in sources :

Example 31 with RuntimeProperties

use of io.fabric8.api.RuntimeProperties in project fabric8 by jboss-fuse.

the class ClusterBootstrapManager method getCreateEnsembleOptions.

static CreateEnsembleOptions getCreateEnsembleOptions(RuntimeProperties sysprops, Map<String, Object> options) {
    String username = (String) options.remove("username");
    String password = (String) options.remove("password");
    String role = (String) options.remove("role");
    if (username == null || password == null || role == null) {
        throw new FabricException("Must specify an administrator username, password and administrative role when creating a fabric");
    }
    Object profileObject = options.remove("profiles");
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
    CreateEnsembleOptions.Builder builder = mapper.convertValue(options, CreateEnsembleOptions.Builder.class);
    if (profileObject != null) {
        List profiles = mapper.convertValue(profileObject, List.class);
        builder.profiles(profiles);
    }
    org.apache.felix.utils.properties.Properties userProps = null;
    try {
        userProps = new org.apache.felix.utils.properties.Properties(sysprops.getConfPath().resolve("users.properties").toFile());
    } catch (IOException e) {
        userProps = new org.apache.felix.utils.properties.Properties();
    }
    if (userProps.get(username) == null) {
        userProps.put(username, password + "," + role);
    }
    CreateEnsembleOptions answer = builder.users(userProps).withUser(username, password, role).build();
    LOG.debug("Creating ensemble with options: {}", answer);
    System.setProperty(ZkDefs.GLOBAL_RESOLVER_PROPERTY, answer.getGlobalResolver());
    System.setProperty(ZkDefs.LOCAL_RESOLVER_PROPERTY, answer.getResolver());
    System.setProperty(ZkDefs.MANUAL_IP, answer.getManualIp());
    System.setProperty(ZkDefs.BIND_ADDRESS, answer.getBindAddress());
    System.setProperty(ZkDefs.MINIMUM_PORT, "" + answer.getMinimumPort());
    System.setProperty(ZkDefs.MAXIMUM_PORT, "" + answer.getMaximumPort());
    return answer;
}
Also used : FabricException(io.fabric8.api.FabricException) CreateEnsembleOptions(io.fabric8.api.CreateEnsembleOptions) IOException(java.io.IOException) RuntimeProperties(io.fabric8.api.RuntimeProperties) List(java.util.List) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 32 with RuntimeProperties

use of io.fabric8.api.RuntimeProperties in project fabric8 by jboss-fuse.

the class ClusterBootstrapManager method createCluster.

@Override
public void createCluster() {
    assertValid();
    RuntimeProperties sysprops = runtimeProperties.get();
    bootstrap.get().create(CreateEnsembleOptions.builder().fromRuntimeProperties(sysprops).build());
}
Also used : RuntimeProperties(io.fabric8.api.RuntimeProperties)

Example 33 with RuntimeProperties

use of io.fabric8.api.RuntimeProperties in project fabric8 by jboss-fuse.

the class ClusterServiceManager method addToCluster.

@Override
public void addToCluster(List<String> containers, Map<String, Object> options) {
    assertValid();
    RuntimeProperties sysprops = runtimeProperties.get();
    CreateEnsembleOptions createEnsembleOptions = ClusterBootstrapManager.getCreateEnsembleOptions(sysprops, options);
    addToCluster(containers, createEnsembleOptions);
}
Also used : CreateEnsembleOptions(io.fabric8.api.CreateEnsembleOptions) RuntimeProperties(io.fabric8.api.RuntimeProperties)

Aggregations

RuntimeProperties (io.fabric8.api.RuntimeProperties)24 IOException (java.io.IOException)12 File (java.io.File)9 AbstractRuntimeProperties (io.fabric8.api.scr.AbstractRuntimeProperties)6 BootstrapConfiguration (io.fabric8.zookeeper.bootstrap.BootstrapConfiguration)6 HashMap (java.util.HashMap)6 FabricException (io.fabric8.api.FabricException)5 MavenResolver (io.fabric8.maven.MavenResolver)5 CreateEnsembleOptions (io.fabric8.api.CreateEnsembleOptions)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 Configuration (org.osgi.service.cm.Configuration)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Map (java.util.Map)3 KeeperException (org.apache.zookeeper.KeeperException)3 Server (org.eclipse.jetty.server.Server)3 ServerConnector (org.eclipse.jetty.server.ServerConnector)3 Container (io.fabric8.api.Container)2 GitContext (io.fabric8.api.GitContext)2