use of io.pravega.shared.controller.event.AbortEvent in project pravega by pravega.
the class AbortRequestHandler method processEvent.
@Override
public CompletableFuture<Void> processEvent(AbortEvent event) {
String scope = event.getScope();
String stream = event.getStream();
int epoch = event.getEpoch();
UUID txId = event.getTxid();
long requestId = event.getRequestId();
if (requestId == 0L) {
requestId = ControllerService.nextRequestId();
}
Timer timer = new Timer();
OperationContext context = streamMetadataStore.createStreamContext(scope, stream, requestId);
log.info(requestId, "Aborting transaction {} on stream {}/{}", event.getTxid(), event.getScope(), event.getStream());
return Futures.toVoid(streamMetadataStore.getSegmentsInEpoch(event.getScope(), event.getStream(), epoch, context, executor).thenApply(segments -> segments.stream().map(StreamSegmentRecord::segmentId).collect(Collectors.toList())).thenCompose(segments -> streamMetadataTasks.notifyTxnAbort(scope, stream, segments, txId, context.getRequestId())).thenCompose(x -> streamMetadataStore.abortTransaction(scope, stream, txId, context, executor)).whenComplete((result, error) -> {
if (error != null) {
log.warn(context.getRequestId(), "Failed aborting transaction {} on stream {}/{}", event.getTxid(), event.getScope(), event.getStream());
TransactionMetrics.getInstance().abortTransactionFailed(scope, stream);
} else {
log.info(context.getRequestId(), "Successfully aborted transaction {} on stream {}/{}", event.getTxid(), event.getScope(), event.getStream());
if (processedEvents != null) {
processedEvents.offer(event);
}
TransactionMetrics.getInstance().abortTransaction(scope, stream, timer.getElapsed());
}
}));
}
use of io.pravega.shared.controller.event.AbortEvent in project pravega by pravega.
the class ControllerEventProcessors method initialize.
private void initialize() {
// region Create commit event processor
EventProcessorGroupConfig commitReadersConfig = EventProcessorGroupConfigImpl.builder().streamName(config.getCommitStreamName()).readerGroupName(config.getCommitReaderGroupName()).eventProcessorCount(config.getCommitReaderGroupSize()).checkpointConfig(CheckpointConfig.none()).build();
EventProcessorConfig<CommitEvent> commitConfig = EventProcessorConfig.<CommitEvent>builder().config(commitReadersConfig).decider(ExceptionHandler.DEFAULT_EXCEPTION_HANDLER).serializer(COMMIT_EVENT_SERIALIZER).supplier(() -> new ConcurrentEventProcessor<>(commitRequestHandler, executor)).minRebalanceIntervalMillis(rebalanceIntervalMillis).build();
log.debug("Creating commit event processors");
Retry.indefinitelyWithExpBackoff(DELAY, MULTIPLIER, MAX_DELAY, e -> log.warn("Error creating commit event processor group", e)).run(() -> {
commitEventProcessors = system.createEventProcessorGroup(commitConfig, checkpointStore, rebalanceExecutor);
return null;
});
// endregion
// region Create abort event processor
EventProcessorGroupConfig abortReadersConfig = EventProcessorGroupConfigImpl.builder().streamName(config.getAbortStreamName()).readerGroupName(config.getAbortReaderGroupName()).eventProcessorCount(config.getAbortReaderGroupSize()).checkpointConfig(CheckpointConfig.none()).build();
EventProcessorConfig<AbortEvent> abortConfig = EventProcessorConfig.<AbortEvent>builder().config(abortReadersConfig).decider(ExceptionHandler.DEFAULT_EXCEPTION_HANDLER).serializer(ABORT_EVENT_SERIALIZER).supplier(() -> new ConcurrentEventProcessor<>(abortRequestHandler, executor)).minRebalanceIntervalMillis(rebalanceIntervalMillis).build();
log.debug("Creating abort event processors");
Retry.indefinitelyWithExpBackoff(DELAY, MULTIPLIER, MAX_DELAY, e -> log.warn("Error creating commit event processor group", e)).run(() -> {
abortEventProcessors = system.createEventProcessorGroup(abortConfig, checkpointStore, rebalanceExecutor);
return null;
});
// endregion
// region Create request event processor
EventProcessorGroupConfig requestReadersConfig = EventProcessorGroupConfigImpl.builder().streamName(config.getRequestStreamName()).readerGroupName(config.getRequestReaderGroupName()).eventProcessorCount(1).checkpointConfig(CheckpointConfig.none()).build();
EventProcessorConfig<ControllerEvent> requestConfig = EventProcessorConfig.builder().config(requestReadersConfig).decider(ExceptionHandler.DEFAULT_EXCEPTION_HANDLER).serializer(CONTROLLER_EVENT_SERIALIZER).supplier(() -> new ConcurrentEventProcessor<>(streamRequestHandler, executor)).minRebalanceIntervalMillis(rebalanceIntervalMillis).build();
log.debug("Creating stream request event processors");
Retry.indefinitelyWithExpBackoff(DELAY, MULTIPLIER, MAX_DELAY, e -> log.warn("Error creating request event processor group", e)).run(() -> {
requestEventProcessors = system.createEventProcessorGroup(requestConfig, checkpointStore, rebalanceExecutor);
return null;
});
// endregion
// region Create KVtable event processor
EventProcessorGroupConfig kvtReadersConfig = EventProcessorGroupConfigImpl.builder().streamName(config.getKvtStreamName()).readerGroupName(config.getKvtReaderGroupName()).eventProcessorCount(1).checkpointConfig(CheckpointConfig.none()).build();
EventProcessorConfig<ControllerEvent> kvtRequestConfig = EventProcessorConfig.builder().config(kvtReadersConfig).decider(ExceptionHandler.DEFAULT_EXCEPTION_HANDLER).serializer(CONTROLLER_EVENT_SERIALIZER).supplier(() -> new ConcurrentEventProcessor<>(kvtRequestHandler, executor)).minRebalanceIntervalMillis(rebalanceIntervalMillis).build();
log.debug("Creating kvt request event processors");
Retry.indefinitelyWithExpBackoff(DELAY, MULTIPLIER, MAX_DELAY, e -> log.warn("Error creating request event processor group", e)).run(() -> {
kvtRequestEventProcessors = system.createEventProcessorGroup(kvtRequestConfig, checkpointStore, rebalanceExecutor);
return null;
});
// endregion
log.info("Awaiting start of event processors...");
commitEventProcessors.awaitRunning();
log.info("Commit event processor started.");
abortEventProcessors.awaitRunning();
log.info("Abort event processor started.");
requestEventProcessors.awaitRunning();
log.info("Stream request event processor started.");
kvtRequestEventProcessors.awaitRunning();
log.info("KVT request event processor started.");
}
use of io.pravega.shared.controller.event.AbortEvent in project pravega by pravega.
the class TxnSweeper method failOverAbortingTxn.
private CompletableFuture<Void> failOverAbortingTxn(String failedHost, int epoch, TxnResource txn) {
String scope = txn.getScope();
String stream = txn.getStream();
UUID txnId = txn.getTxnId();
log.info("Host = {}, failing over aborting transaction {}/{}/{}", failedHost, scope, stream, txnId);
return transactionMetadataTasks.writeAbortEvent(new AbortEvent(scope, stream, epoch, txnId, ControllerService.nextRequestId())).thenComposeAsync(status -> streamMetadataStore.removeTxnFromIndex(failedHost, txn, true), executor);
}
Aggregations