in tso-server/src/main/java/org/apache/omid/tso/LeaseManager.java [126:156]
void tryToGetInitialLeasePeriod() throws Exception {
baseTimeInMs.set(System.currentTimeMillis());
if (canAcquireLease()) {
endLeaseInMs.set(baseTimeInMs.get() + leasePeriodInMs);
LOG.info("{} got the lease (Master) Ver. {}/End of lease: {}ms", tsoHostAndPort,
leaseNodeVersion, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(endLeaseInMs));
tsoStateInitializer.submit(new Runnable() {
// TSO State initialization
@Override
public void run() {
try {
TSOState newTSOState = stateManager.initialize();
advertiseTSOServerInfoThroughZK(newTSOState.getEpoch());
tsoChannelHandler.reconnect();
} catch (Exception e) {
Thread t = Thread.currentThread();
t.getUncaughtExceptionHandler().uncaughtException(t, e);
}
}
});
} else {
tsoStateInitializer.submit(new Runnable() {
// TSO State initialization
@Override
public void run() {
// In case the TSO was paused close the connection
tsoChannelHandler.closeConnection();
}
});
}
}