Package org.rioproject.opstring

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


    @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

     * @param newElem The ServiceElement for the ServiceBean
     */
    public void setServiceElement(final ServiceElement newElem) {
        if(newElem==null)
            throw new IllegalArgumentException("sElem is null");               
        ServiceElement preElem = sElem;
        this.sElem = newElem;                       
        try {
            updating = true;
            stateChange(preElem, sElem);
        } finally {
View Full Code Here

        if(updating) {           
            if(logger.isTraceEnabled())
                logger.trace("Updating ServiceElement, ServiceBeanConfig update ignored");
            return;
        }
        ServiceElement preElem = ServiceElementUtil.copyServiceElement(sElem);
        Long instanceID = sElem.getServiceBeanConfig().getInstanceID();
        sElem.setServiceBeanConfig(sbConfig);
        if(instanceID!=null)
            sElem = ServiceElementUtil.prepareInstanceID(sElem, false, instanceID);
        else
View Full Code Here

            if (!artifactDir.exists()) {
                artifactDir.mkdirs();
            }
            FileUtils.copy(new File("src/test/resources/darkside-1.0.config"),
                           new File(artifactDir, "darkside-1.0.config"));
            ServiceElement service = new ServiceElement();
            service.getServiceBeanConfig().setConfigArgs("rio-test.something.something:darkside:config:1.0");
            String[] args = ConfigHelper.getConfigArgs(service);
            Assert.assertNotNull(args);
            Assert.assertEquals(1, args.length);
            Configuration configuration = new GroovyConfig(args, Thread.currentThread().getContextClassLoader());
            Assert.assertNotNull(configuration);
View Full Code Here

        File file = new File("src/test/resources/opstring/simple_opstring_with_http_config.groovy");
        List<OpString> opStrings = opStringParser.parse(file,   // opstring
                                                        null,     // parent classloader
                                                        null,     // defaultGroups
                                                        null);    // loadPath
        ServiceElement serviceElement = opStrings.get(0).getServices()[0];

        ServiceBeanContext context = new ServiceContextFactory().create(serviceElement,
                                                                    new DefaultServiceBeanManager(serviceElement,
                                                                                   InetAddress.getLocalHost().getHostName(),
                                                                                   InetAddress.getLocalHost().getHostAddress(),
View Full Code Here

        int[] res = new int[cybernodes.length];
        for (int i = 0; i < cybernodes.length; i++) {
            Cybernode cybernode = cybernodes[i];
            ServiceRecord[] records = cybernode.getServiceRecords(ServiceRecord.ACTIVE_SERVICE_RECORD);
            for (ServiceRecord record : records) {
                ServiceElement element = record.getServiceElement();
                ClassBundle[] exportBundles = element.getExportBundles();
                for (ClassBundle bundle : exportBundles) {
                    if (bundle.getClassName().equals(type.getName())) {
                        res[i]++;
                        break;
                    }
View Full Code Here

        OperationalStringManager mgr = testManager.getOperationalStringManager();
        testManager.waitForDeployment(mgr);

        DeploymentMap dMap = mgr.getDeploymentMap();
        Assert.assertEquals(1, dMap.getServiceElements().length);
        ServiceElement elem = dMap.getServiceElements()[0];
        List<DeployedService> list = dMap.getDeployedServices(elem);
        Assert.assertEquals(1, list.size());
        DeployedService deployed =  list.get(0);
        Assert.assertNotNull(deployed);
View Full Code Here

            loader.parseOperationalString(
                new File("src/test/resources/opstring/simple_opstring.groovy"));
        Assert.assertEquals(1, opstrings.length);
        OpString opstring = (OpString)opstrings[0];
        Assert.assertEquals(1, opstring.getServices().length);
        ServiceElement service = opstring.getServices()[0];
        service.setPlanned(maintain);
        service.setProvisionType(provisionType);               

        int[] counts = CybernodeUtils.calcServices(cyberMon.getServices(),
                                                   Simple.class);
        logger.info("Services found before deploying the OpString: {}",
                   Arrays.asList(ArrayUtils.asObjects(counts)).toString());
View Full Code Here

        OperationalString[] opstrings =
            loader.parseOperationalString(new File("src/test/resources/opstring/simple_opstring.groovy"));
        org.junit.Assert.assertEquals(1, opstrings.length);
        OpString opstring = (OpString)opstrings[0];
        org.junit.Assert.assertEquals(1, opstring.getServices().length);
        ServiceElement service = opstring.getServices()[0];
        service.setPlanned(maintain);
        service.setMaxPerMachine(maxPerMachine);
        service.setProvisionType(fixed? ServiceElement.ProvisionType.FIXED: ServiceElement.ProvisionType.DYNAMIC);

        prevCounts = CybernodeUtils.calcServices(cyberMon.getServices(),Simple.class);
        logger.info("**** Services found before deploying the OpString: {}",
                   Arrays.asList(ArrayUtils.asObjects(prevCounts)));
        logger.debug("Service details: ["+service.getProvisionType()+"]");
        if (maxPerMachine == -1) {
            maxPerMachine = Integer.MAX_VALUE;
        }

        testManager.deploy(opstring, monitor);
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.