Search in sources :

Example 51 with Server

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

the class ActiveJmsResourceAdapter method startResourceAdapter.

@Override
protected void startResourceAdapter(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
    JmsService jmsService = getJmsService();
    if (jmsService != null && jmsService.getType().equals("DISABLED")) {
        return;
    }
    try {
        if (this.moduleName_.equals(ConnectorRuntime.DEFAULT_JMS_ADAPTER)) {
            if (connectorRuntime.isServer()) {
                Domain domain = Globals.get(Domain.class);
                ServerContext serverContext = Globals.get(ServerContext.class);
                Server server = domain.getServerNamed(serverContext.getInstanceName());
                try {
                    initializeLazyListener(jmsService);
                } catch (Throwable ex) {
                    Logger.getLogger(ActiveJmsResourceAdapter.class.getName()).log(Level.SEVERE, null, ex);
                    throw new ResourceAdapterInternalException(ex);
                }
            }
            // System.setProperty("imq.jmsra.direct.clustered", "true");
            AccessController.doPrivileged(new java.security.PrivilegedExceptionAction() {

                public Object run() throws ResourceAdapterInternalException {
                    // set the JMSRA system property to enable XA JOINS
                    // disabling this due to issue - 8727
                    // System.setProperty(XA_JOIN_ALLOWED, "true");
                    // to prevent classloader leaks in new threads clear invocation manager before bootstrapping JMS
                    resourceadapter_.start(bootStrapContextImpl);
                    return null;
                }
            });
        // setResourceAdapter(resourceadapter_);
        } else {
            resourceadapter_.start(bootStrapContextImpl);
        }
    } catch (PrivilegedActionException ex) {
        throw new ResourceAdapterInternalException(ex);
    }
}
Also used : JmsService(com.sun.enterprise.connectors.jms.config.JmsService) ServerContext(org.glassfish.internal.api.ServerContext) Server(com.sun.enterprise.config.serverbeans.Server) PrivilegedActionException(java.security.PrivilegedActionException) ResourceAdapterInternalException(javax.resource.spi.ResourceAdapterInternalException) Domain(com.sun.enterprise.config.serverbeans.Domain) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction)

Example 52 with Server

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

the class ActiveJmsResourceAdapter method isDBEnabled.

private boolean isDBEnabled() {
    Domain domain = Globals.get(Domain.class);
    ServerContext serverContext = Globals.get(ServerContext.class);
    Server server = domain.getServerNamed(serverContext.getInstanceName());
    AvailabilityService as = server.getConfig().getAvailabilityService();
    if (as != null) {
        JmsAvailability jmsAvailability = as.getExtensionByType(JmsAvailability.class);
        if (jmsAvailability.getAvailabilityEnabled() != null && Boolean.parseBoolean(jmsAvailability.getAvailabilityEnabled())) {
            return true;
        } else if (jmsAvailability.getConfigStoreType() != null && !"MASTERBROKER".equalsIgnoreCase(jmsAvailability.getConfigStoreType()))
            return true;
    }
    return false;
}
Also used : AvailabilityService(com.sun.enterprise.config.serverbeans.AvailabilityService) ServerContext(org.glassfish.internal.api.ServerContext) Server(com.sun.enterprise.config.serverbeans.Server) JmsAvailability(com.sun.enterprise.connectors.jms.config.JmsAvailability) Domain(com.sun.enterprise.config.serverbeans.Domain)

Example 53 with Server

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

the class JMSPing method execute.

/**
 * Executes the command with the command parameters passed as Properties
 * where the keys are the paramter names and the values the parameter values
 *
 * @param context information
 */
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    Server targetServer = domain.getServerNamed(target);
    // String configRef = targetServer.getConfigRef();
    if (targetServer != null) {
        config = domain.getConfigNamed(targetServer.getConfigRef());
    }
    com.sun.enterprise.config.serverbeans.Cluster cluster = domain.getClusterNamed(target);
    if (cluster != null) {
        config = domain.getConfigNamed(cluster.getConfigRef());
    }
    JmsService jmsservice = config.getExtensionByType(JmsService.class);
    /* for (Config c : configs.getConfig()) {

                      if(configRef.equals(c.getName()))
                            jmsservice = c.getJmsService();
                   } */
    String defaultJmshostStr = jmsservice.getDefaultJmsHost();
    JmsHost defaultJmsHost = null;
    for (JmsHost jmshost : jmsservice.getJmsHost()) {
        if (jmshost.getName().equals(defaultJmshostStr)) {
            defaultJmsHost = jmshost;
        }
    }
    if (defaultJmsHost == null) {
        report.setMessage(localStrings.getLocalString("jms-ping.noDefaultJMSHost", "Unable to PING the JMS Broker as no Default JMS Host is configured on the DAS"));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    String tmpJMSResource = "test_jms_adapter";
    ActionReport subReport = report.addSubActionsReport();
    createJMSResource(defaultJmsHost, subReport, tmpJMSResource, context.getSubject());
    if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())) {
        report.setMessage(localStrings.getLocalString("jms-ping.cannotCreateJMSResource", "Unable to create a temporary Connection Factory to the JMS Host"));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    try {
        boolean value = pingConnectionPool(tmpJMSResource + JNDINAME_APPENDER);
        if (!value) {
            report.setMessage(localStrings.getLocalString("jms-ping.pingConnectionPoolFailed", "Pinging to the JMS Host failed."));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        } else {
            report.setMessage(localStrings.getLocalString("jms-ping.pingConnectionPoolSuccess", "JMS-ping command executed successfully"));
            report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
        }
    } catch (ResourceException e) {
        report.setMessage(localStrings.getLocalString("jms-ping.pingConnectionPoolException", "An exception occured while trying to ping the JMS Host.", e.getMessage()));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    }
    deleteJMSResource(subReport, tmpJMSResource, context.getSubject());
    if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())) {
        report.setMessage(localStrings.getLocalString("jms-ping.cannotdeleteJMSResource", "Unable to delete the temporary JMS Resource " + tmpJMSResource + ". Please delete this manually.", tmpJMSResource));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server) JmsService(com.sun.enterprise.connectors.jms.config.JmsService) ResourceException(javax.resource.ResourceException) ActionReport(org.glassfish.api.ActionReport) JmsHost(com.sun.enterprise.connectors.jms.config.JmsHost) Cluster(com.sun.enterprise.config.serverbeans.Cluster)

Example 54 with Server

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

the class MigrateTimers method validateCluster.

private String validateCluster() {
    // verify fromServer is clusteredInstance
    Cluster fromServerCluster = targetUtil.getClusterForInstance(fromServer);
    if (fromServerCluster == null) {
        return localStrings.getString("migrate.timers.fromServerNotClusteredInstance", fromServer);
    }
    // verify fromServer is not running
    if (isServerRunning(fromServer)) {
        return localStrings.getString("migrate.timers.migrateFromServerStillRunning", fromServer);
    }
    // in the same cluster as fromServer
    if (target.equals(SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME)) {
        List<Server> instances = fromServerCluster.getInstances();
        for (Server instance : instances) {
            if (instance.isRunning()) {
                target = instance.getName();
                needRedirect = true;
            }
        }
        // if destination is still DAS, that means no running server is available
        if (target.equals(SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME)) {
            return localStrings.getString("migrate.timers.noRunningInstanceToChoose", target);
        }
    } else {
        // verify fromServer and destinationServer are in the same cluster, and
        // verify destination is a clustered instance.
        Cluster destinationServerCluster = targetUtil.getClusterForInstance(target);
        if (!fromServerCluster.getName().equals(destinationServerCluster.getName())) {
            return localStrings.getString("migrate.timers.fromServerAndTargetNotInSameCluster", fromServer, target);
        }
        // verify destinationServer is running
        if (!isServerRunning(target)) {
            return localStrings.getString("migrate.timers.destinationServerIsNotAlive", target);
        }
    }
    return null;
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server) Cluster(com.sun.enterprise.config.serverbeans.Cluster)

Example 55 with Server

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

the class GetHostAndPortCommand method getAccessChecks.

@Override
public Collection<? extends AccessCheck> getAccessChecks() {
    final List<AccessCheck> accessChecks = new ArrayList<AccessCheck>();
    String configName = null;
    Server server = domain.getServerNamed(target);
    if (server != null) {
        configName = server.getConfigRef();
    } else {
        Cluster cluster = domain.getClusterNamed(target);
        if (cluster != null) {
            configName = cluster.getConfigRef();
        }
    }
    config = configs.getConfigByName(configName);
    if (config != null) {
        accessChecks.add(new AccessCheck(AccessRequired.Util.resourceNameFromConfigBeanProxy(config), "read"));
    }
    return accessChecks;
}
Also used : AccessCheck(org.glassfish.api.admin.AccessRequired.AccessCheck) VirtualServer(com.sun.enterprise.config.serverbeans.VirtualServer) Server(com.sun.enterprise.config.serverbeans.Server) ArrayList(java.util.ArrayList) Cluster(com.sun.enterprise.config.serverbeans.Cluster)

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