Package org.apache.ace.log

Examples of org.apache.ace.log.LogDescriptor


    // Handle a call to the query 'command'
    protected boolean handleQuery(String targetID, String logID, String filter, ServletOutputStream output) throws IOException {
        if ((targetID != null) && (logID != null)) {
            // target and log id are specified, return only the range that matches these id's
            LogDescriptor range = m_store.getDescriptor(targetID, Long.parseLong(logID));
            output.print(range.toRepresentation());
            return true;
        }
        else if ((targetID == null) && (logID == null)) {
            // no target or log id has been specified, return all ranges
            List<LogDescriptor> ranges = m_store.getDescriptors();
            for (LogDescriptor range : ranges) {
                output.print(range.toRepresentation() + "\n");
            }
            return true;
        }
        return false;
    }
View Full Code Here


    // Handle a call to the receive 'command'
    protected boolean handleReceive(String targetID, String logID, String range, String filter, ServletOutputStream output) throws IOException {
        if ((targetID != null) && (logID != null)) {
            // target and log id are specified, return only the events that are in the range that matches these id's
            if (range != null) {
                LogDescriptor storeDescriptor = m_store.getDescriptor(targetID, Long.parseLong(logID));
                outputRange(output, new LogDescriptor(storeDescriptor.getTargetID(), storeDescriptor.getLogID(), new SortedRangeSet(range)));
            }
            else {
                outputRange(output, m_store.getDescriptor(targetID, Long.parseLong(logID)));
            }
            return true;
View Full Code Here

        Long high = m_fileToID.get(new File(new File(m_dir,
                targetIDToFilename(targetID)), String.valueOf(logID))
                .getAbsolutePath());
        if (high != null) {
            Range r = new Range(1, high);
            return new LogDescriptor(targetID, logID, new SortedRangeSet(
                    r.toRepresentation()));
        }
        List<LogEvent> events = get(new LogDescriptor(targetID, logID,
                SortedRangeSet.FULL_SET));

        long[] idsArray = new long[events.size()];
        int i = 0;
        for (LogEvent e : events) {
            idsArray[i++] = e.getID();
        }
        return new LogDescriptor(targetID, logID, new SortedRangeSet(idsArray));
    }
View Full Code Here

                cached = true;
            }
        }
        List<LogEvent> events = null;
        if (!cached) {
            events = get(new LogDescriptor(targetID, logID,
                    SortedRangeSet.FULL_SET));

            // remove duplicates first
            list.removeAll(events);
        }
View Full Code Here

         * that the remote does not have. If we do not find a matching one at all, we send the complete local
         * log.
         */
        List<LogDescriptor> result = new ArrayList<LogDescriptor>();
        for (LogDescriptor s : source) {
            LogDescriptor diffs = s;
            for (LogDescriptor d : destination) {
                if ((s.getLogID() == d.getLogID()) && (s.getTargetID().equals(d.getTargetID()))) {
                    SortedRangeSet rangeDiff = d.getRangeSet().diffDest(s.getRangeSet());
                    if (!isEmptyRangeSet(rangeDiff)) {
                        diffs = new LogDescriptor(s.getTargetID(), s.getLogID(), rangeDiff);
                    }
                    else {
                        diffs = null;
                    }
                }
View Full Code Here

        try {
            queryReader = new BufferedReader(new InputStreamReader(stream));

            for (String line = queryReader.readLine(); line != null; line = queryReader.readLine()) {
                try {
                    result.add(new LogDescriptor(line));
                }
                catch (IllegalArgumentException iae) {
                    throw new IOException("Could not determine highest remote event id, received malformed event range: " + line);
                }
            }
View Full Code Here

    long high = 1;
    if (cursor.hasNext()) {
      DBObject row = cursor.next();
      high = (Long) row.get("id");
      return new LogDescriptor(targetID, logID, new SortedRangeSet(
          new Range(1, high).toRepresentation()));
    } else {
      return new LogDescriptor(targetID, logID, SortedRangeSet.FULL_SET);
    }
  }
View Full Code Here

        try {
            queryReader = new BufferedReader(new InputStreamReader(queryInput));
            String rangeString = queryReader.readLine();
            if (rangeString != null) {
                try {
                    return new LogDescriptor(rangeString);
                }
                catch (IllegalArgumentException iae) {
                    throw new IOException(
                            "Could not determine highest remote event id, received malformed event range ("
                                    + rangeString + ")");
View Full Code Here

        TestUtils.configureObject(m_task, LogStore.class);
    }

    @Test(groups = { UNIT })
    public synchronized void getRange() throws Exception {
        final LogDescriptor range = new LogDescriptor("gwID", 1, new SortedRangeSet("1-10"));
        m_task.getDescriptor(new InputStream() {
            int m_count = 0;
            byte[] m_bytes = (range.toRepresentation() + "\n").getBytes();
            @Override
            public int read() throws IOException {
                if (m_count < m_bytes.length) {
                    byte b = m_bytes[m_count];
                    m_count++;
View Full Code Here

        });
    }

    @Test(groups = { UNIT })
    public synchronized void synchronizeLog() throws Exception {
        final LogDescriptor range = new LogDescriptor("gwID", 1, new SortedRangeSet(new long[] {0}));
        final LogEvent event = new LogEvent("gwID", 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];
View Full Code Here

TOP

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

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.