Package net.tomp2p.message

Examples of net.tomp2p.message.KeyCollection


                        }
                    }
                }
            }
        }
        responseMessage.keyCollection(new KeyCollection(retVal));
        responder.response(responseMessage);
    }
View Full Code Here


        if (getBuilder.to() != null && getBuilder.from() != null) {
            final Collection<Number640> keys = new ArrayList<Number640>(2);
            keys.add(getBuilder.from());
            keys.add(getBuilder.to());
            message.intValue(getBuilder.returnNr());
            message.keyCollection(new KeyCollection(keys));
        } else if (getBuilder.keys() == null) {

            if (getBuilder.locationKey() == null || getBuilder.domainKey() == null) {
                throw new IllegalArgumentException("Null not allowed in location or domain");
            }
            message.key(getBuilder.locationKey());
            message.key(getBuilder.domainKey());

            if (getBuilder.contentKeys() != null) {
                message.keyCollection(new KeyCollection(getBuilder.locationKey(), getBuilder
                        .domainKey(), getBuilder.versionKey(), getBuilder.contentKeys()));
            } else {
                message.intValue(getBuilder.returnNr());
                if (getBuilder.keyBloomFilter() != null || getBuilder.contentBloomFilter() != null) {
                    if (getBuilder.keyBloomFilter() != null) {
                        message.bloomFilter(getBuilder.keyBloomFilter());
                    }
                    if (getBuilder.contentBloomFilter() != null) {
                        message.bloomFilter(getBuilder.contentBloomFilter());
                    }
                }
            }
        } else {
            message.keyCollection(new KeyCollection(getBuilder.keys()));
        }

        final FutureResponse futureResponse = new FutureResponse(message);
        final RequestHandler<FutureResponse> request = new RequestHandler<FutureResponse>(futureResponse,
                peerBean(), connectionBean(), getBuilder);
View Full Code Here

        if (getBuilder.to() != null && getBuilder.from() != null) {
            final Collection<Number640> keys = new ArrayList<Number640>(2);
            keys.add(getBuilder.from());
            keys.add(getBuilder.to());
            message.intValue(getBuilder.returnNr());
            message.keyCollection(new KeyCollection(keys));
        } else if (getBuilder.keys() == null) {

            if (getBuilder.locationKey() == null || getBuilder.domainKey() == null) {
                throw new IllegalArgumentException("Null not allowed in location or domain");
            }
            message.key(getBuilder.locationKey());
            message.key(getBuilder.domainKey());

            if (getBuilder.contentKeys() != null) {
                message.keyCollection(new KeyCollection(getBuilder.locationKey(), getBuilder
                        .domainKey(), getBuilder.versionKey(), getBuilder.contentKeys()));
            } else {
                message.intValue(getBuilder.returnNr());
                if (getBuilder.keyBloomFilter() != null || getBuilder.contentBloomFilter() != null) {
                    if (getBuilder.keyBloomFilter() != null) {
                        message.bloomFilter(getBuilder.keyBloomFilter());
                    }
                    if (getBuilder.contentBloomFilter() != null) {
                        message.bloomFilter(getBuilder.contentBloomFilter());
                    }
                }
            }
        } else {
            message.keyCollection(new KeyCollection(getBuilder.keys()));
        }

        final FutureResponse futureResponse = new FutureResponse(message);
        final RequestHandler<FutureResponse> request = new RequestHandler<FutureResponse>(futureResponse,
                peerBean(), connectionBean(), getBuilder);
View Full Code Here

            final Collection<Number640> keys = new ArrayList<Number640>(2);
            keys.add(removeBuilder.from());
            keys.add(removeBuilder.to());
            //marker
            message.intValue(0);
            message.keyCollection(new KeyCollection(keys));
        } else if (removeBuilder.keys() == null) {

            if (removeBuilder.locationKey() == null || removeBuilder.domainKey() == null) {
                throw new IllegalArgumentException("Null not allowed in location or domain");
            }
            message.key(removeBuilder.locationKey());
            message.key(removeBuilder.domainKey());

            if (removeBuilder.contentKeys() != null) {
                message.keyCollection(new KeyCollection(removeBuilder.locationKey(), removeBuilder
                        .domainKey(), removeBuilder.versionKey(), removeBuilder.contentKeys()));
            }
        } else {
            message.keyCollection(new KeyCollection(removeBuilder.keys()));
        }

        final FutureResponse futureResponse = new FutureResponse(message);

        final RequestHandler<FutureResponse> request = new RequestHandler<FutureResponse>(futureResponse,
View Full Code Here

    private Message handleGet(final Message message, final Message responseMessage) {
      LOG.debug("handleGet {}", message);
        final Number160 locationKey = message.key(0);
        final Number160 domainKey = message.key(1);
        final KeyCollection contentKeys = message.keyCollection(0);
        final SimpleBloomFilter<Number160> contentBloomFilter = message.bloomFilter(0);
        final SimpleBloomFilter<Number160> versionBloomFilter = message.bloomFilter(1);
        final Integer returnNr = message.intAt(0);
        final int limit = returnNr == null ? -1 : returnNr;
        final boolean ascending = isAscending(message);
View Full Code Here

    private Message handleDigest(final Message message, final Message responseMessage) {
      LOG.debug("handleDigest {}", message);
        final Number160 locationKey = message.key(0);
        final Number160 domainKey = message.key(1);
        final KeyCollection contentKeys = message.keyCollection(0);
        final SimpleBloomFilter<Number160> contentBloomFilter = message.bloomFilter(0);
        final SimpleBloomFilter<Number160> versionBloomFilter = message.bloomFilter(1);
        final Integer returnNr = message.intAt(0);
        final int limit = returnNr == null ? -1 : returnNr;
        final boolean ascending = isAscending(message);
View Full Code Here

    private Message handleRemove(final Message message, final Message responseMessage,
            final boolean sendBackResults) {
      LOG.debug("handleRemove {}", message);
        final Number160 locationKey = message.key(0);
        final Number160 domainKey = message.key(1);
        final KeyCollection keys = message.keyCollection(0);
        final PublicKey publicKey = message.publicKey(0);
        Map<Number640, Data> result1 = null;
        Map<Number640, Byte> result2 = null;
        final Integer returnNr = message.intAt(0);
        //used as a marker for the moment
        //final int limit = returnNr == null ? -1 : returnNr;
        final boolean isRange = keys != null && returnNr != null;
        final boolean isCollection = keys != null && returnNr == null;
              
        if (isCollection) {
          if(sendBackResults) {
            result1 = new HashMap<Number640, Data>(keys.size());
            for (Number640 key : keys.keys()) {
                    Pair<Data,Enum<?>> data = storageLayer.remove(key, publicKey, sendBackResults);
                    notifyRemoveResponsibility(key.locationKey(), data.element1());
                    if(data.element0() != null) {
                      result1.put(key, data.element0());
                    }
                }
          } else {
            result2 = new HashMap<Number640, Byte>(keys.size());
            for (Number640 key : keys.keys()) {
                    Pair<Data,Enum<?>> data = storageLayer.remove(key, publicKey, sendBackResults);
                    notifyRemoveResponsibility(key.locationKey(), data.element1());
                    result2.put(key, (byte) data.element1().ordinal());
                }
          }
           
        } else if(isRange) {
            Iterator<Number640> iterator = keys.keys().iterator();
            Number640 from = iterator.next();
            Number640 to = iterator.next();
            if(sendBackResults) {
              result1 = storageLayer.removeReturnData(from, to, publicKey);
            } else {
View Full Code Here

       
        if(searchValues.from() !=null && searchValues.to()!=null) {
          Collection<Number640> collection = new ArrayList<Number640>(2);
          collection.add(searchValues.from());
          collection.add(searchValues.to());
          KeyCollection keyCollection = new KeyCollection(collection);
          message.keyCollection(keyCollection);
        } else {
          if (searchValues.contentKey() != null) {
            message.key(searchValues.contentKey());
          }
View Full Code Here

        // check content length, 0 for content not here , > 0 content here
        // int contentLength = -1;
        Number160 contentKey = message.key(2);
        SimpleBloomFilter<Number160> keyBloomFilter = message.bloomFilter(0);
        SimpleBloomFilter<Number160> contentBloomFilter = message.bloomFilter(1);
        KeyCollection keyCollection = message.keyCollection(0);
        // it is important to set an integer if a value is present
        boolean isDigest = message.type() != Type.REQUEST_1;
        if (isDigest) {
            if (message.type() == Type.REQUEST_2) {
                final DigestInfo digestInfo;
                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);
View Full Code Here

TOP

Related Classes of net.tomp2p.message.KeyCollection

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.