Skip to content

Commit

Permalink
[improve] [broker] Print warn log if ssl handshake error & print ledg…
Browse files Browse the repository at this point in the history
…er id when switch ledger (apache#21201)

### Modifications
- Print a warning log if the SSL handshake error 
- Print ledger ID when switching ledger
  • Loading branch information
poorbarcode authored Sep 28, 2023
1 parent 6d82b09 commit 8485d68
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,8 @@ protected void internalResetCursor(PositionImpl proposedReadPosition,
newReadPosition = proposedReadPosition;
}

log.info("[{}] Initiate reset readPosition to {} on cursor {}", ledger.getName(), newReadPosition, name);
log.info("[{}] Initiate reset readPosition from {} to {} on cursor {}", ledger.getName(), readPosition,
newReadPosition, name);

synchronized (pendingMarkDeleteOps) {
if (!RESET_CURSOR_IN_PROGRESS_UPDATER.compareAndSet(this, FALSE, TRUE)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,8 @@ public void operationFailed(MetaStoreException e) {
return;
}

log.info("[{}] Created ledger {}", name, lh.getId());
log.info("[{}] Created ledger {} after closed {}", name, lh.getId(),
currentLedger == null ? "null" : currentLedger.getId());
STATE_UPDATER.set(this, State.LedgerOpened);
updateLastLedgerCreatedTimeAndScheduleRolloverTask();
currentLedger = lh;
Expand Down Expand Up @@ -1770,7 +1771,8 @@ public void skipNonRecoverableLedger(long ledgerId){

synchronized void createLedgerAfterClosed() {
if (isNeededCreateNewLedgerAfterCloseLedger()) {
log.info("[{}] Creating a new ledger after closed", name);
log.info("[{}] Creating a new ledger after closed {}", name,
currentLedger == null ? "null" : currentLedger.getId());
STATE_UPDATER.set(this, State.CreatingLedger);
this.lastLedgerCreationInitiationTimestamp = System.currentTimeMillis();
mbean.startDataLedgerCreateOp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import io.netty.channel.EventLoopGroup;
import io.netty.channel.unix.Errors.NativeIoException;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.ssl.SslHandshakeCompletionEvent;
import io.netty.util.concurrent.Promise;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
Expand Down Expand Up @@ -1311,6 +1312,18 @@ public void close() {
}
}

@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt instanceof SslHandshakeCompletionEvent) {
SslHandshakeCompletionEvent sslHandshakeCompletionEvent = (SslHandshakeCompletionEvent) evt;
if (sslHandshakeCompletionEvent.cause() != null) {
log.warn("{} Got ssl handshake exception {}", ctx.channel(),
sslHandshakeCompletionEvent);
}
}
ctx.fireUserEventTriggered(evt);
}

protected void closeWithException(Throwable e) {
if (ctx != null) {
connectionFuture.completeExceptionally(e);
Expand Down

0 comments on commit 8485d68

Please sign in to comment.