Github user WangTaoTheTonic commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2425#discussion_r106335331
  
    --- Diff: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/netty/CookieHandler.java
 ---
    @@ -0,0 +1,130 @@
    +/**
    + * 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.flink.runtime.io.network.netty;
    +
    +import io.netty.buffer.ByteBuf;
    +import io.netty.buffer.Unpooled;
    +import io.netty.channel.Channel;
    +import io.netty.channel.ChannelHandlerContext;
    +import io.netty.channel.ChannelInboundHandlerAdapter;
    +import io.netty.handler.codec.MessageToMessageDecoder;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.nio.charset.Charset;
    +import java.util.ArrayList;
    +import java.util.Arrays;
    +import java.util.List;
    +
    +public class CookieHandler {
    +
    +   public static class ClientCookieHandler extends 
ChannelInboundHandlerAdapter {
    +
    +           private final Logger LOG = 
LoggerFactory.getLogger(ClientCookieHandler.class);
    +
    +           private final String secureCookie;
    +
    +           final Charset DEFAULT_CHARSET = Charset.forName("utf-8");
    +
    +           public ClientCookieHandler(String secureCookie) {
    +                   this.secureCookie = secureCookie;
    +           }
    +
    +           @Override
    +           public void channelActive(ChannelHandlerContext ctx) throws 
Exception {
    +                   super.channelActive(ctx);
    +                   LOG.debug("In channelActive method of 
ClientCookieHandler");
    +
    +                   if(this.secureCookie != null && 
this.secureCookie.length() != 0) {
    +                           LOG.debug("In channelActive method of 
ClientCookieHandler -> sending secure cookie");
    +                           final ByteBuf buffer = Unpooled.buffer(4 + 
this.secureCookie.getBytes(DEFAULT_CHARSET).length);
    +                           
buffer.writeInt(secureCookie.getBytes(DEFAULT_CHARSET).length);
    +                           
buffer.writeBytes(secureCookie.getBytes(DEFAULT_CHARSET));
    +                           ctx.writeAndFlush(buffer);
    +                   }
    +           }
    +   }
    +
    +   public static class ServerCookieDecoder extends 
MessageToMessageDecoder<ByteBuf> {
    +
    +           private final String secureCookie;
    +
    +           private final List<Channel> channelList = new ArrayList<>();
    --- End diff --
    
    Is it better to use `Set` instead of a `List` here? As it is mainly used 
for lookup.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to