Package org.rioproject.opstring

Examples of org.rioproject.opstring.ServiceElement


        }

    }

    private ServiceElement makeServiceElement(String name) {
        ServiceElement elem = new ServiceElement();
        ClassBundle main = new ClassBundle("");
        elem.setComponentBundle(main);
        ServiceBeanConfig sbc = new ServiceBeanConfig();
        sbc.setName(name);
        elem.setServiceBeanConfig(sbc);
        return elem;
    }
View Full Code Here


   
    /*
     * Get the ServiceElement
     */
    protected ServiceElement getServiceElement() {
        ServiceElement elem;
        synchronized(serviceElementLock) {
            elem = sElem;
        }
        return(elem);
    }
View Full Code Here

     */
    protected int getPendingRequestCount(OperationalStringManager opMgr) {
        int pendingCount = 0;
        try {           
            opMgr.getClass().getMethod("getPendingCount", ServiceElement.class);
            ServiceElement elem = getServiceElement();
            pendingCount = opMgr.getPendingCount(elem);
        } catch (NoSuchObjectException e) {          
            logger.warn("Remote manager decomissioned for [{}] ScalingPolicyHandler [{}], force disconnect",
                        getName(), getID());
            disconnect();
View Full Code Here

            OperationalStringManager opMgr = context.getServiceBeanManager().getOperationalStringManager();
            if(opMgr==null) {
                logger.debug("[{}] No OperationalStringManager, increment aborted", getName());
                return;
            }
            ServiceElement elem = getServiceElement();
            ServiceBeanInstance[] instances = opMgr.getServiceBeanInstances(elem);
            int pendingCount = getPendingRequestCount(opMgr);                      
            int realTotal = instances.length+pendingCount;
           
            /* If we have an unbounded maxServices property, always increment.
View Full Code Here

                    if (node.getOpString() != null) {
                        if (node.getOpStringName().equals(name))
                            delete = true;
                    }
                    if (node.isServiceElement()) {
                        ServiceElement se = node.getServiceElement();
                        if (se.getOperationalStringName().equals(name))
                            delete = true;
                    }
                    if (node.isServiceInstance())
                        delete = true;
                }
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;
View Full Code Here

    public void decrement(String serviceName, String opstring) {
        /* 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) {
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);
        }
        return service;
    }
View Full Code Here

        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;
                }
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;
                }
            }
            StringBuilder sb = new StringBuilder();
            for(ServiceBeanInstance instance : instances) {
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.