scala.runtime.BoxedUnit Java Examples

The following examples show how to use scala.runtime.BoxedUnit. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PinLaterServiceImpl.java    From pinlater with Apache License 2.0 6 votes vote down vote up
@Override
public Future<PinLaterDequeueResponse> dequeueJobs(
    RequestContext context, final PinLaterDequeueRequest request) {
  if (!queueConfig.allowDequeue(request.getQueueName(), request.getLimit())) {
    Stats.incr(request.getQueueName() + "_dequeue_requests_rate_limited");
    return Future.exception(new PinLaterException(ErrorCode.DEQUEUE_RATE_LIMITED,
        "Dequeue rate limit exceeded for queue: " + request.getQueueName()));
  }

  return Stats.timeFutureMillis(
      "PinLaterService.dequeueJobs",
      backend.dequeueJobs(context.getSource(), request).onSuccess(
          new Function<PinLaterDequeueResponse, BoxedUnit>() {
            @Override
            public BoxedUnit apply(PinLaterDequeueResponse response) {
              Stats.incr(request.getQueueName() + "_dequeue", response.getJobsSize());
              return null;
            }
          }).rescue(new LogAndWrapException<PinLaterDequeueResponse>(
          context, "dequeueJobs", request.toString())));
}
 
Example #2
Source File: MonitoredFuturePool.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
@Override
public <T> Future<T> apply(Function0<T> function0) {
    if (traceTaskExecution) {
        taskPendingCounter.inc();
        Stopwatch taskEnqueueStopwatch = Stopwatch.createStarted();
        Future<T> futureResult = futurePool.apply(new TimedFunction0<T>(function0));
        taskEnqueueTime.registerSuccessfulEvent(taskEnqueueStopwatch.elapsed(TimeUnit.MICROSECONDS));
        futureResult.ensure(new com.twitter.util.Function0<BoxedUnit>() {
            @Override
            public BoxedUnit apply() {
                taskPendingCounter.dec();
                return null;
            }
        });
        return futureResult;
    } else {
        return futurePool.apply(function0);
    }
}
 
Example #3
Source File: ZKSessionLock.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
Future<BoxedUnit> asyncUnlock(final Throwable cause) {
    final Promise<BoxedUnit> promise = new Promise<BoxedUnit>();

    // Use lock executor here rather than lock action, because we want this opertaion to be applied
    // whether the epoch has changed or not. The member node is EPHEMERAL_SEQUENTIAL so there's no
    // risk of an ABA problem where we delete and recreate a node and then delete it again here.
    lockStateExecutor.submit(lockPath, new SafeRunnable() {
        @Override
        public void safeRun() {
            acquireFuture.updateIfEmpty(new Throw<Boolean>(cause));
            unlockInternal(promise);
            promise.addEventListener(new OpStatsListener<BoxedUnit>(unlockStats));
        }
    });

    return promise;
}
 
Example #4
Source File: StreamImpl.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
/**
 * Close the stream and schedule cache eviction at some point in the future.
 * We delay this as a way to place the stream in a probationary state--cached
 * in the proxy but unusable.
 * This mechanism helps the cluster adapt to situations where a proxy has
 * persistent connectivity/availability issues, because it keeps an affected
 * stream off the proxy for a period of time, hopefully long enough for the
 * issues to be resolved, or for whoop to kick in and kill the shard.
 */
synchronized void handleServiceTimeout(String reason) {
    if (StreamStatus.isUnavailable(status)) {
        return;
    }
    // Mark stream in error state
    setStreamInErrorStatus();

    // Async close request, and schedule eviction when its done.
    Future<Void> closeFuture = requestClose(reason, false /* dont remove */);
    closeFuture.onSuccess(new AbstractFunction1<Void, BoxedUnit>() {
        @Override
        public BoxedUnit apply(Void result) {
            streamManager.scheduleRemoval(StreamImpl.this, streamProbationTimeoutMs);
            return BoxedUnit.UNIT;
        }
    });
}
 
Example #5
Source File: SafeQueueingFuturePool.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
public synchronized Future<T> apply(final Function0<T> fn) {
    Preconditions.checkNotNull(fn);
    if (closed) {
        return Future.exception(new RejectedExecutionException("Operation submitted to closed SafeQueueingFuturePool"));
    }
    ++outstanding;
    queue.add(fn);
    Future<T> result = orderedFuturePool.apply(new Function0<T>() {
        @Override
        public T apply() {
            return queue.poll().apply();
        }
        @Override
        public String toString() {
            return fn.toString();
        }
    }).ensure(new Function0<BoxedUnit>() {
        public BoxedUnit apply() {
            if (decrOutstandingAndCheckDone()) {
                applyAll();
            }
            return null;
        }
    });
    return result;
}
 
Example #6
Source File: TestReadUtils.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
private Future<LogRecordWithDLSN> getFirstGreaterThanRecord(BKDistributedLogManager bkdlm, int ledgerNo, DLSN dlsn) throws Exception {
    List<LogSegmentMetadata> ledgerList = bkdlm.getLogSegments();
    final LedgerHandleCache handleCache = LedgerHandleCache.newBuilder()
            .bkc(bkdlm.getWriterBKC())
            .conf(conf)
            .build();
    return ReadUtils.asyncReadFirstUserRecord(
            bkdlm.getStreamName(), ledgerList.get(ledgerNo), 2, 16, new AtomicInteger(0), Executors.newFixedThreadPool(1),
            handleCache, dlsn
    ).ensure(new AbstractFunction0<BoxedUnit>() {
        @Override
        public BoxedUnit apply() {
            handleCache.clear();
            return BoxedUnit.UNIT;
        }
    });
}
 
Example #7
Source File: Utils.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
/**
 * Asynchronously create zookeeper path recursively and optimistically
 *
 * @param zkc Zookeeper client
 * @param pathToCreate  Zookeeper full path
 * @param parentPathShouldNotCreate zookeeper parent path should not be created
 * @param data Zookeeper data
 * @param acl Acl of the zk path
 * @param createMode Create mode of zk path
 */
public static Future<BoxedUnit> zkAsyncCreateFullPathOptimistic(
    final ZooKeeperClient zkc,
    final String pathToCreate,
    final Optional<String> parentPathShouldNotCreate,
    final byte[] data,
    final List<ACL> acl,
    final CreateMode createMode) {
    final Promise<BoxedUnit> result = new Promise<BoxedUnit>();

    zkAsyncCreateFullPathOptimisticRecursive(zkc, pathToCreate, parentPathShouldNotCreate,
            data, acl, createMode, new AsyncCallback.StringCallback() {
        @Override
        public void processResult(int rc, String path, Object ctx, String name) {
            handleKeeperExceptionCode(rc, path, result);
        }
    }, result);

    return result;
}
 
Example #8
Source File: FederatedZKLogMetadataStore.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
@Override
public Future<Optional<URI>> getLogLocation(final String logName) {
    if (duplicatedLogFound.get()) {
        return duplicatedLogException(duplicatedLogName.get());
    }
    URI location = log2Locations.get(logName);
    if (null != location) {
        return postStateCheck(Future.value(Optional.of(location)));
    }
    if (!forceCheckLogExistence) {
        Optional<URI> result = Optional.absent();
        return Future.value(result);
    }
    return postStateCheck(fetchLogLocation(logName).onSuccess(
            new AbstractFunction1<Optional<URI>, BoxedUnit>() {
                @Override
                public BoxedUnit apply(Optional<URI> uriOptional) {
                    if (uriOptional.isPresent()) {
                        log2Locations.putIfAbsent(logName, uriOptional.get());
                    }
                    return BoxedUnit.UNIT;
                }
            }));
}
 
Example #9
Source File: DataSource.java    From ndbc with Apache License 2.0 6 votes vote down vote up
protected final <T> Future<T> convert(final io.trane.future.Future<T> future) {
  final Promise<T> promise = Promise.apply();
  promise.setInterruptHandler(new PartialFunction<Throwable, BoxedUnit>() {

    @Override
    public BoxedUnit apply(final Throwable v1) {
      future.raise(v1);
      return BoxedUnit.UNIT;
    }

    @Override
    public boolean isDefinedAt(final Throwable x) {
      return true;
    }
  });
  future.onSuccess(promise::setValue).onFailure(promise::setException);
  return promise;
}
 
Example #10
Source File: TestReadUtils.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
private Future<LogRecordWithDLSN> getLastUserRecord(BKDistributedLogManager bkdlm, int ledgerNo) throws Exception {
    BKLogReadHandler readHandler = bkdlm.createReadHandler();
    List<LogSegmentMetadata> ledgerList = readHandler.getLedgerList(false, false, LogSegmentMetadata.COMPARATOR, false);
    final LedgerHandleCache handleCache = LedgerHandleCache.newBuilder()
            .bkc(bkdlm.getWriterBKC())
            .conf(conf)
            .build();
    return ReadUtils.asyncReadLastRecord(
            bkdlm.getStreamName(), ledgerList.get(ledgerNo), false, false, false, 2, 16, new AtomicInteger(0), Executors.newFixedThreadPool(1),
            handleCache
    ).ensure(new AbstractFunction0<BoxedUnit>() {
        @Override
        public BoxedUnit apply() {
            handleCache.clear();
            return BoxedUnit.UNIT;
        }
    });
}
 
Example #11
Source File: BKLogHandler.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
private Future<LogRecordWithDLSN> asyncReadFirstUserRecord(LogSegmentMetadata ledger, DLSN beginDLSN) {
    final LedgerHandleCache handleCache =
            LedgerHandleCache.newBuilder().bkc(bookKeeperClient).conf(conf).build();
    return ReadUtils.asyncReadFirstUserRecord(
            getFullyQualifiedName(),
            ledger,
            firstNumEntriesPerReadLastRecordScan,
            maxNumEntriesPerReadLastRecordScan,
            new AtomicInteger(0),
            scheduler,
            handleCache,
            beginDLSN
    ).ensure(new AbstractFunction0<BoxedUnit>() {
        @Override
        public BoxedUnit apply() {
            handleCache.clear();
            return BoxedUnit.UNIT;
        }
    });
}
 
Example #12
Source File: Utils.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
/**
 * Asynchronously create zookeeper path recursively and optimistically.
 *
 * @param zkc Zookeeper client
 * @param pathToCreate  Zookeeper full path
 * @param data Zookeeper data
 * @param acl Acl of the zk path
 * @param createMode Create mode of zk path
 */
public static Future<BoxedUnit> zkAsyncCreateFullPathOptimistic(
    final ZooKeeperClient zkc,
    final String pathToCreate,
    final byte[] data,
    final List<ACL> acl,
    final CreateMode createMode) {
    Optional<String> parentPathShouldNotCreate = Optional.absent();
    return zkAsyncCreateFullPathOptimistic(
            zkc,
            pathToCreate,
            parentPathShouldNotCreate,
            data,
            acl,
            createMode);
}
 
Example #13
Source File: tlsValidationEnabledTest.java    From zipkin-finagle with Apache License 2.0 6 votes vote down vote up
@Test public void letOverridesDefault() {
  final boolean override = false;

  final AtomicBoolean ran = new AtomicBoolean();
  Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
    @Override public BoxedUnit apply() {
      ran.set(true); // used to verify this block is executed.
      assertThat(tlsValidationEnabled$.Flag.isDefined()).isTrue();
      assertThat(tlsValidationEnabled$.Flag.apply()).isEqualTo(override);
      return BoxedUnit.UNIT;
    }
  };
  tlsValidationEnabled$.Flag.let(override, fn0);

  assertThat(ran.get()).isTrue();
}
 
Example #14
Source File: hostHeaderTest.java    From zipkin-finagle with Apache License 2.0 6 votes vote down vote up
@Test public void letOverridesDefault() {
  final String override = "amazon";

  final AtomicBoolean ran = new AtomicBoolean();
  Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
    @Override public BoxedUnit apply() {
      ran.set(true); // used to verify this block is executed.
      assertThat(hostHeader$.Flag.isDefined()).isTrue();
      assertThat(hostHeader$.Flag.apply()).isEqualTo(override);
      return BoxedUnit.UNIT;
    }
  };
  hostHeader$.Flag.let(override, fn0);

  assertThat(ran.get()).isTrue();
}
 
Example #15
Source File: BKDistributedLogManager.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
private Future<DLSN> getDLSNNotLessThanTxId(long fromTxnId,
                                            final List<LogSegmentMetadata> segments) {
    if (segments.isEmpty()) {
        return getLastDLSNAsync();
    }
    final int segmentIdx = DLUtils.findLogSegmentNotLessThanTxnId(segments, fromTxnId);
    if (segmentIdx < 0) {
        return Future.value(new DLSN(segments.get(0).getLogSegmentSequenceNumber(), 0L, 0L));
    }
    final LedgerHandleCache handleCache =
            LedgerHandleCache.newBuilder().bkc(readerBKC).conf(conf).build();
    return getDLSNNotLessThanTxIdInSegment(
            fromTxnId,
            segmentIdx,
            segments,
            handleCache
    ).ensure(new AbstractFunction0<BoxedUnit>() {
        @Override
        public BoxedUnit apply() {
            handleCache.clear();
            return BoxedUnit.UNIT;
        }
    });
}
 
Example #16
Source File: BKAbstractLogWriter.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
private Future<BKLogSegmentWriter> asyncStartNewLogSegment(final BKLogWriteHandler writeHandler,
                                                           final long startTxId,
                                                           final boolean allowMaxTxID) {
    return writeHandler.recoverIncompleteLogSegments()
            .flatMap(new AbstractFunction1<Long, Future<BKLogSegmentWriter>>() {
        @Override
        public Future<BKLogSegmentWriter> apply(Long lastTxId) {
            return writeHandler.asyncStartLogSegment(startTxId, false, allowMaxTxID)
                    .onSuccess(new AbstractFunction1<BKLogSegmentWriter, BoxedUnit>() {
                @Override
                public BoxedUnit apply(BKLogSegmentWriter newSegmentWriter) {
                    cacheLogWriter(newSegmentWriter);
                    return BoxedUnit.UNIT;
                }
            });
        }
    });
}
 
Example #17
Source File: PinLaterServiceImpl.java    From pinlater with Apache License 2.0 6 votes vote down vote up
@Override
public Future<Void> ackDequeuedJobs(RequestContext context, final PinLaterJobAckRequest request) {
  return Stats.timeFutureMillis(
      "PinLaterService.ackDequeuedJobs",
      backend.ackDequeuedJobs(request).onSuccess(
          new Function<Void, BoxedUnit>() {
            @Override
            public BoxedUnit apply(Void aVoid) {
              Stats.incr(request.getQueueName() + "_ack_succeeded",
                  request.getJobsSucceededSize());
              Stats.incr(request.getQueueName() + "_ack_failed", request.getJobsFailedSize());
              return null;
            }
          }).rescue(new LogAndWrapException<Void>(context, "ackDequeuedJobs",
          request.toString())));
}
 
Example #18
Source File: StreamImpl.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
/**
 * Close the stream and schedule cache eviction at some point in the future.
 * We delay this as a way to place the stream in a probationary state--cached
 * in the proxy but unusable.
 * This mechanism helps the cluster adapt to situations where a proxy has
 * persistent connectivity/availability issues, because it keeps an affected
 * stream off the proxy for a period of time, hopefully long enough for the
 * issues to be resolved, or for whoop to kick in and kill the shard.
 */
void handleServiceTimeout(String reason) {
    synchronized (this) {
        if (StreamStatus.isUnavailable(status)) {
            return;
        }
        // Mark stream in error state
        setStreamInErrorStatus();
    }

    // Async close request, and schedule eviction when its done.
    Future<Void> closeFuture = requestClose(reason, false /* dont remove */);
    closeFuture.onSuccess(new AbstractFunction1<Void, BoxedUnit>() {
        @Override
        public BoxedUnit apply(Void result) {
            streamManager.scheduleRemoval(StreamImpl.this, streamProbationTimeoutMs);
            return BoxedUnit.UNIT;
        }
    });
}
 
Example #19
Source File: bootstrapServersTest.java    From zipkin-finagle with Apache License 2.0 6 votes vote down vote up
@Test public void letOverridesDefault() {
  final List<InetSocketAddress> override = singletonList(new InetSocketAddress("zipkin", 9092));

  final AtomicBoolean ran = new AtomicBoolean();
  Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
    @Override public BoxedUnit apply() {
      ran.set(true); // used to verify this block is executed.
      assertThat(bootstrapServers$.Flag.isDefined()).isTrue();
      assertThat(bootstrapServers$.Flag.apply()).isEqualTo(override);
      return BoxedUnit.UNIT;
    }
  };
  bootstrapServers$.Flag.let(override, fn0);

  assertThat(ran.get()).isTrue();
}
 
Example #20
Source File: topicTest.java    From zipkin-finagle with Apache License 2.0 6 votes vote down vote up
@Test public void letOverridesDefault() {
  final String override = "zipkin-dev";

  final AtomicBoolean ran = new AtomicBoolean();
  Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
    @Override public BoxedUnit apply() {
      ran.set(true); // used to verify this block is executed.
      assertThat(topic$.Flag.isDefined()).isTrue();
      assertThat(topic$.Flag.apply()).isEqualTo(override);
      return BoxedUnit.UNIT;
    }
  };
  topic$.Flag.let(override, fn0);

  assertThat(ran.get()).isTrue();
}
 
Example #21
Source File: initialSampleRateTest.java    From zipkin-finagle with Apache License 2.0 6 votes vote down vote up
@Test public void letOverridesDefault() {
  final float override = 1.0f;

  final AtomicBoolean ran = new AtomicBoolean();
  Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
    @Override public BoxedUnit apply() {
      ran.set(true); // used to verify this block is executed.
      assertThat(initialSampleRate$.Flag.isDefined()).isTrue();
      assertThat(initialSampleRate$.Flag.apply()).isEqualTo(override);
      return BoxedUnit.UNIT;
    }
  };
  initialSampleRate$.Flag.let(override, fn0);

  assertThat(ran.get()).isTrue();
}
 
Example #22
Source File: localServiceNameTest.java    From zipkin-finagle with Apache License 2.0 6 votes vote down vote up
@Test public void letOverridesDefault() {
  final String override = "favstar";

  final AtomicBoolean ran = new AtomicBoolean();
  Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
    @Override public BoxedUnit apply() {
      ran.set(true); // used to verify this block is executed.
      assertThat(localServiceName$.Flag.isDefined()).isTrue();
      assertThat(localServiceName$.Flag.apply()).isEqualTo(override);
      return BoxedUnit.UNIT;
    }
  };
  localServiceName$.Flag.let(override, fn0);

  assertThat(ran.get()).isTrue();
}
 
Example #23
Source File: SimpleLedgerAllocator.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
void deleteLedger(final long ledgerId) {
    final Future<Void> deleteFuture = bkc.deleteLedger(ledgerId, true);
    synchronized (ledgerDeletions) {
        ledgerDeletions.add(deleteFuture);
    }
    deleteFuture.onFailure(new AbstractFunction1<Throwable, BoxedUnit>() {
        @Override
        public BoxedUnit apply(Throwable cause) {
            LOG.error("Error deleting ledger {} for ledger allocator {}, retrying : ",
                    new Object[] { ledgerId, allocatePath, cause });
            if (!isClosing()) {
                deleteLedger(ledgerId);
            }
            return BoxedUnit.UNIT;
        }
    }).ensure(new AbstractFunction0<BoxedUnit>() {
        @Override
        public BoxedUnit apply() {
            synchronized (ledgerDeletions) {
                ledgerDeletions.remove(deleteFuture);
            }
            return BoxedUnit.UNIT;
        }
    });
}
 
Example #24
Source File: FinagleSender.java    From zipkin-finagle with Apache License 2.0 6 votes vote down vote up
@Override protected void doEnqueue(Callback<Void> callback) {
  try {
    client.apply(makeRequest(spans)).respond(new AbstractFunction1<Try<Rep>, BoxedUnit>() {
      @Override public BoxedUnit apply(Try<Rep> result) {
        if (result.isReturn()) {
          callback.onSuccess(null);
        } else {
          callback.onError(result.throwable());
        }
        return BoxedUnit.UNIT;
      }
    });
  } catch (Exception e) {
    callback.onError(e);
  }
}
 
Example #25
Source File: hostTest.java    From zipkin-finagle with Apache License 2.0 6 votes vote down vote up
@Test public void letOverridesDefault() {
  final String override = "foo:9411";

  final AtomicBoolean ran = new AtomicBoolean();
  Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
    @Override public BoxedUnit apply() {
      ran.set(true); // used to verify this block is executed.
      assertThat(host$.Flag.isDefined()).isTrue();
      assertThat(host$.Flag.apply()).isEqualTo(override);
      return BoxedUnit.UNIT;
    }
  };
  host$.Flag.let(override, fn0);

  assertThat(ran.get()).isTrue();
}
 
Example #26
Source File: tlsEnabledTest.java    From zipkin-finagle with Apache License 2.0 6 votes vote down vote up
@Test public void letOverridesDefault() {
  final boolean override = true;

  final AtomicBoolean ran = new AtomicBoolean();
  Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
    @Override public BoxedUnit apply() {
      ran.set(true); // used to verify this block is executed.
      assertThat(tlsEnabled$.Flag.isDefined()).isTrue();
      assertThat(tlsEnabled$.Flag.apply()).isEqualTo(override);
      return BoxedUnit.UNIT;
    }
  };
  tlsEnabled$.Flag.let(override, fn0);

  assertThat(ran.get()).isTrue();
}
 
Example #27
Source File: MovingAverageRateFactory.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
public MovingAverageRateFactory(Timer timer) {
    this.avgs = new CopyOnWriteArrayList<SampledMovingAverageRate>();
    this.timer = timer;
    Function0<BoxedUnit> sampleTask = new Function0<BoxedUnit>() {
        public BoxedUnit apply() {
            sampleAll();
            return null;
        }
    };
    this.timerTask = timer.schedulePeriodically(
        Time.now(), Duration.fromSeconds(DEFAULT_INTERVAL_SECS), sampleTask);
}
 
Example #28
Source File: ReadAheadWorker.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
<T> Function1<T, BoxedUnit> submit(final Function1<T, BoxedUnit> function) {
    return new AbstractFunction1<T, BoxedUnit>() {
        @Override
        public BoxedUnit apply(final T input) {
            submit(new Runnable() {
                @Override
                public void run() {
                    function.apply(input);
                }
            });
            return BoxedUnit.UNIT;
        }
    };
}
 
Example #29
Source File: ZKSessionLock.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
private void deleteLockNode(final Promise<BoxedUnit> promise) {
    if (null == currentNode) {
        promise.setValue(BoxedUnit.UNIT);
        return;
    }

    zk.delete(currentNode, -1, new AsyncCallback.VoidCallback() {
        @Override
        public void processResult(final int rc, final String path, Object ctx) {
            lockStateExecutor.submit(lockPath, new SafeRunnable() {
                @Override
                public void safeRun() {
                    if (KeeperException.Code.OK.intValue() == rc) {
                        LOG.info("Deleted lock node {} for {} successfully.", path, lockId);
                    } else if (KeeperException.Code.NONODE.intValue() == rc ||
                            KeeperException.Code.SESSIONEXPIRED.intValue() == rc) {
                        LOG.info("Delete node failed. Node already gone for node {} id {}, rc = {}",
                                new Object[] { path, lockId, KeeperException.Code.get(rc) });
                    } else {
                        LOG.error("Failed on deleting lock node {} for {} : {}",
                                new Object[] { path, lockId, KeeperException.Code.get(rc) });
                    }

                    FailpointUtils.checkFailPointNoThrow(FailpointUtils.FailPointName.FP_LockUnlockCleanup);
                    promise.setValue(BoxedUnit.UNIT);
                }
            });
        }
    }, null);
}
 
Example #30
Source File: ZKSessionLock.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
@Override
public void unlock() {
    Future<BoxedUnit> unlockResult = asyncUnlock();
    try {
        Await.result(unlockResult, Duration.fromMilliseconds(lockOpTimeout));
    } catch (TimeoutException toe) {
        // This shouldn't happen unless we lose a watch, and may result in a leaked lock.
        LOG.error("Timeout unlocking {} owned by {} : ", new Object[] { lockPath, lockId, toe });
    } catch (Exception e) {
        LOG.warn("{} failed to unlock {} : ", new Object[] { lockId, lockPath, e });
    }
}