Ejemplo n.º 1
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));
          }
Ejemplo n.º 2
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));
 }
Ejemplo n.º 3
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));
 }
Ejemplo n.º 4
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));
            }
          }