Package com.sun.grid.jgdi

Examples of com.sun.grid.jgdi.JGDI


        log.entering("JGDIJMXBase", "getJGDI");
        JGDISession session = JGDISession.getCurrentSession();
        if (session.getId() != owner.getId()) {
            throw new SecurityException("Session " + session.getId() + " has no permission to mbean of session " + owner.getId());
        }
        JGDI ret = owner.getJGDI();
        log.exiting("JGDIJMXBase", "getJGDI", ret);
        return ret;
    }
View Full Code Here


        jgdi = JGDIFactory.newInstance(url);
    }
   
    public void close() throws RemoteException {
        logger.entering("JGDIRemoteBaseImpl","close");
        JGDI jgdi = this.jgdi;
        this.jgdi = null;
        if( jgdi != null ) {
            try {
                jgdi.close();
            } catch( JGDIException e ) {
                throw new RemoteException(e.getMessage(), e);
            }
        }
        logger.exiting("JGDIRemoteBaseImpl","close");
View Full Code Here

            }
            String url = args[0];
            String objectName = args[1];
            String name = args[2];
           
            JGDI jgdi = JGDIFactory.newInstance(url);
           
            if(name.equals("all")) {
               
                Method method = JGDI.class.getMethod("get" + objectName + "List", (java.lang.Class[])null);
               
View Full Code Here

        }

        public void run() {
            log.entering(getClass().getName(), "run");

            JGDI jgdi = null;
            try {
                setState(State.STARTING);
                jgdi = JGDIFactory.newInstance(url);

                log.log(Level.FINER, "calling initNative({0})", regId);
                evcIndex = initNative(jgdi, regId);

                log.log(Level.FINER, "calling registerNative({0})", evcIndex);
                int id = registerNative(evcIndex);
                log.log(Level.FINER, "event client registered (id={0})", id);
                lock.lock();
                try {
                    this.evcId = id;
                } finally {
                    lock.unlock();
                }
                setState(State.RUNNING);

                boolean gotShutdownEvent = false;
                List<Event> eventList = new ArrayList<Event>();

                while (true) {
                    if (Thread.currentThread().isInterrupted()) {
                        log.log(Level.FINE, "event loop has been interrupted");
                        break;
                    }
                    if (gotShutdownEvent) {
                        break;
                    }

                    doCommit(evcIndex);

                    log.log(Level.FINER, "calling native method fillEvents for event client {0}", evcId);
                    fillEvents(evcIndex, eventList);

                    if (log.isLoggable(Level.FINER)) {
                        log.log(Level.FINE, "got {0} events from qmaster for event client {1}",
                                new Object[]{eventList.size(), evcId});
                    }

                    if (Thread.currentThread().isInterrupted()) {
                        log.log(Level.FINE, "event loop has been interrupted");
                        break;
                    }
                    for (Event event : eventList) {
                        try {
                            fireEventOccured(event);
                            if (event instanceof QmasterGoesDownEvent || event instanceof ShutdownEvent) {
                                if (gotShutdownEvent == false) {
                                    log.log(Level.FINE, "got shutdown event");
                                    gotShutdownEvent = true;
                                }
                            }
                        } catch (Exception e) {
                            log.log(Level.WARNING, "error in fire event", e);
                        }
                    }
                    eventList.clear();
                }
            } catch (JGDIException ex) {
                error(ex);
            } catch (Throwable ex) {
                error(new JGDIException(ex, "Unknown error in event loop"));
            } finally {
                setState(State.STOPPING);
                if (evcIndex >= 0) {
                    try {
                        closeNative(evcIndex);
                    } catch (Exception ex) {
                    // Ignore
                    } finally {
                        evcIndex = -1;
                    }
                }
                if (jgdi != null) {
                    try {
                        jgdi.close();
                    } catch (Exception ex) {
                    // Igore
                    }
                }
                setState(State.STOPPED);
View Full Code Here

            if (args.length == 1) {
                url = args[0];
            }

            JGDI jgdi = JGDIFactory.newInstance(url);

            try {
                System.out.println("Successfully connected to " + url);

                EventClient evc = JGDIFactory.createEventClient(url, 0);

                evc.subscribe(EventTypeEnum.CheckpointAdd);
                evc.subscribe(EventTypeEnum.CheckpointMod);
                evc.subscribe(EventTypeEnum.CheckpointDel);

                evc.commit();

                evc.addEventListener(new EventListener() {

                    public void eventOccured(Event evt) {
                        System.out.println("got event " + evt);
                    }
                });


                try {

                    // Create a new checkpoint object which intialized with default values
                    Checkpoint ckpt = ConfigurationFactory.createCheckpointWithDefaults();
                    ckpt.setName("sample");
                    ckpt.setCkptCommand("/usr/bin/ckpt");
                    ckpt.setCkptDir("/tmp");

                    jgdi.addCheckpoint(ckpt);
                    try {
                        System.out.println("Checkpoint " + ckpt.getName() + " successfully added");
                        ckpt = jgdi.getCheckpoint(ckpt.getName());
                        ckpt.setRestCommand("/tmp/blubber");
                        jgdi.updateCheckpoint(ckpt);
                        System.out.println("Checkpoint " + ckpt.getName() + " successfully modified");
                    } finally {
                        jgdi.deleteCheckpoint(ckpt);
                        System.out.println("Checkpoint " + ckpt.getName() + " successfully deleted");
                    }

                    Thread.sleep(60000);
                } finally {
                    evc.close();
                }
            } finally {
                jgdi.close();
            }
        } catch (JGDIException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
        // Ignore
View Full Code Here

        TestSuite suite = new TestSuite(TestQueueInstanceSummary.class);
        return suite;
    }
   
    public void testFullOutput() throws Exception {
        JGDI jgdi = createJGDI();
        try {
            QueueInstanceSummaryOptions options = new QueueInstanceSummaryOptions();
            options.setShowFullOutput(true);
            QueueInstanceSummaryResult result = jgdi.getQueueInstanceSummary(options);
            if (logger.isLoggable(Level.FINE)) {
                PrintWriter pw = new PrintWriter(System.out);
                QueueInstanceSummaryPrinter.print(pw, result, options);
                pw.flush();
            }
        } finally {
            jgdi.close();
        }
    }
View Full Code Here

        }
    }
   
    public void testAllResourceAttributes() throws Exception {
       
        JGDI jgdi = createJGDI();
        try {
            QueueInstanceSummaryOptions options = new QueueInstanceSummaryOptions();
            ResourceAttributeFilter raf = new ResourceAttributeFilter();
            options.setResourceAttributeFilter(raf);
            QueueInstanceSummaryResult result = jgdi.getQueueInstanceSummary(options);
            if (logger.isLoggable(Level.FINE)) {
                PrintWriter pw = new PrintWriter(System.out);
                QueueInstanceSummaryPrinter.print(pw, result, options);
                pw.flush();
            }
        } finally {
            jgdi.close();
        }
    }
View Full Code Here

   
    public void testQueueStateFilterSuspended() throws Exception {
       
        QueueInstanceSummaryOptions options = new QueueInstanceSummaryOptions();
        options.setShowFullOutput(true);
        JGDI jgdi = createJGDI();
        try {
            QueueInstanceSummaryResult result = jgdi.getQueueInstanceSummary(options);
            List<QueueInstanceSummary> qiList = result.getQueueInstanceSummary();
            QueueStateFilter qsf = new QueueStateFilter();
            qsf.setSuspended(true);
            options.setQueueStateFilter(qsf);
            options.setShowFullOutput(true);
            for (QueueInstanceSummary qis : qiList) {
                logger.fine("Suspend queue " + qis.getName());
                jgdi.suspendQueues(new String[]{qis.getName()}, false);
                result = jgdi.getQueueInstanceSummary(options);
                // if (logger.isLoggable(Level.FINE)) {
                PrintWriter pw = new PrintWriter(System.out);
                QueueInstanceSummaryPrinter.print(pw, result, options);
                pw.flush();
                // }
                boolean found = false;
                for (QueueInstanceSummary susQis : result.getQueueInstanceSummary()) {
                    pw.println("susQis.getName() = " + susQis.getName() + " state = " + susQis.getState());
                    assertTrue("expect state 's' for queue instance " + susQis.getName(), (susQis.getState().indexOf('s') >= 0));
                    if (qis.getName().equals(susQis.getName())) {
                        found = true;
                    }
                }
                assertTrue("suspended queue instance " + qis.getName() + " is not in result", found);
                logger.fine("Unsuspend queue " + qis.getName());
                jgdi.unsuspendQueues(new String[]{qis.getName()}, false);
            }
        } finally {
            jgdi.close();
        }
    }
View Full Code Here

        QueueInstanceSummaryOptions options = new QueueInstanceSummaryOptions();
        options.setShowFullOutput(true);
        QueueStateFilter qsf = new QueueStateFilter();
        qsf.setDisabled(true);
        options.setQueueStateFilter(qsf);
        JGDI jgdi = createJGDI();
        try {
            QueueInstanceSummaryResult result = jgdi.getQueueInstanceSummary(options);
            List<QueueInstanceSummary> qiList = result.getQueueInstanceSummary();
            // Disable all queues
            jgdi.disableQueues(new String[]{"*"}, false);
            result = jgdi.getQueueInstanceSummary(options);
            List<QueueInstanceSummary> newQiList = result.getQueueInstanceSummary();
            for (QueueInstanceSummary qis : qiList) {
                boolean found = false;
                for (QueueInstanceSummary qis1 : newQiList) {
                    if (qis.getName().equals(qis1.getName())) {
                        found = true;
                        break;
                    }
                }
                assertTrue("queue instance " + qis.getName() + " has not been found in disabled queue list", found);
            }
            jgdi.enableQueues(new String[]{"*"}, true);
            result = jgdi.getQueueInstanceSummary(options);
            newQiList = result.getQueueInstanceSummary();
            if (logger.isLoggable(Level.FINE)) {
                PrintWriter pw = new PrintWriter(System.out);
                QueueInstanceSummaryPrinter.print(pw, result, options);
                pw.flush();
            }
            assertEquals("got queue instances, but all queues are disabled", 0, newQiList.size());
        } finally {
            jgdi.close();
        }
    }
View Full Code Here

    public void testQueueFilter() throws Exception {
       
        QueueInstanceSummaryOptions options = new QueueInstanceSummaryOptions();
        options.setShowFullOutput(true);
       
        JGDI jgdi = createJGDI();
       
        try {
            QueueInstanceSummaryResult result = jgdi.getQueueInstanceSummary(options);
            List<QueueInstanceSummary> qiList = result.getQueueInstanceSummary();
           
            for (QueueInstanceSummary qis : qiList) {
                logger.fine("Filter for queue instance " + qis.getName());
                QueueFilter qf = new QueueFilter();
                qf.addQueue(qis.getName());
                options.setQueueFilter(qf);
                result = jgdi.getQueueInstanceSummary(options);
                if (logger.isLoggable(Level.FINE)) {
                    PrintWriter pw = new PrintWriter(System.out);
                    QueueInstanceSummaryPrinter.print(pw, result, options);
                    pw.flush();
                }
               
                List<QueueInstanceSummary> newQiList = result.getQueueInstanceSummary();
                assertTrue("Missing queue instance " + qis.getName(), !newQiList.isEmpty());
                for (QueueInstanceSummary newQis : newQiList) {
                    assertEquals("Queue instance " + newQis.getName() + " is not in queue filter", qis.getName(), newQis.getName());
                }
            }
        } finally {
            jgdi.close();
        }
    }
View Full Code Here

TOP

Related Classes of com.sun.grid.jgdi.JGDI

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.