code: private static Observable<Boolean> initiateFlush(final ClusterFacade core, final String bucket, final String username, final String password) {
          return deferAndWatch(new Func1<Subscriber, Observable<FlushResponse>>() {
                  @Override
                  public Observable<FlushResponse> call(Subscriber subscriber) {
                      FlushRequest request = new FlushRequest(bucket, username, password);
                      request.subscriber(subscriber);
                      return core.send(request);
                  }
              })
              .retryWhen(any().delay(Delay.fixed(100, TimeUnit.MILLISECONDS)).max(Integer.MAX_VALUE).build())
              .map(new Func1<FlushResponse, Boolean>() {
                  @Override
                  public Boolean call(FlushResponse flushResponse) {
                      if (!flushResponse.status().isSuccess()) {
                          if (flushResponse.content().contains("disabled")) {
                              throw new FlushDisabledException("Flush is disabled for this bucket.");
                          } else {
                              throw new CouchbaseException("Flush failed because of: " + flushResponse.content());
                          }
                      }
                      return flushResponse.isDone();
                  }
              });
      }
docs: Initiates a flush request against the server.
  
  The result indicates if polling needs to be done or the flush is already complete. It can also fail in case
  flush is disabled or something else went wrong in the server response.
  
  @param core the core reference.
  @param bucket the bucket to flush.
  @param username the user authorized for bucket access
  @param password the password of the user.
  @return an observable indicating if done (true) or polling needs to happen (false).