Examples of ServiceElement


Examples of org.rioproject.opstring.ServiceElement

*/
public class ConfigHelperTest {

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

Examples of org.rioproject.opstring.ServiceElement

        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

Examples of org.rioproject.opstring.ServiceElement

        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

Examples of org.rioproject.opstring.ServiceElement

        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

Examples of org.rioproject.opstring.ServiceElement

     *
     * @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

Examples of org.rioproject.opstring.ServiceElement

            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

Examples of org.rioproject.opstring.ServiceElement

     * @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

Examples of org.rioproject.opstring.ServiceElement

        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

Examples of org.rioproject.opstring.ServiceElement

        public void recover(InputStream in) throws Exception {
            ObjectInputStream oistream = new ObjectInputStream(in);
            if(!logDirName.equals(oistream.readUTF()))
                throw new IOException("log from wrong implementation");
            DefaultServiceBeanContext serviceBeanContext = (DefaultServiceBeanContext)oistream.readObject();
            ServiceElement sElem = serviceBeanContext.getServiceElement();
            ServiceBeanConfig sAttr = sElem.getServiceBeanConfig();
            try {
                String[] groups = (String[])oistream.readObject();
                LookupLocator[] locators = (LookupLocator[])oistream.readObject();
                sAttr.setGroups(groups);
                sAttr.setLocators(locators);
            } catch(Throwable t) {
                logger.error("Couldnt get groups or locators", t);
            }
            sElem.setServiceBeanConfig(sAttr);
            serviceBeanContext.setServiceElement(sElem);
            restoredContext = serviceBeanContext;
        }
View Full Code Here

Examples of org.rioproject.opstring.ServiceElement

        statement.putServiceRecord(getUuid(), serviceRecord);
        serviceStatementManager.record(statement);
        //setChanged(StatusType.NORMAL);
        if(loaderLogger.isInfoEnabled()) {
            int instantiatedServiceCount = getInstantiatedServiceCount();
            ServiceElement service = serviceRecord.getServiceElement();
            logger.info("Instantiated {}, {}, total services active: {}",
                        ServiceLogUtil.logName(service),
                        ServiceLogUtil.discoveryInfo(service),
                        instantiatedServiceCount);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.