use of io.pravega.segmentstore.server.host.security.TLSConfigChangeFileConsumer in project pravega by pravega.
the class AbstractConnectionListener method prepareCertificateMonitor.
@VisibleForTesting
FileModificationMonitor prepareCertificateMonitor(boolean isTLSCertPathSymLink, String tlsCertificatePath, String tlsKeyPath, AtomicReference<SslContext> sslCtx) {
FileModificationMonitor result;
try {
if (isTLSCertPathSymLink) {
// For symbolic links, the event-based watcher doesn't work, so we use a polling monitor.
log.info("The path to certificate file [{}] was found to be a symbolic link, " + " so using [{}] to monitor for certificate changes", tlsCertificatePath, FileModificationPollingMonitor.class.getSimpleName());
result = new FileModificationPollingMonitor(Paths.get(tlsCertificatePath), new TLSConfigChangeFileConsumer(sslCtx, tlsCertificatePath, tlsKeyPath, tlsProtocolVersion));
} else {
// For non symbolic links we'll use the event-based watcher, which is more efficient than a
// polling-based monitor.
result = new FileModificationEventWatcher(Paths.get(tlsCertificatePath), new TLSConfigChangeEventConsumer(sslCtx, tlsCertificatePath, tlsKeyPath, tlsProtocolVersion));
}
return result;
} catch (FileNotFoundException e) {
log.error("Failed to prepare a monitor for the certificate at path [{}]", tlsCertificatePath, e);
throw new RuntimeException(e);
}
}
Aggregations