Package net.tomp2p.dht

Examples of net.tomp2p.dht.StorageLayer


  }

  @Test
  public void testConcurrency2() throws InterruptedException, IOException {
    final Storage sM = createStorage();
    final StorageLayer storageGeneric = new StorageLayer(sM);
    store(storageGeneric);
    final AtomicInteger counter = new AtomicInteger();
    for (int i = 0; i < 100; i++) {
      new Thread(new Runnable() {
        @Override
        public void run() {
          Data result1 = null;
          Data result2 = null;
          Data result3 = null;
          try {
            result1 = storageGeneric.get(key1);
            Assert.assertEquals("test1", result1.object());
            result3 = storageGeneric.get(key3);
            Assert.assertEquals(null, result3);
            store(storageGeneric, 1);
          } catch (Throwable t) {
            t.printStackTrace();
            counter.incrementAndGet();
          }
          try {
            result2 = storageGeneric.get(key2);
            Assert.assertEquals("test2", result2.object());
            result3 = storageGeneric.get(key3);
            Assert.assertEquals(null, result3);
            store(storageGeneric, 1);
          } catch (Throwable t) {
            t.printStackTrace();
            counter.incrementAndGet();
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

TOP

Related Classes of net.tomp2p.dht.StorageLayer

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.