Search in sources :

Example 1 with ContainerDTO

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

the class Containers method aliveAndSuccessfulContainers.

/**
 * Returns all the current alive and successful containers for the given profile which have completed provisioning
 */
public static List<ContainerDTO> aliveAndSuccessfulContainers(Iterable<ContainerDTO> allContainers) {
    List<ContainerDTO> answer = new ArrayList<>();
    for (ContainerDTO container : allContainers) {
        boolean alive = container.isAlive();
        boolean provisioningPending = container.isProvisioningPending();
        String provisionResult = container.getProvisionResult();
        boolean aliveAndProvisionSuccess = alive && !provisioningPending && Container.PROVISION_SUCCESS.equals(provisionResult);
        if (aliveAndProvisionSuccess) {
            answer.add(container);
        }
    }
    return answer;
}
Also used : ArrayList(java.util.ArrayList) ContainerDTO(io.fabric8.api.jmx.ContainerDTO)

Example 2 with ContainerDTO

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

the class FabricDTO method createContainerDTO.

public static ContainerDTO createContainerDTO(Container container, String baseApiLink) {
    ContainerDTO answer = new ContainerDTO();
    String containerId = container.getId();
    answer.setId(containerId);
    answer.setType(container.getType());
    answer.setChildren(Containers.containerIds(container.getChildren()));
    List<String> profileIds = Profiles.profileIds(container.getProfiles());
    String profileLinkPrefix = baseApiLink + "/version/" + Profiles.versionId(container.getVersion()) + "/profile/";
    answer.setProfiles(Links.mapIdsToLinks(profileIds, profileLinkPrefix));
    answer.setVersion(Profiles.versionId(container.getVersion()));
    answer.setParent(Containers.containerId(container.getParent()));
    answer.setIp(container.getIp());
    answer.setLocalIp(container.getLocalIp());
    answer.setManualIp(container.getManualIp());
    answer.setPublicIp(container.getPublicIp());
    answer.setLocalHostName(container.getLocalHostname());
    answer.setPublicHostName(container.getPublicHostname());
    answer.setResolver(container.getResolver());
    answer.setMaximumPort(container.getMaximumPort());
    answer.setMinimumPort(container.getMinimumPort());
    answer.setGeoLocation(container.getGeoLocation());
    answer.setLocation(container.getLocation());
    answer.setProcessId(container.getProcessId());
    answer.setDebugPort(container.getDebugPort());
    answer.setHttpUrl(container.getHttpUrl());
    answer.setJmxUrl(container.getJmxUrl());
    answer.setJolokiaUrl(container.getJolokiaUrl());
    answer.setSshUrl(container.getSshUrl());
    answer.setProvisionException(container.getProvisionException());
    answer.setProvisionResult(container.getProvisionResult());
    answer.setProvisionStatus(container.getProvisionStatus());
    answer.setProvisionList(container.getProvisionList());
    answer.setJmxDomains(container.getJmxDomains());
    answer.setAlive(container.isAlive());
    answer.setAliveAndOK(container.isAliveAndOK());
    answer.setEnsembleServer(container.isEnsembleServer());
    answer.setManaged(container.isManaged());
    answer.setProvisioningComplete(container.isProvisioningComplete());
    answer.setProvisioningPending(container.isProvisioningPending());
    answer.setRoot(container.isRoot());
    answer.setStartLink(baseApiLink + "/container/" + containerId + "/start");
    return answer;
}
Also used : ContainerDTO(io.fabric8.api.jmx.ContainerDTO)

Example 3 with ContainerDTO

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

the class FabricMBeanFacadeTest method testContainersWithFields.

@Test
public void testContainersWithFields() {
    // this can only be run if you have a fabric running...
    Assume.assumeTrue(Boolean.valueOf(System.getProperty("hasFabric")));
    FabricMBean facade = getFabricMBean();
    String json = facade.containers(Helpers.toList("id"));
    try {
        Collection<ContainerDTO> containers = Helpers.getObjectMapper().readValue(json, TypeFactory.defaultInstance().constructParametricType(Collection.class, ContainerDTO.class));
        Assume.assumeNotNull(containers);
        for (ContainerDTO container : containers) {
            System.out.println(container);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : FabricMBean(io.fabric8.jolokia.facade.mbeans.FabricMBean) Collection(java.util.Collection) Test(org.junit.Test)

Example 4 with ContainerDTO

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

the class FabricMBeanFacadeTest method testContainers.

@Test
public void testContainers() {
    // this can only be run if you have a fabric running...
    Assume.assumeTrue(Boolean.valueOf(System.getProperty("hasFabric")));
    FabricMBean facade = getFabricMBean();
    String json = facade.containers();
    try {
        Collection<ContainerDTO> containers = Helpers.getObjectMapper().readValue(json, TypeFactory.defaultInstance().constructParametricType(Collection.class, ContainerDTO.class));
        Assume.assumeNotNull(containers);
        for (ContainerDTO container : containers) {
            System.out.println(container);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : FabricMBean(io.fabric8.jolokia.facade.mbeans.FabricMBean) Collection(java.util.Collection) Test(org.junit.Test)

Aggregations

ContainerDTO (io.fabric8.api.jmx.ContainerDTO)2 FabricMBean (io.fabric8.jolokia.facade.mbeans.FabricMBean)2 Collection (java.util.Collection)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1