Package org.apache.ace.range

Examples of org.apache.ace.range.SortedRangeSet


        List<LogDescriptor> result = new ArrayList<LogDescriptor>();
        for (LogDescriptor s : source) {
            LogDescriptor diffs = s;
            for (LogDescriptor d : destination) {
                if ((s.getLogID() == d.getLogID()) && (s.getGatewayID().equals(d.getGatewayID()))) {
                    SortedRangeSet rangeDiff = d.getRangeSet().diffDest(s.getRangeSet());
                    if (!isEmptyRangeSet(rangeDiff)) {
                        diffs = new LogDescriptor(s.getGatewayID(), s.getLogID(), rangeDiff);
                    }
                    else {
                        diffs = null;
View Full Code Here


        // Not used in test
        return false;
    }

    public SortedRangeSet getRange() throws IOException {
        return new SortedRangeSet(m_range);
    }
View Full Code Here

    protected boolean handleReceive(String gatewayID, String logID, String range, String filter, ServletOutputStream output) throws IOException {
        if ((gatewayID != null) && (logID != null)) {
            // gateway 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(gatewayID, Long.parseLong(logID));
                outputRange(output, new LogDescriptor(storeDescriptor.getGatewayID(), storeDescriptor.getLogID(), new SortedRangeSet(range)));
            }
            else {
                outputRange(output, m_store.getDescriptor(gatewayID, Long.parseLong(logID)));
            }
            return true;
View Full Code Here

        try {
            URL host = m_discovery.discover();
            ServiceReference[] refs = m_context.getServiceReferences(RepositoryReplication.class.getName(), null);
            for (ServiceReference ref : refs) {
                RepositoryReplication repository = (RepositoryReplication) m_context.getService(ref);
                SortedRangeSet localRange = repository.getRange();
                Object customer = ref.getProperty("customer");
                Object name = ref.getProperty("name");
                String filter = "customer=" + customer + "&name=" + name;
                URL query = new URL(host, "/replication/query?" + filter);
                HttpURLConnection connection = (HttpURLConnection) query.openConnection();
                if (connection.getResponseCode() == HttpServletResponse.SC_OK) {
                    BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                    try {
                        String line = reader.readLine();
                        int i = line.lastIndexOf(',');
                        if (i > 0) {
                            SortedRangeSet remoteRange = new SortedRangeSet(line.substring(i + 1));
                            SortedRangeSet delta = localRange.diffDest(remoteRange);
                            RangeIterator iterator = delta.iterator();
                            while (iterator.hasNext()) {
                                long version = iterator.next();
                                URL get = new URL(host, "/replication/get?" + filter + "&version=" + version);
                                HttpURLConnection connection2 = (HttpURLConnection) get.openConnection();
                                repository.put(connection2.getInputStream(), version);
View Full Code Here

            m_storeID = Long.parseLong(st.nextToken());
            String rangeSet = "";
            if (st.hasMoreTokens()) {
                rangeSet = st.nextToken();
            }
            m_rangeSet = new SortedRangeSet(Codec.decode(rangeSet));
        }
        catch (NoSuchElementException e) {
            throw new IllegalArgumentException("Could not create range from: " + representation);
        }
    }
View Full Code Here

        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            String targetID = request.getParameter("tid");
            long logID = Long.parseLong(request.getParameter("logid"));
            response.getOutputStream().print(new Descriptor(targetID, logID, new SortedRangeSet(new long[0])).toRepresentation());
            response.setStatus(200);
        }
View Full Code Here

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

    @Test(groups = { UNIT })
    public synchronized void getRange() throws Exception {
        final Descriptor range = new Descriptor(TARGET_ID, 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 {
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() {
View Full Code Here

            }
            catch (InterruptedException e) {
                throw new IOException(e);
            }
        }
        return new SortedRangeSet(m_range);
    }
View Full Code Here

        if (highestLocal <= 0) {
            // manager is closed...
            return;
        }

        SortedRangeSet localRange = new SortedRangeSet("1-" + highestLocal);
        SortedRangeSet remoteRange = getQueryDescriptor(queryInput).getRangeSet();
        SortedRangeSet delta = remoteRange.diffDest(localRange);
        RangeIterator rangeIterator = delta.iterator();
        if (!rangeIterator.hasNext()) {
            // nothing to sync...
            return;
        }
        long lowest = rangeIterator.next();
        long highest = delta.getHigh();
        if (lowest > highest) {
            // nothing to sync...
            return;
        }
View Full Code Here

TOP

Related Classes of org.apache.ace.range.SortedRangeSet

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.