本文整理了Java中io.pravega.common.Exceptions.checkNotClosed()
方法的一些代码示例,展示了Exceptions.checkNotClosed()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Exceptions.checkNotClosed()
方法的具体详情如下:
包路径:io.pravega.common.Exceptions
类名称:Exceptions
方法名:checkNotClosed
[英]Throws an ObjectClosedException if the closed argument is true.
[中]如果closed参数为true,则引发ObjectClosedException。
代码示例来源:origin: pravega/pravega
/**
* Adds a new Result Entry.
*
* @param entry The entry to add.
*/
public void add(FutureReadResultEntry entry) {
synchronized (this.reads) {
Exceptions.checkNotClosed(this.closed, this);
this.reads.add(entry);
}
}
代码示例来源:origin: pravega/pravega
@Override
public CompletableFuture<Void> seal(String segmentName, Duration timeout) {
Exceptions.checkNotClosed(this.closed.get(), this);
throw new UnsupportedOperationException("seal");
}
代码示例来源:origin: pravega/pravega
private synchronized EventStreamReader<byte[]> getReader() {
Exceptions.checkNotClosed(this.closed, this);
if (this.reader == null) {
this.reader = ClientReader.this.clientFactory.createReader(this.readerId, this.readerGroup, ClientAdapterBase.SERIALIZER, READER_CONFIG);
}
return this.reader;
}
}
代码示例来源:origin: pravega/pravega
@Override
public ReadIndex createReadIndex(ContainerMetadata containerMetadata, ReadOnlyStorage storage) {
Exceptions.checkNotClosed(this.closed.get(), this);
return new ContainerReadIndex(this.config, containerMetadata, this.cacheFactory, storage, this.cacheManager, this.executorService);
}
代码示例来源:origin: pravega/pravega
@Override
public void cleanup(Collection<Long> segmentIds) {
Exceptions.checkNotClosed(this.closed.get(), this);
closeIndices(segmentIds, true);
log.info("{}: Cleaned up Attribute Indices for {} Segment(s).", this.traceObjectId, segmentIds == null ? "all" : segmentIds.size());
}
代码示例来源:origin: pravega/pravega
@Override
protected void doStop() {
Exceptions.checkNotClosed(this.closed.get(), this);
this.actorManager.stopAsync();
}
代码示例来源:origin: pravega/pravega
/**
* Executes the given Callable asynchronously and returns a CompletableFuture that will be completed with the result.
* @param operation The Callable to execute.
* @param segmentNames The names of the Segments involved in this operation (for sequencing purposes).
*/
private <R> CompletableFuture<R> supplyAsync(Callable<R> operation, String... segmentNames) {
Exceptions.checkNotClosed(this.closed.get(), this);
return this.taskProcessor.add(Arrays.asList(segmentNames), () -> execute(operation));
}
代码示例来源:origin: pravega/pravega
private void invoke(MethodInvocation methodInvocation) {
Exceptions.checkNotClosed(this.closed, this);
if (this.methodInvokeCallback != null) {
this.methodInvokeCallback.accept(methodInvocation);
}
}
代码示例来源:origin: pravega/pravega
/**
* Forces a flush of the current DataFrame. This should be invoked if there are no more items to add to the current
* DataFrame, but it is desired to have its outstanding contents flushed to the underlying DurableDataLog.
*/
void flush() {
Exceptions.checkNotClosed(this.closed.get(), this);
this.outputStream.flush();
this.outputStream.releaseBuffer();
}
代码示例来源:origin: pravega/pravega
@Override
public CompletableFuture<Void> stopContainer(ContainerHandle handle, Duration timeout) {
Exceptions.checkNotClosed(this.closed.get(), this);
ContainerWithHandle result = this.containers.getOrDefault(handle.getContainerId(), null);
if (result == null) {
return CompletableFuture.completedFuture(null); // This could happen due to some race (or AutoClose) in the caller.
}
// Stop the container and then unregister it.
return Services.stopAsync(result.container, this.executor);
}
代码示例来源:origin: pravega/pravega
@Override
public Collection<WriterSegmentProcessor> createWriterSegmentProcessors(UpdateableSegmentMetadata metadata) {
Exceptions.checkNotClosed(this.closed.get(), this);
if (!metadata.getAttributes().containsKey(Attributes.TABLE_INDEX_OFFSET)) {
// Not a Table Segment; nothing to do.
return Collections.emptyList();
}
return Collections.singletonList(new WriterTableProcessor(new TableWriterConnectorImpl(metadata), this.executor));
}
代码示例来源:origin: pravega/pravega
@Override
public void append(long streamSegmentId, long offset, byte[] data) throws StreamSegmentNotExistsException {
Exceptions.checkNotClosed(this.closed.get(), this);
log.debug("{}: append (StreamSegmentId = {}, Offset = {}, DataLength = {}).", this.traceObjectId, streamSegmentId, offset, data.length);
// Append the data to the StreamSegment Index. It performs further validation with respect to offsets, etc.
StreamSegmentReadIndex index = getOrCreateIndex(streamSegmentId);
Exceptions.checkArgument(!index.isMerged(), "streamSegmentId", "StreamSegment is merged. Cannot append to it anymore.");
index.append(offset, data);
}
代码示例来源:origin: pravega/pravega
@Override
public CompletableFuture<WriterFlushResult> flush(Duration timeout) {
Exceptions.checkNotClosed(this.closed.get(), this);
this.firstUnAcked.set(this.operations.size());
return CompletableFuture.completedFuture(new WriterFlushResult());
}
代码示例来源:origin: pravega/pravega
@Override
public CompletableFuture<ReadResult> read(String streamSegmentName, long offset, int maxLength, Duration timeout) {
Exceptions.checkNotClosed(this.closed.get(), this);
TimeoutTimer timer = new TimeoutTimer(timeout);
return READ_RETRY.run(() -> getStreamSegmentInfo(streamSegmentName, timer.getRemaining())
.thenApply(si -> StreamSegmentStorageReader.read(si, offset, maxLength, MAX_READ_AT_ONCE_BYTES, this.storage)));
}
代码示例来源:origin: pravega/pravega
@Override
public CompletableFuture<Void> awaitOnline() {
Exceptions.checkNotClosed(this.closed.get(), this);
if (state() != State.RUNNING) {
throw new IllegalContainerStateException(this.getId(), state(), State.RUNNING);
}
return this.delayedStart;
}
代码示例来源:origin: pravega/pravega
@Override
public CompletableFuture<List<Long>> put(String segmentName, List<TableEntry> entries, Duration timeout) {
Exceptions.checkNotClosed(this.closed.get(), this);
return CompletableFuture.supplyAsync(() -> getTableData(segmentName).put(entries), this.executor);
}
代码示例来源:origin: pravega/pravega
@Override
public CompletableFuture<Void> remove(String segmentName, Collection<TableKey> keys, Duration timeout) {
Exceptions.checkNotClosed(this.closed.get(), this);
return CompletableFuture.runAsync(() -> getTableData(segmentName).remove(keys), this.executor);
}
代码示例来源:origin: pravega/pravega
@Override
public void beginMerge(long targetStreamSegmentId, long offset, long sourceStreamSegmentId) throws StreamSegmentNotExistsException {
Exceptions.checkNotClosed(this.closed.get(), this);
log.debug("{}: beginMerge (TargetId = {}, Offset = {}, SourceId = {}).", this.traceObjectId, targetStreamSegmentId, offset, sourceStreamSegmentId);
StreamSegmentReadIndex targetIndex = getOrCreateIndex(targetStreamSegmentId);
StreamSegmentReadIndex sourceIndex = getOrCreateIndex(sourceStreamSegmentId);
Exceptions.checkArgument(!targetIndex.isMerged(), "targetStreamSegmentId", "StreamSegment is merged. Cannot access it anymore.");
Exceptions.checkArgument(!sourceIndex.isMerged(), "sourceStreamSegmentId", "StreamSegment is merged. Cannot access it anymore.");
targetIndex.beginMerge(offset, sourceIndex);
sourceIndex.markMerged();
}
代码示例来源:origin: pravega/pravega
private void ensureRunning() {
Exceptions.checkNotClosed(this.closed.get(), this);
if (state() != State.RUNNING) {
throw new IllegalContainerStateException(getId(), state(), State.RUNNING);
} else if (isOffline()) {
throw new ContainerOfflineException(getId());
}
}
代码示例来源:origin: pravega/pravega
@Override
public long fetchProperty(SegmentAttribute attribute) {
Exceptions.checkNotClosed(closed.get(), this);
val future = RETRY_SCHEDULE.retryingOn(ConnectionFailedException.class)
.throwingOn(NoSuchSegmentException.class)
.runAsync(() -> getPropertyAsync(attribute.getValue(), delegationToken),
connectionFactory.getInternalExecutor());
return Futures.getThrowingException(future).getValue();
}
内容来源于网络,如有侵权,请联系作者删除!