Package org.apache.ace.repository

Examples of org.apache.ace.repository.RepositoryReplication


        return m_context.getServiceReferences(RepositoryReplication.class.getName(), filter);
    }

    @Override
    protected SortedRangeSet getRange(ServiceReference ref) throws IOException {
        RepositoryReplication repository = (RepositoryReplication) m_context.getService(ref);
        SortedRangeSet range = repository.getRange();
        m_context.ungetService(ref);
        return range;
    }
View Full Code Here


        return range;
    }

    @Override
    protected boolean doCommit(ServiceReference ref, long version, InputStream data) throws IllegalArgumentException, IOException {
        RepositoryReplication r = (RepositoryReplication) m_context.getService(ref);
        boolean result = r.put(data, version);
        m_context.ungetService(ref);
        return result;
    }
View Full Code Here

        return result;
    }

    @Override
    protected InputStream doCheckout(ServiceReference ref, long version) throws IllegalArgumentException, IOException {
        RepositoryReplication r = (RepositoryReplication) m_context.getService(ref);
        InputStream result = r.get(version);
        m_context.ungetService(ref);
        return result;
    }
View Full Code Here

            if (refs == null) {
                return;
            }

            for (ServiceReference ref : refs) {
                RepositoryReplication repository = (RepositoryReplication) m_context.getService(ref);

                try {
                    String filter = getQueryFilter(ref);
                    URL host = m_discovery.discover();
                    URL query = new URL(host, "/replication/query?" + filter);

                    HttpURLConnection connection = (HttpURLConnection) m_connectionFactory.createConnection(query);

                    if (connection.getResponseCode() == HttpServletResponse.SC_OK) {
                        SortedRangeSet localRange = repository.getRange();

                        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) m_connectionFactory.createConnection(get);

                                    repository.put(connection2.getInputStream(), version);
                                }
                            }
                        }
                        catch (Exception e) {
                            m_log.log(LogService.LOG_WARNING, "Error parsing remote range", e);
View Full Code Here

    public void run() {
        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);
                            }
                        }
                    }
                    catch (Exception e) {
                        m_log.log(LogService.LOG_WARNING, "Error parsing remote range", e);
View Full Code Here

        // The URL to the server to replicate...
        URL master = m_discovery.discover();

        for (Entry<ServiceReference, RepositoryReplication> entry : replicators.entrySet()) {
            RepositoryReplication repository = entry.getValue();
            ServiceReference ref = entry.getKey();

            try {
                replicate(master, ref, repository);
            }
View Full Code Here

        return m_context.getServiceReferences(RepositoryReplication.class.getName(), filter);
    }

    @Override
    protected SortedRangeSet getRange(ServiceReference ref) throws IOException {
        RepositoryReplication repository = (RepositoryReplication) m_context.getService(ref);
        SortedRangeSet range = repository.getRange();
        m_context.ungetService(ref);
        return range;
    }
View Full Code Here

        return range;
    }

    @Override
    protected boolean doCommit(ServiceReference ref, long version, InputStream data) throws IllegalArgumentException, IOException {
        RepositoryReplication r = (RepositoryReplication) m_context.getService(ref);
        boolean result = r.put(data, version);
        m_context.ungetService(ref);
        return result;
    }
View Full Code Here

        return result;
    }

    @Override
    protected InputStream doCheckout(ServiceReference ref, long version) throws IllegalArgumentException, IOException {
        RepositoryReplication r = (RepositoryReplication) m_context.getService(ref);
        InputStream result = r.get(version);
        m_context.ungetService(ref);
        return result;
    }
View Full Code Here

TOP

Related Classes of org.apache.ace.repository.RepositoryReplication

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.