コード例 #1
0
          public void handle(Start event) {
            trigger(
                new GetIpRequest(
                    false,
                    EnumSet.of(
                        GetIpRequest.NetworkInterfacesMask.IGNORE_LOCAL_ADDRESSES,
                        GetIpRequest.NetworkInterfacesMask.IGNORE_TEN_DOT_PRIVATE)),
                resolveIp.getPositive(ResolveIpPort.class));

            logger.info("Starting");
            ScheduleTimeout st = new ScheduleTimeout(30 * 1000);
            MsgTimeout mt = new MsgTimeout(st);
            st.setTimeoutEvent(mt);
            trigger(st, timer.getPositive(Timer.class));
          }
コード例 #2
0
          @Override
          public void handle(GetIpResponse event) {
            InetAddress ip = null;
            int clientPort = 54644;
            int serverPort = 54645;

            try {
              ip = InetAddress.getLocalHost();
            } catch (UnknownHostException ex) {
              logger.error("UnknownHostException");
              fail();
            }
            Address cAddr = new Address(ip, clientPort, 0);
            Address sAddr = new Address(ip, serverPort, 1);

            logger.info("Server: " + cAddr);
            logger.info("Client: " + cAddr);

            clientAddr = new VodAddress(cAddr, VodConfig.SYSTEM_OVERLAY_ID);
            serverAddr = new VodAddress(sAddr, VodConfig.SYSTEM_OVERLAY_ID);

            nodeDesc = new VodDescriptor(clientAddr, utility, 0, BaseCommandLineConfig.DEFAULT_MTU);
            nodes = new ArrayList<VodDescriptor>();
            nodes.add(nodeDesc);

            PortBindRequest requestServer =
                new PortBindRequest(serverAddr.getPeerAddress(), Transport.TCP);
            requestServer.setResponse(new PortBindResponse(requestServer) {});
            trigger(requestServer, server.getPositive(NatNetworkControl.class));
          }
コード例 #3
0
 @Override
 public void handle(TConnectionMsg.Pong event) {
   logger.info("Received pong");
   CloseConnectionRequest request =
       new CloseConnectionRequest(0, serverAddr.getPeerAddress(), Transport.TCP);
   request.setResponse(new CloseConnectionResponse(request));
   trigger(request, client.getPositive(NatNetworkControl.class));
 }
コード例 #4
0
 @Override
 public void handle(TConnectionMsg.Ping event) {
   logger.info("Received ping");
   trigger(
       new TConnectionMsg.Pong(
           serverAddr, clientAddr, Transport.TCP, event.getTimeoutId()),
       server.getPositive(VodNetwork.class));
 }
コード例 #5
0
 @Override
 public void handle(CloseConnectionResponse event) {
   logger.info("Received CloseConnectionResponse");
   Set set = new HashSet<Integer>();
   set.add(serverAddr.getPort());
   PortDeleteRequest request = new PortDeleteRequest(0, set, Transport.UDT);
   request.setResponse(new PortDeleteResponse(request, 0) {});
   trigger(request, server.getPositive(NatNetworkControl.class));
 }
コード例 #6
0
    public TestStClientComponent() {
      timer = create(JavaTimer.class, Init.NONE);
      client = create(NettyNetwork.class, new NettyInit(132, true, BaseMsgFrameDecoder.class));
      server = create(NettyNetwork.class, new NettyInit(132, true, BaseMsgFrameDecoder.class));
      resolveIp = create(ResolveIp.class, Init.NONE);

      subscribe(handleStart, control);
      subscribe(handleMsgTimeout, timer.getPositive(Timer.class));
      subscribe(handlePong, client.getPositive(VodNetwork.class));
      subscribe(handlePortBindResponse, client.getPositive(NatNetworkControl.class));
      subscribe(handlePortBindResponse, server.getPositive(NatNetworkControl.class));
      subscribe(handlePing, server.getPositive(VodNetwork.class));
      subscribe(handleGetIpResponse, resolveIp.getPositive(ResolveIpPort.class));
      subscribe(handleCloseConnectionResponse, client.getPositive(NatNetworkControl.class));
      subscribe(handlePortDeletionResponse, server.getPositive(NatNetworkControl.class));
    }
コード例 #7
0
          @Override
          public void handle(PortBindResponse event) {
            logger.info("Port bind response");

            if (event.getStatus() == Status.FAIL) {
              testObj.failAndRelease();
              return;
            }

            if (event.getPort() == serverAddr.getPort()) {
              trigger(
                  new TConnectionMsg.Ping(clientAddr, serverAddr, Transport.TCP, UUID.nextUUID()),
                  client.getPositive(VodNetwork.class));
            }
          }