本文整理了Java中io.pravega.common.Exceptions.checkNotNullOrEmpty()
方法的一些代码示例,展示了Exceptions.checkNotNullOrEmpty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Exceptions.checkNotNullOrEmpty()
方法的具体详情如下:
包路径:io.pravega.common.Exceptions
类名称:Exceptions
方法名:checkNotNullOrEmpty
[英]Throws a NullPointerException if the arg argument is null. Throws an IllegalArgumentException if the String arg argument has a length of zero.
[中]如果arg参数为null,则引发NullPointerException。如果字符串arg参数的长度为零,则引发IllegalArgumentException。
代码示例来源:origin: pravega/pravega
/**
* Constructs a {@code Principal} representing the given user name.
*
* @param name the user name
*/
public UserPrincipal(String name) {
Exceptions.checkNotNullOrEmpty(name, "name");
this.name = name;
}
代码示例来源:origin: pravega/pravega
/**
* Creates a new instance of the SegmentChunk class.
*
* @param chunkName The name of this SegmentChunk (not of the owning Segment).
* @param startOffset The offset within the owning Segment where this SegmentChunk starts at.
*/
SegmentChunk(String chunkName, long startOffset) {
this.name = Exceptions.checkNotNullOrEmpty(chunkName, "chunkName");
Preconditions.checkArgument(startOffset >= 0, "startOffset must be a non-negative number.");
this.startOffset = startOffset;
}
代码示例来源:origin: pravega/pravega
public CompletableFuture<List<ScaleMetadata>> getScaleRecords(final String scope, final String stream, final long from, final long to) {
Exceptions.checkNotNullOrEmpty(scope, "scope");
Exceptions.checkNotNullOrEmpty(stream, "stream");
return streamStore.getScaleMetadata(scope, stream, from, to, null, executor);
}
代码示例来源:origin: pravega/pravega
/**
* Creates a new ValidationResult for a failed verification.
*/
static ValidationResult failed(String message) {
Exceptions.checkNotNullOrEmpty(message, "message");
ValidationResult result = new ValidationResult();
result.failureMessage = message;
return result;
}
代码示例来源:origin: pravega/pravega
/**
* Creates a new instance of the MetricProxy class.
*
* @param instance The initial Metric Instance.
* @param proxyName The name of the MetricProxy. This may be different from the name of the Metric's instance.
* @param closeCallback A Consumer that will be invoked when this Proxy is closed.
*/
MetricProxy(T instance, String proxyName, Consumer<String> closeCallback) {
this.closeCallback = Preconditions.checkNotNull(closeCallback, "closeCallback");
this.proxyName = Exceptions.checkNotNullOrEmpty(proxyName, "name");
updateInstance(instance);
}
代码示例来源:origin: pravega/pravega
long acquireLock(String clientId) throws DataLogDisabledException {
Exceptions.checkNotNullOrEmpty(clientId, "clientId");
if (!this.enabled.get()) {
throw new DataLogDisabledException("Log is disabled; cannot acquire lock.");
}
this.writeLock.set(clientId);
return this.epoch.incrementAndGet();
}
代码示例来源:origin: pravega/pravega
/**
* Controller Service API to delete scope.
*
* @param scope Name of scope to be deleted.
* @return Status of delete scope.
*/
public CompletableFuture<DeleteScopeStatus> deleteScope(final String scope) {
Exceptions.checkNotNullOrEmpty(scope, "scope");
return streamStore.deleteScope(scope);
}
代码示例来源:origin: pravega/pravega
public CompletableFuture<PingTxnStatus> pingTransaction(final String scope,
final String stream,
final TxnId txnId,
final long lease) {
Exceptions.checkNotNullOrEmpty(scope, "scope");
Exceptions.checkNotNullOrEmpty(stream, "stream");
Preconditions.checkNotNull(txnId, "txnId");
UUID txId = ModelHelper.encode(txnId);
return streamTransactionMetadataTasks.pingTxn(scope, stream, txId, lease, null);
}
代码示例来源:origin: pravega/pravega
public CompletableFuture<Map<SegmentId, Long>> getSegmentsAtHead(final String scope, final String stream) {
Exceptions.checkNotNullOrEmpty(scope, "scope");
Exceptions.checkNotNullOrEmpty(stream, "stream");
// First fetch segments active at specified timestamp from the specified stream.
// Divide current segments in segmentFutures into at most count positions.
return streamStore.getSegmentsAtHead(scope, stream, null, executor).thenApply(segments -> {
return segments.entrySet().stream()
.collect(Collectors.toMap(entry -> ModelHelper.createSegmentId(scope, stream, entry.getKey().segmentId()),
Map.Entry::getValue));
});
}
代码示例来源:origin: pravega/pravega
public CompletableFuture<Boolean> isSegmentValid(final String scope,
final String stream,
final long segmentId) {
Exceptions.checkNotNullOrEmpty(scope, "scope");
Exceptions.checkNotNullOrEmpty(stream, "stream");
return streamStore.getActiveSegments(scope, stream, null, executor)
.thenApplyAsync(x -> x.stream().anyMatch(z -> z.segmentId() == segmentId), executor);
}
代码示例来源:origin: pravega/pravega
@Override
public CompletableFuture<Void> readAllStorage(String segmentName, Consumer<Event> eventHandler, CancellationToken cancellationToken) {
Exceptions.checkNotNullOrEmpty(segmentName, "segmentName");
Preconditions.checkNotNull(eventHandler, "eventHandler");
if (cancellationToken == null) {
cancellationToken = CancellationToken.NONE;
}
return new StorageReader(segmentName, eventHandler, cancellationToken).run();
}
代码示例来源:origin: pravega/pravega
public static final SegmentId createSegmentId(final String scope, final String stream, final long segmentId) {
Exceptions.checkNotNullOrEmpty(scope, "scope");
Exceptions.checkNotNullOrEmpty(stream, "stream");
return SegmentId.newBuilder()
.setStreamInfo(createStreamInfo(scope, stream))
.setSegmentId(segmentId)
.build();
}
代码示例来源:origin: pravega/pravega
public static final Controller.StreamCutRangeResponse createStreamCutRangeResponse(final String scope, final String stream,
final List<SegmentId> segments, String delegationToken) {
Exceptions.checkNotNullOrEmpty(scope, "scope");
Exceptions.checkNotNullOrEmpty(stream, "stream");
Exceptions.checkArgument(segments.stream().allMatch(x -> x.getStreamInfo().getScope().equals(scope) &&
x.getStreamInfo().getStream().equals(stream)),
"streamInfo", "stream info does not match segment id", scope, stream, segments);
return Controller.StreamCutRangeResponse.newBuilder()
.addAllSegments(segments)
.setDelegationToken(delegationToken)
.build();
}
代码示例来源:origin: pravega/pravega
public static Controller.StreamCutRange decode(final String scope, final String stream, Map<Long, Long> from, Map<Long, Long> to) {
Exceptions.checkNotNullOrEmpty(scope, "scope");
Exceptions.checkNotNullOrEmpty(stream, "stream");
return Controller.StreamCutRange.newBuilder().setStreamInfo(createStreamInfo(scope, stream)).putAllFrom(from)
.putAllTo(to).build();
}
代码示例来源:origin: pravega/pravega
RollingSegmentHandle(SegmentHandle segmentHandle) {
this.headerHandle = null;
this.readOnly = segmentHandle.isReadOnly();
this.segmentName = Exceptions.checkNotNullOrEmpty(segmentHandle.getSegmentName(), "headerHandle.getSegmentName()");
this.rollingPolicy = SegmentRollingPolicy.NO_ROLLING;
this.segmentChunks = Collections.singletonList(new SegmentChunk(segmentHandle.getSegmentName(), 0));
}
代码示例来源:origin: pravega/pravega
@Override
public void onRemoval(RemovalNotification<String, Gauge> removal) {
Gauge gauge = removal.getValue();
if (removal.getCause() != RemovalCause.REPLACED) {
Exceptions.checkNotNullOrEmpty(gauge.getName(), "gauge");
metrics.remove(gauge.getName());
log.debug("Removed Gauge: {}.", gauge.getName());
}
}
}).
代码示例来源:origin: pravega/pravega
public static final Controller.ScopeInfo createScopeInfo(final String scope) {
Exceptions.checkNotNullOrEmpty(scope, "scope");
return Controller.ScopeInfo.newBuilder().setScope(scope).build();
}
代码示例来源:origin: pravega/pravega
public static final SegmentRange createSegmentRange(final String scope, final String stream,
final long segmentId, final double rangeMinKey, final double rangeMaxKey) {
Exceptions.checkNotNullOrEmpty(scope, "scope");
Exceptions.checkNotNullOrEmpty(stream, "stream");
return SegmentRange.newBuilder()
.setSegmentId(createSegmentId(scope, stream, segmentId))
.setMinKey(rangeMinKey)
.setMaxKey(rangeMaxKey)
.build();
}
代码示例来源:origin: pravega/pravega
public CompletableFuture<TxnState> checkTransactionStatus(final String scope, final String stream,
final TxnId txnId) {
Exceptions.checkNotNullOrEmpty(scope, "scope");
Exceptions.checkNotNullOrEmpty(stream, "stream");
Preconditions.checkNotNull(txnId, "txnId");
return streamStore.transactionStatus(scope, stream, ModelHelper.encode(txnId), null, executor)
.thenApplyAsync(res -> TxnState.newBuilder().setState(TxnState.State.valueOf(res.name())).build(), executor);
}
代码示例来源:origin: pravega/pravega
public CompletableFuture<UpdateStreamStatus> sealStream(final String scope, final String stream) {
Exceptions.checkNotNullOrEmpty(scope, "scope");
Exceptions.checkNotNullOrEmpty(stream, "stream");
Timer timer = new Timer();
return streamMetadataTasks.sealStream(scope, stream, null)
.thenApplyAsync(status -> {
reportSealStreamMetrics(scope, stream, status, timer.getElapsed());
return UpdateStreamStatus.newBuilder().setStatus(status).build();
}, executor);
}
内容来源于网络,如有侵权,请联系作者删除!