Package freenet.keys

Examples of freenet.keys.ClientCHK


    for(int i=0;i<5;i++) {
      String test = "test" + i;
      ClientCHKBlock block = encodeBlockCHK(test);
      store.put(block.getBlock(), false);
      ClientCHK key = block.getClientKey();
      // It should pass straight through.
      assertNotNull(saltStore.fetch(key.getRoutingKey(), key.getNodeCHK().getFullKey(), false, false, false, false, null));
      CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
      String data = decodeBlockCHK(verify, key);
      assertEquals(test, data);
    }
   
    cachingStore.close();
View Full Code Here


    cachingStore.start(null, true);

    for(int i=0;i<5;i++) {
      String test = tests.remove(0); //get the first element
      ClientCHKBlock block = chkBlocks.remove(0); //get the first element
      ClientCHK key = block.getClientKey();
      CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
      String data = decodeBlockCHK(verify, key);
      assertEquals(test, data);
    }
   
    cachingStore.close();
View Full Code Here

   
    //Fetch five chk blocks
    for(int i=0; i<5; i++){
      String test = tests.remove(0); //get the first element
      ClientCHKBlock block = chkBlocks.remove(0); //get the first element
      ClientCHK key = block.getClientKey();
      CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
      String data = decodeBlockCHK(verify, key);
      assertEquals(test, data);
      // Check that it's in the underlying store now.
      assertNotNull(saltStore.fetch(block.getKey().getRoutingKey(), block.getKey().getFullKey(), false, false, false, false, null));
    }
View Full Code Here

    for(int i=0;i<5;i++) {
      String test = "test" + i;
      ClientCHKBlock block = encodeBlockCHK(test);
      store.put(block.getBlock(), false);
      ClientCHK key = block.getClientKey();
      CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
      String data = decodeBlockCHK(verify, key);
      assertEquals(test, data);
    }
   
    saltStore.close();
View Full Code Here

    int falsePositives = 0;

    for(int i=0;i<testCount;i++) {
      String test = "test" + i;
      ClientCHKBlock block = encodeBlockCHK(test);
      ClientCHK key = block.getClientKey();
      byte[] routingKey = key.getRoutingKey();
      if(saltStore.probablyInStore(routingKey))
        falsePositives++;
      store.put(block.getBlock(), false);
      assertTrue(saltStore.probablyInStore(routingKey));
      CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
      String data = decodeBlockCHK(verify, key);
      assertEquals(test, data);
    }
   
    assertTrue(falsePositives <= acceptableFalsePositives);
   
    for(int i=0;i<testCount;i++) {
      String test = "test" + i;
      ClientCHKBlock block = encodeBlockCHK(test);
      ClientCHK key = block.getClientKey();
      byte[] routingKey = key.getRoutingKey();
      assertTrue(saltStore.probablyInStore(routingKey));
      CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
      String data = decodeBlockCHK(verify, key);
      assertEquals(test, data);
    }
   
    saltStore.close();
View Full Code Here

    int falsePositives = 0;

    for(int i=0;i<TEST_COUNT;i++) {
      String test = "test" + i;
      ClientCHKBlock block = encodeBlockCHK(test);
      ClientCHK key = block.getClientKey();
      byte[] routingKey = key.getRoutingKey();
      if(saltStore.probablyInStore(routingKey))
        falsePositives++;
      store.put(block.getBlock(), false);
      assertTrue(saltStore.probablyInStore(routingKey));
      CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
      String data = decodeBlockCHK(verify, key);
      assertEquals(test, data);
    }
   
    assertTrue(falsePositives <= ACCEPTABLE_FALSE_POSITIVES);
   
    saltStore.close();
    store = new CHKStore();
    saltStore = SaltedHashFreenetStore.construct(f, "testCachingFreenetStoreCHK", store, weakPRNG, STORE_SIZE, true, SemiOrderedShutdownHook.get(), true, true, ticker, null);
    saltStore.start(null, true);
   
    for(int i=0;i<TEST_COUNT;i++) {
      String test = "test" + i;
      ClientCHKBlock block = encodeBlockCHK(test);
      ClientCHK key = block.getClientKey();
      byte[] routingKey = key.getRoutingKey();
      assertTrue(saltStore.probablyInStore(routingKey));
      CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
      String data = decodeBlockCHK(verify, key);
      assertEquals(test, data);
    }
   
    saltStore.close();
View Full Code Here

    int falsePositives = 0;

    for(int i=0;i<TEST_COUNT;i++) {
      String test = "test" + i;
      ClientCHKBlock block = encodeBlockCHK(test);
      ClientCHK key = block.getClientKey();
      byte[] routingKey = key.getRoutingKey();
      if(saltStore.probablyInStore(routingKey))
        falsePositives++;
      store.put(block.getBlock(), false);
      assertTrue(saltStore.probablyInStore(routingKey));
      CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
      String data = decodeBlockCHK(verify, key);
      assertEquals(test, data);
    }
   
    assertTrue(falsePositives <= ACCEPTABLE_FALSE_POSITIVES);
   
    try {
      Thread.sleep(2*delay);
    } catch (InterruptedException e) {
      // Ignore
    }

    // Abrupt abort. The slots should have been written by now.
    saltStore.close(true);
    store = new CHKStore();
    saltStore = SaltedHashFreenetStore.construct(f, "testCachingFreenetStoreCHK", store, weakPRNG, STORE_SIZE, true, SemiOrderedShutdownHook.get(), true, true, ticker, null);
    saltStore.start(null, true);
   
    for(int i=0;i<TEST_COUNT;i++) {
      String test = "test" + i;
      ClientCHKBlock block = encodeBlockCHK(test);
      ClientCHK key = block.getClientKey();
      byte[] routingKey = key.getRoutingKey();
      assertTrue(saltStore.probablyInStore(routingKey));
      CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
      String data = decodeBlockCHK(verify, key);
      assertEquals(test, data);
    }
   
    saltStore.close();
View Full Code Here

    int falsePositives = 0;

    for(int i=0;i<TEST_COUNT;i++) {
      String test = "test" + i;
      ClientCHKBlock block = encodeBlockCHK(test);
      ClientCHK key = block.getClientKey();
      byte[] routingKey = key.getRoutingKey();
      if(saltStore.probablyInStore(routingKey))
        falsePositives++;
      store.put(block.getBlock(), false);
      assertTrue(saltStore.probablyInStore(routingKey));
      CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
      String data = decodeBlockCHK(verify, key);
      assertEquals(test, data);
    }
   
    assertTrue(falsePositives == TEST_COUNT);
   
    saltStore.close();
    store = new CHKStore();
    // Now turn on slot filters. Does it still work?
    saltStore = SaltedHashFreenetStore.construct(f, "testCachingFreenetStoreCHK", store, weakPRNG, STORE_SIZE, true, SemiOrderedShutdownHook.get(), true, true, ticker, null);
    saltStore.start(null, true);
   
    for(int i=0;i<TEST_COUNT;i++) {
      String test = "test" + i;
      ClientCHKBlock block = encodeBlockCHK(test);
      ClientCHK key = block.getClientKey();
      byte[] routingKey = key.getRoutingKey();
      assertTrue(saltStore.probablyInStore(routingKey));
      CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
      String data = decodeBlockCHK(verify, key);
      assertEquals(test, data);
    }
   
    saltStore.close();
View Full Code Here

    int falsePositives = 0;

    for(int i=0;i<TEST_COUNT;i++) {
      String test = "test" + i;
      ClientCHKBlock block = encodeBlockCHK(test);
      ClientCHK key = block.getClientKey();
      byte[] routingKey = key.getRoutingKey();
      if(saltStore.probablyInStore(routingKey))
        falsePositives++;
      store.put(block.getBlock(), false);
      assertTrue(saltStore.probablyInStore(routingKey));
      CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
      String data = decodeBlockCHK(verify, key);
      assertEquals(test, data);
    }
   
    assertTrue(falsePositives == TEST_COUNT);
   
    saltStore.close();
    store = new CHKStore();
    // Now turn on slot filters. Does it still work?
    SaltedHashFreenetStore.NO_CLEANER_SLEEP = true;
    saltStore = SaltedHashFreenetStore.construct(f, "testCachingFreenetStoreCHK", store, weakPRNG, STORE_SIZE, true, SemiOrderedShutdownHook.get(), true, true, ticker, null);
    saltStore.start(null, true);
    saltStore.testingWaitForCleanerDone(50, 100);
   
    for(int i=0;i<TEST_COUNT;i++) {
      String test = "test" + i;
      ClientCHKBlock block = encodeBlockCHK(test);
      ClientCHK key = block.getClientKey();
      byte[] routingKey = key.getRoutingKey();
      assertTrue(saltStore.probablyInStore(routingKey));
      CHKBlock verify = store.fetch(key.getNodeCHK(), false, false, null);
      String data = decodeBlockCHK(verify, key);
      assertEquals(test, data);
    }
   
    saltStore.close();
View Full Code Here

    }
   
    void setKey(int blockNumber, ClientCHK key) throws IOException {
        if(logMINOR) Logger.minor(this, "Setting key "+key+" for block "+blockNumber+" on "+this, new Exception("debug"));
        try {
            ClientCHK oldKey = readKey(blockNumber);
            if(!oldKey.equals(key))
                throw new IOException("Key for block has changed! Data corruption or bugs in SplitFileInserter code");
        } catch (MissingKeyException e) {
            // Ok.
            writeKey(blockNumber, key);
        }
View Full Code Here

TOP

Related Classes of freenet.keys.ClientCHK

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.