throw new TimeoutException(); itr.next().blockUntil(Duration.ofMillis(w)); if (itr.hasNext()) { now = System.currentTimeMillis();
/** {@inheritDoc} */ @Override public String toString() { return instant().toString(); } }
/** * Get time since epoch, with up to microsecond resolution. * * @return time since epoch, with up to microsecond resolution. */ public Instant instant() { long usec = micros(); long secs = usec / 1000000L; long nanos = (usec % 1000000L) * 1000L; return Instant.ofEpochSecond(secs, nanos); }
/** * Get milliseconds since epoch; {@code read(MILLISECONDS}). * * @return milliseconds since epoch; {@code read(MILLISECONDS}). */ public long millis() { return read(MILLISECONDS); }
/** * Construct a new {@link org.eclipse.jgit.lib.PersonIdent} with current * time. * * @param aName * a {@link java.lang.String} object. * @param aEmailAddress * a {@link java.lang.String} object. * @param when * a {@link org.eclipse.jgit.util.time.ProposedTimestamp} object. * @since 4.6 */ public PersonIdent(String aName, String aEmailAddress, ProposedTimestamp when) { this(aName, aEmailAddress, when.millis()); }
/** * Get microseconds since epoch; {@code read(MICROSECONDS}). * * @return microseconds since epoch; {@code read(MICROSECONDS}). */ public long micros() { return read(MICROSECONDS); }
/** * Get time since epoch, with up to millisecond resolution. * * @return time since epoch, with up to millisecond resolution. */ public Date date() { return new Date(millis()); }
private void blockUntil(ProposedTimestamp ts) throws TimeIsUncertainException { List<ProposedTimestamp> times = todo.stream() .flatMap(p -> p.getProposedTimestamps().stream()) .collect(Collectors.toCollection(ArrayList::new)); times.add(ts); try { Duration maxWait = getSystem().getMaxWaitForMonotonicClock(); ProposedTimestamp.blockUntil(times, maxWait); } catch (InterruptedException | TimeoutException e) { throw new TimeIsUncertainException(e); } }
RevCommit c = rw.parseCommit(acceptedOldIndex); if (getSystem().requireMonotonicLeaderElections()) { if (ts.read(SECONDS) < c.getCommitTime()) { throw new TimeIsUncertainException();
/** * Construct a new {@link org.eclipse.jgit.lib.PersonIdent} with current * time. * * @param aName * a {@link java.lang.String} object. * @param aEmailAddress * a {@link java.lang.String} object. * @param when * a {@link org.eclipse.jgit.util.time.ProposedTimestamp} object. * @since 4.6 */ public PersonIdent(String aName, String aEmailAddress, ProposedTimestamp when) { this(aName, aEmailAddress, when.millis()); }
/** * Get time since epoch, with up to microsecond resolution. * * @return time since epoch, with up to microsecond resolution. */ public Timestamp timestamp() { return Timestamp.from(instant()); }
/** * Get time since epoch, with up to microsecond resolution. * * @return time since epoch, with up to microsecond resolution. */ public Instant instant() { long usec = micros(); long secs = usec / 1000000L; long nanos = (usec % 1000000L) * 1000L; return Instant.ofEpochSecond(secs, nanos); }
private void blockUntil(ProposedTimestamp ts) throws IOException { try { ts.blockUntil(getSystem().getMaxWaitForMonotonicClock()); } catch (InterruptedException | TimeoutException e) { throw new TimeIsUncertainException(e); } } }
/** * Get microseconds since epoch; {@code read(MICROSECONDS}). * * @return microseconds since epoch; {@code read(MICROSECONDS}). */ public long micros() { return read(MICROSECONDS); }
/** * Get time since epoch, with up to millisecond resolution. * * @return time since epoch, with up to millisecond resolution. */ public Date date() { return new Date(millis()); }
/** {@inheritDoc} */ @Override public String toString() { return instant().toString(); } }
/** * Wait for timestamps to be in the past, aborting commands on timeout. * * @param maxWait * maximum amount of time to wait for timestamps to resolve. * @return true if timestamps were successfully waited for; false if * commands were aborted. * @since 4.6 */ protected boolean blockUntilTimestamps(Duration maxWait) { if (timestamps == null) { return true; } try { ProposedTimestamp.blockUntil(timestamps, maxWait); return true; } catch (TimeoutException | InterruptedException e) { String msg = JGitText.get().timeIsUncertain; for (ReceiveCommand c : commands) { if (c.getResult() == NOT_ATTEMPTED) { c.setResult(REJECTED_OTHER_REASON, msg); } } return false; } }
/** * Get milliseconds since epoch; {@code read(MILLISECONDS}). * * @return milliseconds since epoch; {@code read(MILLISECONDS}). */ public long millis() { return read(MILLISECONDS); }
/** * Get time since epoch, with up to microsecond resolution. * * @return time since epoch, with up to microsecond resolution. */ public Timestamp timestamp() { return Timestamp.from(instant()); }
throw new TimeoutException(); itr.next().blockUntil(Duration.ofMillis(w)); if (itr.hasNext()) { now = System.currentTimeMillis();