Search in sources :

Example 1 with StreamingException

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);
}
Also used : StreamingException(io.pravega.segmentstore.contracts.StreamingException) StreamSegmentExistsException(io.pravega.segmentstore.contracts.StreamSegmentExistsException) CompletionException(java.util.concurrent.CompletionException) StreamConfiguration(io.pravega.client.stream.StreamConfiguration) ArrayList(java.util.ArrayList) EventStreamWriter(io.pravega.client.stream.EventStreamWriter)

Example 2 with StreamingException

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);
    }
}
Also used : StreamingException(io.pravega.segmentstore.contracts.StreamingException) CompletionException(java.util.concurrent.CompletionException)

Example 3 with StreamingException

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();
    }
}
Also used : StreamingException(io.pravega.segmentstore.contracts.StreamingException)

Aggregations

StreamingException (io.pravega.segmentstore.contracts.StreamingException)3 CompletionException (java.util.concurrent.CompletionException)2 EventStreamWriter (io.pravega.client.stream.EventStreamWriter)1 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)1 StreamSegmentExistsException (io.pravega.segmentstore.contracts.StreamSegmentExistsException)1 ArrayList (java.util.ArrayList)1