Search in sources :

Example 6 with Start

use of io.fabric8.arquillian.kubernetes.event.Start in project docker-maven-plugin by fabric8io.

the class LogMatchCallbackTest method matchingLinesNonConformantToThePatternFails.

@Test
public void matchingLinesNonConformantToThePatternFails() throws Exception {
    final String patterString = "The start has started right now";
    final LogMatchCallback logMatchCallback = new LogMatchCallback(logger, callback, patterString);
    new Expectations() {

        {
            callback.matched();
            times = 0;
        }
    };
    logMatchCallback.log(1, new Timestamp(), "LOG:  database system is ready to accept connections");
}
Also used : Expectations(mockit.Expectations) Timestamp(io.fabric8.maven.docker.util.Timestamp) Test(org.junit.Test)

Example 7 with Start

use of io.fabric8.arquillian.kubernetes.event.Start in project fabric8 by jboss-fuse.

the class AbstractChildContainerCreateAction method preCreateContainer.

/**
 * Pre validates input before creating the container(s)
 *
 * @param name the name of the container to create
 * @throws IllegalArgumentException is thrown if input is invalid
 */
protected void preCreateContainer(String name) throws IllegalArgumentException {
    FabricValidations.validateContainerName(name);
    if (clusterService.getEnsembleContainers().isEmpty()) {
        return;
    }
    if (FabricCommand.doesContainerExist(fabricService, name)) {
        throw new IllegalArgumentException("A container with name " + name + " already exists.");
    }
    // get the profiles for the given version
    Version ver = version != null ? profileService.getRequiredVersion(version) : fabricService.getRequiredDefaultVersion();
    List<Profile> profiles = ver.getProfiles();
    // validate profiles exists before creating a new container
    Set<String> names = getProfileNames();
    for (String profile : names) {
        Profile prof = getProfile(profiles, profile, ver);
        if (prof == null) {
            throw new IllegalArgumentException("Profile " + profile + " with version " + ver.getId() + " does not exist.");
        }
        if (prof.isAbstract()) {
            throw new IllegalArgumentException("Profile " + profile + " with version " + ver.getId() + " is abstract and can not be associated to containers.");
        }
    }
    if (fabricService.getZookeeperUrl() == null) {
        throw new IllegalArgumentException("should start a zookeeper ensemble first.");
    }
}
Also used : Version(io.fabric8.api.Version) Profile(io.fabric8.api.Profile)

Example 8 with Start

use of io.fabric8.arquillian.kubernetes.event.Start in project fabric8 by jboss-fuse.

the class AbstractContainerCreateAction method preCreateContainer.

/**
 * Pre validates input before creating the container(s)
 *
 * @param name the name of the container to create
 * @throws IllegalArgumentException is thrown if input is invalid
 */
protected void preCreateContainer(String name) throws IllegalArgumentException {
    FabricValidations.validateContainerName(name);
    if (!isEnsembleServer) {
        if (clusterService.getEnsembleContainers().isEmpty()) {
            if (!isEnsembleServer) {
                throw new IllegalStateException("The use of the --ensemble-server option is mandatory when creating an initial container");
            }
            return;
        }
        if (FabricCommand.doesContainerExist(fabricService, name)) {
            throw new IllegalArgumentException("A container with name " + name + " already exists.");
        }
        // get the profiles for the given version
        Version ver = version != null ? profileService.getRequiredVersion(version) : fabricService.getRequiredDefaultVersion();
        List<Profile> profiles = ver.getProfiles();
        // validate profiles exists before creating a new container
        Set<String> names = getProfileNames();
        for (String profile : names) {
            Profile prof = getProfile(profiles, profile, ver);
            if (prof == null) {
                throw new IllegalArgumentException("Profile " + profile + " with version " + ver.getId() + " does not exist.");
            }
            if (prof.isAbstract()) {
                throw new IllegalArgumentException("Profile " + profile + " with version " + ver.getId() + " is abstract and can not be associated to containers.");
            }
        }
    }
    if (!isEnsembleServer && fabricService.getZookeeperUrl() == null) {
        throw new IllegalArgumentException("Either start a zookeeper ensemble or use --ensemble-server.");
    }
}
Also used : Version(io.fabric8.api.Version) Profile(io.fabric8.api.Profile)

Example 9 with Start

use of io.fabric8.arquillian.kubernetes.event.Start in project fabric8 by jboss-fuse.

the class ContainerEditJvmOptionsAction method doExecute.

protected Object doExecute() throws Exception {
    validateContainerName(container);
    if (!FabricCommand.doesContainerExist(fabricService, container)) {
        System.out.println("Container " + container + " does not exists!");
        return null;
    }
    Container containerInstance = FabricCommand.getContainerIfExists(fabricService, container);
    String type = containerInstance.getType();
    if (!"karaf".equals(type)) {
        System.out.println("Sorry, currently only \"karaf\" type container are supported");
        return null;
    }
    // read current jvm values
    FabricManager fabricManager = new FabricManager(fabricService);
    if (full) {
        String jmxUrl = null;
        JMXConnector connector = null;
        MBeanServerConnection remote = null;
        HashMap<String, String[]> authenticationData = null;
        jmxUrl = containerInstance.getJmxUrl();
        authenticationData = prepareAuthenticationData();
        try {
            connector = connectOrRetry(authenticationData, jmxUrl);
        } catch (Exception e) {
            username = null;
            password = null;
            System.out.println("Operation Failed. Check logs.");
            log.error("Unable to connect to JMX Server", e);
            return null;
        }
        ObjectName objName = new ObjectName(JAVA_LANG_OBJECT_NAME);
        try {
            remote = connector.getMBeanServerConnection();
            String[] arguments = (String[]) remote.getAttribute(objName, "InputArguments");
            String output = Arrays.toString(arguments);
            output = output.replaceAll(",", "");
            output = output.substring(1, output.length() - 1);
            System.out.println(output);
        } catch (Exception e) {
            System.out.println("Operation Failed. Check logs.");
            log.error("Unable to fetch child jvm opts", e);
        }
        try {
            connector.close();
        } catch (IOException e) {
            log.error("Errors closing remote MBean connection", e);
        }
    } else {
        try {
            String output = fabricManager.getJvmOpts(container);
            if ("Inapplicable".equals(output)) {
                String message = container + " jvmOpts cannot be handled within Fabric. You have to set required values directly in startup scripts.";
                System.out.println(message);
                log.error(message);
                return null;
            }
            if (jvmOptions == null) {
                System.out.println(output);
            } else {
                fabricManager.setJvmOpts(container, jvmOptions);
                System.out.println("Operation succeeded. New JVM flags will be loaded at the next start of " + container + " container");
                log.info("Updated JVM flags for container {}", container);
            }
        } catch (Exception e) {
            System.out.println("Operation Failed. Check logs.");
            log.error("Unable to set ssh jvm opts", e);
        }
    }
    return null;
}
Also used : Container(io.fabric8.api.Container) FabricManager(io.fabric8.core.jmx.FabricManager) JMXConnector(javax.management.remote.JMXConnector) IOException(java.io.IOException) MBeanServerConnection(javax.management.MBeanServerConnection) FabricAuthenticationException(io.fabric8.api.FabricAuthenticationException) IOException(java.io.IOException) ObjectName(javax.management.ObjectName)

Example 10 with Start

use of io.fabric8.arquillian.kubernetes.event.Start in project fabric8 by jboss-fuse.

the class MavenDownloadProxyServlet method start.

@Override
public synchronized void start() throws IOException {
    // Create a thread pool with the given maxmimum number of threads
    // All threads will time out after 60 seconds
    int nbThreads = threadMaximumPoolSize > 0 ? threadMaximumPoolSize : 8;
    executorService = new ThreadPoolExecutor(0, nbThreads, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new ThreadFactory("MavenDownloadProxyServlet"));
    if (this.timeout <= 0) {
        // default
        this.timeout = 5000;
    }
    LOGGER.info("Starting maven download servlet. Using async timeout value: " + this.timeout + "ms");
    super.start();
}
Also used : ThreadFactory(io.fabric8.utils.ThreadFactory) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue)

Aggregations

Test (org.junit.Test)25 IOException (java.io.IOException)24 File (java.io.File)18 HashMap (java.util.HashMap)15 Map (java.util.Map)10 Git (org.eclipse.jgit.api.Git)10 GitPatchRepository (io.fabric8.patch.management.impl.GitPatchRepository)8 ArrayList (java.util.ArrayList)8 Bundle (org.osgi.framework.Bundle)8 PatchException (io.fabric8.patch.management.PatchException)7 URISyntaxException (java.net.URISyntaxException)7 BundleException (org.osgi.framework.BundleException)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 CuratorFramework (org.apache.curator.framework.CuratorFramework)6 Container (io.fabric8.api.Container)5 CreateContainerMetadata (io.fabric8.api.CreateContainerMetadata)5 FabricService (io.fabric8.api.FabricService)5 GitPatchManagementServiceImpl (io.fabric8.patch.management.impl.GitPatchManagementServiceImpl)5 MalformedURLException (java.net.MalformedURLException)5 URI (java.net.URI)5