Search in sources :

Example 16 with DeploymentGroup

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

the class DGTest method getNamedDeploymentGroup.

@Test
public void getNamedDeploymentGroup() {
    Domain d = habitat.getService(Domain.class);
    DeploymentGroups dgs = d.getDeploymentGroups();
    assertNotNull("Deployment Groups should not be null", dgs);
    DeploymentGroup dg = dgs.getDeploymentGroup("dg1");
    assertNotNull("Deployment Group should not be null", dg);
    assertEquals("Deployment Group Name should be dg1", "dg1", dg.getName());
}
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 17 with DeploymentGroup

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

the class DGTest method testGetServersFromDG.

@Test
public void testGetServersFromDG() {
    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());
    // get first named group
    DeploymentGroup dg = dgs.getDeploymentGroup("dg1");
    assertNotNull("Deployment Group dg1 should not be null", dg);
    List<Server> servers = dg.getInstances();
    assertNotNull("Servers List for dg1 should not be null", servers);
    assertEquals("List should have 1 Server", 1L, servers.size());
    Server server = servers.get(0);
    assertNotNull("Server for dg1 should not be null", server);
    assertEquals("Server should be called server", "server", server.getName());
    // get second named group
    dg = dgs.getDeploymentGroup("dg2");
    assertNotNull("Deployment Group dg2 should not be null", dg);
    servers = dg.getInstances();
    assertNotNull("Servers List for dg2 should not be null", servers);
    assertEquals("List should have 2 Servers", 2L, servers.size());
    server = servers.get(0);
    assertNotNull("First Server for dg2 should not be null", server);
    assertEquals("First Server should be called server", "server", server.getName());
    server = servers.get(1);
    assertNotNull("Second Server for dg2 should not be null", server);
    assertEquals("Second Server should be called server2", "server2", server.getName());
}
Also used : DeploymentGroups(fish.payara.enterprise.config.serverbeans.DeploymentGroups) 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 18 with DeploymentGroup

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

the class DGTest method testGetDeploymentGroupsForServer.

@Test
public void testGetDeploymentGroupsForServer() {
    Domain d = habitat.getService(Domain.class);
    DeploymentGroup dg1 = d.getDeploymentGroupNamed("dg1");
    List<DeploymentGroup> dgs = d.getDeploymentGroupsForInstance("server");
    assertEquals("List should have 2 Deployment Groups", 2L, dgs.size());
}
Also used : 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 19 with DeploymentGroup

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

the class DeleteResourceRef method execute.

/**
 * Executes the command with the command parameters passed as Properties
 * where the keys are the parameter names and the values the parameter values
 *
 * @param context information
 */
@Override
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    try {
        deleteResourceRef();
        if (refContainer instanceof Cluster) {
            // delete ResourceRef for all instances of Cluster
            Target tgt = habitat.getService(Target.class);
            List<Server> instances = tgt.getInstances(target);
            for (Server svr : instances) {
                svr.deleteResourceRef(refName);
            }
        }
        if (refContainer instanceof DeploymentGroup) {
            // delete ResourceRef for all instances of Cluster
            Target tgt = habitat.getService(Target.class);
            List<Server> instances = tgt.getInstances(target);
            for (Server svr : instances) {
                svr.deleteResourceRef(refName);
            }
        }
    } catch (Exception e) {
        setFailureMessage(report, e);
        return;
    }
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    report.setMessage(LOCAL_STRINGS.getLocalString("delete.resource.ref.success", "resource-ref {0} deleted successfully from target {1}.", refName, target));
}
Also used : Target(org.glassfish.internal.api.Target) CommandTarget(org.glassfish.config.support.CommandTarget) ActionReport(org.glassfish.api.ActionReport) DeploymentGroup(fish.payara.enterprise.config.serverbeans.DeploymentGroup)

Example 20 with DeploymentGroup

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

the class CreateResourceRef method execute.

/**
 * Executes the command with the command parameters passed as Properties
 * where the keys are the parameter names and the values the parameter values
 *
 * @param context information
 */
@Override
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    if (isResourceRefAlreadyPresent()) {
        report.setMessage(LOCAL_STRINGS.getLocalString("create.resource.ref.existsAlready", "Resource ref {0} already exists for target {1}", refName, target));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    try {
        createResourceRef();
        // create new ResourceRef for all instances of Cluster, if it's a cluster
        if (refContainer instanceof Cluster && isElegibleResource(refName)) {
            Target tgt = locator.getService(Target.class);
            List<Server> instances = tgt.getInstances(target);
            for (Server server : instances) {
                server.createResourceRef(enabled.toString(), refName);
            }
        }
        // create new ResourceRef for all instances of DeploymentGroup, if it's a DeploymentGroup
        if (refContainer instanceof DeploymentGroup && isElegibleResource(refName)) {
            DeploymentGroup deploymentGroup = (DeploymentGroup) refContainer;
            for (Server server : deploymentGroup.getInstances()) {
                if (server.getResourceRef(refName) == null) {
                    server.createResourceRef(enabled.toString(), refName);
                }
            }
        }
        ActionReport.ExitCode ec = ActionReport.ExitCode.SUCCESS;
        report.setMessage(LOCAL_STRINGS.getLocalString("create.resource.ref.success", "resource-ref {0} created successfully.", refName));
        report.setActionExitCode(ec);
    } catch (TransactionFailure tfe) {
        report.setMessage(LOCAL_STRINGS.getLocalString("create.resource.ref.failed", "Resource ref {0} creation failed", refName));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(tfe);
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) Target(org.glassfish.internal.api.Target) CommandTarget(org.glassfish.config.support.CommandTarget) ActionReport(org.glassfish.api.ActionReport) 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