Examples of CachedRepository


Examples of org.apache.ace.repository.ext.CachedRepository

     * @return An input stream to the repository document. Will return an empty stream if none can be found.
     * @throws java.io.IOException if there is a problem communicating with the local or remote repository.
     */
    private InputStream getRepositoryStream(boolean fail) throws IOException {
        // cache the repositories, since we do not want them to change while we're in this method.
        CachedRepository cachedRepository = m_cachedRepository;
        Repository repository = m_directRepository;
        InputStream result;

        if (cachedRepository != null) {
            // we can use the cached repository
            if (cachedRepository.isCurrent()) {
                result = cachedRepository.getLocal(fail);
            }
            else {
                result = cachedRepository.checkout(fail);
            }
        }
        else {
            RangeIterator ri = repository.getRange().iterator();
            long resultVersion = 0;
View Full Code Here

Examples of org.apache.ace.repository.ext.CachedRepository

        return new GZIPInputStream(result);
    }
   
    private boolean isCacheUpToDate() {
        CachedRepository cachedRepository = m_cachedRepository;
        try {
      return (cachedRepository != null && cachedRepository.isCurrent());
    }
        catch (IOException ioe) {
          m_log.log(LogService.LOG_WARNING, "Failed to check if cache is current. Assuming it's not.", ioe);
          return false;
    }
View Full Code Here

Examples of org.apache.ace.repository.ext.CachedRepository

        Repository m_repository = new MockRepository();
        byte[] testContent = new byte[] {'i', 'n', 'i', 't', 'i', 'a', 'l'};
        m_repository.commit(new ByteArrayInputStream(testContent), 0);
        BackupRepository m_backupRepository = new MockBackupRepository();

        CachedRepository m_cachedRepository = new CachedRepositoryImpl(m_repository, m_backupRepository, 0);

        InputStream input = m_cachedRepository.checkout(1);
        byte[] inputBytes = AdminTestUtil.copy(input);
        assert AdminTestUtil.byteArraysEqual(inputBytes, testContent) : "We got something different than 'initial' from checkout: " + new String(inputBytes);
        input = m_cachedRepository.getLocal(false);
        inputBytes = AdminTestUtil.copy(input);
        assert AdminTestUtil.byteArraysEqual(inputBytes, testContent) : "We got something different than 'initial' from getLocal: " + new String(inputBytes);
        input = m_backupRepository.read();
        inputBytes = AdminTestUtil.copy(input);
        assert AdminTestUtil.byteArraysEqual(inputBytes, testContent) : "We got something different than 'initial' from the backup repository: " + new String(inputBytes);
View Full Code Here

Examples of org.apache.ace.repository.ext.CachedRepository

    @Test( groups = { TestUtils.UNIT } )
    public void testCommit() throws IllegalArgumentException, IOException {
        Repository m_repository = new MockRepository();
        BackupRepository m_backupRepository = new MockBackupRepository();

        CachedRepository m_cachedRepository = new CachedRepositoryImpl(m_repository, m_backupRepository, 0);
        byte[] testContent = new byte[] {'i', 'n', 'i', 't', 'i', 'a', 'l'};

        InputStream input = new ByteArrayInputStream(testContent);
        m_cachedRepository.commit(input, 0);

        m_cachedRepository = new CachedRepositoryImpl(m_repository, m_backupRepository, 0);
        input = m_cachedRepository.checkout(1);
        byte[] inputBytes = AdminTestUtil.copy(input);
        assert AdminTestUtil.byteArraysEqual(inputBytes, testContent) : "We got something different than 'initial' from checkout: " + new String(inputBytes);

        byte[] newTestContent = new byte[] {'n', 'e', 'w'};

        m_cachedRepository.writeLocal(new ByteArrayInputStream(newTestContent));

        m_cachedRepository.commit();

        m_cachedRepository = new CachedRepositoryImpl(m_repository, m_backupRepository, 0);
        input = m_cachedRepository.checkout(2);
        inputBytes = AdminTestUtil.copy(input);
        assert AdminTestUtil.byteArraysEqual(inputBytes, newTestContent) : "We got something different than 'new' from checkout: " + new String(inputBytes);
    }
View Full Code Here

Examples of org.apache.ace.repository.ext.CachedRepository

    @Test( groups = { TestUtils.UNIT } )
    public void testRevert() throws IllegalArgumentException, IOException {
        Repository m_repository = new MockRepository();
        BackupRepository m_backupRepository = new MockBackupRepository();

        CachedRepository m_cachedRepository = new CachedRepositoryImpl(m_repository, m_backupRepository, 0);
        byte[] testContent = new byte[] {'i', 'n', 'i', 't', 'i', 'a', 'l'};

        InputStream input = new ByteArrayInputStream(testContent);
        m_cachedRepository.commit(input, 0);

        m_cachedRepository = new CachedRepositoryImpl(m_repository, m_backupRepository, 0);
        input = m_cachedRepository.checkout(1);

        byte[] newTestContent = new byte[] {'n', 'e', 'w'};

        m_cachedRepository.writeLocal(new ByteArrayInputStream(newTestContent));
        input = m_cachedRepository.getLocal(false);
        byte[] inputBytes = AdminTestUtil.copy(input);
        assert AdminTestUtil.byteArraysEqual(inputBytes, newTestContent) : "We got something different than 'new' from getLocal: " + new String(inputBytes);

        m_cachedRepository.revert();
        input = m_cachedRepository.getLocal(false);
        inputBytes = AdminTestUtil.copy(input);
        assert AdminTestUtil.byteArraysEqual(inputBytes, testContent) : "We got something different than 'initial' from getLocal: " + new String(inputBytes);
    }
View Full Code Here

Examples of org.apache.ace.repository.ext.CachedRepository

     * @return An input stream to the repository document. Will return an empty stream if none can be found.
     * @throws java.io.IOException if there is a problem communicating with the local or remote repository.
     */
    private InputStream getRepositoryStream(boolean fail) throws IOException {
        // cache the repositories, since we do not want them to change while we're in this method.
        CachedRepository cachedRepository = m_cachedRepository;
        Repository repository = m_directRepository;
        InputStream result;

        if (cachedRepository != null) {
            // we can use the cached repository
            if (cachedRepository.isCurrent()) {
                result = cachedRepository.getLocal(fail);
            }
            else {
                result = cachedRepository.checkout(fail);
            }
        }
        else {
            RangeIterator ri = repository.getRange().iterator();
            long resultVersion = 0;
View Full Code Here

Examples of org.apache.ace.repository.ext.CachedRepository

          return new GZIPInputStream(result);
        }
    }
   
    private boolean isCacheUpToDate() {
        CachedRepository cachedRepository = m_cachedRepository;
        try {
      return (cachedRepository != null && cachedRepository.isCurrent());
    }
        catch (IOException ioe) {
          m_log.log(LogService.LOG_WARNING, "Failed to check if cache is current. Assuming it's not.", ioe);
          return false;
    }
View Full Code Here

Examples of org.apache.ace.repository.ext.CachedRepository

     * @return An input stream to the repository document. Will return an empty stream if none can be found.
     * @throws java.io.IOException if there is a problem communicating with the local or remote repository.
     */
    private InputStream getRepositoryStream() throws IOException {
        // cache the repositories, since we do not want them to change while we're in this method.
        CachedRepository cachedRepository = m_cachedRepository;
        Repository repository = m_directRepository;
        InputStream result;

        if (cachedRepository != null) {
            // we can use the cached repository
            if (cachedRepository.isCurrent()) {
                result = cachedRepository.getLocal(true);
            }
            else {
                result = cachedRepository.checkout(true);
            }
        }
        else {
            RangeIterator ri = repository.getRange().iterator();
            long resultVersion = 0;
View Full Code Here

Examples of org.apache.ace.repository.ext.CachedRepository

        Repository m_repository = new MockRepository();
        byte[] testContent = new byte[] {'i', 'n', 'i', 't', 'i', 'a', 'l'};
        m_repository.commit(new ByteArrayInputStream(testContent), 0);
        BackupRepository m_backupRepository = new MockBackupRepository();

        CachedRepository m_cachedRepository = new CachedRepositoryImpl(null, m_repository, m_backupRepository, 0);

        InputStream input = m_cachedRepository.checkout(1);
        byte[] inputBytes = AdminTestUtil.copy(input);
        assert AdminTestUtil.byteArraysEqual(inputBytes, testContent) : "We got something different than 'initial' from checkout: " + new String(inputBytes);
        input = m_cachedRepository.getLocal(false);
        inputBytes = AdminTestUtil.copy(input);
        assert AdminTestUtil.byteArraysEqual(inputBytes, testContent) : "We got something different than 'initial' from getLocal: " + new String(inputBytes);
        input = m_backupRepository.read();
        inputBytes = AdminTestUtil.copy(input);
        assert AdminTestUtil.byteArraysEqual(inputBytes, testContent) : "We got something different than 'initial' from the backup repository: " + new String(inputBytes);
View Full Code Here

Examples of org.apache.ace.repository.ext.CachedRepository

    @Test( groups = { TestUtils.UNIT } )
    public void testCommit() throws IllegalArgumentException, IOException {
        Repository m_repository = new MockRepository();
        BackupRepository m_backupRepository = new MockBackupRepository();

        CachedRepository m_cachedRepository = new CachedRepositoryImpl(null, m_repository, m_backupRepository, 0);
        byte[] testContent = new byte[] {'i', 'n', 'i', 't', 'i', 'a', 'l'};

        InputStream input = new ByteArrayInputStream(testContent);
        m_cachedRepository.commit(input, 0);

        m_cachedRepository = new CachedRepositoryImpl(null, m_repository, m_backupRepository, 0);
        input = m_cachedRepository.checkout(1);
        byte[] inputBytes = AdminTestUtil.copy(input);
        assert AdminTestUtil.byteArraysEqual(inputBytes, testContent) : "We got something different than 'initial' from checkout: " + new String(inputBytes);

        byte[] newTestContent = new byte[] {'n', 'e', 'w'};

        m_cachedRepository.writeLocal(new ByteArrayInputStream(newTestContent));

        m_cachedRepository.commit();

        m_cachedRepository = new CachedRepositoryImpl(null, m_repository, m_backupRepository, 0);
        input = m_cachedRepository.checkout(2);
        inputBytes = AdminTestUtil.copy(input);
        assert AdminTestUtil.byteArraysEqual(inputBytes, newTestContent) : "We got something different than 'new' from checkout: " + new String(inputBytes);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.