@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof io.pravega.controller.stream.api.grpc.v1.Controller.ScaleResponse)) { return super.equals(obj); } io.pravega.controller.stream.api.grpc.v1.Controller.ScaleResponse other = (io.pravega.controller.stream.api.grpc.v1.Controller.ScaleResponse) obj; boolean result = true; result = result && status_ == other.status_; result = result && getSegmentsList() .equals(other.getSegmentsList()); result = result && (getEpoch() == other.getEpoch()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + STATUS_FIELD_NUMBER; hash = (53 * hash) + status_; if (getSegmentsCount() > 0) { hash = (37 * hash) + SEGMENTS_FIELD_NUMBER; hash = (53 * hash) + getSegmentsList().hashCode(); } hash = (37 * hash) + EPOCH_FIELD_NUMBER; hash = (53 * hash) + getEpoch(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
assertEquals(Controller.ScaleResponse.ScaleStreamStatus.STARTED, scaleStatus.getStatus()); AtomicBoolean done = new AtomicBoolean(false); Futures.loop(() -> !done.get(), () -> consumer.checkScale(SCOPE, STREAM, scaleStatus.getEpoch()) .thenAccept(x -> done.set(x.getStatus().equals(Controller.ScaleStatusResponse.ScaleStatus.SUCCESS))), executor).get();
final Controller.ScaleStatusRequest scalestatusRequest = Controller.ScaleStatusRequest.newBuilder() .setStreamInfo(ModelHelper.createStreamInfo(SCOPE1, STREAM1)) .setEpoch(scaleResponse.getEpoch()) .build();
cancellableRequest.start(() -> { if (started) { return checkScaleStatus(stream, startScaleResponse.getEpoch()); } else { return CompletableFuture.completedFuture(false);
@Override public CancellableRequest<Boolean> scaleStream(final Stream stream, final List<Long> sealedSegments, final Map<Double, Double> newKeyRanges, final ScheduledExecutorService executor) { CancellableRequest<Boolean> cancellableRequest = new CancellableRequest<>(); startScaleInternal(stream, sealedSegments, newKeyRanges) .whenComplete((startScaleResponse, e) -> { if (e != null) { cancellableRequest.start(() -> Futures.failedFuture(e), any -> true, executor); } else { final boolean started = startScaleResponse.getStatus().equals(ScaleResponse.ScaleStreamStatus.STARTED); cancellableRequest.start(() -> { if (started) { return checkScaleStatus(stream, startScaleResponse.getEpoch()); } else { return CompletableFuture.completedFuture(false); } }, isDone -> !started || isDone, executor); } }); return cancellableRequest; }
private void scale(long start, List<Long> segmentsToSeal, Map<Double, Double> keyRanges) throws InterruptedException, java.util.concurrent.ExecutionException { Controller.ScaleResponse scaleStatus = consumer.scale(SCOPE, STREAM, segmentsToSeal, keyRanges, start) .get(); AtomicBoolean done = new AtomicBoolean(false); Futures.loop(() -> !done.get(), () -> Futures.delayedFuture(() -> consumer.checkScale(SCOPE, STREAM, scaleStatus.getEpoch()), 1000, executor) .thenAccept(x -> done.set(x.getStatus().equals(Controller.ScaleStatusResponse.ScaleStatus.SUCCESS))), executor).get(); } }