Package org.rioproject.eventcollector.api

Examples of org.rioproject.eventcollector.api.EventCollectorAdmin


    public void delete(Collection<RemoteServiceEvent> events) {
        if(events!=null && !events.isEmpty() && useEventCollector.get()) {
            for(EventCollector eventCollector : eventCollectors) {
                try {
                    EventCollectorAdmin admin = (EventCollectorAdmin)eventCollector.getAdmin();
                    admin.delete(events);
                } catch(IOException e) {

                }
            }
        }
View Full Code Here


    /**
     * Override parents getServiceAdmin method
     */
    public ServiceAdmin getServiceAdmin() throws RemoteException {
        if(adminProxy==null) {
            EventCollectorAdmin remoteRef = (EventCollectorAdmin)exporter.export(this);
            adminProxy =  EventCollectorAdminProxy.getInstance(remoteRef, UuidFactory.generate());
        }
        return(adminProxy);
    }
View Full Code Here

    public void stopEventCollector() {
        cybernode.deactivate(eventCollector);
    }
    @Test
    public void testGettingTheAdminProxy() {
        EventCollectorAdmin admin = (EventCollectorAdmin) eventCollector.getAdmin();
        Assert.assertNotNull(admin);
    }
View Full Code Here

        Assert.assertNotNull(admin);
    }

    @Test
    public void testUsingTheAdminProxy() throws IOException, InterruptedException {
        EventCollectorAdmin admin = (EventCollectorAdmin) eventCollector.getAdmin();
        Assert.assertNotNull(admin);
        PersistentEventManager eventManager = (PersistentEventManager)eventCollector.getEventManager();
        eventManager.addRemoteEvents(TransientEventManagerTest.createRemoteServiceEvents(10));
        /* Writing events to disk is an async operation, sleep for a bit before asserting */
        waitForFileCount(10, eventManager.getPersistentEventDirectory());
        Assert.assertEquals("Expected 10 events, got "+eventManager.getNumberOfCollectedEvents(),
                            10, eventManager.getNumberOfCollectedEvents());

        Collection<RemoteServiceEvent> events = eventManager.getEvents();
        int deleted = admin.delete(events);
        Assert.assertEquals("Expected 10, got "+deleted, 10, deleted);
        Assert.assertEquals("Expected 0 events, got "+eventManager.getNumberOfCollectedEvents(),
                            0, eventManager.getNumberOfCollectedEvents());
        File directory = eventManager.getPersistentEventDirectory();
        Assert.assertEquals("Expected 0 event files, got " + directory.list().length,
View Full Code Here

                            0, directory.list().length);
    }

    @Test
    public void testOnlyDeleteSome() throws IOException, InterruptedException {
        EventCollectorAdmin admin = (EventCollectorAdmin) eventCollector.getAdmin();
        Assert.assertNotNull(admin);
        PersistentEventManager eventManager = (PersistentEventManager)eventCollector.getEventManager();
        eventManager.addRemoteEvents(TransientEventManagerTest.createRemoteServiceEvents(10));
        waitForFileCount(10, eventManager.getPersistentEventDirectory());
        Assert.assertEquals("Expected 10 events, got "+eventManager.getNumberOfCollectedEvents(),
                            10, eventManager.getNumberOfCollectedEvents());
        List<RemoteServiceEvent> eventsToDelete = new ArrayList<RemoteServiceEvent>();
        eventsToDelete.addAll(eventManager.getEvents());
        for(int i=0; i<3; i++)
            eventsToDelete.remove(0);
        int deleted = admin.delete(eventsToDelete);
        Assert.assertEquals("Expected 7, got "+deleted, 7, deleted);
        Assert.assertEquals("Expected 3 events, got "+eventManager.getNumberOfCollectedEvents(),
                            3, eventManager.getNumberOfCollectedEvents());
        File directory = eventManager.getPersistentEventDirectory();
        Assert.assertEquals("Expected 3 event files, got "+directory.list().length,
                            3, directory.list().length);
        /* Now delete the rest */
        eventsToDelete.clear();
        eventsToDelete.addAll(eventManager.getEvents());
        deleted = admin.delete(eventsToDelete);
        Assert.assertEquals("Expected 3, got "+deleted, 3, deleted);
        Assert.assertEquals("Expected 0 events, got "+eventManager.getNumberOfCollectedEvents(),
                            0, eventManager.getNumberOfCollectedEvents());
        Assert.assertEquals("Expected 0 event files, got "+directory.list().length,
                            0, directory.list().length);
View Full Code Here

TOP

Related Classes of org.rioproject.eventcollector.api.EventCollectorAdmin

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.