Package io.fabric8.api

Examples of io.fabric8.api.Container


        String containerId = options.getName();
        metadata.setCreateOptions(options);
        metadata.setContainerName(containerId);

        Container container = null;
        try {
            container = fabricService.getContainer(containerId);
        } catch (Exception e) {
            LOG.debug("Could not find container: " + containerId);
        }
        if (container != null) {
            container.setProvisionResult(Container.PROVISION_DOWNLOADING);
        }
        ProcessManager procManager = processManager;
        Map<String,String> initialEnvironmentVariables = new HashMap<String, String>();
        Installation installation = createInstallation(procManager, container, options, metadata, initialEnvironmentVariables);
        if (container != null) {
            container.setProvisionResult(Container.PROVISION_FINALIZING);
        }
        if (installation != null) {
            installation.getController().start();
        }
        return metadata;
View Full Code Here


    }

    protected DownloadStrategy createDownloadStrategy() throws MalformedURLException {
        // lets check we're in an active profile and not in a test case that has no profile
        if (fabricService != null) {
            Container container = fabricService.getCurrentContainer();
            if (container != null) {
                final DownloadManager downloadManager = DownloadManagers.createDownloadManager(fabricService, downloadExecutor);
                return new DownloadStrategy() {
                    @Override
                    public File downloadContent(URL sourceUrl, File installDir) throws IOException {
View Full Code Here

                }
            }
        }

        String jolokiaUrl = null;
        Container currentContainer = fabricService.getCurrentContainer();
        String listenHost = currentContainer.getLocalIp();
        if (Strings.isNullOrBlank(listenHost)) {
            listenHost = currentContainer.getLocalHostname();
        }
        if (Strings.isNullOrBlank(listenHost)) {
            listenHost = "localhost";
        }
        if (!environmentVariables.containsKey(EnvironmentVariables.FABRIC8_LISTEN_ADDRESS)) {
View Full Code Here

            }
        }
        TablePrinter table = new TablePrinter();
        table.columns("id", "resolver", "local hostname", "local ip", "public hostname", "public ip", "manual ip");
        for (String containerId : containerIds) {
            Container container = fabricService.getContainer(containerId);
            String localHostName = container.getLocalHostname();
            String localIp = container.getLocalIp();
            String publicHostName = container.getPublicHostname();
            String publicIp = container.getPublicIp();
            String manualIp = container.getManualIp();

            localHostName = localHostName != null ? localHostName : "";
            localIp = localIp != null ? localIp : "";
            publicHostName = publicHostName != null ? publicHostName : "";
            publicIp = publicIp != null ? publicIp : "";
            manualIp = manualIp != null ? manualIp : "";

            String resolver = container.getResolver();
            table.row(containerId, resolver, localHostName, localIp, publicHostName, publicIp, manualIp);
        }
        table.print();
        return null;
    }
View Full Code Here

    executeCommand("fabric:create -n");
        Set<ContainerProxy> containers = null;
        ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(bundleContext, FabricService.class);
        try {
            containers= ContainerBuilder.child(fabricProxy, 1).withName("child").assertProvisioningResult().build();
      Container childContainer = containers.iterator().next();
            Assert.assertEquals("Expected to find the child container", "child1", childContainer.getId());

      // Add the WildFly profile and start the process
      executeCommand("container-add-profile child1 controller-wildfly");
      Provision.containerStatus(containers, PROVISION_TIMEOUT);

      // FIXME: [FABRIC-541] process-list broken for remote containers
      // String response = executeCommand("process-list child1");

      SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss:SSS");

      // FIXME: [FABRIC-543] Provide a Process API that allows testing of managed processes
      File childHome = new File(System.getProperty("runtime.home") + "/instances/" + childContainer.getId());
      Assert.assertTrue("[" + df.format(new Date()) + "] Child home exists: " + childHome, childHome.exists());

      File procHome = new File(childHome + "/processes/1");
      System.out.println("[" + df.format(new Date()) + "] Waiting for: " + procHome);
      for (int i=0; !procHome.exists() && i < 30; i++) {
View Full Code Here

        ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(bundleContext, FabricService.class);
        try {
            Set<ContainerProxy> containers = ContainerBuilder.create(fabricProxy, 2).withName("child").withProfiles("default").assertProvisioningResult().build();
            try {
                LinkedList<Container> containerList = new LinkedList<Container>(containers);
                Container broker = containerList.removeLast();

                Profile brokerProfile = broker.getVersion().getRequiredProfile("mq-broker-default.mq");
                broker.setProfiles(new Profile[]{brokerProfile});

                Provision.provisioningSuccess(Arrays.asList(broker), PROVISION_TIMEOUT);

                waitForBroker("default");

                final BrokerViewMBean bean = (BrokerViewMBean)Provision.getMBean(broker, new ObjectName("org.apache.activemq:type=Broker,brokerName=mq"), BrokerViewMBean.class, 120000);
                Assert.assertNotNull("Cannot get BrokerViewMBean from JMX", bean);

                System.out.println(executeCommand("container-list"));

                for (Container c : containerList) {
                    Profile exampleProfile = broker.getVersion().getRequiredProfile("example-mq");
                    c.setProfiles(new Profile[]{exampleProfile});
                }

                Provision.provisioningSuccess(containers, PROVISION_TIMEOUT);
View Full Code Here

        ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(bundleContext, FabricService.class);
        try {
            Set<ContainerProxy> containers = ContainerBuilder.create(fabricProxy, 4).withName("child").withProfiles("default").assertProvisioningResult().build();
            try {
                LinkedList<Container> containerList = new LinkedList<Container>(containers);
                Container eastBroker = containerList.removeLast();
                Container westBroker = containerList.removeLast();

                Profile eastBrokerProfile = eastBroker.getVersion().getRequiredProfile("mq-broker-us-east.us-east");
                eastBroker.setProfiles(new Profile[]{eastBrokerProfile});

                Profile westBrokerProfile = eastBroker.getVersion().getRequiredProfile("mq-broker-us-west.us-west");
                westBroker.setProfiles(new Profile[]{westBrokerProfile});

                Provision.provisioningSuccess(Arrays.asList(westBroker, eastBroker), PROVISION_TIMEOUT);

                waitForBroker("us-east");
                waitForBroker("us-west");

                final BrokerViewMBean brokerEast = (BrokerViewMBean)Provision.getMBean(eastBroker, new ObjectName("org.apache.activemq:type=Broker,brokerName=us-east"), BrokerViewMBean.class, 120000);
                final BrokerViewMBean brokerWest = (BrokerViewMBean)Provision.getMBean(westBroker, new ObjectName("org.apache.activemq:type=Broker,brokerName=us-west"), BrokerViewMBean.class, 120000);
                Assert.assertNotNull("Cannot get BrokerViewMBean from JMX", brokerEast);
                Assert.assertNotNull("Cannot get BrokerViewMBean from JMX", brokerWest);

                Container eastProducer = containerList.removeLast();
                executeCommand("container-add-profile " + eastProducer.getId()+" example-mq-producer mq-client-us-east");
                Container westConsumer = containerList.removeLast();
                executeCommand("container-add-profile " + westConsumer.getId() + " example-mq-consumer mq-client-us-west");

                Provision.provisioningSuccess(Arrays.asList(eastProducer, westConsumer), PROVISION_TIMEOUT);

                System.out.println(executeCommand("fabric:container-list"));
View Full Code Here

public class WaitForProvisionTaskTest {

    @Test
    public void testStraightSuccess() throws Exception {
        Container container = createMock(Container.class);
        expect(container.getId()).andReturn("container").anyTimes();
        expect(container.isAlive()).andReturn(true).anyTimes();
        expect(container.isManaged()).andReturn(true).anyTimes();
        expect(container.getProvisionStatus()).andReturn("success").anyTimes();
        expect(container.getSshUrl()).andReturn("container:8181").anyTimes();
        expect(container.getProvisionException()).andReturn(null).anyTimes();

        replay(container);

        WaitForProvisionTask task = new WaitForProvisionTask(container, "success", 10000L);
        assertTrue(task.call());
View Full Code Here

        verify(container);
    }

    @Test
    public void testSuccess() throws Exception {
        Container container = createMock(Container.class);
        expect(container.getId()).andReturn("container").anyTimes();
        expect(container.isAlive()).andReturn(false).times(6);
        expect(container.isAlive()).andReturn(true).anyTimes();
        expect(container.isManaged()).andReturn(true).anyTimes();
        expect(container.getProvisionStatus()).andReturn("").times(3);
        expect(container.getProvisionStatus()).andReturn("analyzing").times(3);
        expect(container.getProvisionStatus()).andReturn("success").anyTimes();
        expect(container.getSshUrl()).andReturn("container:8181").anyTimes();
        expect(container.getProvisionException()).andReturn(null).anyTimes();

        replay(container);

        WaitForProvisionTask task = new WaitForProvisionTask(container, "success", 10000L);
        assertTrue(task.call());
View Full Code Here

            assertTrue("Expected successful creation of remote ssh container", metadata[0].isSuccess());
            assertNotNull("Expected successful creation of remote ssh container", metadata[0].getContainer());
            Provision.containersStatus(Arrays.asList(metadata[0].getContainer()), "success", PROVISION_TIMEOUT);
            System.out.println(executeCommand("fabric:container-list -v"));
            System.out.println(executeCommand("fabric:container-resolver-list"));
            Container ssh1 = fabricService.getContainer("ssh1");
            assertTrue(ssh1.isAlive());
            createAndAssertChildContainer(fabricService, "ssh2", "ssh1", "default");

            //Stop & Start Remote Child
            Container ssh2 = fabricService.getContainer("ssh2");
            ssh2.stop();
            assertFalse(ssh2.isAlive());
            ssh2.start();
            Provision.containersStatus(Arrays.asList(ssh2), "success", PROVISION_TIMEOUT);
            assertTrue(ssh2.isAlive());
            ssh2.stop();

            //Try stopping and starting the remote container.
            ssh1.stop();
            assertFalse(ssh1.isAlive());
            System.out.println(executeCommand("fabric:container-list -v"));
View Full Code Here

TOP

Related Classes of io.fabric8.api.Container

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.