Package net.tomp2p.message

Examples of net.tomp2p.message.DataMap


            fcc.awaitUninterruptibly();
            cc = fcc.channelCreator();

            PutBuilder putBuilder = new PutBuilder(recv1, new Number160(33));
            putBuilder.domainKey(Number160.createHash("test"));
            DataMap dataMap = new DataMap(new Number160(33), Number160.createHash("test"), Number160.ZERO, tmp);
            putBuilder.dataMapContent(tmp);
            putBuilder.versionKey(Number160.ZERO);

            FutureResponse fr = smmSender.put(recv1.peerAddress(), putBuilder, cc);
            fr.awaitUninterruptibly();
            // get

            GetBuilder getBuilder = new GetBuilder(recv1, new Number160(33));
            getBuilder.domainKey(Number160.createHash("test"));
            getBuilder.contentKeys(tmp.keySet());
            getBuilder.versionKey(Number160.ZERO);

            fr = smmSender.get(recv1.peerAddress(), getBuilder, cc);
            fr.awaitUninterruptibly();
            Assert.assertEquals(true, fr.isSuccess());
            System.err.println(fr.failedReason());
            Message m = fr.responseMessage();
            Map<Number640, Data> stored = m.dataMap(0).dataMap();
            compare(dataMap.convertToMap640(), stored);
            System.err.println("done!");
        } finally {
            if (cc != null) {
                cc.shutdown().awaitListenersUninterruptibly();
            }
View Full Code Here


            fcc.awaitUninterruptibly();
            cc = fcc.channelCreator();

            PutBuilder putBuilder = new PutBuilder(recv1, new Number160(33));
            putBuilder.domainKey(Number160.createHash("test"));
            DataMap dataMap = new DataMap(new Number160(33), Number160.createHash("test"), Number160.ZERO, tmp);
            putBuilder.dataMapContent(tmp);
            putBuilder.forceUDP();
            putBuilder.versionKey(Number160.ZERO);

            FutureResponse fr = smmSender.put(recv1.peerAddress(), putBuilder, cc);
            fr.awaitUninterruptibly();
            Assert.assertEquals(true, fr.isSuccess());

            GetBuilder getBuilder = new GetBuilder(recv1, new Number160(33));
            getBuilder.domainKey(Number160.createHash("test"));
            getBuilder.contentKeys(tmp.keySet());
            getBuilder.forceUDP();
            getBuilder.versionKey(Number160.ZERO);

            // get
            fr = smmSender.get(recv1.peerAddress(), getBuilder, cc);
            fr.awaitUninterruptibly();
            Assert.assertEquals(true, fr.isSuccess());
            Message m = fr.responseMessage();
            Map<Number640, Data> stored = m.dataMap(0).dataMap();
            compare(dataMap.convertToMap640(), stored);
        } finally {
            if (cc != null) {
                cc.shutdown().awaitListenersUninterruptibly();
            }
            if (sender != null) {
View Full Code Here

            Message m = fr.responseMessage();
            Assert.assertEquals(true, fr.isSuccess());

            // check for returned results
            Map<Number640, Data> stored = m.dataMap(0).dataMap();
            DataMap dataMap = new DataMap(new Number160(33), Number160.createHash("test"), Number160.ZERO, tmp);
            compare(dataMap.convertToMap640(), stored);

            // get
            GetBuilder getBuilder = new GetBuilder(recv1, new Number160(33));
            getBuilder.domainKey(Number160.createHash("test"));
            getBuilder.contentKeys(tmp.keySet());
            getBuilder.versionKey(Number160.ZERO);

            fr = smmSender.get(recv1.peerAddress(), getBuilder, cc);
            fr.awaitUninterruptibly();
            Assert.assertEquals(true, fr.isSuccess());
            m = fr.responseMessage();
            DataMap stored2 = m.dataMap(0);
            Assert.assertEquals(0, stored2.size());
        } finally {
            if (cc != null) {
                cc.shutdown().awaitListenersUninterruptibly();
            }
            if (sender != null) {
View Full Code Here

            fcc.awaitUninterruptibly();
            cc = fcc.channelCreator();

            PutBuilder putBuilder = new PutBuilder(recv1, new Number160(33));
            putBuilder.domainKey(Number160.createHash("test"));
            DataMap dataMap = new DataMap(new Number160(33), Number160.createHash("test"), Number160.ZERO, tmp);
            putBuilder.dataMapContent(tmp);
            putBuilder.versionKey(Number160.ZERO);

            FutureResponse fr = smmSender.put(recv1.peerAddress(), putBuilder, cc);
            fr.awaitUninterruptibly();
            Assert.assertEquals(true, fr.isSuccess());
            KeyMapByte keys = fr.responseMessage().keyMapByte(0);
            Utils.isSameSets(keys.keysMap().keySet(), dataMap.convertToMap640().keySet());

        } finally {
            if (cc != null) {
                cc.shutdown().awaitListenersUninterruptibly();
            }
View Full Code Here

        if (synchronizationBuilder.isSign()) {
            message.publicKeyAndSign(synchronizationBuilder.keyPair());
        }

        DataMap dataMap = synchronizationBuilder.dataMap();
        message.setDataMap(dataMap);

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

                retVal.put(entry.getKey(), new Data().flag2());
                LOG.debug("copy required, not found on this peer {}", entry.getKey());
              }
            }
        }
        responseMessage.setDataMap(new DataMap(retVal));
        responder.response(responseMessage);
    }
View Full Code Here

     */
    private void handleSync(final Message message, final Message responseMessage, Responder responder) {
        LOG.debug("Sync received: got from {} -> I'm {}", message.sender().peerId(), message.recipient()
                .peerId());

        final DataMap dataMap = message.dataMap(0);
        final PublicKey publicKey = message.publicKey(0);
        final List<Number640> retVal = new ArrayList<Number640>(dataMap.size());

        for (Map.Entry<Number640, Data> entry : dataMap.dataMap().entrySet()) {
            if (entry.getValue().isFlag2()) {
              LOG.debug("remove entry {}", entry.getKey());
              Pair<Data, Enum<?>> result = storageLayer.remove(entry.getKey(), publicKey, false);
                if (replicationListener != null && result.element1() == PutStatus.OK) {
                  replicationListener.dataRemoved(entry.getKey().locationKey());
View Full Code Here

      final Number160 domainKey = Number160.ZERO;
      final Number160 contentKey = Number160.ZERO;
      final String value = "Test";

      HashMap<Number640, Data> map = new HashMap<Number640, Data>();
      final DataMap dataMap = new DataMap(map);
      map.put(new Number640(locationKey, domainKey, contentKey, Number160.ZERO), new Data("Test"));

      sender.put(locationKey).data(new Data(value)).start().awaitUninterruptibly();
      receiver.put(locationKey).data(new Data(value)).start().awaitUninterruptibly();
View Full Code Here

      final Number160 domainKey = Number160.ZERO;
      final Number160 contentKey = Number160.ZERO;
      final String value = "Test";

      HashMap<Number640, Data> map = new HashMap<Number640, Data>();
      final DataMap dataMap = new DataMap(map);
      map.put(new Number640(locationKey, domainKey, contentKey, Number160.ZERO), new Data("Test"));

      sender.put(locationKey).data(new Data(value)).start().awaitUninterruptibly();

      sender.peer().bootstrap().peerAddress(receiver.peerAddress()).start().awaitUninterruptibly();
View Full Code Here

      sender.put(locationKey).data(new Data(value)).start().awaitUninterruptibly();
      receiver.put(locationKey).data(new Data(value1)).start().awaitUninterruptibly();

      HashMap<Number640, Data> map = new HashMap<Number640, Data>();
      final DataMap dataMap = new DataMap(map);
      map.put(new Number640(locationKey, domainKey, contentKey, Number160.ZERO), new Data("Test"));

      sender.peer().bootstrap().peerAddress(receiver.peerAddress()).start().awaitUninterruptibly();

      final CountDownLatch latch = new CountDownLatch(1);
View Full Code Here

TOP

Related Classes of net.tomp2p.message.DataMap

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.