Package org.apache.ace.feedback

Examples of org.apache.ace.feedback.Event


            List<Event> newEvents = m_repository.getAuditEvents(newDescriptors);
            boolean foundDeploymentEvent = false;
            boolean foundPropertiesEvent = false;
            for (int position = newEvents.size() - 1; position >= 0; position--) {
                Event event = newEvents.get(position);
               
                if (!foundDeploymentEvent) {
                    // TODO we need to check here if the deployment package is actually the right one
                    String currentVersion = (String) event.getProperties().get(AuditEvent.KEY_VERSION);
                    if (event.getType() == AuditEvent.DEPLOYMENTCONTROL_INSTALL) {
                        addStatusAttribute(KEY_LAST_INSTALL_VERSION, currentVersion);
                        setProvisioningState(ProvisioningState.InProgress);
                        sendNewAuditlog(newDescriptors);
                        m_processedAuditEvents = allDescriptors;
                        foundDeploymentEvent = true;
                    }
                    if (event.getType() == AuditEvent.DEPLOYMENTADMIN_COMPLETE) {
                        addStatusAttribute(KEY_LAST_INSTALL_VERSION, currentVersion);
                        if ((currentVersion != null) && currentVersion.equals(getStatusAttribute(KEY_ACKNOWLEDGED_INSTALL_VERSION))) {
                            setProvisioningState(ProvisioningState.Idle);
                            sendNewAuditlog(newDescriptors);
                            m_processedAuditEvents = allDescriptors;
                            foundDeploymentEvent = true;
                        }
                        else {
                            String value = (String) event.getProperties().get(AuditEvent.KEY_SUCCESS);
                            addStatusAttribute(KEY_LAST_INSTALL_SUCCESS, value);
                            if (Boolean.parseBoolean(value)) {
                                setProvisioningState(ProvisioningState.OK);
                                sendNewAuditlog(newDescriptors);
                                m_processedAuditEvents = allDescriptors;
                                foundDeploymentEvent = true;
                            }
                            else {
                                setProvisioningState(ProvisioningState.Failed);
                                sendNewAuditlog(newDescriptors);
                                m_processedAuditEvents = allDescriptors;
                                foundDeploymentEvent = true;
                            }
                        }
                    }
                }
                if (!foundPropertiesEvent) {
                    if (event.getType() == AuditEvent.TARGETPROPERTIES_SET) {
                        m_processedTargetProperties = event.getProperties();
                        foundPropertiesEvent = true;
                        determineTargetPropertiesState();
                    }
                }
                // as soon as we've found the latest of both types of events, we're done
View Full Code Here


    }

    @Test(groups = { UNIT })
    public synchronized void synchronizeLog() throws Exception {
        final Descriptor range = new Descriptor(TARGET_ID, 1, new SortedRangeSet(new long[] {0}));
        final Event event = new Event(TARGET_ID, 1, 1, 1, 1);
        final List<Event> events = new ArrayList<Event>();
        events.add(event);

        InputStream input = new InputStream() {
            byte[] bytes = range.toRepresentation().getBytes();
            int count = 0;
            @Override
            public int read() throws IOException {
                if (count < bytes.length) {
                    byte b = bytes[count];
                    count++;
                    return b;
                } else {
                    return -1;
                }
            }
        };
        TestUtils.configureObject(m_task, LogStore.class, new LogStore() {
            public List<?> get(long logID, long from, long to) throws IOException {
                return events;
            }
            public long getHighestID(long logID) throws IOException {
                return event.getID();
            }
            public List<?> get(long logID) throws IOException { return null; }
            public long[] getLogIDs() throws IOException { return null; }
            public Event put(int type, Dictionary props) throws IOException { return null; }
        });
        MockConnection connection = new MockConnection(new URL("http://mock"));
       
        m_task.synchronizeLog(1, input, connection);
        String expectedString = event.toRepresentation() + "\n";
        String actualString = connection.getString();

        assert actualString.equals(expectedString) : "We expected " + expectedString + " but received " + actualString;
    }
View Full Code Here

        for (Event current : events) {
            while ((current.getID() > lowest) && rangeIterator.hasNext()) {
                lowest = rangeIterator.next();
            }
            if (current.getID() == lowest) {
                Event event = new Event(identification, current);
                sendWriter.write(event.toRepresentation());
                sendWriter.write("\n");
            }
        }
    }
View Full Code Here

            // Sort the records by their event ID...
            Collections.sort(records);
            // Unmarshal the records into concrete log events...
            List<Event> result = new ArrayList<Event>();
            for (Record record : records) {
                result.add(new Event(record.m_entry));
            }
            return result;
        }
        finally {
            closeIfNeeded(stores);
View Full Code Here

                // check if we exceed the maximum allowed store size, if so, we do clean up old files...
                cleanupOldStoreFiles();
            }

            // log the event XXX shouldn't the target ID be filled in?
            Event result = new Event(getTargetID(), storeID, nextEventId, System.currentTimeMillis(), type, properties);

            currentStore.append(result.getID(), result.toRepresentation().getBytes());
        }
        catch (IOException ex) {
            handleException(currentStore, ex);
        }
    }
View Full Code Here

            }

            while (store.hasNext()) {
                long eventID = store.readCurrentID();
                if ((eventID >= from) && (eventID <= to)) {
                    result.add(new Event(new String(store.read())));
                } else {
                    store.skip();
                }
            }
        }
View Full Code Here

            while (keys.hasMoreElements()) {
                String key = (String) keys.nextElement();
                props.put(key, (String) dict.get(key));
            }
           
            Event result = new Event(null, m_store.getId(), getNextID(), System.currentTimeMillis(), type, props);
            m_store.append(result.getID(), result.toRepresentation().getBytes());
            return result;
        }
        catch (IOException ex) {
            handleException(m_store, ex);
        }
View Full Code Here

import org.testng.annotations.Test;

public class LogEventTest {
    @Test(groups = { UNIT })
    public void serializeLogEvent() {
        Event e = new Event("gwid", 1, 2, 3, AuditEvent.FRAMEWORK_STARTED);
        assert e.toRepresentation().equals("gwid,1,2,3," + AuditEvent.FRAMEWORK_STARTED);
        Map<String, String> p = new HashMap<String, String>();
        p.put(AuditEvent.KEY_ID, "my first value");
        e = new Event("gwid", 1, 2, 3, AuditEvent.BUNDLE_INSTALLED, p);
        assert e.toRepresentation().equals("gwid,1,2,3," + AuditEvent.BUNDLE_INSTALLED + "," + AuditEvent.KEY_ID + ",my first value");
        e = new Event("gwid,gwid\n\r$", 1, 2, 3, AuditEvent.FRAMEWORK_STARTED);
        assert e.toRepresentation().equals("gwid$kgwid$n$r$$,1,2,3," + AuditEvent.FRAMEWORK_STARTED);
    }
View Full Code Here

        try {
            m_store.put(type, properties);
        }
        catch (NullPointerException e) {
            // if we cannot store the event, we log it to the normal log as extensively as possible
            m_log.log(LogService.LOG_WARNING, "Could not store event: " + (new Event("", 0, 0, 0, type, properties)).toRepresentation(), e);
        }
        catch (IOException e) {
            // if we cannot store the event, we log it to the normal log as extensively as possible
            m_log.log(LogService.LOG_WARNING, "Could not store event: " + (new Event("", 0, 0, 0, type, properties)).toRepresentation(), e);
        }
    }
View Full Code Here

        assert e.toRepresentation().equals("gwid$kgwid$n$r$$,1,2,3," + AuditEvent.FRAMEWORK_STARTED);
    }

    @Test(groups = { UNIT })
    public void deserializeLogEvent() {
        Event e = new Event("gwid$kgwid$n$r$$,1,2,3," + AuditEvent.FRAMEWORK_STARTED + ",a,1,b,2,c,3");
        assert e.getTargetID().equals("gwid,gwid\n\r$") : "Target ID is not correctly parsed";
        assert e.getStoreID() == 1 : "Log ID is not correctly parsed";
        assert e.getID() == 2 : "ID is not correctly parsed";
        assert e.getTime() == 3 : "Time is not correctly parsed";
        assert e.getType() == AuditEvent.FRAMEWORK_STARTED : "Event type is wrong";
        Map<String, String> p = e.getProperties();
        assert p != null : "Properties are not correctly parsed";
        assert p.get("a").equals("1") : "Property a should be 1";
        assert p.get("b").equals("2") : "Property a should be 1";
        assert p.get("c").equals("3") : "Property a should be 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.