Package org.rioproject.sla

Examples of org.rioproject.sla.RuleMap


        ProvisionMonitor monitor;

        public void run() {
            while (true) {
                waitForMonitor();
                RuleMap ruleMap;
                try {
                    ruleMap = addRuleMapQ.take();
                } catch (InterruptedException e) {
                    logger.debug("RuleMapWorker breaking out of main loop");
                    break;
                }
                if (ruleMap != null) {
                    RuleMapAssociationController controller;
                    ClassLoader ruleLoader;
                    ClassLoader currentCL = null;
                    try {
                        ruleLoader = getRuleClassLoader(ruleMap);
                        if(ruleLoader!=null) {
                            currentCL = Thread.currentThread().getContextClassLoader();
                            Thread.currentThread().setContextClassLoader(ruleLoader);
                        }
                        controller = new RuleMapAssociationController(ruleMap,
                                                                      kAgent,
                                                                      //kBase,
                                                                      monitor,
                                                                      context.getServiceBeanConfig().getGroups(),
                                                                      ruleLoader);
                        controller.addRuleMapListener(new RuleMapNotificationListener());
                        controllers.add(controller);
                        controller.process();
                    } catch (ResolverException e) {
                        logger.warn("Unable to provision artifact [{}] for RuleMap {}",
                                   ruleMap.getRuleDefinition().getRuleClassPath(), ruleMap, e);
                    } catch (MalformedURLException e) {
                        logger.warn("Unable to create URL from rule classpath [{}], cannot set classpath for rule classpath jars",
                                   ruleMap.getRuleDefinition().getRuleClassPath(), e);
                    } catch (URISyntaxException e) {
                        logger.warn("Unable to create URI from rule classpath [{}], cannot set classpath for rule classpath jars",
                                    ruleMap.getRuleDefinition().getRuleClassPath(), e);
                    } catch (IllegalArgumentException e) {
                        logger.warn("Unable to create RuleMapAssociationController", e);
                    } finally {
                        if(currentCL!=null)
                            Thread.currentThread().setContextClassLoader(currentCL);
View Full Code Here


            s1Instances = getServices("S1", TestService.class, testManager.getGroups());
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            RuleMap ruleMap = getRuleMap();
            addRuleMap(ruleMap);
            List<RuleMap> ruleMappings = gnostic.get();
            Assert.assertEquals("Expected 1 RuleMap", 1, ruleMappings.size());
            Assert.assertEquals("RuleMaps should be the same", ruleMap, ruleMappings.get(0));
            List<TestService> services = null;
View Full Code Here

                s2Instances = getServices("S2", TestService.class, testManager.getGroups());
            } catch (Exception e) {
                e.printStackTrace();
            }

            RuleMap ruleMap = getRuleMap();
            RuleMap ruleMap2 = getRuleMap2();
            Assert.assertFalse("RuleMaps should not equal each other", ruleMap.equals(ruleMap2));
            addRuleMap(ruleMap);
            addRuleMap(ruleMap2);
            List<RuleMap> ruleMaps = gnostic.get();
            Assert.assertEquals("Expected 2 RuleMaps", 2, ruleMaps.size());
View Full Code Here

        added = gnostic.add(ruleMap);
        Assert.assertFalse("Should have returned false for re-adding an already existing RuleMap", added);
    }

    private static RuleMap getRuleMap() {
        RuleMap ruleMap = new RuleMap();
        List<ServiceDefinition> services = new ArrayList<ServiceDefinition>();
        ServiceDefinition service = new ServiceDefinition("S1");
        //service.addWatches("load", "CPU");
        service.addWatches("load");
        services.add(service);
        RuleDefinition rule = new RuleDefinition("ScalingRuleHandler");
        ruleMap.addRuleMapping(rule, services.toArray(new ServiceDefinition[services.size()]));
        return ruleMap;
    }
View Full Code Here

        ruleMap.addRuleMapping(rule, services.toArray(new ServiceDefinition[services.size()]));
        return ruleMap;
    }

    private static RuleMap getRuleMap2() {
        RuleMap ruleMap = new RuleMap();
        List<ServiceDefinition> services = new ArrayList<ServiceDefinition>();
        ServiceDefinition service = new ServiceDefinition("S2");
        service.addWatches("load");
        services.add(service);
       
        service = new ServiceDefinition("S3");
        service.addWatches("load");
        services.add(service);

        RuleDefinition rule = new RuleDefinition("ScalingRuleHandler");

        ruleMap.addRuleMapping(rule, services.toArray(new ServiceDefinition[services.size()]));
        return ruleMap;
    }
View Full Code Here

TOP

Related Classes of org.rioproject.sla.RuleMap

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.