Search in sources :

Example 1 with Server

use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.

the class ServerConfigSource method getValue.

@Override
public String getValue(String propertyName) {
    String result = null;
    Server config = domainConfiguration.getServerNamed(configurationName);
    if (config != null) {
        result = config.getPropertyValue(PROPERTY_PREFIX + propertyName);
    }
    return result;
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server)

Example 2 with Server

use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.

the class SetCommand method replicateSetCommand.

private boolean replicateSetCommand(AdminCommandContext context, String targetName, String value) {
    // "domain." on the front of the attribute name is optional.  So if it is
    // there, strip it off.
    List<Server> replicationInstances = null;
    String tName;
    if (targetName.startsWith("domain.")) {
        tName = targetName.substring("domain.".length());
        if (tName.indexOf('.') == -1) {
            // This is a domain-level attribute, replicate to all instances
            replicationInstances = targetService.getAllInstances();
        }
    } else {
        tName = targetName;
    }
    if (replicationInstances == null) {
        int dotIdx = tName.indexOf('.');
        String firstElementOfName = dotIdx != -1 ? tName.substring(0, dotIdx) : tName;
        Integer targetElementLocation = targetLevel.get(firstElementOfName);
        if (targetElementLocation == null) {
            targetElementLocation = 1;
        }
        if (targetElementLocation == 0) {
            if ("resources".equals(firstElementOfName)) {
                replicationInstances = targetService.getAllInstances();
            }
            if ("applications".equals(firstElementOfName)) {
                String appName = getElementFromString(tName, 3);
                if (appName == null) {
                    fail(context, localStrings.getLocalString("admin.set.invalid.appname", "Unable to extract application name from {0}", targetName));
                    return false;
                }
                replicationInstances = targetService.getInstances(domain.getAllReferencedTargetsForApplication(appName));
            }
        } else {
            String target = getElementFromString(tName, targetElementLocation);
            if (target == null) {
                fail(context, localStrings.getLocalString("admin.set.invalid.target", "Unable to extract replication target from {0}", targetName));
                return false;
            }
            replicationInstances = targetService.getInstances(target);
        }
    }
    if (replicationInstances != null && !replicationInstances.isEmpty()) {
        ParameterMap params = new ParameterMap();
        params.set("DEFAULT", targetName + "=" + value);
        ActionReport.ExitCode ret = ClusterOperationUtil.replicateCommand("set", FailurePolicy.Error, FailurePolicy.Warn, FailurePolicy.Ignore, replicationInstances, context, params, habitat);
        if (ret.equals(ActionReport.ExitCode.FAILURE)) {
            return false;
        }
    }
    return true;
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server) ParameterMap(org.glassfish.api.admin.ParameterMap) ActionReport(org.glassfish.api.ActionReport)

Example 3 with Server

use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.

the class RestartHazelcast method isThisForMe.

private boolean isThisForMe() {
    boolean result = false;
    String instanceName = serverEnv.getInstanceName();
    if (instanceName.equals(target)) {
        result = true;
    }
    if (targetUtil.isCluster(target)) {
        List<Server> servers = targetUtil.getInstances(target);
        for (Server server : servers) {
            if (server.getName().equals(instanceName)) {
                result = true;
                break;
            }
        }
    } else if (target.equals("domain")) {
        result = true;
    }
    return result;
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server)

Example 4 with Server

use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.

the class NotificationEventFactory method initializeEvent.

protected E initializeEvent(E e) {
    try {
        e.setHostName(InetAddress.getLocalHost().getHostName());
    } catch (UnknownHostException ex) {
    // No-op
    }
    e.setDomainName(environment.getDomainName());
    e.setInstanceName(environment.getInstanceName());
    Server server = habitat.getService(Server.class, environment.getInstanceName());
    e.setServerName(server.getName());
    return e;
}
Also used : UnknownHostException(java.net.UnknownHostException) Server(com.sun.enterprise.config.serverbeans.Server)

Example 5 with Server

use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.

the class EjbDeployer method getOwnerId.

private String getOwnerId(String target) {
    // If target is a cluster or deployment group replace it with the instance
    List<Server> instances = Collections.EMPTY_LIST;
    Cluster cluster = domain.getClusterNamed(target);
    if (cluster != null) {
        instances = cluster.getInstances();
    } else {
        DeploymentGroup dg = domain.getDeploymentGroupNamed(target);
        if (dg != null) {
            instances = dg.getInstances();
        } else {
            return target;
        }
    }
    // Try a random instance in a cluster
    int useInstance = random.nextInt(instances.size());
    Server s0 = instances.get(useInstance);
    if (s0.isRunning()) {
        return s0.getName();
    } else {
        // Pick the first running instead
        for (Server s : instances) {
            if (s.isRunning()) {
                return s.getName();
            }
        }
    }
    // cluster
    return s0.getName();
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server) Cluster(com.sun.enterprise.config.serverbeans.Cluster) DeploymentGroup(fish.payara.enterprise.config.serverbeans.DeploymentGroup)

Aggregations

Server (com.sun.enterprise.config.serverbeans.Server)86 ActionReport (org.glassfish.api.ActionReport)27 Cluster (com.sun.enterprise.config.serverbeans.Cluster)26 Domain (com.sun.enterprise.config.serverbeans.Domain)16 Config (com.sun.enterprise.config.serverbeans.Config)15 ArrayList (java.util.ArrayList)12 DeploymentGroup (fish.payara.enterprise.config.serverbeans.DeploymentGroup)11 PropertyVetoException (java.beans.PropertyVetoException)11 Properties (java.util.Properties)10 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)10 HashMap (java.util.HashMap)9 ApplicationRef (com.sun.enterprise.config.serverbeans.ApplicationRef)8 File (java.io.File)8 IOException (java.io.IOException)8 Test (org.junit.Test)8 Property (org.jvnet.hk2.config.types.Property)8 Node (com.sun.enterprise.config.serverbeans.Node)7 Map (java.util.Map)7 Logger (java.util.logging.Logger)7 ParameterMap (org.glassfish.api.admin.ParameterMap)7