Package org.rioproject.opstring

Examples of org.rioproject.opstring.ServiceElement


        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;
                }
View Full Code Here


        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

    private ServiceHandle getServiceHandle(Object o, List<String> watches, Entry[] entries) {
        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())) {
                                    c = (Cybernode)s;
                                    break;
                                }
                            }
                        }
                    }
                    if(c!=null) {
                        Watchable w;
                        if(elem.forkService()) {
                            int registryPort = ((CybernodeAdmin)c.getAdmin()).getRegistryPort();
                            String address = c.getInetAddress().getHostAddress();
                            Registry registry = LocateRegistry.getRegistry(address, registryPort);
                            Remote r = null;
                            NotBoundException notBound = null;
                            //for(int i=0; i<3; i++) {
                                try {
                                    r = registry.lookup(RMIServiceNameHelper.createBindName(elem));
                                } catch (NotBoundException e) {
                                    notBound = e;
                                    //try {
                                    //    Thread.sleep(1000);
                                    //} catch (InterruptedException e1) {
                                    //    e1.printStackTrace();
                                    //}
                                }
                            //}
                            if(r==null) {
                                logger.error("Could not get ServiceBeanExecutor, unable to create AssociationsWatchDataReplicator.",
                                             notBound);
                                return null;
                            }
                            if(r instanceof Watchable) {
                                w = (Watchable)r;
                            } else {
                                logger.warn("Could not get Watchable from Registry at [{}:{}], unable to " +
                                            "create AssociationsWatchDataReplicator for service [{}]",
                                            address, registryPort, elem.getName());
                                return null;
                            }
                        } else {
                            w = c;
                        }

                        for(String watch : watches) {
                            try {
                                WatchDataSource wds = w.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);
                            }
                        }

                    } else {
                        logger.warn("Unable to obtain Cybernode for service [{}]", elem.getName());
                    }
                } catch (RemoteException e) {
                    handle = null;
                    logger.warn("Could not get ServiceElement or OperationalStringManager.", e);
                } catch (OperationalStringException e) {
View Full Code Here

            execService.shutdownNow();
        try {
            if (wdr != null) {
                for (Map.Entry<WatchDataSource, ServiceElement> entry : watchDataSources.entrySet()) {
                    WatchDataSource wds = entry.getKey();
                    ServiceElement elem = entry.getValue();
                    try {
                        wds.removeWatchDataReplicator(wdr);
                        logger.info("Unregistered from Watch [{}], service [{}]", wds.getID(), elem.getName());
                    } catch (RemoteException e) {
                        logger.debug("Non-fatal problem unregistering from remote WatchDataSource, most likely " +
                                     "the service is no longer present. {}:{}",
                                     e.getClass().getName(), e.getMessage());
                    }
View Full Code Here

                return;
            } 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 {
                logger.warn("While trying to increment [{}] services", serviceName, e);
            }
        } catch (Throwable t) {
            logger.warn("While trying to increment [{}] services", serviceName, t);
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.