2012-06-14 3 views
0

서버는 일반적으로 다음을 수행합니다.Netty는 서버 멀티플렉서 구현에 적합한 선택입니까?

-Netty 서버는 TCP 포트 (모든 매우 간단한 텍스트 프로토콜)에서 clientX bind를 수신합니다.

-Netty 수신 인증 요청.

-Netty는 이제 clientX라는 채널 그룹을 만듭니다.이 채널 그룹 안에는 4 개의 TCP 연결 (각 외부 서버에 하나씩)이 생성되어 사용자에 대해 서버에 대해 인증을 수행하고 1 ACK가 clientX로 되돌려 보내집니다.

-clientX에서 다음 요청을 수신하면 clientX의 채널 그룹 내 connection1에 메시지를 전달합니다.

-clientX의 채널 그룹 내에서 다음 메시지를 수신하고 connection2에 대한 경로/중계 요청을 수신합니다.

- 수신 로그 아웃 요청. 채널 그룹 연결을 해제하면 클라이언트 X의 채널 그룹에있는 모든 연결이 끊어집니다.

-Messages는 외부 서버 중 하나가 전달되어야에서/그런 일이 그물코와 함께 할 수

답변

2

(MUX를)는 clientX 다시 전달 받았다.

나는 좋은 출발점이 프록시 예라고 생각합니다 :

https://github.com/netty/netty/tree/3/src/main/java/org/jboss/netty/example/proxy


내가 전술 한 바와 같이 서버를 구현하는 프록시 예를 수정했습니다. 디자인 : with netty-3.5.3

클라이언트 < -> (s-soc) -MUX_NIO_server- (c-socks) | < -> 서버 1 (lb)의

         |<->server2 
             |<->server3 
             |<->server4 

파이프 라인 => framedecoder -> stringdecoder -> ClientHandler에 -> framedecoder -> stringdecoder -> serverHandler-- |

+/- 100 tps에 도달 할 때까지 100 % 실행 된 다음 클라이언트의 동일한 메시지가 계속해서 서버로 보내지면서 교착 상태가 발생합니다. 내가 같이 쓰기 모두 핸들러 메시지 RX의 {

if (e.getChannel().isWritable()) { 

     inboundChannel.setReadable(true); 

      if (inboundChannel != null) { 

      inboundChannel.setReadable(true); 
     } 

    } 

}

// channelInterestChanged 동기 (trafficLock) : 내 channelInterestChanged의 양쪽 모두의 이벤트 핸들러에서

은 다음과 같습니다

synchronized (trafficLock) {

final ChannelFutureListener writeListener = 
       new ChannelFutureListener() { 

        @Override 
        public void operationComplete(final ChannelFuture future) 
          throws Exception { 
         if (Consts.DEBUG_ENABLED) { 
          log.debug("Finished Writing message); 
         } 
        } 
       }; 

     /* if channel is write */ 
     if (inboundChannel.isWritable()) { 
       inboundChannel.write(bufferMsg).addListener(writeListener); 
     } 
     // If inboundChannel is saturated, do not read until notified in 
     if (!inboundChannel.isWritable()) { 
      e.getChannel().setReadable(false); 
     } 

}

어디에서이 문제를 해결하기 위해보고 잘못 될 수 어떤 생각?감사합니다.

+0

감사합니다. 기본 예제를 통해 먼저 작업해야합니다. ( – Neels

+0

좋은 예처럼 보입니까? http://www.littleshoot.org/littleproxy/xref/index.html – Neels

관련 문제