Package freenet.store

Examples of freenet.store.CHKStore


      throw new NodeInitException(NodeInitException.EXIT_INVALID_STORE_SIZE, "Slashdot cache size too small");
    }

    maxSlashdotCacheKeys = (int) Math.min(maxSlashdotCacheSize / sizePerKey, Integer.MAX_VALUE);

    chkSlashdotcache = new CHKStore();
    chkSlashdotcacheStore = new SlashdotStore<CHKBlock>(chkSlashdotcache, maxSlashdotCacheKeys, slashdotCacheLifetime, PURGE_INTERVAL, ticker, this.clientCore.tempBucketFactory);
    pubKeySlashdotcache = new PubkeyStore();
    pubKeySlashdotcacheStore = new SlashdotStore<DSAPublicKey>(pubKeySlashdotcache, maxSlashdotCacheKeys, slashdotCacheLifetime, PURGE_INTERVAL, ticker, this.clientCore.tempBucketFactory);
    getPubKey.setLocalSlashdotcache(pubKeySlashdotcache);
    sskSlashdotcache = new SSKStore(getPubKey);
View Full Code Here


  private void createPasswordUserAlert() {
    this.clientCore.alerts.register(masterPasswordUserAlert);
  }

  private void initRAMClientCacheFS() {
    chkClientcache = new CHKStore();
    new RAMFreenetStore<CHKBlock>(chkClientcache, (int) Math.min(Integer.MAX_VALUE, maxClientCacheKeys));
    pubKeyClientcache = new PubkeyStore();
    new RAMFreenetStore<DSAPublicKey>(pubKeyClientcache, (int) Math.min(Integer.MAX_VALUE, maxClientCacheKeys));
    sskClientcache = new SSKStore(getPubKey);
    new RAMFreenetStore<SSKBlock>(sskClientcache, (int) Math.min(Integer.MAX_VALUE, maxClientCacheKeys));
View Full Code Here

    sskClientcache = new SSKStore(getPubKey);
    new RAMFreenetStore<SSKBlock>(sskClientcache, (int) Math.min(Integer.MAX_VALUE, maxClientCacheKeys));
  }

  private void initNoClientCacheFS() {
    chkClientcache = new CHKStore();
    new NullFreenetStore<CHKBlock>(chkClientcache);
    pubKeyClientcache = new PubkeyStore();
    new NullFreenetStore<DSAPublicKey>(pubKeyClientcache);
    sskClientcache = new SSKStore(getPubKey);
    new NullFreenetStore<SSKBlock>(sskClientcache);
View Full Code Here

    sskDatastore.getStore().setUserAlertManager(clientCore.alerts);
    sskDatacache.getStore().setUserAlertManager(clientCore.alerts);
  }

  private void initRAMFS() {
    chkDatastore = new CHKStore();
    new RAMFreenetStore<CHKBlock>(chkDatastore, (int) Math.min(Integer.MAX_VALUE, maxStoreKeys));
    chkDatacache = new CHKStore();
    new RAMFreenetStore<CHKBlock>(chkDatacache, (int) Math.min(Integer.MAX_VALUE, maxCacheKeys));
    pubKeyDatastore = new PubkeyStore();
    new RAMFreenetStore<DSAPublicKey>(pubKeyDatastore, (int) Math.min(Integer.MAX_VALUE, maxStoreKeys));
    pubKeyDatacache = new PubkeyStore();
    getPubKey.setDataStore(pubKeyDatastore, pubKeyDatacache);
View Full Code Here

  private long cachingFreenetStoreMaxSize;
  private long cachingFreenetStorePeriod;

  private void initSaltHashFS(final String suffix, boolean dontResizeOnStart, byte[] masterKey) throws NodeInitException {
    try {
      final CHKStore chkDatastore = new CHKStore();
      final FreenetStore<CHKBlock> chkDataFS = makeStore("CHK", true, chkDatastore, dontResizeOnStart, masterKey);
      final CHKStore chkDatacache = new CHKStore();
      final FreenetStore<CHKBlock> chkCacheFS = makeStore("CHK", false, chkDatacache, dontResizeOnStart, masterKey);
      ((SaltedHashFreenetStore<CHKBlock>) chkCacheFS.getUnderlyingStore()).setAltStore(((SaltedHashFreenetStore<CHKBlock>) chkDataFS.getUnderlyingStore()));
      final PubkeyStore pubKeyDatastore = new PubkeyStore();
      final FreenetStore<DSAPublicKey> pubkeyDataFS = makeStore("PUBKEY", true, pubKeyDatastore, dontResizeOnStart, masterKey);
      final PubkeyStore pubKeyDatacache = new PubkeyStore();
View Full Code Here

    }

  private void initSaltHashClientCacheFS(final String suffix, boolean dontResizeOnStart, byte[] clientCacheMasterKey) throws NodeInitException {

    try {
      final CHKStore chkClientcache = new CHKStore();
      final FreenetStore<CHKBlock> chkDataFS = makeClientcache("CHK", true, chkClientcache, dontResizeOnStart, clientCacheMasterKey);
      final PubkeyStore pubKeyClientcache = new PubkeyStore();
      final FreenetStore<DSAPublicKey> pubkeyDataFS = makeClientcache("PUBKEY", true, pubKeyClientcache, dontResizeOnStart, clientCacheMasterKey);
      final SSKStore sskClientcache = new SSKStore(getPubKey);
      final FreenetStore<SSKBlock> sskDataFS = makeClientcache("SSK", true, sskClientcache, dontResizeOnStart, clientCacheMasterKey);
View Full Code Here

    if(logMINOR) dumpStoreHits();
    try {
      nodeStats.avgRequestLocation.report(loc);
      CHKBlock block = chkDatastore.fetch(key, dontPromote || !canWriteDatastore, ignoreOldBlocks, meta);
      if(block == null) {
        CHKStore store = oldCHK;
        if(store != null)
          block = store.fetch(key, dontPromote || !canWriteDatastore, ignoreOldBlocks, meta);
      }
      if (block != null) {
        nodeStats.avgStoreCHKSuccess.report(loc);
        if (dist > nodeStats.furthestStoreCHKSuccess)
          nodeStats.furthestStoreCHKSuccess=dist;
        return block;
      }
      block=chkDatacache.fetch(key, dontPromote || !canWriteDatastore, ignoreOldBlocks, meta);
      if(block == null) {
        CHKStore store = oldCHKCache;
        if(store != null)
          block = store.fetch(key, dontPromote || !canWriteDatastore, ignoreOldBlocks, meta);
      }
      if (block != null) {
        nodeStats.avgCacheCHKSuccess.report(loc);
        if (dist > nodeStats.furthestCacheCHKSuccess)
          nodeStats.furthestCacheCHKSuccess=dist;
View Full Code Here

  /* Simple test with CHK for SaltedHashFreenetStore without slotFilter */
  public void testSimpleCHK() throws IOException, CHKEncodeException, CHKVerifyException, CHKDecodeException {
    File f = new File(tempDir, "saltstore");
    FileUtil.removeAll(f);

    CHKStore store = new CHKStore();
    SaltedHashFreenetStore<CHKBlock> saltStore = SaltedHashFreenetStore.construct(f, "testSaltedHashFreenetStoreCHK", store, weakPRNG, 10, false, SemiOrderedShutdownHook.get(), true, true, ticker, null);
    saltStore.start(null, true);

    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

  private void checkCHKPresent(int persistenceTime, int testCount, int acceptableFalsePositives, int storeSize) throws IOException, CHKEncodeException, CHKVerifyException, CHKDecodeException {
    ResizablePersistentIntBuffer.setPersistenceTime(persistenceTime);
    File f = new File(tempDir, "saltstore");
    FileUtil.removeAll(f);

    CHKStore store = new CHKStore();
    SaltedHashFreenetStore<CHKBlock> saltStore = SaltedHashFreenetStore.construct(f, "testCachingFreenetStoreCHK", store, weakPRNG, storeSize, true, SemiOrderedShutdownHook.get(), true, true, ticker, null);
    saltStore.start(null, true);
   
    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

  public void checkCHKPresentWithClose(int persistenceTime) throws IOException, CHKEncodeException, CHKVerifyException, CHKDecodeException {
    ResizablePersistentIntBuffer.setPersistenceTime(persistenceTime);
    File f = new File(tempDir, "saltstore");
    FileUtil.removeAll(f);

    CHKStore store = new CHKStore();
    SaltedHashFreenetStore<CHKBlock> saltStore = SaltedHashFreenetStore.construct(f, "testCachingFreenetStoreCHK", store, weakPRNG, STORE_SIZE, true, SemiOrderedShutdownHook.get(), true, true, ticker, null);
    saltStore.start(null, true);
   
    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

TOP

Related Classes of freenet.store.CHKStore

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.