io.pravega.common.Exceptions.mustRethrow()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中io.pravega.common.Exceptions.mustRethrow()方法的一些代码示例,展示了Exceptions.mustRethrow()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Exceptions.mustRethrow()方法的具体详情如下:
包路径:io.pravega.common.Exceptions
类名称:Exceptions
方法名:mustRethrow

Exceptions.mustRethrow介绍

[英]Determines if the given Throwable represents a fatal exception and cannot be handled.
[中]确定给定的Throwable是否表示致命异常,并且无法处理。

代码示例

代码示例来源:origin: pravega/pravega

private boolean isCriticalError(Throwable ex) {
  return Exceptions.mustRethrow(ex)
      || Exceptions.unwrap(ex) instanceof DataCorruptionException;
}

代码示例来源:origin: pravega/pravega

@Override
protected void runOneIteration() {
  if (this.closed.get()) {
    // We are done.
    return;
  }
  try {
    applyCachePolicy();
  } catch (Throwable ex) {
    if (Exceptions.mustRethrow(ex)) {
      throw ex;
    }
    // Log the error and move on. If we don't catch the exception here, the AbstractScheduledService will
    // auto-shutdown.
    log.error("{}: Error.", TRACE_OBJECT_ID, ex);
  }
}

代码示例来源:origin: pravega/pravega

task.run();
} catch (Throwable ex) {
  if (!Exceptions.mustRethrow(ex)) {

代码示例来源:origin: pravega/pravega

@GuardedBy("processingLock")
private CompletableFuture<ResultType> processInternal(ItemType data) {
  try {
    val result = this.processor.apply(data);
    result.whenCompleteAsync((r, ex) -> executionComplete(ex), this.executor);
    return result;
  } catch (Throwable ex) {
    if (!Exceptions.mustRethrow(ex)) {
      executionComplete(ex);
    }
    throw ex;
  }
}

代码示例来源:origin: pravega/pravega

private CompletableFuture<Void> deleteSegments(Collection<String> segmentNames) {
  ArrayList<CompletableFuture<Void>> deletionFutures = new ArrayList<>();
  for (String segmentName : segmentNames) {
    try {
      deletionFutures.add(deleteStream(segmentName));
    } catch (Throwable ex) {
      if (Exceptions.mustRethrow(ex) || !(Exceptions.unwrap(ex) instanceof StreamSegmentNotExistsException)) {
        throw ex;
      }
    }
  }
  return Futures.allOf(deletionFutures);
}

代码示例来源:origin: pravega/pravega

private long updateClients() {
  long sizeReduction = 0;
  int cg = this.currentGeneration.get();
  int og = this.oldestGeneration.get();
  for (Client c : getCurrentClients()) {
    try {
      sizeReduction += Math.max(0, c.updateGenerations(cg, og));
    } catch (ObjectClosedException ex) {
      // This object was closed but it was not unregistered. Do it now.
      log.warn("{} Detected closed client {}.", TRACE_OBJECT_ID, c);
      unregister(c);
    } catch (Throwable ex) {
      if (Exceptions.mustRethrow(ex)) {
        throw ex;
      }
      log.warn("{} Unable to update client {}. {}", TRACE_OBJECT_ID, c, ex);
    }
  }
  return sizeReduction;
}

代码示例来源:origin: pravega/pravega

@Override
public void initialize() throws DurableDataLogException {
  Preconditions.checkState(this.bookKeeper.get() == null, "BookKeeperLogFactory is already initialized.");
  try {
    this.bookKeeper.set(startBookKeeperClient());
  } catch (IllegalArgumentException | NullPointerException ex) {
    // Most likely a configuration issue; re-throw as is.
    close();
    throw ex;
  } catch (Throwable ex) {
    if (!Exceptions.mustRethrow(ex)) {
      // Make sure we close anything we may have opened.
      close();
    }
    // ZooKeeper not reachable, some other environment issue.
    throw new DataLogNotAvailableException("Unable to establish connection to ZooKeeper or BookKeeper.", ex);
  }
}

代码示例来源:origin: pravega/pravega

/**
 * Processes the given Operation. This method returns when the given Operation has been added to the internal queue.
 *
 * @param operation The Operation to process.
 * @return A CompletableFuture that, when completed, will indicate the Operation has finished processing. If the
 * Operation completed successfully, the Future will contain the Sequence Number of the Operation. If the Operation
 * failed, it will contain the exception that caused the failure.
 * @throws IllegalContainerStateException If the OperationProcessor is not running.
 */
public CompletableFuture<Void> process(Operation operation) {
  CompletableFuture<Void> result = new CompletableFuture<>();
  if (!isRunning()) {
    result.completeExceptionally(new IllegalContainerStateException("OperationProcessor is not running."));
  } else {
    log.debug("{}: process {}.", this.traceObjectId, operation);
    try {
      this.operationQueue.add(new CompletableOperation(operation, result));
    } catch (Throwable e) {
      if (Exceptions.mustRethrow(e)) {
        throw e;
      }
      result.completeExceptionally(e);
    }
  }
  return result;
}

代码示例来源:origin: pravega/pravega

private void fetchContents(long segmentOffset, int readLength, Consumer<ReadResultEntryContents> successCallback,
              Consumer<Throwable> failureCallback, Duration timeout) {
  try {
    byte[] readBuffer = new byte[readLength];
    getHandle()
        .thenCompose(h -> this.storage.read(h, segmentOffset, readBuffer, 0, readLength, timeout))
        .thenAccept(bytesRead -> successCallback.accept(toReadResultEntry(readBuffer, bytesRead)))
        .exceptionally(ex -> {
          // Async failure.
          Callbacks.invokeSafely(failureCallback, ex, null);
          return null;
        });
  } catch (Throwable ex) {
    // Synchronous failure.
    if (!Exceptions.mustRethrow(ex)) {
      Callbacks.invokeSafely(failureCallback, ex, null);
    }
    throw ex;
  }
}

代码示例来源:origin: pravega/pravega

@Override
protected void startUp() throws Exception {
  try {
    startZooKeeper();
    startBookKeeper();
    startAllControllers();
    // TODO: There is no way to figure out when the Controller or SegmentStore services are up. Until we have that,
    // we will need to wait some arbitrary time between these calls.
    Thread.sleep(3000);
    startAllSegmentStores();
    Thread.sleep(3000);
  } catch (Throwable ex) {
    if (!Exceptions.mustRethrow(ex)) {
      close();
    }
    throw ex;
  }
  super.startUp();
}

代码示例来源:origin: pravega/pravega

/**
 * Completes this Request with the given request as a source (this Request is a sub-interval of the given request).
 *
 * @param source The source Request to complete with.
 */
private void complete(Request source) {
  Preconditions.checkState(!isDone(), "This Request is already completed.");
  Preconditions.checkArgument(source.isDone(), "Given request is not completed.");
  Preconditions.checkArgument(isSubRequest(source, this), "This Request is not a sub-request of the given one.");
  try {
    // Get the source Request's result, slice it and return the sub-segment that this request maps to.
    Result sourceResult = source.resultFuture.join();
    int offset = (int) (this.getOffset() - source.getOffset());
    this.resultFuture.complete(new Result(sourceResult.getData().subSegment(offset, getLength()), true));
  } catch (Throwable ex) {
    if (Exceptions.mustRethrow(ex)) {
      throw ex;
    }
    fail(ex);
  }
}

代码示例来源:origin: pravega/pravega

if (!Exceptions.mustRethrow(ex)) {
  indexInitializationFailed(streamSegmentId, result, ex);

代码示例来源:origin: pravega/pravega

operation = new CachedStreamSegmentAppendOperation((StreamSegmentAppendOperation) operation);
} catch (Throwable ex) {
  if (Exceptions.mustRethrow(ex)) {
    throw ex;
  } else {

代码示例来源:origin: pravega/pravega

throw ex;
} catch (Exception ex) {
  if (!Exceptions.mustRethrow(ex) && headerHandle != null) {

代码示例来源:origin: pravega/pravega

/**
 * Executes the Storage Read for the given request.
 *
 * @param request The request.
 */
private void executeStorageRead(Request request) {
  try {
    byte[] buffer = new byte[request.length];
    getHandle()
        .thenComposeAsync(handle -> this.storage.read(handle, request.offset, buffer, 0, buffer.length, request.getTimeout()), this.executor)
        .thenAcceptAsync(bytesRead -> request.complete(new ByteArraySegment(buffer, 0, bytesRead)), this.executor)
        .whenComplete((r, ex) -> {
          if (ex != null) {
            request.fail(ex);
          }
          // Unregister the Request after every request fulfillment.
          finalizeRequest(request);
        });
  } catch (Throwable ex) {
    if (Exceptions.mustRethrow(ex)) {
      throw ex;
    }
    request.fail(ex);
    finalizeRequest(request);
  }
}

代码示例来源:origin: pravega/pravega

log("Client initialized; using scope '%s'.", SCOPE);
} catch (Throwable ex) {
  if (!Exceptions.mustRethrow(ex)) {
    close();

相关文章