Search in sources :

Example 31 with Configuration

use of io.fabric8.maven.core.model.Configuration in project fabric8 by jboss-fuse.

the class DownloadManagers method createDownloadManager.

/**
 * Creates a download manager using the current container's maven configuration
 */
public static DownloadManager createDownloadManager(FabricService fabricService, ScheduledExecutorService executorService) {
    Profile overlayProfile = fabricService.getCurrentContainer().getOverlayProfile();
    Profile effectiveProfile = Profiles.getEffectiveProfile(fabricService, overlayProfile);
    return createDownloadManager(fabricService, effectiveProfile, executorService);
}
Also used : Profile(io.fabric8.api.Profile)

Example 32 with Configuration

use of io.fabric8.maven.core.model.Configuration in project fabric8 by jboss-fuse.

the class BootstrapConfiguration method configureInternal.

void configureInternal(Map<String, ?> conf) throws Exception {
    configuration = configurer.configure(conf, this);
    if (Strings.isNullOrBlank(runtimeId)) {
        throw new IllegalArgumentException("Runtime id must not be null or empty.");
    }
    if (Strings.isNullOrBlank(localResolver)) {
        localResolver = globalResolver;
    }
    String decodedZookeeperPassword = null;
    Properties userProps = new Properties();
    try {
        userProps.load(new File(confDir, "users.properties"));
    } catch (IOException e) {
        LOGGER.warn("Failed to load users from etc/users.properties. No users will be imported.", e);
    }
    if (Strings.isNotBlank(zookeeperPassword)) {
        decodedZookeeperPassword = PasswordEncoder.decode(zookeeperPassword);
    } else if (userProps.containsKey(DEFAULT_ADMIN_USER)) {
        String passwordAndRole = userProps.getProperty(DEFAULT_ADMIN_USER).trim();
        decodedZookeeperPassword = passwordAndRole.substring(0, passwordAndRole.indexOf(ROLE_DELIMITER));
    } else {
        decodedZookeeperPassword = PasswordEncoder.encode(CreateEnsembleOptions.generatePassword());
    }
    // do not trigger io.fabric8.zookeeper update if restart is pending (fabric:join)
    if (!Boolean.getBoolean("karaf.restart") && zookeeperUrl != null && zookeeperPassword != null) {
        Configuration zkConfugiration = configAdmin.get().getConfiguration(Constants.ZOOKEEPER_CLIENT_PID);
        if (zkConfugiration.getProperties() == null) {
            Hashtable<String, Object> zkProperties = new Hashtable<>();
            zkProperties.put("zookeeper.url", zookeeperUrl);
            zkProperties.put("zookeeper.password", PasswordEncoder.encode(decodedZookeeperPassword));
            zkConfugiration.update(zkProperties);
        }
    }
    if (userProps.isEmpty()) {
        userProps.put(DEFAULT_ADMIN_USER, decodedZookeeperPassword + ROLE_DELIMITER + DEFAULT_ADMIN_ROLE);
    }
    String minimumPort = (String) configuration.get("minimum.port");
    if (!Strings.isNullOrBlank(minimumPort)) {
        this.minport = Integer.valueOf(minimumPort);
    }
    String maximumPort = (String) configuration.get("maximum.port");
    if (!Strings.isNullOrBlank(maximumPort)) {
        this.maxport = Integer.valueOf(maximumPort);
    }
    options = CreateEnsembleOptions.builder().bindAddress(bindAddress).agentEnabled(agentAutoStart).ensembleStart(ensembleAutoStart).zookeeperPassword(decodedZookeeperPassword).zooKeeperServerPort(zookeeperServerPort).zooKeeperServerConnectionPort(zookeeperServerConnectionPort).autoImportEnabled(profilesAutoImport).importPath(profilesAutoImportPath).resolver(localResolver).globalResolver(globalResolver).users(userProps).minimumPort(minport).maximumPort(maxport).profiles(profiles).version(version).build();
}
Also used : Configuration(org.osgi.service.cm.Configuration) Hashtable(java.util.Hashtable) IOException(java.io.IOException) RuntimeProperties(io.fabric8.api.RuntimeProperties) Properties(org.apache.felix.utils.properties.Properties) File(java.io.File)

Example 33 with Configuration

use of io.fabric8.maven.core.model.Configuration in project fabric8 by jboss-fuse.

the class ZooKeeperServerFactory method activateInternal.

private Destroyable activateInternal(BundleContext context, Map<String, ?> configuration) throws Exception {
    LOGGER.info("Creating zookeeper server with: {}", configuration);
    Properties props = new Properties();
    for (Entry<String, ?> entry : configuration.entrySet()) {
        props.put(entry.getKey(), entry.getValue());
    }
    // Remove the dependency on the current dir from dataDir
    String dataDir = props.getProperty("dataDir");
    if (dataDir != null && !Paths.get(dataDir).isAbsolute()) {
        dataDir = runtimeProperties.get().getDataPath().resolve(dataDir).toFile().getAbsolutePath();
        props.setProperty("dataDir", dataDir);
    }
    props.put("clientPortAddress", bootstrapConfiguration.get().getBindAddress());
    // Create myid file
    String serverId = (String) props.get("server.id");
    if (serverId != null) {
        props.remove("server.id");
        File myId = new File(dataDir, "myid");
        if (myId.exists() && !myId.delete()) {
            throw new IOException("Failed to delete " + myId);
        }
        if (myId.getParentFile() == null || (!myId.getParentFile().exists() && !myId.getParentFile().mkdirs())) {
            throw new IOException("Failed to create " + myId.getParent());
        }
        FileOutputStream fos = new FileOutputStream(myId);
        try {
            fos.write((serverId + "\n").getBytes());
        } finally {
            fos.close();
        }
    }
    QuorumPeerConfig peerConfig = getPeerConfig(props);
    if (!peerConfig.getServers().isEmpty()) {
        NIOServerCnxnFactory cnxnFactory = new NIOServerCnxnFactory();
        cnxnFactory.configure(peerConfig.getClientPortAddress(), peerConfig.getMaxClientCnxns());
        QuorumPeer quorumPeer = new QuorumPeer();
        quorumPeer.setClientPortAddress(peerConfig.getClientPortAddress());
        quorumPeer.setTxnFactory(new FileTxnSnapLog(new File(peerConfig.getDataLogDir()), new File(peerConfig.getDataDir())));
        quorumPeer.setQuorumPeers(peerConfig.getServers());
        quorumPeer.setElectionType(peerConfig.getElectionAlg());
        quorumPeer.setMyid(peerConfig.getServerId());
        quorumPeer.setTickTime(peerConfig.getTickTime());
        quorumPeer.setMinSessionTimeout(peerConfig.getMinSessionTimeout());
        quorumPeer.setMaxSessionTimeout(peerConfig.getMaxSessionTimeout());
        quorumPeer.setInitLimit(peerConfig.getInitLimit());
        quorumPeer.setSyncLimit(peerConfig.getSyncLimit());
        quorumPeer.setQuorumVerifier(peerConfig.getQuorumVerifier());
        quorumPeer.setCnxnFactory(cnxnFactory);
        quorumPeer.setZKDatabase(new ZKDatabase(quorumPeer.getTxnFactory()));
        quorumPeer.setLearnerType(peerConfig.getPeerType());
        try {
            LOGGER.debug("Starting quorum peer \"{}\" on address {}", quorumPeer.getMyid(), peerConfig.getClientPortAddress());
            quorumPeer.start();
            LOGGER.debug("Started quorum peer \"{}\"", quorumPeer.getMyid());
        } catch (Exception e) {
            LOGGER.warn("Failed to start quorum peer \"{}\", reason : {} ", quorumPeer.getMyid(), e.getMessage());
            quorumPeer.shutdown();
            throw e;
        }
        // Register stats provider
        ClusteredServer server = new ClusteredServer(quorumPeer);
        registration = context.registerService(QuorumStats.Provider.class, server, null);
        return server;
    } else {
        ServerConfig serverConfig = getServerConfig(peerConfig);
        ZooKeeperServer zkServer = new ZooKeeperServer();
        FileTxnSnapLog ftxn = new FileTxnSnapLog(new File(serverConfig.getDataLogDir()), new File(serverConfig.getDataDir()));
        zkServer.setTxnLogFactory(ftxn);
        zkServer.setTickTime(serverConfig.getTickTime());
        zkServer.setMinSessionTimeout(serverConfig.getMinSessionTimeout());
        zkServer.setMaxSessionTimeout(serverConfig.getMaxSessionTimeout());
        NIOServerCnxnFactory cnxnFactory = new NIOServerCnxnFactory() {

            protected void configureSaslLogin() throws IOException {
            }
        };
        cnxnFactory.configure(serverConfig.getClientPortAddress(), serverConfig.getMaxClientCnxns());
        try {
            LOGGER.debug("Starting ZooKeeper server on address {}", peerConfig.getClientPortAddress());
            cnxnFactory.startup(zkServer);
            LOGGER.debug("Started ZooKeeper server");
        } catch (Exception e) {
            LOGGER.warn("Failed to start ZooKeeper server, reason : {}", e);
            cnxnFactory.shutdown();
            throw e;
        }
        // Register stats provider
        SimpleServer server = new SimpleServer(zkServer, cnxnFactory);
        registration = context.registerService(ServerStats.Provider.class, server, null);
        startCleanupManager(serverConfig, props);
        return server;
    }
}
Also used : IOException(java.io.IOException) RuntimeProperties(io.fabric8.api.RuntimeProperties) Properties(java.util.Properties) FileTxnSnapLog(org.apache.zookeeper.server.persistence.FileTxnSnapLog) ConfigException(org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException) IOException(java.io.IOException) QuorumPeerConfig(org.apache.zookeeper.server.quorum.QuorumPeerConfig) FileOutputStream(java.io.FileOutputStream) QuorumPeer(org.apache.zookeeper.server.quorum.QuorumPeer) File(java.io.File)

Example 34 with Configuration

use of io.fabric8.maven.core.model.Configuration in project fabric8 by jboss-fuse.

the class ProxyServlet method init.

/**
 * Initialize the <code>ProxyServlet</code>
 *
 * @param config The Servlet configuration passed in by the servlet container
 */
@Override
public void init(ServletConfig config) throws ServletException {
    HttpProxyRuleBase ruleBase = new HttpProxyRuleBase();
    loadRuleBase(config, ruleBase);
    resolver.setMappingRules(ruleBase);
    Protocol.registerProtocol("http", new Protocol("http", new NonBindingSocketFactory(), 80));
    Protocol.registerProtocol("https", new Protocol("https", new NonBindingSocketFactory(), 443));
}
Also used : HttpProxyRuleBase(io.fabric8.gateway.model.HttpProxyRuleBase) Protocol(org.apache.commons.httpclient.protocol.Protocol) NonBindingSocketFactory(io.fabric8.gateway.servlet.support.NonBindingSocketFactory)

Example 35 with Configuration

use of io.fabric8.maven.core.model.Configuration in project fabric8 by jboss-fuse.

the class FabricCreateCommandTest method testLocalFabricCluster.

@Test
public void testLocalFabricCluster() throws Exception {
    CommandSupport.executeCommand("fabric:create --force --clean -n --wait-for-provisioning");
    FabricService fabricService = ServiceLocator.getRequiredService(FabricService.class);
    Container[] containers = fabricService.getContainers();
    Assert.assertNotNull("Containers not null", containers);
    // Test that a provided default password exists
    ConfigurationAdmin configurationAdmin = ServiceLocator.getRequiredService(ConfigurationAdmin.class);
    org.osgi.service.cm.Configuration configuration = configurationAdmin.getConfiguration(io.fabric8.api.Constants.ZOOKEEPER_CLIENT_PID);
    Dictionary<String, Object> dictionary = configuration.getProperties();
    Assert.assertEquals("Expected provided zookeeper password", PasswordEncoder.encode(ADMIN_PASSWORD), dictionary.get("zookeeper.password"));
}
Also used : Container(io.fabric8.api.Container) FabricService(io.fabric8.api.FabricService) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin) Test(org.junit.Test)

Aggregations

ParallelTest (io.strimzi.test.annotations.ParallelTest)142 Kafka (io.strimzi.api.kafka.model.Kafka)138 KafkaBuilder (io.strimzi.api.kafka.model.KafkaBuilder)132 HashMap (java.util.HashMap)97 IOException (java.io.IOException)86 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)83 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)80 Map (java.util.Map)79 StatefulSet (io.fabric8.kubernetes.api.model.apps.StatefulSet)76 ArrayList (java.util.ArrayList)76 List (java.util.List)70 TopologySpreadConstraint (io.fabric8.kubernetes.api.model.TopologySpreadConstraint)66 GenericKafkaListenerBuilder (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder)66 Matchers.containsString (org.hamcrest.Matchers.containsString)58 Service (io.fabric8.kubernetes.api.model.Service)55 Collectors (java.util.stream.Collectors)55 Container (io.fabric8.kubernetes.api.model.Container)54 PersistentVolumeClaim (io.fabric8.kubernetes.api.model.PersistentVolumeClaim)50 Quantity (io.fabric8.kubernetes.api.model.Quantity)48 File (java.io.File)47