Package org.rioproject.opstring

Examples of org.rioproject.opstring.OperationalStringManager


        ServiceHandle handle = new ServiceHandle();
        if(o instanceof Service) {
            Service s = (Service)o;
            try {
                ServiceElement elem = ((ServiceAdmin)s.getAdmin()).getServiceElement();
                OperationalStringManager opMgr = ((DeployAdmin)monitor.getAdmin()).getOperationalStringManager(elem.getOperationalStringName());
                handle.setElem(elem);
                handle.setOpMgr(opMgr);
                for(String watch : watches) {
                    try {
                        WatchDataSource wds = s.fetch(watch);
                        logger.debug("WatchDataSource for watch [{}]: {}", watch, wds);
                        if(wds==null)
                            continue;
                        handle.addToWatchMap(watch, wds);
                        ThresholdValues tVals = wds.getThresholdValues();
                        if(tVals instanceof SLA) {
                            handle.addToSLAMap(watch, (SLA)tVals);
                        }
                    } catch (RemoteException e) {
                        logger.warn("Could not add AssociationsWatchDataReplicator to remote WatchDataSource.", e);
                    }
                }
            } catch (RemoteException e) {
                handle = null;
                logger.warn("Could not get ServiceElement or OperationalStringManager.", e);

            } catch (OperationalStringException e) {
                handle = null;
                logger.error("Could not get OperationalStringManager, unable to create AssociationsWatchDataReplicator.",
                             e);
            }
        } else {
            String opStringName = null;
            for(Entry e : entries) {
                if(e instanceof OperationalStringEntry) {
                    opStringName = ((OperationalStringEntry)e).name;
                    break;
                }
            }
            logger.info("OperationalString for service: [{}]", opStringName);
            if(opStringName!=null) {
                try {
                    OperationalStringManager opMgr = ((DeployAdmin)monitor.getAdmin()).getOperationalStringManager(opStringName);
                    ServiceElement elem = opMgr.getServiceElement(o);
                    if(elem==null) {
                        logger.warn("Unable to obtain ServiceElement for service [{}], cannot create AssociationsWatchDataReplicator.",
                                    o.toString());
                        return null;
                    }
                    handle.setElem(elem);
                    handle.setOpMgr(opMgr);
                    Cybernode c = null;

                    for(ServiceBeanInstance sbi : opMgr.getServiceBeanInstances(elem)) {
                        if(o.equals(sbi.getService())) {
                            elem.setServiceBeanConfig(sbi.getServiceBeanConfig());
                            Uuid uuid = sbi.getServiceBeanInstantiatorID();
                            for(ServiceBeanInstantiator s : monitor.getServiceBeanInstantiators()) {
                                if(uuid.equals(s.getInstantiatorUuid())) {
View Full Code Here


            } else {
                deployed.put(entry.getKey(), entry.getValue());
            }
        }
        ServiceElement serviceElement = entry.getKey();
        OperationalStringManager opMgr = entry.getValue();
        if(logger.isDebugEnabled())
            logger.debug("Increment service {}", getNameForLogging(serviceElement));
        try {
            opMgr.increment(serviceElement, true, null);
        } catch(RemoteException e) {
            if(!ThrowableUtil.isRetryable(e)) {
                logger.warn("Unable to connect to OperationalStringManager to increment service {}/{}",
                               serviceElement.getOperationalStringName(), serviceElement.getName());
            } else {
View Full Code Here

    public static Integer getServiceCount(String serviceName, String opstring) {
        Map.Entry<ServiceElement, OperationalStringManager> entry = getMapEntry(serviceName, opstring);
        if(entry==null)
            return 0;
        ServiceElement serviceElement = entry.getKey();
        OperationalStringManager opMgr = entry.getValue();
        int count = 0;
        logger.debug("Increment service {}", getNameForLogging(serviceElement));
        try {
            count = opMgr.getServiceBeanInstances(serviceElement).length;
        } catch (Throwable t) {
            logger.warn("While trying to get the service count for {}", serviceName, t);
        }
        return count;
    }
View Full Code Here

        /* decrement the number of services by 1 */
        Map.Entry<ServiceElement, OperationalStringManager> entry = getMapEntry(serviceName, opstring);
        if(entry==null)
            return;
        ServiceElement serviceElement = entry.getKey();
        OperationalStringManager opMgr = entry.getValue();
        logger.debug("Decrement service {}", getNameForLogging(serviceElement));
        try {
            ServiceBeanInstance[] instances = opMgr.getServiceBeanInstances(serviceElement);
            if(instances.length>0) {
                ServiceBeanInstance instance = instances[instances.length-1];
                opMgr.decrement(instance, true, true);
            }
        } catch (Throwable t) {
            logger.warn("While trying to get the decrement {}", serviceName, t);
        }
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    private <T> T doGetService(Map.Entry<ServiceElement, OperationalStringManager> entry, Class<T> type) {
        T service = null;
        ServiceElement serviceElement = entry.getKey();
        OperationalStringManager opMgr = entry.getValue();
        try {
            ServiceBeanInstance[] instances = opMgr.getServiceBeanInstances(serviceElement);
            if(instances.length>0)
                service = (T)instances[0].getService();
        } catch (Throwable t) {
            logger.warn("While trying to get [{}] services from the OperationalStringManager", serviceElement.getName(), t);
        }
View Full Code Here

    @SuppressWarnings("unchecked")
    private <T> T doLookupService(String serviceName, String opstringName, Class<T> type) {
        T service = null;
        try {
            DeployAdmin dAdmin = (DeployAdmin)monitor.getAdmin();
            OperationalStringManager opMgr = dAdmin.getOperationalStringManager(opstringName);
            OperationalString opstring = opMgr.getOperationalString();
            ServiceElement serviceElement = null;
            for(ServiceElement elem : opstring.getServices()) {
                if(elem.getName().equals(serviceName)) {
                    serviceElement = elem;
                    break;
                }
            }
            if(serviceElement!=null) {
                ServiceBeanInstance[] instances = opMgr.getServiceBeanInstances(serviceElement);
                if(instances.length>0)
                    service = (T)instances[0].getService();
            }
        } catch (Throwable t) {
            logger.warn("While trying to lookup [{}] services", serviceName, t);
View Full Code Here

    @SuppressWarnings("unchecked")
    private <T> List<T> doGetServices(Map.Entry<ServiceElement, OperationalStringManager> entry, Class<T> type) {
        List<T> services = new ArrayList<T>();
        ServiceElement serviceElement = entry.getKey();
        OperationalStringManager opMgr = entry.getValue();
        try {
            ServiceBeanInstance[] instances = new ServiceBeanInstance[0];
            try {
                instances = opMgr.getServiceBeanInstances(serviceElement);
            } catch(RemoteException e) {
                if(!ThrowableUtil.isRetryable(e)) {
                    logger.warn("Unable to connect to OperationalStringManager for instances of type {}, service: {}/{}",
                                   type.getName(), serviceElement.getOperationalStringName(), serviceElement.getName());
                    return services;
View Full Code Here

    @SuppressWarnings("unchecked")
    private <T> List<T> doLookupServices(String serviceName, String opstringName, Class<T> type) {
        List<T> services = new ArrayList<T>();
        try {
            DeployAdmin dAdmin = (DeployAdmin)monitor.getAdmin();
            OperationalStringManager opMgr = dAdmin.getOperationalStringManager(opstringName);
            OperationalString opstring = opMgr.getOperationalString();
            ServiceElement serviceElement = null;
            for(ServiceElement elem : opstring.getServices()) {
                if(elem.getName().equals(serviceName)) {
                    serviceElement = elem;
                    break;
                }
            }
            if(serviceElement!=null) {
                ServiceBeanInstance[] instances = opMgr.getServiceBeanInstances(serviceElement);
                for(ServiceBeanInstance instance : instances) {
                    services.add((T)instance.getService());
                }
            }
        } catch (Throwable t) {
View Full Code Here

    @SuppressWarnings("unchecked")
    private Map.Entry<ServiceElement, OperationalStringManager> doLookupServiceEntry(String serviceName, String opstringName) {
        Map.Entry<ServiceElement, OperationalStringManager> entry = null;
        try {
            DeployAdmin dAdmin = (DeployAdmin)monitor.getAdmin();
            OperationalStringManager opMgr = dAdmin.getOperationalStringManager(opstringName);
            OperationalString opstring = opMgr.getOperationalString();
            ServiceElement serviceElement = null;
            for(ServiceElement elem : opstring.getServices()) {
                if(elem.getName().equals(serviceName)) {
                    serviceElement = elem;
                    break;
View Full Code Here

    public void verifyChangingRuleLoadedFromClassPathWorks() {
        Throwable thrown;
        Assert.assertNotNull(testManager);
        File opstring = new File("src/test/opstring/artifactNotification2.groovy");
        Assert.assertTrue(opstring.exists());
        OperationalStringManager mgr = testManager.deploy(opstring);
        testManager.waitForDeployment(mgr);
        TestService test = (TestService)testManager.waitForService("Test");
        thrown = null;
        Gnostic g = (Gnostic)testManager.waitForService(Gnostic.class);
        Util.waitForRule(g, "CounterNotification");
View Full Code Here

TOP

Related Classes of org.rioproject.opstring.OperationalStringManager

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.