Package net.tomp2p.peers

Examples of net.tomp2p.peers.Number320


    PeerAddress selfAddress = new PeerAddress(self);
    PeerMapConfiguration pmc = new PeerMapConfiguration(self);
    PeerMap pm = new PeerMap(pmc);
    TrackerStorage trackerStorage = new TrackerStorage(10, new int[] { 10 }, 1, pm, selfAddress, true);

    Number320 n320 = new Number320(Number160.ZERO, Number160.ZERO);

    trackerStorage.put(n320, selfAddress, null, new Data("test"));
    PeerStatistic ps = trackerStorage.nextForMaintenance(null);
    trackerStorage.peerFound(selfAddress, null, null);
    ps = trackerStorage.nextForMaintenance(null);
View Full Code Here


     *            <b>Note:</b> If you register multiple handlers with the same command, only the last registered handler
     *            will receive these messages!
     */
    public void registerIoHandler(final Number160 peerId, final Number160 onBehalfOf, final DispatchHandler ioHandler, final int... names) {
        Map<Number320, Map<Integer, DispatchHandler>> copy = new HashMap<Number320, Map<Integer, DispatchHandler>>(ioHandlers);
        Map<Integer, DispatchHandler> types = copy.get(new Number320(peerId, onBehalfOf));
        if (types == null) {
            types = new HashMap<Integer, DispatchHandler>();
            copy.put(new Number320(peerId, onBehalfOf), types);
        }
        for (Integer name : names) {
            types.put(name, ioHandler);
        }
       
View Full Code Here

     * @param onBehalfOf
     *         The ioHandler can be registered for the own use of in behalf of another peer (e.g. in case of relay node).
     */
    public void removeIoHandler(final Number160 peerId, final Number160 onBehalfOf) {
        Map<Number320, Map<Integer, DispatchHandler>> copy = new HashMap<Number320, Map<Integer, DispatchHandler>>(ioHandlers);
        copy.remove(new Number320(peerId, onBehalfOf));
        ioHandlers = Collections.unmodifiableMap(copy);
    }
View Full Code Here

     *            The type of the message to be filtered
     * @return the handler for the given message or null if none has been found
     */
    public DispatchHandler searchHandler(final Number160 recipientID, Number160 onBehalfOf, final int cmd) {
      final Integer command = Integer.valueOf(cmd);
        Map<Integer, DispatchHandler> types = ioHandlers.get(new Number320(recipientID, onBehalfOf));
       
        if (types != null && types.containsKey(command)) {
            return types.get(command);
        } else {
            // not registered
View Full Code Here

     * @param onBehalfOf
     *         The ioHandler can be registered for the own use of in behalf of another peer (e.g. in case of relay node).
     * @return the map containing all dispatchers for each {@link Commands} type
     */
  public Map<Integer, DispatchHandler> searchHandlerMap(Number160 peerId, Number160 onBehalfOf) {
    Map<Integer, DispatchHandler> ioHandlerMap = ioHandlers.get(new Number320(peerId, onBehalfOf));
    return ioHandlerMap;
  }
View Full Code Here

    if (find) {
      Assert.assertEquals(1, test.size());
      Assert.assertEquals(
              44444,
              test.get(
                      new Number640(new Number320(locationKey, Number160.createHash("test")), new Number160(5),
                              Number160.ZERO)).length());
    } else
      Assert.assertEquals(0, test.size());
  }
View Full Code Here

        if (bloomFilter == null) {
            bloomFilter = new SimpleBloomFilter<Number160>(1024, 1024);
        }
        // add myself to my local tracker, since we use a mesh we are part of
        // the tracker mesh as well.
        peer.trackerStorage().put(new Number320(locationKey, domainKey), peer.peerAddress(), keyPair() == null? null: keyPair().getPublic(),
                        attachement);
        final FutureTracker futureTracker = peer.distributedTracker().add(this);

        return futureTracker;
    }
View Full Code Here

                .command() == RPC.Commands.PEX.getNr())) {
            throw new IllegalArgumentException("Message content is wrong");
        }
        final Number160 locationKey = message.key(0);
        final Number160 domainKey = message.key(1);
        Number320 key = new Number320(locationKey, domainKey);
        final TrackerData tmp = message.trackerData(0);
        peerExchange.put(key, tmp, message.sender());
      
        if(message.isUdp()) {
            responder.responseFireAndForget();
View Full Code Here

                if (peerBean().digestStorage() == null) {
                  //no storage to search
                  digestInfo = new DigestInfo();
                }
                else if (contentKey != null && locationKey!=null && domainKey!=null) {
                  Number320 locationAndDomainKey = new Number320(locationKey, domainKey);
                    Number640 from = new Number640(locationAndDomainKey, contentKey, Number160.ZERO);
                    Number640 to = new Number640(locationAndDomainKey, contentKey, Number160.MAX_VALUE);
                    digestInfo = peerBean().digestStorage().digest(from, to, -1, true);
                } else if ((keyBloomFilter != null || contentBloomFilter != null&& locationKey!=null && domainKey!=null) {
                  Number320 locationAndDomainKey = new Number320(locationKey, domainKey);
                    digestInfo = peerBean().digestStorage().digest(locationAndDomainKey, keyBloomFilter,
                            contentBloomFilter, -1, true, true);
                } else if (keyCollection!=null && keyCollection.keys().size() == 2) {
                  Iterator<Number640> iterator = keyCollection.keys().iterator();
                  Number640 from = iterator.next();
                  Number640 to = iterator.next();
                  digestInfo = peerBean().digestStorage().digest(from, to, -1, true);
                } else if (locationKey!=null && domainKey!=null){
                  Number320 locationAndDomainKey = new Number320(locationKey, domainKey);
                    Number640 from = new Number640(locationAndDomainKey, Number160.ZERO, Number160.ZERO);
                    Number640 to = new Number640(locationAndDomainKey, Number160.MAX_VALUE, Number160.MAX_VALUE);
                    digestInfo = peerBean().digestStorage().digest(from, to, -1, true);
                } else {
                  LOG.warn("did not search for anything");
View Full Code Here

    builder.futureChannelCreator().addListener(new BaseFutureAdapter<FutureChannelCreator>() {
      @Override
      public void operationComplete(final FutureChannelCreator futureChannelCreator2) throws Exception {
        if (futureChannelCreator2.isSuccess()) {
             
          TrackerData peers = trackerStorage.peers(new Number320(builder.locationKey(), builder
                  .domainKey()));
          NavigableSet<PeerAddress> queue = new TreeSet<PeerAddress>(PeerMap.createComparator(stableRandom));
          if(peers != null && peers.peerAddresses()!=null) {
            for (PeerStatistic peerAddress : peers.peerAddresses().keySet()) {
              queue.add(peerAddress.peerAddress());
View Full Code Here

TOP

Related Classes of net.tomp2p.peers.Number320

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.