Package org.rioproject.opstring

Examples of org.rioproject.opstring.ServiceElement


            loader.parseOperationalString(
                new File("src/test/resources/opstring/simple_opstring.groovy"));
        org.junit.Assert.assertEquals(1, opstrings.length);
        OpString opstring = (OpString)opstrings[0];
        org.junit.Assert.assertEquals(1, opstring.getServices().length);
        ServiceElement service = opstring.getServices()[0];
        service.setPlanned(maintain);
        service.setMaxPerMachine(maxPerMachine);
            service.setProvisionType(fixed?
                                     ServiceElement.ProvisionType.FIXED:
                                     ServiceElement.ProvisionType.DYNAMIC);

        prevCounts = CybernodeUtils.calcServices(cyberMon.getServices(),
                                                 Simple.class);
View Full Code Here


            loader.parseOperationalString(new File("src/test/resources/opstring/simple_opstring.groovy"));
        org.junit.Assert.assertEquals(1, opstrings.length);
        OpString opstring = (OpString)opstrings[0];
        logger.info("Loaded "+opstring.getName());
        org.junit.Assert.assertEquals(1, opstring.getServices().length);
        ServiceElement service = opstring.getServices()[0];
        service.setProvisionType(fixed? ServiceElement.ProvisionType.FIXED : ServiceElement.ProvisionType.DYNAMIC);
        if (maintain < 0) {
            try {
                service.setPlanned(maintain);
                Assert.fail("IllegalArgumentException expected but not thrown");
            } catch (IllegalArgumentException e) {
            }
            logger.info("checkState, prevFixed: "+prevFixed+", prevMaintainInt: "+prevMaintainInt+", cybernode service count: "+cyberMon.getServices().size());
            checkState(prevFixed, prevMaintainInt, cyberMon.getServices());
        } else {
            logger.info(service.getName()+" set planned="+maintain);
            service.setPlanned(maintain);
            logger.info("Deploy "+opstring.getName());
            testManager.deploy(opstring, monitor);
            logger.info("Deployed "+opstring.getName());
            checkState(fixed, maintain, cyberMon.getServices());
            prevFixed = fixed;
View Full Code Here

*/
public class ConfigHelperTest {

    @Test(expected = IllegalArgumentException.class)
    public void testGetConfigArgsNoCLassLoader() throws IOException {
        ConfigHelper.getConfigArgs(new ServiceElement(), null);
    }
View Full Code Here

        ConfigHelper.getConfigArgs(new ServiceElement(), null);
    }

    @Test
    public void testUsingConfig() throws IOException {
        ServiceElement service = new ServiceElement();
        service.getServiceBeanConfig().setConfigArgs(getConfig());
        String[] args = ConfigHelper.getConfigArgs(service);
        Assert.assertNotNull(args);
        Assert.assertEquals(1, args.length);
        File file = new File(args[0]);
        Assert.assertTrue(file.exists());
View Full Code Here

        Assert.assertNotNull(configuration);
    }

    @Test
    public void testUsingGroovyConfig() throws IOException {
        ServiceElement service = new ServiceElement();
        service.getServiceBeanConfig().setConfigArgs(getGroovyConfig());
        String[] args = ConfigHelper.getConfigArgs(service);
        Assert.assertNotNull(args);
        Assert.assertEquals(1, args.length);
        File file = new File(args[0]);
        Assert.assertFalse(file.exists());
View Full Code Here

        Assert.assertNotNull(configuration);
    }

    @Test(expected = FileNotFoundException.class)
    public void testUsingMissingGroovyFile() throws IOException {
        ServiceElement service = new ServiceElement();
        service.getServiceBeanConfig().setConfigArgs("file:foo");
        String[] args = ConfigHelper.getConfigArgs(service);
        Assert.assertNotNull(args);
        Configuration configuration = new GroovyConfig(args, Thread.currentThread().getContextClassLoader());
        Assert.assertNotNull(configuration);
    }
View Full Code Here

     *
     * @return Return the ServiceElement for the serviceName or null if not
     * found
     */
    public ServiceElement getNamedService(String serviceName) {
        ServiceElement foundService=null;
        synchronized(services) {
            for (ServiceElement sElem : services) {
                if (sElem.getName().equals(serviceName)) {
                    foundService = sElem;
                    break;
View Full Code Here

            WatchDescriptor[] wds = sla.getWatchDescriptors();
            if (wds.length > 0) {
                identifier = wds[0].getName();
            }
            SLAPolicyHandler handler = null;
            ServiceElement elem = context.getServiceElement();
            /* Check if the SLA matches a MeasurableCapability.  */
            MeasurableCapability mCap = getMeasurableCapability(identifier);
            if (mCap != null) {
                logger.trace("[{}] SLA [{}] correlates to a MeasurableCapability", elem.getName(), identifier);
                try {
                    /* Load the SLA PolicyHandler and set attributes */
                    handler = createSLAPolicyHandler(sla, null);

                    ThresholdManager tMgr = new BoundedThresholdManager(mCap.getId());
                    tMgr.setThresholdValues(sla);
                    handler.setThresholdManager(tMgr);
                    mCap.addSecondaryThresholdManager(tMgr);
                    thresholdManagerReg.put(tMgr, mCap);
                    logger.trace("[{}] SLA ID [{}], associated to MeasurableCapability={}, SLAPolicyHandler={}",
                                 elem.getName(), identifier, mCap.getClass().getName(), handler.getClass().getName());
                } catch (Exception e) {
                    logger.warn("Creating SLAPolicyHandler for system SLA [{}]", sla.getIdentifier(), e);
                }

            /* Check if the SLA matches the ThreadDeadlockMonitor. */
            } else if(identifier.equals(ThreadDeadlockMonitor.ID)) {
                WatchDescriptor wDesc = ServiceElementUtil.getWatchDescriptor(elem, ThreadDeadlockMonitor.ID);
                if(wDesc==null)
                    wDesc = ThreadDeadlockMonitor.getWatchDescriptor();

                /* If the service is not forked and running in it's own VM,
                 * we currently do not allow service specific thread deadlock
                 * monitoring. There is one Cybernode-based
                 * ThreadDeadlockMonitor that will send out notifications */
                if(wDesc.getMBeanServerConnection()==null && !runningForked()) {
                    logger.warn("Thread deadlock detection is provided at the process level, not " +
                                "enabled on a service-by-service approach within a Cybernode. The SLA declaration for " +
                                "the [{}] service will be ignored. Note that thread deadlock " +
                                "detection has been enabled by the Cybernode.", elem.getName());
                    return;
                }
                if(wDesc.getPeriod()<1000) {
                    logger.info("Thread deadlock monitoring has been disabled " +
                                "for service [{}]. The configured thread deadlock check time was " +
                                "[{}]. To enable thread deadlock monitoring, the thread deadlock " +
                                "check time must be >= 1000 milliseconds.", elem.getName(), wDesc.getPeriod());
                    return;
                }
                logger.info("Setting Thread deadlock detection: {}", sla);
                try {
                    ClassLoader loader = impl.getClass().getClassLoader();
View Full Code Here

     * @param id The instanceID to assign
     *
     * @return A ServiceElement with it's instanceID set to the value provided
     */
    public static ServiceElement prepareInstanceID(ServiceElement sElem,  boolean copy, long id) {
        ServiceElement elem = sElem;
        if(copy)
            elem = copyServiceElement(sElem);
       
        /* set the instance id */
        Map<String, Object> parms = elem.getServiceBeanConfig().getConfigurationParameters();
        parms.put(ServiceBeanConfig.INSTANCE_ID, id);
        ServiceBeanConfig sbConfig = new ServiceBeanConfig(parms, elem.getServiceBeanConfig().getConfigArgs());
        /* Get the initialization parameters and add them */
        Map<String, Object> initParms = elem.getServiceBeanConfig().getInitParameters();
        for (Map.Entry<String, Object> e : initParms.entrySet()) {
            sbConfig.addInitParameter(e.getKey(), e.getValue());
        }
        if(!elem.getServiceBeanConfig().getAdditionalEntries().isEmpty()) {
            List<Entry> entries = elem.getServiceBeanConfig().getAdditionalEntries();
            sbConfig.addAdditionalEntries(entries.toArray(new Entry[entries.size()]));
        }
        elem.setServiceBeanConfig(sbConfig);       
        return(elem);
    }
View Full Code Here

        sbc.addLoggerConfig(oldSBC.getLoggerConfigs());
        if(!oldSBC.getAdditionalEntries().isEmpty()) {
            List<Entry> entries = oldSBC.getAdditionalEntries();
            sbc.addAdditionalEntries(entries.toArray(new Entry[entries.size()]));
        }
        ServiceElement elem = new ServiceElement(sElem.getProvisionType(),
                                                 sbc,
                                                 sElem.getServiceLevelAgreements(),
                                                 sElem.getExportBundles(),
                                                 sElem.getFaultDetectionHandlerBundle(),
                                                 sElem.getComponentBundle());
        elem.setPlanned(sElem.getPlanned());
        elem.setCluster(sElem.getCluster());
        elem.setMaxPerMachine(sElem.getMaxPerMachine());
        elem.setMatchOnName(sElem.getMatchOnName());
        elem.setMachineBoundary(sElem.getMachineBoundary());
        elem.setAutoAdvertise(sElem.getAutoAdvertise());
        elem.setDiscoveryManagementPooling(sElem.getDiscoveryManagementPooling());
        elem.setAssociationDescriptors(sElem.getAssociationDescriptors());
        elem.setExecDescriptor(sElem.getExecDescriptor());
        elem.setStagedData(sElem.getStagedData());
        elem.setFork(sElem.forkService());
        List<RemoteRepository> rr = new ArrayList<RemoteRepository>();
        rr.addAll(Arrays.asList(sElem.getRemoteRepositories()));
        elem.setRemoteRepositories(rr);
        elem.setRuleMaps(sElem.getRuleMaps());
        return(elem);
    }
View Full Code Here

TOP

Related Classes of org.rioproject.opstring.ServiceElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.