greyp9 commented on a change in pull request #5311: URL: https://github.com/apache/nifi/pull/5311#discussion_r711408737
########## File path: nifi-nar-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-client-service/src/main/java/org/apache/nifi/distributed/cache/client/CacheClientChannelInitializer.java ########## @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.distributed.cache.client; + +import io.netty.channel.Channel; +import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelPipeline; +import io.netty.handler.ssl.SslHandler; +import org.apache.nifi.remote.VersionNegotiator; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLEngine; + +/** + * Bootstrap a new netty connection. This performs the socket handshake used by the nifi distributed set / + * distributed map client controller services. + */ +public class CacheClientChannelInitializer extends ChannelInitializer<Channel> { + + /** + * The (optional) secure context associated with the channel. If null, channel is not SSL protected. + */ + private final SSLContext sslContext; + + /** + * The version of the protocol negotiated between the client and server. + */ + private final VersionNegotiator versionNegotiator; Review comment: > As a stateful object, is it safe to reuse this instance across channels? It seems like a new instance should be created in `initChannel`. Definitely. Swapped `VersionNegotiator` out with a factory, that creates a new negotiator in `initChannel`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
