Examples of ServiceElement


Examples of org.rioproject.opstring.ServiceElement

        Assert.assertFalse(statement.hasActiveServiceRecords());
    }

    @Test
    public void testGetOrganization() {
        ServiceElement element = makeServiceElement("Foo");
        Uuid uuid = UuidFactory.generate();
        ServiceRecord record = new ServiceRecord(uuid, element, "hostname");
        ServiceStatement statement = new ServiceStatement(element);
        statement.putServiceRecord(recordingUuid, record);
        String organization = statement.getOrganization();
View Full Code Here

Examples of org.rioproject.opstring.ServiceElement

        String organization = statement.getOrganization();
        Assert.assertNotNull(organization);
    }

    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

Examples of org.rioproject.opstring.ServiceElement

                                                         double.class,
                                                         defaultSystemThreshold);
        sla.getSystemRequirements().addSystemThreshold(SystemRequirements.SYSTEM,
                                                       new ThresholdValues(0.0, systemThreshold));

        ServiceElement sElem = new ServiceElement(ServiceElement.ProvisionType.EXTERNAL,
                                                  sbConfig,
                                                  sla,
                                                  new ClassBundle[]{exportBundle});
        if(sbLifeCycleManager == null)
            sbLifeCycleManager = new LifeCycleManager();
View Full Code Here

Examples of org.rioproject.opstring.ServiceElement

            for (Key key : keys) {
                ProvisionRequest pr = collection.get(key);
                if (sElem.equals(pr.getServiceElement())) {
                    /* Preserve instance IDs */
                    Long id = pr.getServiceElement().getServiceBeanConfig().getInstanceID();
                    ServiceElement newElem = sElem;
                    if (id != null)
                        newElem = ServiceElementUtil.prepareInstanceID(sElem, id.intValue());
                    pr.setServiceElement(newElem);
                    if(listener!=null) {
                        pr.setServiceProvisionListener(listener);
View Full Code Here

Examples of org.rioproject.opstring.ServiceElement

            buffer.append(type);
            buffer.append(" collection size : ");
            buffer.append(elements.length).append("\n");
            buffer.append("--\n");
            for (ProvisionRequest element : elements) {
                ServiceElement sElem = element.getServiceElement();
                Long id = sElem.getServiceBeanConfig().getInstanceID();
                buffer.append(x++);
                buffer.append(" ");
                buffer.append(sElem.getOperationalStringName());
                buffer.append("/");
                buffer.append(sElem.getName());
                if(!type.startsWith("Fixed")) {
                    buffer.append(" instanceID=");
                    buffer.append(id);
                }
                buffer.append("\n");
View Full Code Here

Examples of org.rioproject.opstring.ServiceElement

            InstantiatorResource ir = (InstantiatorResource) svcResource.getResource();
            /*
             * Make sure the InstantiatorResource has not reached it's
             * serviceLimit
             */
            ServiceElement sElem = provisionRequest.getServiceElement();
            int serviceLimit = ir.getServiceLimit();
            int total = ir.getServiceElementCount() + ir.getInProcessCounter();
            if (total >= serviceLimit) {
                String reason =
                    String.format("%s reached service limit of [%d] (service element count:%d, in-process:%d), " +
                                  "cannot be used to instantiate [%s/%s]",
                                  ir.getName(),
                                  serviceLimit,
                                  ir.getServiceElementCount(),
                                  ir.getInProcessCounter(),
                                  sElem.getOperationalStringName(),
                                  sElem.getName());
                provisionRequest.addFailureReason(reason);
                logger.debug(reason);
                continue;
            }
            /*
             * Check if the InstantiatorResource doesn't already have the
             * maximum amount of services allocated. this is different then
             * MaxPerNode
             */
            int planned = sElem.getPlanned();
            int actual = ir.getServiceElementCount(sElem);
            logger.trace("{} has [{}] instance(s), planned [{}] of [{}/{}]",
                         ir.getName(), actual, planned, sElem.getOperationalStringName(), sElem.getName());
            if (actual >= planned) {
                String message = String.format("%s has reached service limit of [%s], cannot be used to instantiate [%s/%s]",
                                               ir.getName(), serviceLimit, sElem.getOperationalStringName(), sElem.getName());
                provisionRequest.addFailureReason(message);
                continue;
            }
            if (ir.getDynamicEnabled()) {
                try {
                    if (ir.canProvision(provisionRequest)) {
                        serviceResourceSelected(svcResource);
                        logger.trace("[{}, service count: {}] has been selected for service [{}/{}]",
                                     ir.getName(), ir.getServiceCount(), sElem.getOperationalStringName(),
                                     sElem.getName());
                        return (svcResource);
                    }
                } catch (Exception e) {
                    logger.warn("[{}] during canProvision check for [{}]",
                                ir.getName(), sElem.getOperationalStringName(), sElem.getName(),
                                e);
                    if(e instanceof ProvisionException)
                        throw (ProvisionException)e;
                }
            } else {
View Full Code Here

Examples of org.rioproject.opstring.ServiceElement

     * @param provisionRequest
     * @param candidates
     * @return
     */
    public ServiceResource[] filterMachineBoundaries(final ProvisionRequest provisionRequest, final ServiceResource... candidates) {
        ServiceElement elem = provisionRequest.getServiceElement();
        int maxPerMachine = elem.getMaxPerMachine();
        if(!(maxPerMachine!=-1 &&
             elem.getMachineBoundary()==ServiceElement.MachineBoundary.PHYSICAL)) {
            return(candidates);
        }

        /*
         * 1. Create a table composed of keys that are the host address and
         *    values a list of Cybernodes
         * 2. Count the number services each cybernode has on each host
         * 3. Remove table entries that exceed the count per host
         */
        Map<String, List<ServiceResource>> table = new HashMap<String, List<ServiceResource>>();

        for (ServiceResource candidate : candidates) {
            InstantiatorResource ir = (InstantiatorResource)candidate.getResource();
            List<ServiceResource> list = table.get(ir.getHostAddress());
            if(list==null)
                list = new ArrayList<ServiceResource>();
            list.add(candidate);
            table.put(ir.getHostAddress(), list);
        }

        List<String> remove = new ArrayList<String>();
        for(Map.Entry<String, List<ServiceResource>> entry : table.entrySet()) {
            List<ServiceResource> list = entry.getValue();
            int serviceCount = 0;
            for(ServiceResource sr : list) {
                InstantiatorResource ir = (InstantiatorResource)sr.getResource();
                serviceCount += ir.getInProcessCounter(elem) + ir.getServiceElementCount(elem);
                if(serviceCount>=maxPerMachine) {
                    remove.add(ir.getHostAddress());
                    break;
                }
            }
        }
        for(String s : remove) {
            table.remove(s);
        }

        List<ServiceResource> candidateList = new ArrayList<ServiceResource>();
        for(Map.Entry<String, List<ServiceResource>> entry : table.entrySet()) {
            List<ServiceResource> list = entry.getValue();
            for(int i=0; i<list.size(); i++) {
                if(i<maxPerMachine) {
                    candidateList.add(list.get(i));
                } else {
                    break;
                }
            }
        }

        if(logger.isDebugEnabled() && candidateList.isEmpty() && elem.getProvisionType().equals(ServiceElement.ProvisionType.DYNAMIC)) {
            logger.debug("Service [{}/{}] has a physical machine boundary constraint and an " +
                         "instance of the service has been found on all known machines.",
                         elem.getOperationalStringName(), elem.getName());
        }
        return(candidateList.toArray(new ServiceResource[candidateList.size()]));
    }
View Full Code Here

Examples of org.rioproject.opstring.ServiceElement

            String impl = "<not declared>";
            Throwable thrown;
            if(event instanceof ProvisionFailureEvent) {
                String label = "ProvisionFailureEvent."+eventNode.getValueAt(0);
                ProvisionFailureEvent pfe = (ProvisionFailureEvent)event;
                ServiceElement elem = pfe.getServiceElement();
                if(elem.getComponentBundle()!=null)
                    impl = elem.getComponentBundle().getClassName();
                thrown = pfe.getThrowable();
                String exception = getExceptionText(thrown);
                tableData.put("Event", label);
                tableData.put("When", Constants.DATE_FORMAT.format(event.getDate()));
                tableData.put("Deployment", elem.getOperationalStringName());
                tableData.put("Service", elem.getName());
                tableData.put("Class", impl);
                StringBuilder builder = new StringBuilder();
                for(String reason : pfe.getFailureReasons()) {
                    if(builder.length()>0)
                        builder.append("\n    ");
View Full Code Here

Examples of org.rioproject.opstring.ServiceElement

            OperationalStringManager mgr = testManager.getOperationalStringManager();
            Assert.assertNotNull("Expected non-null OperationalStringManager", mgr);
            OperationalString opstring = mgr.getOperationalString();
            Assert.assertNotNull(opstring);
            Assert.assertEquals(1, opstring.getServices().length);
            ServiceElement elem = opstring.getServices()[0];
            Assert.assertNotNull("Expected a non-null ExecDescriptor", elem.getExecDescriptor());
            testManager.waitForDeployment(mgr);
            String jvmVersion = System.getProperty("java.version");
            if(jvmVersion.contains("1.5")) {
                logger.info("The JMX Attach APIs require Java 6 or above. You are running Java "+jvmVersion);
            } else {
                RuntimeMXBean runtime = attach("T62___W_FL___SK_-1");
                Assert.assertNotNull("Expected a RuntimeMXBean", runtime);
                verifyJVMArgs(runtime, elem.getExecDescriptor());
            }
            ServiceBeanInstance[] instances = cybernode.getServiceBeanInstances(opstring.getServices()[0]);
            Assert.assertEquals(1, instances.length);
            Fork fork = (Fork)instances[0].getService();
            Assert.assertTrue("Expected verify() to return true, check service log for details", fork.verify());
View Full Code Here

Examples of org.rioproject.opstring.ServiceElement

    @Test
    public void testServiceDiscoveryTimeout() throws Exception {
        Dummy darrel = (Dummy) testManager.waitForService(Dummy.class);
        new Thread(new Runnable() {
            @Override public void run() {
                ServiceElement elem = new ServiceElement();
                elem.setPlanned(1);
                try {
                    String codebase = "http://"+HostUtil.getHostAddressFromProperty(Constants.RMI_HOST_ADDRESS)+":9010";
                    elem.setExportBundles(makeClassBundle(Dummy.class.getName(), codebase));
                    elem.setComponentBundle(makeClassBundle(DummyImpl.class.getName(), codebase));

                    ServiceBeanConfig sbc = new ServiceBeanConfig();
                    sbc.setName("Add");
                    sbc.setGroups(System.getProperty("org.rioproject.groups"));
                    sbc.setOperationalStringName("association stuff");
                    elem.setServiceBeanConfig(sbc);

                    logger.info("Wait 5 seconds to deploy another dummy...");
                    Thread.sleep(5*1000);
                    logger.info("Deploying another dummy...");
                    manager.addServiceElement(elem, null);
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.