Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions src/main/java/io/openmessaging/storage/dledger/DLedger.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,12 @@ public static void main(String args[]) {
DLedgerServer dLedgerServer = new DLedgerServer(dLedgerConfig);
dLedgerServer.startup();
logger.info("[{}] group {} start ok with config {}", dLedgerConfig.getSelfId(), dLedgerConfig.getGroup(), JSON.toJSONString(dLedgerConfig));
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
private volatile boolean hasShutdown = false;

@Override
public void run() {
synchronized (this) {
logger.info("Shutdown hook was invoked");
if (!this.hasShutdown) {
this.hasShutdown = true;
long beginTime = System.currentTimeMillis();
dLedgerServer.shutdown();
long consumingTimeTotal = System.currentTimeMillis() - beginTime;
logger.info("Shutdown hook over, consuming total time(ms): {}", consumingTimeTotal);
}
}
}
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
logger.info("Shutdown hook was invoked");
long beginTime = System.currentTimeMillis();
dLedgerServer.shutdown();
long consumingTimeTotal = System.currentTimeMillis() - beginTime;
logger.info("Shutdown hook over, consuming total time(ms): {}", consumingTimeTotal);
}, "ShutdownHook"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package io.openmessaging.storage.dledger;

import io.openmessaging.storage.dledger.protocol.DLedgerProtocol;
import io.openmessaging.storage.dledger.protocol.DLedgerProtocolHander;
import io.openmessaging.storage.dledger.protocol.DLedgerProtocolHandler;

public abstract class DLedgerRpcService implements DLedgerProtocol, DLedgerProtocolHander {
public abstract class DLedgerRpcService implements DLedgerProtocol, DLedgerProtocolHandler {

public abstract void startup();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import io.openmessaging.storage.dledger.protocol.AppendEntryRequest;
import io.openmessaging.storage.dledger.protocol.AppendEntryResponse;
import io.openmessaging.storage.dledger.protocol.BatchAppendEntryRequest;
import io.openmessaging.storage.dledger.protocol.DLedgerProtocolHander;
import io.openmessaging.storage.dledger.protocol.DLedgerProtocolHandler;
import io.openmessaging.storage.dledger.protocol.DLedgerResponseCode;
import io.openmessaging.storage.dledger.protocol.GetEntriesRequest;
import io.openmessaging.storage.dledger.protocol.GetEntriesResponse;
Expand Down Expand Up @@ -55,7 +55,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DLedgerServer implements DLedgerProtocolHander {
public class DLedgerServer implements DLedgerProtocolHandler {

private static Logger logger = LoggerFactory.getLogger(DLedgerServer.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* Both the RaftLogServer(inbound) and RaftRpcService (outbound) should implement this protocol
*/
public interface DLedgerProtocolHander extends DLedgerClientProtocolHandler {
public interface DLedgerProtocolHandler extends DLedgerClientProtocolHandler {

CompletableFuture<VoteResponse> handleVote(VoteRequest request) throws Exception;

Expand Down