Package org.apache.ace.log

Examples of org.apache.ace.log.LogEvent


    }

    private void doTestServlet() throws Exception {
        // prepare the store
        List<LogEvent> events = new ArrayList<LogEvent>();
        events.add(new LogEvent("42", 1, 1, 1, 1, new Properties()));
        events.add(new LogEvent("47", 1, 1, 1, 1, new Properties()));
        events.add(new LogEvent("47", 2, 1, 1, 1, new Properties()));
        events.add(new LogEvent("47", 2, 2, 1, 1, new Properties()));
        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


        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 LogEvent("", 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 LogEvent("", 0, 0, 0, type, properties)).toRepresentation(), e);
        }
    }
View Full Code Here

            }

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

     * @throws java.io.IOException
     *             in case of any IO error.
     */
    public synchronized LogEvent put(int type, Dictionary props) throws IOException {
        try {
            LogEvent result = new LogEvent(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

            long highest = delta.getHigh();
            if (lowest <= highest) {
                List events = m_LogStore.get(logID, lowest, highestLocal > highest ? highest : highestLocal);
                Iterator iter = events.iterator();
                while (iter.hasNext()) {
                    LogEvent current = (LogEvent) iter.next();
                    while ((current.getID() > lowest) && rangeIterator.hasNext()) {
                        lowest = rangeIterator.next();
                    }
                    if (current.getID() == lowest) {
                        // before we send the LogEvent to the other side, we fill out the
                        // appropriate identification
                        LogEvent event = new LogEvent(m_identification.getID(), current);
                        writer.write(event.toRepresentation() + "\n");
                    }
                }
            }
        }
View Full Code Here

*/
public class ACE308Test {
    @Test( groups = { TestUtils.UNIT } )
    public void testLogEvents() {
      LogEventComparator c = new LogEventComparator();
      LogEvent left = new LogEvent("t", 1, 1, -1000000000000000000L, 0, null);
      LogEvent right = new LogEvent("t", 1, 1, 1, 0, null);
      Assert.assertTrue((left.getTime() - right.getTime()) < 0L);
      Assert.assertTrue(c.compare(left, right) < 0L);
    }
View Full Code Here

        input.setBytes(expected.getBytes());
        m_logServlet.handleSend(input);

        String actual = "";
        for (Iterator<LogEvent> i = m_mockStore.m_events.iterator(); i.hasNext();) {
            LogEvent event = i.next();
            actual = actual + event.toRepresentation() + "\n";
        }
        assert expected.equals(actual);
    }
View Full Code Here

    }

    @Test(groups = { UNIT })
    public synchronized void synchronizeLog() throws Exception {
        final LogDescriptor range = new LogDescriptor(TARGET_ID, 1, new SortedRangeSet(new long[] {0}));
        final LogEvent event = new LogEvent(TARGET_ID, 1, 1, 1, 1, new Properties());
        final List<LogEvent> events = new ArrayList<LogEvent>();
        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; }
            @SuppressWarnings("unchecked")
            public LogEvent 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

        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 LogEvent("", 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 LogEvent("", 0, 0, 0, type, properties)).toRepresentation(), e);
        }
    }
View Full Code Here

        assert ranges.isEmpty() : "New store should have no ranges.";
        List<LogEvent> events = new ArrayList<LogEvent>();
        for (String target : new String[] { "g1", "g2", "g3" }) {
            for (long log : new long[] { 1, 2, 3, 5 }) {
                for (long id : new long[] { 1, 2, 3, 20 }) {
                    events.add(new LogEvent(target, log, id, System.currentTimeMillis(), AuditEvent.FRAMEWORK_STARTED, new Properties() {
                        {
                            put("test", "bar");
                        }
                    }));
                }
View Full Code Here

TOP

Related Classes of org.apache.ace.log.LogEvent

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.