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); } }
@Override void start() throws IOException { for (Proposal p : todo) { p.notifyState(RUNNING); } try { ObjectId id; try (Repository git = leader.openRepository(); ProposedTimestamp ts = getSystem().getClock().propose()) { id = insertProposals(git, ts); blockUntil(ts); } runAsync(id); } catch (NoOp e) { for (Proposal p : todo) { p.success(); } leader.lock.lock(); try { leader.nextRound(); } finally { leader.lock.unlock(); } } catch (IOException e) { abort(); throw e; } }
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); } }
@Override void start() throws IOException { for (Proposal p : todo) { p.notifyState(RUNNING); } try { ObjectId id; try (Repository git = leader.openRepository(); ProposedTimestamp ts = getSystem().getClock().propose()) { id = insertProposals(git, ts); blockUntil(ts); } runAsync(id); } catch (NoOp e) { for (Proposal p : todo) { p.success(); } leader.lock.lock(); try { leader.nextRound(); } finally { leader.lock.unlock(); } } catch (IOException e) { abort(); throw e; } }