Search in sources :

Example 1 with SiteToSiteTransportProtocol

use of org.apache.nifi.remote.protocol.SiteToSiteTransportProtocol in project nifi by apache.

the class AbstractSiteToSiteReportingTask method setup.

@OnScheduled
public void setup(final ConfigurationContext context) throws IOException {
    final SSLContextService sslContextService = context.getProperty(SSL_CONTEXT).asControllerService(SSLContextService.class);
    final SSLContext sslContext = sslContextService == null ? null : sslContextService.createSSLContext(SSLContextService.ClientAuth.REQUIRED);
    final ComponentLog logger = getLogger();
    final EventReporter eventReporter = new EventReporter() {

        @Override
        public void reportEvent(final Severity severity, final String category, final String message) {
            switch(severity) {
                case WARNING:
                    logger.warn(message);
                    break;
                case ERROR:
                    logger.error(message);
                    break;
                default:
                    break;
            }
        }
    };
    final String destinationUrl = context.getProperty(DESTINATION_URL).evaluateAttributeExpressions().getValue();
    final SiteToSiteTransportProtocol mode = SiteToSiteTransportProtocol.valueOf(context.getProperty(TRANSPORT_PROTOCOL).getValue());
    final HttpProxy httpProxy = mode.equals(SiteToSiteTransportProtocol.RAW) || StringUtils.isEmpty(context.getProperty(HTTP_PROXY_HOSTNAME).getValue()) ? null : new HttpProxy(context.getProperty(HTTP_PROXY_HOSTNAME).getValue(), context.getProperty(HTTP_PROXY_PORT).asInteger(), context.getProperty(HTTP_PROXY_USERNAME).getValue(), context.getProperty(HTTP_PROXY_PASSWORD).getValue());
    siteToSiteClient = new SiteToSiteClient.Builder().urls(SiteToSiteRestApiClient.parseClusterUrls(destinationUrl)).portName(context.getProperty(PORT_NAME).getValue()).useCompression(context.getProperty(COMPRESS).asBoolean()).eventReporter(eventReporter).sslContext(sslContext).timeout(context.getProperty(TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS).transportProtocol(mode).httpProxy(httpProxy).build();
}
Also used : HttpProxy(org.apache.nifi.remote.protocol.http.HttpProxy) SSLContextService(org.apache.nifi.ssl.SSLContextService) RestrictedSSLContextService(org.apache.nifi.ssl.RestrictedSSLContextService) SSLContext(javax.net.ssl.SSLContext) SiteToSiteTransportProtocol(org.apache.nifi.remote.protocol.SiteToSiteTransportProtocol) ComponentLog(org.apache.nifi.logging.ComponentLog) EventReporter(org.apache.nifi.events.EventReporter) OnScheduled(org.apache.nifi.annotation.lifecycle.OnScheduled)

Aggregations

SSLContext (javax.net.ssl.SSLContext)1 OnScheduled (org.apache.nifi.annotation.lifecycle.OnScheduled)1 EventReporter (org.apache.nifi.events.EventReporter)1 ComponentLog (org.apache.nifi.logging.ComponentLog)1 SiteToSiteTransportProtocol (org.apache.nifi.remote.protocol.SiteToSiteTransportProtocol)1 HttpProxy (org.apache.nifi.remote.protocol.http.HttpProxy)1 RestrictedSSLContextService (org.apache.nifi.ssl.RestrictedSSLContextService)1 SSLContextService (org.apache.nifi.ssl.SSLContextService)1