Package net.tomp2p.synchronization

Examples of net.tomp2p.synchronization.PeerSync


        responsibilityListeners = null;
      }
      peer.storeRPC().replicationListener(replication);
     
    if(rsync) {
      replicationSender = new PeerSync(peer, replication, blockSize);
    } else if (replicationSender == null) {
      replicationSender = new DefaultReplicationSender(peer);
    }
     
      scheduledFuture = peer.peer().connectionBean().timer().scheduleAtFixedRate(
View Full Code Here


      //final ReplicationSync syncSender = new ReplicationSync(5);
      sender = new PeerBuilderDHT(new PeerBuilder(new Number160(1)).ports(4001).start()).start();
      //final ReplicationSync syncReceiver = new ReplicationSync(5);
      receiver = new PeerBuilderDHT(new PeerBuilder(new Number160(2)).ports(4002).start()).start();
      final PeerSync senderSync = new PeerSync(sender, 5);
      new PeerSync(receiver, 5);

      final Number160 locationKey = new Number160(100);
      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();

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

      FutureChannelCreator futureChannelCreator = sender.peer().connectionBean().reservation().create(0, 1);

      final CountDownLatch latch = new CountDownLatch(1);
      final PeerAddress receiverAddress = receiver.peerAddress();

      futureChannelCreator.addListener(new BaseFutureAdapter<FutureChannelCreator>() {
        @Override
        public void operationComplete(final FutureChannelCreator future2) throws Exception {
          if (future2.isSuccess()) {
            SyncBuilder synchronizationBuilder = new SyncBuilder(senderSync, receiverAddress, 5);
            synchronizationBuilder.dataMap(dataMap);
            final FutureResponse futureResponse = senderSync.syncRPC().infoMessage(
                    receiverAddress, synchronizationBuilder, future2.channelCreator());
            futureResponse.addListener(new BaseFutureAdapter<FutureResponse>() {
              @Override
              public void operationComplete(FutureResponse future) throws Exception {
                System.err.println(future.failedReason());
View Full Code Here

    try {
      final AtomicReference<DataMap> ref = new AtomicReference<DataMap>();

      sender = new PeerBuilderDHT(new PeerBuilder(new Number160(3)).ports(4003).start()).start();
      receiver = new PeerBuilderDHT(new PeerBuilder(new Number160(4)).ports(4004).start()).start();
      final PeerSync senderSync = new PeerSync(sender, 5);
      new PeerSync(receiver, 5);

      final Number160 locationKey = new Number160(200);
      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();
      final CountDownLatch latch = new CountDownLatch(1);
      final PeerAddress receiverAddress = receiver.peerAddress();
      FutureChannelCreator futureChannelCreator = sender.peer().connectionBean().reservation().create(0, 1);
      futureChannelCreator.addListener(new BaseFutureAdapter<FutureChannelCreator>() {
        @Override
        public void operationComplete(final FutureChannelCreator future2) throws Exception {
          if (future2.isSuccess()) {
            SyncBuilder synchronizationBuilder = new SyncBuilder(senderSync, receiverAddress, 5);
            synchronizationBuilder.dataMap(dataMap);
            final FutureResponse futureResponse = senderSync.syncRPC().infoMessage(
                    receiverAddress, synchronizationBuilder, future2.channelCreator());
            futureResponse.addListener(new BaseFutureAdapter<FutureResponse>() {
              @Override
              public void operationComplete(FutureResponse future) throws Exception {
                ref.set(future.responseMessage().dataMap(0));
View Full Code Here

      sender = new PeerBuilderDHT(new PeerBuilder(new Number160(3)).ports(4003).start()).start();

      receiver = new PeerBuilderDHT(new PeerBuilder(new Number160(4)).ports(4004).start()).start();

      final PeerSync senderSync = new PeerSync(sender, 5);
      new PeerSync(receiver, 5);

      final Number160 locationKey = new Number160(300);
      final Number160 domainKey = Number160.ZERO;
      final Number160 contentKey = Number160.ZERO;

      final String value = "Test";
      final String value1 = "Test1";

      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);
      final PeerAddress receiverAddress = receiver.peerAddress();

      FutureChannelCreator futureChannelCreator = sender.peer().connectionBean().reservation().create(0, 1);
      futureChannelCreator.addListener(new BaseFutureAdapter<FutureChannelCreator>() {
        @Override
        public void operationComplete(final FutureChannelCreator future2) throws Exception {
          if (future2.isSuccess()) {
            SyncBuilder synchronizationBuilder = new SyncBuilder(senderSync, receiverAddress, 5);
            synchronizationBuilder.dataMap(dataMap);
            final FutureResponse futureResponse = senderSync.syncRPC().infoMessage(receiverAddress,
                    synchronizationBuilder, future2.channelCreator());
            futureResponse.addListener(new BaseFutureAdapter<FutureResponse>() {
              @Override
              public void operationComplete(FutureResponse future) throws Exception {
                ref.set(future.responseMessage().dataMap(0));
View Full Code Here

    PeerDHT receiver = null;
    try {
      sender = new PeerBuilderDHT(new PeerBuilder(new Number160(3)).ports(4003).start()).start();
      receiver = new PeerBuilderDHT(new PeerBuilder(new Number160(4)).ports(4004).start()).start();

      final PeerSync senderSync = new PeerSync(sender, 5);
      new PeerSync(receiver, 5);

      final Number160 locationKey = new Number160(500);
      final Number160 domainKey = Number160.ZERO;
      final Number160 contentKey = Number160.ZERO;
      Number640 key = new Number640(locationKey, domainKey, contentKey, Number160.ZERO);
      final String newValue = "Test1Test2Test3Test4";
      final String oldValue = "test0Test2test0Test4";

      Data test1 = new Data(newValue.getBytes());
      Data test2 = new Data(oldValue.getBytes());

      sender.put(locationKey).data(test1).start().awaitUninterruptibly();
      receiver.put(locationKey).data(test2).start().awaitUninterruptibly();

      FutureDone<SyncStat> future = senderSync.synchronize(receiver.peerAddress()).key(key)
              .start();
      future.awaitUninterruptibly();

      System.err.println(future.object().toString());
      Data data = receiver.storageLayer()
View Full Code Here

    PeerDHT receiver = null;
    try {
      sender = new PeerBuilderDHT(new PeerBuilder(new Number160(3)).ports(4003).start()).start();
      receiver = new PeerBuilderDHT(new PeerBuilder(new Number160(4)).ports(4004).start()).start();

      final PeerSync senderSync = new PeerSync(sender, 32);
      new PeerSync(receiver, 32);
     

      final Number160 locationKey = new Number160(500);
      final Number160 domainKey = Number160.ZERO;
      final Number160 contentKey = Number160.ZERO;
      Number640 key = new Number640(locationKey, domainKey, contentKey, Number160.ZERO);
      final String newValue = "TomP2P 5 is around the corner with several new additions. One of the larger changes is the support for relays as described here. Check out the latest alpha version.";
      final String oldValue = "TomP2P 5 is around the corner with several new additions! One of the larger changes is the support for relays as described here. Check out the latest alpha version.";

      Data test1 = new Data(newValue.getBytes());
      Data test2 = new Data(oldValue.getBytes());

      sender.put(locationKey).data(test1).start().awaitUninterruptibly();
      receiver.put(locationKey).data(test2).start().awaitUninterruptibly();

      FutureDone<SyncStat> future = senderSync.synchronize(receiver.peerAddress()).key(key)
              .start();
      future.awaitUninterruptibly();

      System.err.println(future.object().toString());
      Data data = receiver.storageLayer()
View Full Code Here

    PeerDHT receiver = null;
    try {
      sender = new PeerBuilderDHT(new PeerBuilder(new Number160(3)).ports(4003).start()).start();
      receiver = new PeerBuilderDHT(new PeerBuilder(new Number160(4)).ports(4004).start()).start();
     
      final PeerSync senderSync = new PeerSync(sender, 5);
      new PeerSync(receiver, 5);

      final Number160 locationKey = new Number160(500);
      final Number160 domainKey = Number160.ZERO;
      final Number160 contentKey = Number160.ZERO;
      Number640 key = new Number640(locationKey, domainKey, contentKey, Number160.ZERO);
      final String newValue = "Test1Test2Test3Test4";
      final String oldValue = "Test1Test2Test3Test4";

      Data test1 = new Data(newValue.getBytes());
      Data test2 = new Data(oldValue.getBytes());

      sender.put(locationKey).data(test1).start().awaitUninterruptibly();
      receiver.put(locationKey).data(test2).start().awaitUninterruptibly();

      FutureDone<SyncStat> future = senderSync.synchronize(receiver.peerAddress()).key(key)
              .start();
      future.awaitUninterruptibly();

      System.err.println(future.object().toString());
      Data data = receiver.storageLayer()
View Full Code Here

    PeerDHT receiver = null;
    try {
      sender = new PeerBuilderDHT(new PeerBuilder(new Number160(3)).ports(4003).start()).start();
      receiver = new PeerBuilderDHT(new PeerBuilder(new Number160(4)).ports(4004).start()).start();

      final PeerSync senderSync = new PeerSync(sender, 5);
      new PeerSync(receiver, 5);

      final Number160 locationKey = new Number160(600);
      final Number160 domainKey = Number160.ZERO;
      final Number160 contentKey = Number160.ZERO;
      Number640 key = new Number640(locationKey, domainKey, contentKey, Number160.ZERO);
      final String newValue = "Test1Test2Test3Test4";

      Data test1 = new Data(newValue.getBytes());

      sender.put(locationKey).data(test1).start().awaitUninterruptibly();

      FutureDone<SyncStat> future = senderSync.synchronize(receiver.peerAddress()).key(key)
              .start();
      future.awaitUninterruptibly();

      System.err.println(future.object().toString());
View Full Code Here

TOP

Related Classes of net.tomp2p.synchronization.PeerSync

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.