Search in sources :

Example 41 with Cluster

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

the class DuckMethodsTest method getClusterFromServerTest.

@Test
public void getClusterFromServerTest() {
    Domain d = habitat.getService(Domain.class);
    Server server = d.getServerNamed("server");
    assertTrue(server != null);
    Cluster cluster = server.getCluster();
    System.out.println("Cluster name is " + cluster.getName());
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server) Cluster(com.sun.enterprise.config.serverbeans.Cluster) Domain(com.sun.enterprise.config.serverbeans.Domain) ConfigApiTest(com.sun.enterprise.configapi.tests.ConfigApiTest) Test(org.junit.Test)

Example 42 with Cluster

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

the class ReferenceConstrainClusterTest method clusterConfigRefInvalid.

@Test
public void clusterConfigRefInvalid() throws TransactionFailure {
    Cluster cluster = habitat.getService(Cluster.class, "clusterA");
    assertNotNull(cluster);
    ConfigBean serverConfig = (ConfigBean) ConfigBean.unwrap(cluster);
    Map<ConfigBean, Map<String, String>> changes = new HashMap<ConfigBean, Map<String, String>>();
    Map<String, String> configChanges = new HashMap<String, String>();
    configChanges.put("config-ref", "server-config-nonexist");
    changes.put(serverConfig, configChanges);
    try {
        ConfigSupport cs = getHabitat().getService(ConfigSupport.class);
        cs.apply(changes);
        fail("Can not reach this point");
    } catch (TransactionFailure tf) {
        ConstraintViolationException cv = findConstrViolation(tf);
        assertNotNull(cv);
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ConfigSupport(org.jvnet.hk2.config.ConfigSupport) HashMap(java.util.HashMap) Cluster(com.sun.enterprise.config.serverbeans.Cluster) ConstraintViolationException(javax.validation.ConstraintViolationException) ConfigBean(org.jvnet.hk2.config.ConfigBean) HashMap(java.util.HashMap) Map(java.util.Map) ConfigApiTest(com.sun.enterprise.configapi.tests.ConfigApiTest) Test(org.junit.Test)

Example 43 with Cluster

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

the class ReferenceConstrainClusterTest method clusterConfigRefValid.

@Test
public void clusterConfigRefValid() throws TransactionFailure {
    Cluster cluster = habitat.getService(Cluster.class, "clusterA");
    assertNotNull(cluster);
    ConfigBean serverConfig = (ConfigBean) ConfigBean.unwrap(cluster);
    Map<ConfigBean, Map<String, String>> changes = new HashMap<ConfigBean, Map<String, String>>();
    Map<String, String> configChanges = new HashMap<String, String>();
    configChanges.put("config-ref", "server-config");
    changes.put(serverConfig, configChanges);
    try {
        ConfigSupport cs = getHabitat().getService(ConfigSupport.class);
        cs.apply(changes);
    } catch (TransactionFailure tf) {
        fail("Can not reach this point");
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ConfigSupport(org.jvnet.hk2.config.ConfigSupport) HashMap(java.util.HashMap) Cluster(com.sun.enterprise.config.serverbeans.Cluster) ConfigBean(org.jvnet.hk2.config.ConfigBean) HashMap(java.util.HashMap) Map(java.util.Map) ConfigApiTest(com.sun.enterprise.configapi.tests.ConfigApiTest) Test(org.junit.Test)

Example 44 with Cluster

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

the class DomainXml method decorate.

protected void decorate() {
    Server server = habitat.getService(Server.class, env.getInstanceName());
    if (server == null) {
        LogRecord lr = new LogRecord(Level.SEVERE, badEnv);
        lr.setLoggerName(getClass().getName());
        EarlyLogHandler.earlyMessages.add(lr);
        return;
    }
    ServiceLocatorUtilities.addOneConstant(habitat, server, ServerEnvironment.DEFAULT_INSTANCE_NAME, Server.class);
    server.getConfig().addIndex(habitat, ServerEnvironment.DEFAULT_INSTANCE_NAME);
    Cluster c = server.getCluster();
    if (c != null) {
        ServiceLocatorUtilities.addOneConstant(habitat, c, ServerEnvironment.DEFAULT_INSTANCE_NAME, Cluster.class);
    }
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server) LogRecord(java.util.logging.LogRecord) Cluster(com.sun.enterprise.config.serverbeans.Cluster)

Example 45 with Cluster

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

the class ConfigApiTest method decorate.

@Override
public void decorate(ServiceLocator habitat) {
    Server server = habitat.getService(Server.class, "server");
    if (server != null) {
        ActiveDescriptor<Server> serverDescriptor = BuilderHelper.createConstantDescriptor(server, ServerEnvironment.DEFAULT_INSTANCE_NAME, Server.class);
        ServiceLocatorUtilities.addOneDescriptor(habitat, serverDescriptor);
        server.getConfig().addIndex(habitat, ServerEnvironment.DEFAULT_INSTANCE_NAME);
        Cluster c = server.getCluster();
        if (c != null) {
            ActiveDescriptor<Cluster> clusterDescriptor = BuilderHelper.createConstantDescriptor(c, ServerEnvironment.DEFAULT_INSTANCE_NAME, Cluster.class);
            ServiceLocatorUtilities.addOneDescriptor(habitat, clusterDescriptor);
        }
    }
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server) Cluster(com.sun.enterprise.config.serverbeans.Cluster)

Aggregations

Cluster (com.sun.enterprise.config.serverbeans.Cluster)45 Server (com.sun.enterprise.config.serverbeans.Server)26 ActionReport (org.glassfish.api.ActionReport)12 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)9 Domain (com.sun.enterprise.config.serverbeans.Domain)8 HashMap (java.util.HashMap)8 Config (com.sun.enterprise.config.serverbeans.Config)6 DeploymentGroup (fish.payara.enterprise.config.serverbeans.DeploymentGroup)6 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 ServerRef (com.sun.enterprise.config.serverbeans.ServerRef)5 ConfigApiTest (com.sun.enterprise.configapi.tests.ConfigApiTest)5 PropertyVetoException (java.beans.PropertyVetoException)5 Test (org.junit.Test)5 SystemProperty (com.sun.enterprise.config.serverbeans.SystemProperty)4 Logger (java.util.logging.Logger)4 ConfigBean (org.jvnet.hk2.config.ConfigBean)4 ConfigSupport (org.jvnet.hk2.config.ConfigSupport)4 ApplicationRef (com.sun.enterprise.config.serverbeans.ApplicationRef)3 JmsService (com.sun.enterprise.connectors.jms.config.JmsService)3