use of io.pravega.client.stream.impl.ConnectionClosedException in project pravega by pravega.
the class MockController method createSegmentTx.
private CompletableFuture<Void> createSegmentTx(UUID txId, Segment segment) {
CompletableFuture<Void> result = new CompletableFuture<>();
FailingReplyProcessor replyProcessor = new FailingReplyProcessor() {
@Override
public void connectionDropped() {
result.completeExceptionally(new ConnectionClosedException());
}
@Override
public void wrongHost(WrongHost wrongHost) {
result.completeExceptionally(new UnsupportedOperationException());
}
@Override
public void transactionCreated(TransactionCreated transactionCreated) {
result.complete(null);
}
@Override
public void processingFailure(Exception error) {
result.completeExceptionally(error);
}
@Override
public void authTokenCheckFailed(WireCommands.AuthTokenCheckFailed authTokenCheckFailed) {
result.completeExceptionally(new AuthenticationException(authTokenCheckFailed.toString()));
}
};
sendRequestOverNewConnection(new CreateTransaction(idGenerator.get(), segment.getScopedName(), txId, ""), replyProcessor, result);
return result;
}
use of io.pravega.client.stream.impl.ConnectionClosedException in project pravega by pravega.
the class MockController method deleteSegment.
private boolean deleteSegment(String name, PravegaNodeUri uri) {
CompletableFuture<Boolean> result = new CompletableFuture<>();
FailingReplyProcessor replyProcessor = new FailingReplyProcessor() {
@Override
public void connectionDropped() {
result.completeExceptionally(new ConnectionClosedException());
}
@Override
public void wrongHost(WireCommands.WrongHost wrongHost) {
result.completeExceptionally(new UnsupportedOperationException());
}
@Override
public void segmentDeleted(WireCommands.SegmentDeleted segmentDeleted) {
result.complete(true);
}
@Override
public void noSuchSegment(WireCommands.NoSuchSegment noSuchSegment) {
result.complete(false);
}
@Override
public void processingFailure(Exception error) {
result.completeExceptionally(error);
}
@Override
public void authTokenCheckFailed(WireCommands.AuthTokenCheckFailed authTokenCheckFailed) {
result.completeExceptionally(new AuthenticationException(authTokenCheckFailed.toString()));
}
};
DeleteSegment command = new WireCommands.DeleteSegment(idGenerator.get(), name, "");
sendRequestOverNewConnection(command, replyProcessor, result);
return getAndHandleExceptions(result, RuntimeException::new);
}
use of io.pravega.client.stream.impl.ConnectionClosedException in project pravega by pravega.
the class MockController method createSegment.
private boolean createSegment(String name, PravegaNodeUri uri) {
CompletableFuture<Boolean> result = new CompletableFuture<>();
FailingReplyProcessor replyProcessor = new FailingReplyProcessor() {
@Override
public void connectionDropped() {
result.completeExceptionally(new ConnectionClosedException());
}
@Override
public void wrongHost(WireCommands.WrongHost wrongHost) {
result.completeExceptionally(new UnsupportedOperationException());
}
@Override
public void segmentAlreadyExists(WireCommands.SegmentAlreadyExists segmentAlreadyExists) {
result.complete(false);
}
@Override
public void segmentCreated(WireCommands.SegmentCreated segmentCreated) {
result.complete(true);
}
@Override
public void processingFailure(Exception error) {
result.completeExceptionally(error);
}
@Override
public void authTokenCheckFailed(WireCommands.AuthTokenCheckFailed authTokenCheckFailed) {
result.completeExceptionally(new AuthenticationException(authTokenCheckFailed.toString()));
}
};
CreateSegment command = new WireCommands.CreateSegment(idGenerator.get(), name, WireCommands.CreateSegment.NO_SCALE, 0, "");
sendRequestOverNewConnection(command, replyProcessor, result);
return getAndHandleExceptions(result, RuntimeException::new);
}
use of io.pravega.client.stream.impl.ConnectionClosedException in project pravega by pravega.
the class MockController method commitTxSegment.
private CompletableFuture<Void> commitTxSegment(UUID txId, Segment segment) {
CompletableFuture<Void> result = new CompletableFuture<>();
FailingReplyProcessor replyProcessor = new FailingReplyProcessor() {
@Override
public void connectionDropped() {
result.completeExceptionally(new ConnectionClosedException());
}
@Override
public void wrongHost(WrongHost wrongHost) {
result.completeExceptionally(new UnsupportedOperationException());
}
@Override
public void transactionCommitted(TransactionCommitted transactionCommitted) {
result.complete(null);
}
@Override
public void transactionAborted(TransactionAborted transactionAborted) {
result.completeExceptionally(new TxnFailedException("Transaction already aborted."));
}
@Override
public void processingFailure(Exception error) {
result.completeExceptionally(error);
}
@Override
public void authTokenCheckFailed(WireCommands.AuthTokenCheckFailed authTokenCheckFailed) {
result.completeExceptionally(new AuthenticationException(authTokenCheckFailed.toString()));
}
};
sendRequestOverNewConnection(new CommitTransaction(idGenerator.get(), segment.getScopedName(), txId, ""), replyProcessor, result);
return result;
}
use of io.pravega.client.stream.impl.ConnectionClosedException in project pravega by pravega.
the class MockController method abortTxSegment.
private CompletableFuture<Void> abortTxSegment(UUID txId, Segment segment) {
CompletableFuture<Void> result = new CompletableFuture<>();
FailingReplyProcessor replyProcessor = new FailingReplyProcessor() {
@Override
public void connectionDropped() {
result.completeExceptionally(new ConnectionClosedException());
}
@Override
public void wrongHost(WrongHost wrongHost) {
result.completeExceptionally(new UnsupportedOperationException());
}
@Override
public void transactionCommitted(TransactionCommitted transactionCommitted) {
result.completeExceptionally(new RuntimeException("Transaction already committed."));
}
@Override
public void transactionAborted(TransactionAborted transactionAborted) {
result.complete(null);
}
@Override
public void processingFailure(Exception error) {
result.completeExceptionally(error);
}
@Override
public void authTokenCheckFailed(WireCommands.AuthTokenCheckFailed authTokenCheckFailed) {
result.completeExceptionally(new AuthenticationException(authTokenCheckFailed.toString()));
}
};
sendRequestOverNewConnection(new AbortTransaction(idGenerator.get(), segment.getScopedName(), txId, ""), replyProcessor, result);
return result;
}
Aggregations