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());
}
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());
}
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());
}
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));
}
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);
}
}
Aggregations