Search in sources :

Example 6 with DeploymentGroup

use of fish.payara.enterprise.config.serverbeans.DeploymentGroup in project Payara by payara.

the class CreateApplicationRefCommand method isDeploymentGroup.

private boolean isDeploymentGroup(String target) {
    boolean isDeploymentGroup = false;
    List<DeploymentGroup> listOfDeploymentGroups = domain.getDeploymentGroups().getDeploymentGroup();
    for (DeploymentGroup deploymentGroup : listOfDeploymentGroups) {
        if (deploymentGroup.getName().equals(target)) {
            isDeploymentGroup = true;
            break;
        }
    }
    return isDeploymentGroup;
}
Also used : DeploymentGroup(fish.payara.enterprise.config.serverbeans.DeploymentGroup)

Example 7 with DeploymentGroup

use of fish.payara.enterprise.config.serverbeans.DeploymentGroup in project Payara by payara.

the class DGTest method testThereAreTwo.

@Test
public void testThereAreTwo() {
    Domain d = habitat.getService(Domain.class);
    DeploymentGroups dgs = d.getDeploymentGroups();
    assertNotNull("Deployment Groups should not be null", dgs);
    List<DeploymentGroup> ldg = dgs.getDeploymentGroup();
    assertNotNull("Deployment Groups List should not be null", ldg);
    assertEquals("List should have 2 deployment groups", 2L, ldg.size());
}
Also used : DeploymentGroups(fish.payara.enterprise.config.serverbeans.DeploymentGroups) Domain(com.sun.enterprise.config.serverbeans.Domain) DeploymentGroup(fish.payara.enterprise.config.serverbeans.DeploymentGroup) ConfigApiTest(com.sun.enterprise.configapi.tests.ConfigApiTest) Test(org.junit.Test)

Example 8 with DeploymentGroup

use of fish.payara.enterprise.config.serverbeans.DeploymentGroup in project Payara by payara.

the class DGTest method getDeploymentGroupFromServerTest.

@Test
public void getDeploymentGroupFromServerTest() {
    Domain d = habitat.getService(Domain.class);
    Server server = d.getServerNamed("server2");
    assertTrue(server != null);
    List<DeploymentGroup> dgs = server.getDeploymentGroup();
    assertEquals("List should have 1 element", 1L, dgs.size());
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server) Domain(com.sun.enterprise.config.serverbeans.Domain) DeploymentGroup(fish.payara.enterprise.config.serverbeans.DeploymentGroup) ConfigApiTest(com.sun.enterprise.configapi.tests.ConfigApiTest) Test(org.junit.Test)

Example 9 with DeploymentGroup

use of fish.payara.enterprise.config.serverbeans.DeploymentGroup in project Payara by payara.

the class DeploymentUtils method getVirtualServers.

/*
     * @return comma-separated list of all defined virtual servers (exclusive
     * of __asadmin) on the specified target
     */
public static String getVirtualServers(String target, ServerEnvironment env, Domain domain) {
    if (target == null) {
        // return null;
        // work around till the OE sets the virtualservers param when it's
        // handling the default target
        target = "server";
    }
    if (env.isDas() && DeploymentUtils.isDomainTarget(target)) {
        target = "server";
    }
    StringBuilder sb = new StringBuilder();
    boolean first = true;
    Server server = domain.getServerNamed(target);
    Config config = null;
    if (server != null) {
        config = domain.getConfigs().getConfigByName(server.getConfigRef());
    } else {
        Cluster cluster = domain.getClusterNamed(target);
        if (cluster != null) {
            config = domain.getConfigs().getConfigByName(cluster.getConfigRef());
        } else {
            DeploymentGroup dg = domain.getDeploymentGroupNamed(target);
            if (dg != null) {
                // get the first server in the group
                List<Server> servers = dg.getInstances();
                if (servers != null && servers.size() >= 1) {
                    config = servers.get(0).getConfig();
                }
            }
        }
    }
    if (config != null) {
        HttpService httpService = config.getHttpService();
        if (httpService != null) {
            List<VirtualServer> hosts = httpService.getVirtualServer();
            if (hosts != null) {
                for (VirtualServer host : hosts) {
                    if (("__asadmin").equals(host.getId())) {
                        continue;
                    }
                    if (first) {
                        sb.append(host.getId());
                        first = false;
                    } else {
                        sb.append(",");
                        sb.append(host.getId());
                    }
                }
            }
        }
    }
    return sb.toString();
}
Also used : DeploymentGroup(fish.payara.enterprise.config.serverbeans.DeploymentGroup)

Example 10 with DeploymentGroup

use of fish.payara.enterprise.config.serverbeans.DeploymentGroup in project Payara by payara.

the class ListDeploymentGroupsCommand method execute.

@Override
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    DeploymentGroups deploymentGroups = domain.getDeploymentGroups();
    List<DeploymentGroup> listOfDeploymentGroup = deploymentGroups.getDeploymentGroup();
    ArrayList<String> deploymentGroupNames = new ArrayList<>();
    if (listOfDeploymentGroup.isEmpty()) {
        report.appendMessage("No Deployment Group has been created");
    } else {
        StringBuilder sb = new StringBuilder();
        sb.append("List of Deployment Groups" + ":\n");
        for (DeploymentGroup deploymentGroup : listOfDeploymentGroup) {
            sb.append("\t" + deploymentGroup.getName() + "\n");
            deploymentGroupNames.add(deploymentGroup.getName());
        }
        report.setMessage(sb.toString());
    }
    Properties extrasProps = new Properties();
    extrasProps.put("listOfDeploymentGroups", deploymentGroupNames);
    report.setExtraProperties(extrasProps);
}
Also used : DeploymentGroups(fish.payara.enterprise.config.serverbeans.DeploymentGroups) ArrayList(java.util.ArrayList) ActionReport(org.glassfish.api.ActionReport) Properties(java.util.Properties) DeploymentGroup(fish.payara.enterprise.config.serverbeans.DeploymentGroup)

Aggregations

DeploymentGroup (fish.payara.enterprise.config.serverbeans.DeploymentGroup)25 ActionReport (org.glassfish.api.ActionReport)10 Server (com.sun.enterprise.config.serverbeans.Server)9 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)7 ArrayList (java.util.ArrayList)6 Cluster (com.sun.enterprise.config.serverbeans.Cluster)5 Domain (com.sun.enterprise.config.serverbeans.Domain)5 ConfigApiTest (com.sun.enterprise.configapi.tests.ConfigApiTest)5 Test (org.junit.Test)5 DeploymentGroups (fish.payara.enterprise.config.serverbeans.DeploymentGroups)4 ApplicationRef (com.sun.enterprise.config.serverbeans.ApplicationRef)3 ResourceRef (com.sun.enterprise.config.serverbeans.ResourceRef)3 PropertyVetoException (java.beans.PropertyVetoException)3 Logger (java.util.logging.Logger)3 ParameterMap (org.glassfish.api.admin.ParameterMap)3 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)3 DGServerRef (fish.payara.enterprise.config.serverbeans.DGServerRef)2 IOException (java.io.IOException)2 Properties (java.util.Properties)2 DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)2