Package org.apache.ace.feedback

Examples of org.apache.ace.feedback.Event


        }, false, RepositoryAdmin.TOPIC_LOGOUT);
    }

    private void doAutoTargetReg() throws Exception {
        List<Event> events = new ArrayList<Event>();
        events.add(new Event("anotherTarget", 1, 1, 1, AuditEvent.FRAMEWORK_STARTED));
        // fill auditlog; no install data
        m_auditLogStore.put(events);

        int initRepoSize = m_statefulTargetRepository.get().size();

        // Get the processauditlog task and run it
        ServiceTracker tracker = new ServiceTracker(m_bundleContext, m_bundleContext.createFilter("(&(" + Constants.OBJECTCLASS + "="
                + Runnable.class.getName() + ")(" + SchedulerConstants.SCHEDULER_NAME_KEY + "="
                + "org.apache.ace.client.processauditlog" + "))"), null);
        tracker.open();

        final Runnable processAuditlog = (Runnable) tracker.waitForService(2000);

        if (processAuditlog != null) {
            // commit should be called
            runAndWaitForEvent(new Callable<Object>() {
                public Object call() throws Exception {
                    processAuditlog.run();
                    return null;
                }
            }, false, RepositoryAdmin.TOPIC_REFRESH);

            assertEquals("After refresh, we expect 1 target based on auditlogdata;", initRepoSize + 1, m_statefulTargetRepository.get().size());
           
            List<StatefulTargetObject> sgoList = m_statefulTargetRepository.get(m_bundleContext.createFilter("(id=another*)"));
            StatefulTargetObject sgo = sgoList.get(0);
            assertTrue("Expected one (anotherTarget) in the list.", sgo != null);

            // should be registered and auto approved
            assertTrue("The automation target operator should have registered anotherTarget.", sgo.isRegistered());
            assertTrue("The automation target operator should have auto-approved anotherTarget.", sgo.getAutoApprove());

            // add a target which will not be autoregistered
            events.clear();
            events.add(new Event("secondTarget", 1, 1, 1, AuditEvent.FRAMEWORK_STARTED));
            m_auditLogStore.put(events);

            // do auto target action
            processAuditlog.run();
            assertEquals("After refresh, we expect an additional target based on auditlogdata;", initRepoSize + 2, m_statefulTargetRepository.get().size());
View Full Code Here


        // do checks
        assertTrue("We just preregistered a target, so it should be registered.", sgo1.isRegistered());

        // add auditlog data
        List<Event> events = new ArrayList<Event>();
        events.add(new Event("myNewTarget3", 1, 1, 1, AuditEvent.FRAMEWORK_STARTED));
        // add an (old) set of target properties
        Map<String, String> props2 = new HashMap<String, String>();
        props2.put("mykey", "myoldvalue");
        props2.put("myoldkey", "myoldvalue");
        events.add(new Event("myNewTarget3", 1, 2, 2, AuditEvent.TARGETPROPERTIES_SET, props2));
        // add a new set of target properties
        Map<String, String> props3 = new HashMap<String, String>();
        props3.put("mykey", "myvalue");
        events.add(new Event("myNewTarget3", 1, 3, 3, AuditEvent.TARGETPROPERTIES_SET, props3));
        m_auditLogStore.put(events);
        m_statefulTargetRepository.refresh();

        // do checks
        TargetObject to = sgo1.getTargetObject();
        assertNotNull("Stateful target should be backed by a target object.", to);
        assertEquals("Target should have a property mykey with value myvalue.", "myvalue", to.getTag("target.mykey"));
        assertNull("This old key should no longer have been associated with this target.", to.getTag("target.myoldkey"));
        assertTrue("Adding auditlog data for a target does not influence its isRegistered().", sgo1.isRegistered());

        // add auditlog data for other target
        events = new ArrayList<Event>();
        events.add(new Event("myNewTarget4", 1, 1, 1, AuditEvent.FRAMEWORK_STARTED));
        m_auditLogStore.put(events);
        runAndWaitForEvent(new Callable<Object>() {
            public Object call() throws Exception {
                m_statefulTargetRepository.refresh();
                return false;
View Full Code Here

        // do checks
        assertTrue("We just preregistered a gateway, so it should be registered.", sgo1.isRegistered());

        // add auditlog data
        List<Event> events = new ArrayList<Event>();
        events.add(new Event("myNewGatewayA", 1, 1, 1, AuditEvent.FRAMEWORK_STARTED));
        m_auditLogStore.put(events);
        m_statefulTargetRepository.refresh();

        // do checks
        assertTrue("Adding auditlog data for a gateway does not influence its isRegistered().", sgo1.isRegistered());
        try {
            sgo1.getTargetObject();
        }
        catch (IllegalStateException ise) {
            assertTrue("We should be able to get sgo1's gatewayObject.", false);
        }
        // add auditlog data for other gateway
        events = new ArrayList<Event>();
        events.add(new Event("myNewGatewayB", 1, 1, 1, AuditEvent.FRAMEWORK_STARTED));
        m_auditLogStore.put(events);
        runAndWaitForEvent(new Callable<Object>() {
            public Object call() throws Exception {
                m_statefulTargetRepository.refresh();
                return false;
View Full Code Here

        final String targetId = String.format("target-%s", Long.toHexString(System.nanoTime()));

        List<Event> events = new ArrayList<Event>();

        events.add(new Event(targetId, 1, 1, 1, AuditEvent.FRAMEWORK_STARTED));
        // fill auditlog; no install data
        m_auditLogStore.put(events);

        runAndWaitForEvent(new Callable<Void>() {
            public Void call() throws Exception {
                m_statefulTargetRepository.refresh();
                return null;
            }
        }, false, StatefulTargetObject.TOPIC_AUDITEVENTS_CHANGED, StatefulTargetObject.TOPIC_ADDED);

        StatefulTargetObject sgo = findStatefulTarget(targetId);
        assertNotNull("Expected new target object to become available!", sgo);

        assertEquals("We expect our object's provisioning state to be Idle;", ProvisioningState.Idle, sgo.getProvisioningState());

        // fill auditlog with complete-data
        events = new ArrayList<Event>();
        Map<String, String> props = new HashMap<String, String>();
        props.put(AuditEvent.KEY_NAME, "mypackage");
        props.put(AuditEvent.KEY_VERSION, "123");
        events.add(new Event(targetId, 1, 2, 2, AuditEvent.DEPLOYMENTCONTROL_INSTALL, props));

        m_auditLogStore.put(events);

        runAndWaitForEvent(new Callable<Void>() {
            public Void call() throws Exception {
                m_statefulTargetRepository.refresh();
                return null;
            }
        }, false, StatefulTargetObject.TOPIC_STATUS_CHANGED, StatefulTargetObject.TOPIC_AUDITEVENTS_CHANGED);

        assertEquals("Our last install version should be 123;", "123", sgo.getLastInstallVersion());
        assertEquals("We expect our object's provisioning state to be InProgress;", ProvisioningState.InProgress, sgo.getProvisioningState());

        // fill auditlog with install data
        events = new ArrayList<Event>();
        props = new HashMap<String, String>();
        props.put(AuditEvent.KEY_NAME, "mypackage");
        props.put(AuditEvent.KEY_VERSION, "123");
        props.put(AuditEvent.KEY_SUCCESS, "false");
        events.add(new Event(targetId, 1, 3, 3, AuditEvent.DEPLOYMENTADMIN_COMPLETE, props));

        m_auditLogStore.put(events);

        runAndWaitForEvent(new Callable<Void>() {
            public Void call() throws Exception {
                m_statefulTargetRepository.refresh();
                return null;
            }
        }, false, StatefulTargetObject.TOPIC_AUDITEVENTS_CHANGED, StatefulTargetObject.TOPIC_STATUS_CHANGED);

        assertEquals("Our last install version should be 123;", "123", sgo.getLastInstallVersion());
        assertEquals("We expect our object's provisioning state to be Failed;", ProvisioningState.Failed, sgo.getProvisioningState());
        assertFalse("Our last install was not successful, but according to the sgo it was.", sgo.getLastInstallSuccess());

        sgo.acknowledgeInstallVersion("123");

        assertEquals("We expect our object's provisioning state to be Idle;", ProvisioningState.Idle, sgo.getProvisioningState());

        // add another install event.
        events = new ArrayList<Event>();
        props = new HashMap<String, String>();
        props.put(AuditEvent.KEY_NAME, "mypackage");
        props.put(AuditEvent.KEY_VERSION, "124");
        events.add(new Event(targetId, 1, 4, 4, AuditEvent.DEPLOYMENTCONTROL_INSTALL, props));

        m_auditLogStore.put(events);

        runAndWaitForEvent(new Callable<Void>() {
            public Void call() throws Exception {
                m_statefulTargetRepository.refresh();
                return null;
            }
        }, false, StatefulTargetObject.TOPIC_AUDITEVENTS_CHANGED, StatefulTargetObject.TOPIC_STATUS_CHANGED);

        assertEquals("Our last install version should be 124;", "124", sgo.getLastInstallVersion());
        assertEquals("We expect our object's provisioning state to be InProgress;", ProvisioningState.InProgress, sgo.getProvisioningState());

        // fill auditlog with install data
        events = new ArrayList<Event>();
        props = new HashMap<String, String>();
        props.put(AuditEvent.KEY_NAME, "mypackage");
        props.put(AuditEvent.KEY_VERSION, "124");
        props.put(AuditEvent.KEY_SUCCESS, "true");
        events.add(new Event(targetId, 1, 5, 5, AuditEvent.DEPLOYMENTADMIN_COMPLETE, props));

        m_auditLogStore.put(events);

        runAndWaitForEvent(new Callable<Void>() {
            public Void call() throws Exception {
View Full Code Here

        final String targetID = ":)";

        List<Event> events = new ArrayList<Event>();

        // add a target with a weird name.
        events.add(new Event(targetID, 1, 1, 1, AuditEvent.FRAMEWORK_STARTED));
        // fill auditlog; no install data
        m_auditLogStore.put(events);

        runAndWaitForEvent(new Callable<Void>() {
            public Void call() throws Exception {
View Full Code Here

        storeEvents();

        Map<String, String> props = new HashMap<String, String>();
        props.put("myProperty", "myvalue");

        Event event1 = new Event("mytarget1", 2, 1, System.currentTimeMillis(), LogService.LOG_ERROR, props);
        Event event2 = new Event("mytarget1", 2, 2, System.currentTimeMillis(), LogService.LOG_ERROR, props);

        m_logStore.put(Arrays.asList(event1, event2));

        List<Descriptor> descriptors = m_logStore.getDescriptors("mytarget1");
        assertEquals(2, descriptors.size());
View Full Code Here

        storeEvents();

        Map<String, String> props = new HashMap<String, String>();
        props.put("myProperty", "myvalue");

        Event event1 = new Event("mytarget1", 2, 1, System.currentTimeMillis(), LogService.LOG_ERROR, props);
        Event event2 = new Event("mytarget1", 2, 2, System.currentTimeMillis(), LogService.LOG_ERROR, props);

        m_logStore.put(Arrays.asList(event1, event2));

        List<Descriptor> descriptors = m_logStore.getDescriptors();
        assertEquals(3, descriptors.size());
View Full Code Here

    }

    private void storeEvents() throws IOException {
        Map<String, String> props = new HashMap<String, String>();
        props.put("myProperty", "myvalue");
        Event event1 = new Event("mytarget1", 1, 1, System.currentTimeMillis(), LogService.LOG_ERROR, props);
        Event event2 = new Event("mytarget1", 1, 2, System.currentTimeMillis(), LogService.LOG_ERROR, props);
        Event event3 = new Event("mytarget2", 1, 3, System.currentTimeMillis(), LogService.LOG_ERROR, props);
        Event event4 = new Event("mytarget2", 1, 5, System.currentTimeMillis(), LogService.LOG_ERROR, props);
        Event event5 = new Event("mytarget1", 1, 4, System.currentTimeMillis(), LogService.LOG_ERROR, props);

        m_logStore.put(Arrays.asList(event1, event2, event3, event4, event5));
    }
View Full Code Here

        protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            resp.setContentType("text/plain");
            BufferedReader reader = new BufferedReader(new InputStreamReader(req.getInputStream()));
            String eventString;
            while ((eventString = reader.readLine()) != null) {
                Event event = new Event(eventString);
                m_events.add(event);
            }
            resp.setStatus(200);
        }
View Full Code Here

    }

    private void doTestServlet() throws Exception {
        // prepare the store
        List<Event> events = new ArrayList<Event>();
        events.add(new Event("42", 1, 1, 1, 1));
        events.add(new Event("47", 1, 1, 1, 1));
        events.add(new Event("47", 2, 1, 1, 1));
        events.add(new Event("47", 2, 2, 1, 1));
        m_serverStore.put(events);

        List<String> result = getResponse("http://localhost:" + TestConstants.PORT + "/auditlog/query");
        assertTrue("We expect at least two logs on the server.", result.size() > 1);
View Full Code Here

TOP

Related Classes of org.apache.ace.feedback.Event

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.