@Override public boolean apply(RevFeature f) { return !progress.isCanceled(); } };
@Override public void complete() { try { progressListener.setProgress(count); progressListener.complete(); sw.stop(); String msg = String.format("%,d entities processed in %s", count, sw); progressListener.setDescription(msg); } finally { try { target.noMoreInput(); } finally { pointCache.dispose(); } } }
@Override public Pack build() { final java.util.function.Function<ProgressListener, String> oldIndicator = progress .progressIndicator(); progress.setProgressIndicator((p) -> String .format("Server: resolving missing commits... %,d", (int) p.getProgress())); progress.started(); LinkedHashMap<RefRequest, List<ObjectId>> missingCommits; try { // byte[] byteArray = ByteStreams.toByteArray(in); // in.close(); // this.in = new DataInputStream(new ByteArrayInputStream(byteArray)); packIO.readHeader(in); missingCommits = readRefsCommits(); } catch (Exception e) { e.printStackTrace(); try { in.close(); } catch (IOException ex) { } throw propagate(e); } progress.complete(); progress.setProgressIndicator(oldIndicator); return new StreamingPack(missingCommits, in); }
private void notifyProgressListener() { progress.setProgress(progress.getProgress() + 1); }
@Override public boolean feature(final @Nullable NodeRef left, final NodeRef right) { while (!nodes.offer(new Tuple(left, right))) { addAll(); } progress.setProgress(count.incrementAndGet()); final boolean keepGoing = !progress.isCanceled(); return keepGoing; }
@Test public void testCancelDefaultListener() { ProgressListener progress = new DefaultProgressListener(); progress.setDescription("progress description"); progress.setMaxProgress(500); progress.started(); assertEquals("progress description", progress.getDescription()); assertEquals(0, (int) progress.getProgress()); progress.setProgress(250); assertEquals(250, (int) progress.getProgress()); progress.cancel(); assertTrue(progress.isCanceled()); progress.dispose(); }
private void applyIndex(PackProcessor target, RefRequest req, Deduplicator deduplicator, ProgressListener progress) { progress.setDescription("Updating spatial indexes for " + req.name); ObjectReporter objectReport = new ObjectReporter(progress); // back up current progress indicator final Function<ProgressListener, String> defaultProgressIndicator; defaultProgressIndicator = progress.progressIndicator(); // set our custom progress indicator progress.setProgressIndicator((p) -> objectReport.toString()); final List<IndexDef> indexes = missingIndexes.get(req); checkNotNull(indexes); final IndexDatabase sourceStore = source.indexDatabase(); try { final Stopwatch sw = Stopwatch.createStarted(); for (IndexDef def : indexes) { target.putIndex(def, sourceStore, objectReport, deduplicator); } progress.complete(); if (objectReport.total.get() > 0) { progress.started(); String description = String.format("Indexes updated: %,d, repeated: %,d, time: %s", objectReport.inserted(), objectReport.found(), sw.stop()); progress.setDescription(description); } } finally { // restore previous progress indicator progress.setProgressIndicator(defaultProgressIndicator); } }
@Test public void testDefaultListener() { ProgressListener progress = new DefaultProgressListener(); progress.setDescription("progress description"); progress.setMaxProgress(500); progress.started(); assertEquals("progress description", progress.getDescription()); assertEquals(0, (int) progress.getProgress()); progress.setProgress(250); assertEquals(250, (int) progress.getProgress()); progress.complete(); assertEquals(500, (int) progress.getProgress()); assertTrue(progress.isCompleted()); progress.dispose(); }
@Override public void fetchNewData(Repository local, Ref ref, Optional<Integer> fetchLimit, ProgressListener progress) { CommitTraverser traverser = getFetchTraverser(local, fetchLimit); progress.setDescription("Fetching objects from " + ref.getName()); progress.setProgress(0); traverser.traverse(ref.getObjectId()); List<ObjectId> toSend = new LinkedList<ObjectId>(traverser.commits); Collections.reverse(toSend);// send oldest commits first for (ObjectId newHeadId : toSend) { walkHead(newHeadId, remoteRepository, local, progress); } }
try { ProgressListener listener = command.getProgressListener(); listener.started(); log.debug("Calling UpdateIndexesOp for {}", ref); updates = context.command(UpdateIndexesOp.class)// if (!listener.isCanceled() && !updates.isEmpty()) { listener.setDescription("updated indexes: %s", updates);
progress.started(); progress.setDescription("Fetching " + remoteRepo.getInfo()); final List<LocalRemoteRef> localToRemoteRemoteRefs = resolveRemoteRefs(remoteRepo); request.syncIndexes(args.fetchIndexes); if (progress.isCanceled()) return null; if (progress.isCanceled()) return null; args.prune); transferSummary.addAll(remote.getFetchURL(), Lists.newArrayList(remoteRemoteRefs)); progress.setDescription("Fetched " + remoteRepo.getInfo()); if (progress.isCanceled()) return null; progress.complete();
public void run(Connection cx, PGStorageTableManager tableManager, ProgressListener progress) throws SQLException { List<String> repoNames = PGStorage.listRepos(cx, env.getTables()); progress.setDescription(String.format("Upgrading commit graph for all %,d repositories...", repoNames.size())); Collections.sort(repoNames); int i = 0; for (String repoName : repoNames) { progress.setProgressIndicator( p -> String.format("Upgrading graph for repository %s", repoName)); URI repoURI = env.connectionConfig.toURI(repoName); Repository repo; try { repo = RepositoryResolver.load(repoURI); } catch (RepositoryConnectionException e) { throw new IllegalStateException("Unable to connnect to repo " + repoName, e); } try { progress.setProgress(++i); rebuildGraph(repo); } finally { repo.close(); } } progress.setProgressIndicator(ProgressListener.DEFAULT_PROGRES_INDICATOR); }
/** * Finds the common {@link RevCommit commit} ancestor of two commits. * * @return an {@link Optional} of the ancestor commit, or {@link Optional#absent()} if no common * ancestor was found */ @Override protected Optional<ObjectId> _call() { Preconditions.checkState(left != null, "Left commit has not been set."); Preconditions.checkState(right != null, "Right commit has not been set."); if (left.equals(right)) { // They are the same commit return Optional.of(left); } getProgressListener().started(); Optional<ObjectId> ancestor = findLowestCommonAncestor(left, right); getProgressListener().complete(); return ancestor; }
/** * Sets the description of the task. * * @param description the text to use for the description */ @Override public void setDescription(String description) { parentProgressListener.setDescription(description); }
@Override public void finished() { progress.complete(); progress.started(); try { AutoCloseableIterator<DiffEntry> unstaged = AutoCloseableIterator.emptyIterator(); if (mergedBuffer.size() > 0) { progress.setDescription( String.format("Saving %,d merged features...", mergedBuffer.size())); workingTree.insert(mergedBuffer.iterator(), progress); progress.setDescription( String.format("Staging %,d unconflicted and %,d merged differences...", unconflictedBuffer.size(), mergedBuffer.size())); progress.setDescription( String.format("Saving %,d conflicts...", conflictsBuffer.size())); context.command(ConflictsWriteOp.class).setConflicts(conflictsBuffer).call();
@Test public void testSubProgress() { ProgressListener progress = new DefaultProgressListener(); progress.setDescription("progress description"); progress.setMaxProgress(100); progress.started(); SubProgressListener subProgress = new SubProgressListener(progress, 20); assertEquals("progress description", progress.getDescription()); assertEquals("progress description", subProgress.getDescription()); subProgress.setDescription("sub progress description"); assertEquals("sub progress description", progress.getDescription()); assertEquals("sub progress description", subProgress.getDescription()); subProgress.setMaxProgress(1000); subProgress.started(); assertEquals(0, (int) progress.getProgress()); assertEquals(0, (int) subProgress.getProgress()); subProgress.setProgress(100); assertEquals(100, (int) subProgress.getProgress()); assertEquals(2, (int) progress.getProgress()); subProgress.setProgress(500); assertEquals(500, (int) subProgress.getProgress()); assertEquals(10, (int) progress.getProgress()); subProgress.complete(); assertEquals(1000, (int) subProgress.getProgress()); assertEquals(20, (int) progress.getProgress()); assertTrue(subProgress.isCompleted()); subProgress.dispose(); progress.dispose(); }
this.progressListener.setProgressIndicator((p) -> { final NumberFormat percentFormat = NumberFormat.getPercentInstance(); final NumberFormat numberFormat = NumberFormat.getIntegerInstance(); float percent = p.getProgress(); if (percent > 100) { return numberFormat.format(percent);
/** * @param read */ private void progress(int read) { readCount += read; float percent = (float) (readCount * 100) / contentLength; listener.setProgress(percent); } }
@Test public void testCancelSubProgress() { ProgressListener progress = new DefaultProgressListener(); progress.setMaxProgress(100); SubProgressListener subProgress = new SubProgressListener(progress, 20); subProgress.setProgress(10); assertEquals(10, (int) subProgress.getProgress()); assertEquals(2, (int) progress.getProgress()); subProgress.cancel(); assertTrue(subProgress.isCanceled()); assertTrue(progress.isCanceled()); subProgress.dispose(); progress.dispose(); }
@Override public void complete() { try { progressListener.setProgress(count); progressListener.complete(); } finally { try { target.noMoreInput(); } finally { pointCache.dispose(); } } }