Package dijjer.io.comm

Examples of dijjer.io.comm.Peer


    api.start(new String[] {"seednode=none"});
    Thread.sleep(20000); //manually start another peer here if you want
    Peer[] peers = api.getConnectedPeers();
    System.out.println("peers = " + peers.length);
    for (int i = 0; i < peers.length; i++) {
      Peer peer = peers[i];
      System.out.println("peer = " + peer);
      PeerInfo info = api.getPeerInfo(peer);
      System.out.println("info = " + info);
    }
  }
View Full Code Here


    private int _pongcount = 0;
    private Object lock = new Object();

    public void testManager() throws Exception {

        final Peer source = new Peer(Inet4Address.getLocalHost(), (short) 5555);
        final Peer dest = new Peer(Inet4Address.getLocalHost(), (short) 5556);
        final MessageType ping = DMT.ping;
        final MessageType pong = DMT.pong;
        final UdpSocketManager sourceUSM = new UdpSocketManager((short) 5555);
        final UdpSocketManager destUSM = new UdpSocketManager((short) 5556);
        ping.addField("id", Integer.class);
View Full Code Here

    UdpSocketManager usm2 = new UdpSocketManager(8001);
    UdpSocketManager usm3 = new UdpSocketManager(8002);
    usm1.setDropProbability(8);
    usm2.setDropProbability(8);
    usm3.setDropProbability(8);
    Peer p1 = new Peer(InetAddress.getLocalHost(), 8000);
    Peer p2 = new Peer(InetAddress.getLocalHost(), 8001);
    Peer p3 = new Peer(InetAddress.getLocalHost(), 8002);
    byte[] block = new byte[1024 * 256];
    for (int x = 0; x < block.length; x++) {
      block[x] = (byte) x;
    }
    PartiallyReceivedBlock prb1 = new PartiallyReceivedBlock(256, 1024, block);
View Full Code Here

  public void testRouting() throws Exception {

    TestUdpSocketManager usm = new TestUdpSocketManager(-1);
    RoutingTable rt = new RoutingTable(100, usm, null, false);
    Peer p = new Peer(InetAddress.getByAddress(new byte[]{5, 6, 7, 8}), 105);
    rt.joinSeed(p);   
    assertEquals(p, usm._sentPeers.get(0));

  }
View Full Code Here

    VeryLongInteger confirmHash = new VeryLongInteger(prb.getBlock());
    boolean dataHashFailure = !confirmHash.equals(actualHash);
    boolean hashHashFailure = !confirmHash.equals(retrievedHash);
    Logger.info("Sending corruptionNotification for " + bi + " (" + dataHashFailure + ", " + hashHashFailure + ")");
    for (Iterator i = ((ArrayList) RoutingTable.getRoutingTable().getPeers().clone()).iterator(); i.hasNext();) {
      Peer p = (Peer) i.next();
      if (dataHashFailure) {
        UdpSocketManager.getUdpSocketManager().send(p,
            DMT.createCorruptionNotification(Misc.nextInt(), bi, false));
      }
      if (hashHashFailure) {
View Full Code Here

    written[5] = Long.toString(r.nextLong());
    byte[] buf = new byte[r.nextInt() % 100];
    r.nextBytes(buf);
    written[6] = new Buffer(buf);
    written[7] = new VeryLongInteger(r.nextLong(), r.nextLong());
    written[8] = new Peer(InetAddress.getByName("google.com"), 1234);
    BitArray ba = new BitArray(r.nextInt() % 100);
    for (int x=0; x<ba.getSize(); x++) {
      ba.setBit(x, r.nextBoolean());
    }
    written[9] = ba;
View Full Code Here

    StringBuffer output = new StringBuffer();
    if (RoutingTable.getRoutingTable().getPeers().size() > 0) {
      output.append("<table border=\"1\"><tr>" + "<th>Peer</th>" + "<th>Port</th>" + "<th>Build</th>"
          + "<th>Throttle</th>" + "</tr>");
      for (Iterator i = RoutingTable.getRoutingTable().getPeers().iterator(); i.hasNext();) {
        Peer p = (Peer) i.next();
        RoutingTable.PeerInfo pi = RoutingTable.getRoutingTable().getPeerInfo(p);
        if (p != null) {
          if (Dijjer.getDijjer().getSeedNodes().contains(p)) {
            output.append("<tr><td><font color=\"green\">" + p.getAddress().getHostName()
                + "</font></td><td><font color=\"green\">" + p.getPort() + "</font></td>");
          } else {
            output.append("<tr><td>" + p.getAddress().getHostName() + "</td><td>" + p.getPort() + "</td>");
          }
          if (pi != null) {
            output.append("<td>" + pi.getBuild() + "</td>");
          } else {
            output.append("<td>Unknown</td>");
View Full Code Here

      blue[ppos][0] = (byte) 255;
      red[ppos][0] = (byte) (220 * DataStore.getDataStore().getAgeByKey(vli));
      green[ppos][0] = (byte) (220 * DataStore.getDataStore().getAgeByKey(vli));
    }
    for (Iterator i = ((ArrayList) RoutingTable.getRoutingTable().getPeers().clone()).iterator(); i.hasNext();) {
      Peer p = (Peer) i.next();
      if (p == null) {
        continue;
      }
      int ppos = p.getHash().getMostSignificantByte();
      green[ppos][0] = (byte) 255;
      red[ppos][0] = (byte) 0;
      blue[ppos][0] = (byte) 0;
    }
    int ppos = RoutingTable.getRoutingTable().getPeer().getHash().getMostSignificantByte();
View Full Code Here

    } else if (type.equals(Buffer.class)) {
      return new Buffer(dis);
    } else if (type.equals(VeryLongInteger.class)) {
      return new VeryLongInteger(dis);
    } else if (type.equals(Peer.class)) {
      return new Peer(dis);
    } else if (type.equals(BitArray.class)) {
      return new BitArray(dis);
    } else {
      throw new RuntimeException("Unrecognised field type: " + type);
    }
View Full Code Here

      if (_rt.getPeerInfo(m.getSource()) == null) {
        _usm.send(m.getSource(), DMT.createWhoAreYou());
      }
      return true;
    } else if (m.getSpec().equals(DMT.introduce)) {
      Peer externalAddress = (Peer) m.getObject(DMT.EXTERNAL_ADDRESS);
      int build = m.getInt(DMT.BUILD);
      int firstGoodBuild = m.getInt(DMT.FIRST_GOOD_BUILD);
      _rt.setPeer(externalAddress);
      _rt.setPeerInfo(m.getSource(), new RoutingTable.PeerInfo(build, firstGoodBuild, externalAddress));
      return true;
View Full Code Here

TOP

Related Classes of dijjer.io.comm.Peer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.