use of io.pravega.segmentstore.contracts.StreamingException in project pravega by pravega.
the class ClientAdapterBase method createStream.
@Override
public CompletableFuture<Void> createStream(String streamName, Duration timeout) {
ensureRunning();
return CompletableFuture.runAsync(() -> {
if (this.streamWriters.containsKey(streamName)) {
throw new CompletionException(new StreamSegmentExistsException(streamName));
}
StreamConfiguration config = StreamConfiguration.builder().streamName(streamName).scalingPolicy(ScalingPolicy.fixed(this.testConfig.getSegmentsPerStream())).scope(SCOPE).build();
if (!getStreamManager().createStream(SCOPE, streamName, config)) {
throw new CompletionException(new StreamingException(String.format("Unable to create Stream '%s'.", streamName)));
}
int writerCount = Math.max(1, this.testConfig.getProducerCount() / this.testConfig.getStreamCount());
List<EventStreamWriter<byte[]>> writers = new ArrayList<>(writerCount);
if (this.streamWriters.putIfAbsent(streamName, writers) == null) {
for (int i = 0; i < writerCount; i++) {
writers.add(getClientFactory().createEventWriter(streamName, SERIALIZER, WRITER_CONFIG));
}
}
}, this.testExecutor);
}
use of io.pravega.segmentstore.contracts.StreamingException in project pravega by pravega.
the class ClientAdapterBase method delete.
@Override
public CompletableFuture<Void> delete(String streamName, Duration timeout) {
ensureRunning();
String parentName = StreamSegmentNameUtils.getParentStreamSegmentName(streamName);
if (isTransaction(streamName, parentName)) {
// We have a transaction to abort.
return abortTransaction(streamName, timeout);
} else {
return CompletableFuture.runAsync(() -> {
if (getStreamManager().deleteStream(SCOPE, streamName)) {
closeWriters(streamName);
} else {
throw new CompletionException(new StreamingException(String.format("Unable to delete stream '%s'.", streamName)));
}
}, this.testExecutor);
}
}
use of io.pravega.segmentstore.contracts.StreamingException in project pravega by pravega.
the class DurableLog method queueStoppedHandler.
private void queueStoppedHandler() {
if (state() != State.STOPPING && state() != State.FAILED) {
// The Queue Processor stopped but we are not in a stopping phase. We need to shut down right away.
log.warn("{}: OperationProcessor stopped unexpectedly (no error) but DurableLog was not currently stopping. Shutting down DurableLog.", this.traceObjectId);
this.stopException.set(new StreamingException("OperationProcessor stopped unexpectedly (no error) but DurableLog was not currently stopping."));
stopAsync();
}
}
Aggregations