Package org.rioproject.opstring

Examples of org.rioproject.opstring.OperationalStringManager


                                    "src"+File.separator+
                                    "test"+File.separator+
                                    "resources"+File.separator+
                                    "opstring"+File.separator+
                                    "outofmemory_test.groovy");
        OperationalStringManager mgr = testManager.deploy(opstring);
        OutOfMemory outOfMemory = (OutOfMemory)testManager.waitForService(OutOfMemory.class);
        try {
            BasicEventConsumer eventConsumer = new BasicEventConsumer(ProvisionMonitorEvent.getEventDescriptor(), l);
            eventConsumer.register(items[0]);
        } catch (Exception e) {
            thrown = e;
            e.printStackTrace();
        }
        Assert.assertNull(thrown);
        thrown = null;
        try {
            outOfMemory.createOOME();
        } catch (IOException e) {
            thrown = e;
            e.printStackTrace();
        }
        Assert.assertNull(thrown);
        long waited = wait(l, true);
        System.out.println("Waited "+waited/1000+" seconds for failure to be observed");
        Assert.assertTrue("OutOfMemory should have failed", l.failed);
        waited = wait(l, false);
        System.out.println("Waited "+waited/1000+" seconds for re-creation to be observed");
        Assert.assertNotNull("OutOfMemory should be re-allocated", outOfMemory);

        thrown = null;
        try {
            sleep(10*1000);
            testManager.undeploy(mgr.getOperationalString().getName());
        } catch (IOException e) {
            thrown = e;
            e.printStackTrace();
        }
        Assert.assertNull(thrown);
View Full Code Here


        Throwable thrown = null;
        try {
            /* Count the generated groovy config files in /tmp. We want to
             * make sure that if we generate a temp config file it is removed*/
            int configFilesInTmp = countTempConfigFiles();
            OperationalStringManager mgr = testManager.deploy();
            Assert.assertNotNull("Expected non-null OperationalStringManager", mgr);
            OperationalString opstring = mgr.getOperationalString();
            Assert.assertNotNull(opstring);
            Assert.assertEquals(1, opstring.getServices().length);
            testManager.waitForDeployment(mgr);
            ServiceBeanInstance[] instances =
                cybernode.getServiceBeanInstances(opstring.getServices()[0]);
View Full Code Here

    public void testSimpleIncrement() {
        Assert.assertNotNull(testManager);
        Assert.assertNotNull(cybernode);
        Throwable thrown = null;
        try {
            OperationalStringManager mgr = testManager.deploy();
            Assert.assertNotNull("Expected non-null OperationalStringManager", mgr);
            OperationalString opstring = mgr.getOperationalString();
            Assert.assertNotNull(opstring);
            Assert.assertEquals(1, opstring.getServices().length);
            testManager.waitForDeployment(mgr);
            ServiceBeanInstance[] instances =
                cybernode.getServiceBeanInstances(opstring.getServices()[0]);
            Assert.assertEquals(1, instances.length);           
            mgr.increment(opstring.getServices()[0], true, null);
            ServiceMonitor<Simple> sMon =
                new ServiceMonitor<Simple>(testManager.getServiceDiscoveryManager(), Simple.class);
            sMon.waitFor(2);
            instances =
                cybernode.getServiceBeanInstances(opstring.getServices()[0]);
View Full Code Here

    @Test
    public void testSimpleDecrement() {
        Assert.assertNotNull(testManager);
        Throwable thrown = null;
        try {
            OperationalStringManager mgr = testManager.deploy();
            Assert.assertNotNull("Expected non-null OperationalStringManager", mgr);
            OperationalString opstring = mgr.getOperationalString();
            Assert.assertNotNull(opstring);
            Assert.assertEquals(1, opstring.getServices().length);
            testManager.waitForDeployment(mgr);
            ServiceBeanInstance[] instances =
                cybernode.getServiceBeanInstances(opstring.getServices()[0]);
            Assert.assertEquals(1, instances.length);
            Simple simple = (Simple)instances[0].getService();
            Assert.assertEquals("Hello visitor : 1", simple.hello("hi"));
            mgr.decrement(instances[0], true, true);
            ServiceMonitor<Simple> sMon =
                new ServiceMonitor<Simple>(testManager.getServiceDiscoveryManager(), Simple.class);
            sMon.waitFor(0);
            instances =
                cybernode.getServiceBeanInstances(opstring.getServices()[0]);
View Full Code Here

    public void testForkServiceHasPreDestroyInvoked() {
        Assert.assertNotNull(testManager);
        Assert.assertNotNull(cybernode);
        Throwable thrown = null;
        try {
            OperationalStringManager mgr = testManager.getOperationalStringManager();
            Assert.assertNotNull("Expected non-null OperationalStringManager", mgr);
            testManager.waitForDeployment(mgr);
            File marker = ForkImpl.getMarkerFile();
            Assert.assertTrue("The marker file should exist", marker.exists());
            DestroyAdmin dAdmin = (DestroyAdmin)cybernode.getAdmin();
View Full Code Here

            }
            lCache.discard(m);
        }

        OperationalStringManager getManager() throws Throwable {
            OperationalStringManager opMgr = null;
            ProvisionManager monitor;
            synchronized(monitors) {
                if(!monitors.isEmpty())
                    monitor = monitors.get(0);
                else {
View Full Code Here

     *
     * @throws Exception If there are errors redeploying
     */
    static void redeploy(ProvisionMonitor monitor,
                         String opStringName) throws Exception {
        OperationalStringManager mgr =
            Util.getOperationalStringManager(monitor, opStringName);
        mgr.redeploy(null, null, false, 0, null);
    }
View Full Code Here

     */
    static void redeploy(ProvisionMonitor monitor,
                         String opStringName,
                         ServiceElement sElem) throws Exception {

        OperationalStringManager mgr =
            Util.getOperationalStringManager(monitor, opStringName);
        if(mgr!=null) {
            mgr.redeploy(sElem, null, false, 0, null);
        }
    }
View Full Code Here

     */
    static void redeploy(ProvisionMonitor monitor,
                         String opStringName,
                         ServiceBeanInstance instance) throws Exception {

        OperationalStringManager mgr =
            Util.getOperationalStringManager(monitor, opStringName);
        if(mgr!=null) {
            mgr.redeploy(null, instance, false, 0, null);
        }
    }
View Full Code Here

        }
    }

    private void decrementOnFailedAdvertiseLifecycle() {
        if(context!=null) {
            OperationalStringManager manager = context.getServiceBeanManager().getOperationalStringManager();
            try {
                manager.decrement(context.getServiceBeanManager().getServiceBeanInstance(),
                                  true,
                                  true);
                logger.debug("Decremented {}, the instance will not be re-allocated", clientName);
            } catch (Exception e1) {
                logger.warn("Unable to remove service {}/{}:{} instance from OperationalStringManager",
View Full Code Here

TOP

Related Classes of org.rioproject.opstring.OperationalStringManager

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.