Package net.tomp2p.dht

Examples of net.tomp2p.dht.StorageMemory


  private static final Logger LOG = LoggerFactory.getLogger(LoggingStorageLayer.class);
  private final String peerName;
  private final boolean accept;

  public LoggingStorageLayer(String peerName, boolean accept) {
    super(new StorageMemory());
    this.peerName = peerName;
    this.accept = accept;
  }
View Full Code Here


  final private Number640 key2 = new Number640(locationKey, domainKey, content2, Number160.ZERO);
  final private Number640 key3 = new Number640(locationKey, domainKey, content3, Number160.ZERO);
  final private Number640 key4 = new Number640(locationKey, domainKey, content4, Number160.ZERO);

  public Storage createStorage() throws IOException {
    return new StorageMemory();
  }
View Full Code Here

     *            All the peers
     * @param max
     *            The max. number of elements per node.
     */
    private static StorageLayer setupStorage(final int max) {
          StorageLayer sl = new StorageLayer(new StorageMemory()) {
            @Override
            public Enum<?> put(Number640 key, Data newData, PublicKey publicKey, boolean putIfAbsent,
                    boolean domainProtection) {
              Map<Number640, Data> map = get(key.minContentKey(), key.maxContentKey(), -1, false);
              if (map.size() < max) {
View Full Code Here

public class TestStorageMemoryReplication {

  @Test
  public void testStorageMemoryReplication1() {
    StorageMemory storageMemoryReplication = new StorageMemory();
    Number160 testLoc = Number160.createHash("test1");
    Number160 testPer = Number160.createHash("test2");
    storageMemoryReplication.updateResponsibilities(testLoc, testPer);
    Assert.assertEquals(testPer, storageMemoryReplication.findPeerIDsForResponsibleContent(testLoc)
        .iterator().next());
  }
View Full Code Here

        .iterator().next());
  }

  @Test
  public void testStorageMemoryReplication2() {
    StorageMemory storageMemoryReplication = new StorageMemory();
    Number160 testLoc = Number160.createHash("loc1");
    Number160 testPer1 = Number160.createHash("peer1");
    Number160 testPer2 = Number160.createHash("peer2");
    storageMemoryReplication.updateResponsibilities(testLoc, testPer1);
    storageMemoryReplication.updateResponsibilities(testLoc, testPer2);
    Assert.assertFalse(storageMemoryReplication.updateResponsibilities(testLoc, testPer1));
    Assert.assertFalse(storageMemoryReplication.updateResponsibilities(testLoc, testPer2));
  }
View Full Code Here

    Assert.assertFalse(storageMemoryReplication.updateResponsibilities(testLoc, testPer2));
  }

  @Test
  public void testStorageMemoryReplication3() {
    StorageMemory storageMemoryReplication = new StorageMemory();
    Number160 testLoc = Number160.createHash("test1");
    Number160 testPer = Number160.createHash("test2");
    storageMemoryReplication.updateResponsibilities(testLoc, testPer);
    Assert.assertEquals(testLoc, storageMemoryReplication.findContentForResponsiblePeerID(testPer)
        .iterator().next());
  }
View Full Code Here

        .iterator().next());
  }

  @Test
  public void testStorageMemoryReplication4() {
    StorageMemory storageMemoryReplication = new StorageMemory();
    Number160 testLoc = Number160.createHash("loc1");
    Number160 testPer1 = Number160.createHash("peer1");
    Number160 testPer2 = Number160.createHash("peer2");
    storageMemoryReplication.updateResponsibilities(testLoc, testPer1);
    storageMemoryReplication.updateResponsibilities(testLoc, testPer2);
    Assert.assertEquals(testLoc, storageMemoryReplication.findContentForResponsiblePeerID(testPer1)
        .iterator().next());
    Assert.assertEquals(testLoc, storageMemoryReplication.findContentForResponsiblePeerID(testPer2)
        .iterator().next());
  }
View Full Code Here

        .iterator().next());
  }

  @Test
  public void testStorageMemoryReplication5() {
    StorageMemory storageMemoryReplication = new StorageMemory();
    Number160 testLoc = Number160.createHash("test1");
    Number160 testPer = Number160.createHash("test2");
    storageMemoryReplication.updateResponsibilities(testLoc, testPer);
    storageMemoryReplication.updateResponsibilities(testLoc, testPer);
    Assert.assertEquals(testPer, storageMemoryReplication.findPeerIDsForResponsibleContent(testLoc)
        .iterator().next());
    Assert.assertEquals(testLoc, storageMemoryReplication.findContentForResponsiblePeerID(testPer)
        .iterator().next());
  }
View Full Code Here

        .iterator().next());
  }

  @Test
  public void testStorageMemoryReplication6() {
    StorageMemory storageMemoryReplication = new StorageMemory();
    Number160 testLoc = Number160.createHash("test1");
    Number160 testPer = Number160.createHash("test2");
    storageMemoryReplication.updateResponsibilities(testLoc, testPer);
    storageMemoryReplication.updateResponsibilities(testLoc, testPer);
    storageMemoryReplication.removeResponsibility(testLoc);
    Assert.assertEquals(null, storageMemoryReplication.findPeerIDsForResponsibleContent(testLoc));
  }
View Full Code Here

    Assert.assertEquals(null, storageMemoryReplication.findPeerIDsForResponsibleContent(testLoc));
  }

  @Test
  public void testStorageMemoryReplication7() {
    StorageMemory storageMemoryReplication = new StorageMemory();
    Number160 testLoc = Number160.createHash("test1");
    Number160 testPer1 = Number160.createHash("test2");
    Number160 testPer2 = Number160.createHash("test3");
    storageMemoryReplication.updateResponsibilities(testLoc, testPer1);
    storageMemoryReplication.updateResponsibilities(testLoc, testPer2);
    storageMemoryReplication.removeResponsibility(testLoc);
    Assert.assertEquals(null, storageMemoryReplication.findPeerIDsForResponsibleContent(testLoc));
    Assert.assertEquals(null, storageMemoryReplication.findContentForResponsiblePeerID(testPer1));
    Assert.assertEquals(null, storageMemoryReplication.findContentForResponsiblePeerID(testPer2));
  }
View Full Code Here

TOP

Related Classes of net.tomp2p.dht.StorageMemory

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.