Package org.locationtech.geogig.remote

Examples of org.locationtech.geogig.remote.IRemoteRepo


            Optional<IRemoteRepo> remoteRepo = getRemoteRepo(remote, repository()
                    .deduplicationService());

            Preconditions.checkState(remoteRepo.isPresent(), "Failed to connect to the remote.");
            IRemoteRepo remoteRepoInstance = remoteRepo.get();
            try {
                remoteRepoInstance.open();
            } catch (IOException e) {
                Throwables.propagate(e);
            }
            try {
                int refCount = 0;
                for (ChangedRef ref : needUpdate) {
                    if (ref.getType() != ChangeTypes.REMOVED_REF) {
                        refCount++;

                        Optional<Integer> newFetchLimit = depth;
                        // If we haven't specified a depth, but this is a shallow repository, set
                        // the
                        // fetch limit to the current repository depth.
                        if (!newFetchLimit.isPresent() && repoDepth.isPresent()
                                && ref.getType() == ChangeTypes.ADDED_REF) {
                            newFetchLimit = repoDepth;
                        }
                        // Fetch updated data from this ref
                        Ref newRef = ref.getNewRef();
                        remoteRepoInstance.fetchNewData(newRef, newFetchLimit, progressListener);

                        if (repoDepth.isPresent() && !fullDepth) {
                            // Update the repository depth if it is deeper than before.
                            int newDepth;
                            try {
                                newDepth = repository().graphDatabase().getDepth(
                                        newRef.getObjectId());
                            } catch (IllegalStateException e) {
                                throw new RuntimeException(ref.toString(), e);
                            }

                            if (newDepth > repoDepth.get()) {
                                command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET)
                                        .setScope(ConfigScope.LOCAL)
                                        .setName(Repository.DEPTH_CONFIG_KEY)
                                        .setValue(Integer.toString(newDepth)).call();
                                repoDepth = Optional.of(newDepth);
                            }
                        }

                        // Update the ref
                        Ref updatedRef = updateLocalRef(newRef, remote, localRemoteRefs);
                        ref.setNewRef(updatedRef);
                    }
                }

                if (needUpdate.size() > 0) {
                    result.addAll(remote.getFetchURL(), needUpdate);
                }

                // Update HEAD ref
                if (!remote.getMapped()) {
                    Ref remoteHead = remoteRepoInstance.headRef();
                    if (remoteHead != null) {
                        updateLocalRef(remoteHead, remote, localRemoteRefs);
                    }
                }
            } finally {
                try {
                    remoteRepoInstance.close();
                } catch (IOException e) {
                    Throwables.propagate(e);
                }
            }
        }
View Full Code Here


    @Override
    protected TransferSummary _call() {
        checkState(remote != null, "no remote specified");
        checkState(!refsToPush.isEmpty(), "no refs to push specified");

        final IRemoteRepo remoteRepo = openRemoteRepo(remote);
        TransferSummary transferResult;
        try {
            transferResult = callInternal(remoteRepo);
            checkState(transferResult != null);
        } finally {
            try {
                remoteRepo.close();
            } catch (IOException e) {
                Throwables.propagate(e);
            }
        }
        return transferResult;
View Full Code Here

        }
        return result;
    }

    private IRemoteRepo openRemoteRepo(final Remote remote) {
        final IRemoteRepo remoteRepo;
        Optional<IRemoteRepo> resolvedRemoteRepo = getRemoteRepo(remote);
        checkState(resolvedRemoteRepo.isPresent(), "Failed to connect to the remote.");

        remoteRepo = resolvedRemoteRepo.get();
        try {
            remoteRepo.open();
        } catch (IOException e) {
            Throwables.propagate(e);
        }
        return remoteRepo;
    }
View Full Code Here

            Optional<IRemoteRepo> remoteRepo = RemoteUtils.newRemote(
                    GlobalContextBuilder.builder.build(Hints.readOnly()), remote, repository,
                    repository.deduplicationService());

            Preconditions.checkState(remoteRepo.isPresent(), "Failed to connect to the remote.");
            IRemoteRepo remoteRepoInstance = remoteRepo.get();
            try {
                remoteRepoInstance.open();
            } catch (IOException e) {
                Throwables.propagate(e);
            }
            try {
                depth = remoteRepoInstance.getDepth();
            } finally {
                try {
                    remoteRepoInstance.close();
                } catch (IOException e) {
                    Throwables.propagate(e);
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.remote.IRemoteRepo

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.