Search in sources :

Example 1 with TLSConfigChangeFileConsumer

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);
    }
}
Also used : FileModificationMonitor(io.pravega.common.io.filesystem.FileModificationMonitor) TLSConfigChangeEventConsumer(io.pravega.segmentstore.server.host.security.TLSConfigChangeEventConsumer) FileNotFoundException(java.io.FileNotFoundException) FileModificationPollingMonitor(io.pravega.common.io.filesystem.FileModificationPollingMonitor) FileModificationEventWatcher(io.pravega.common.io.filesystem.FileModificationEventWatcher) TLSConfigChangeFileConsumer(io.pravega.segmentstore.server.host.security.TLSConfigChangeFileConsumer) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 FileModificationEventWatcher (io.pravega.common.io.filesystem.FileModificationEventWatcher)1 FileModificationMonitor (io.pravega.common.io.filesystem.FileModificationMonitor)1 FileModificationPollingMonitor (io.pravega.common.io.filesystem.FileModificationPollingMonitor)1 TLSConfigChangeEventConsumer (io.pravega.segmentstore.server.host.security.TLSConfigChangeEventConsumer)1 TLSConfigChangeFileConsumer (io.pravega.segmentstore.server.host.security.TLSConfigChangeFileConsumer)1 FileNotFoundException (java.io.FileNotFoundException)1