Package org.jboss.cache

Examples of org.jboss.cache.Node


  }
 
  @Override
  public V get(K key) {
    Node<K, V> node = getRootNode();
    Node child = node.getChild(getFqn(key));
    if (child != null) {
      return (V)child.get(key);
    }
    return null;
  }
View Full Code Here


  @Override
  public V remove(K key) {
    Node<K, V> node = getRootNode();
    Fqn<String> fqn = getFqn(key);
    Node child = node.getChild(fqn);
    if (child != null) {
      V value = (V)child.remove(key);
      node.removeChild(fqn);
      return value;
    }
    return null;
  }
View Full Code Here

  }
 
  @Override
  public V put(K key, V value, Long ttl) {
    Node<K, V> node = getRootNode();
    Node child = node.addChild(getFqn(key));
   
    long future = DefaultCache.getExpirationTime(config.getMaxAgeInSeconds()*1000, ttl);       
    child.put(ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
    return (V)child.put(key, value);
  }
View Full Code Here

     
      if (!this.cacheStore.getCacheStatus().allowInvocations()) {
        this.cacheStore.start();
      }
     
      Node cacheRoot = this.cacheStore.getRoot().addChild(Fqn.fromString("Teiid")); //$NON-NLS-1$
      Node node = cacheRoot.addChild(Fqn.fromString(location));
      node.setResident(true);
     
      Region cacheRegion = this.cacheStore.getRegion(node.getFqn(), true);
      cacheRegion.setEvictionRegionConfig(buildEvictionConfig(node.getFqn(), config));
           
      JBossCache jc = null;
      if (config != null && config.getPolicy().equals(Policy.EXPIRATION)) {
        jc = new ExpirationAwareCache(this.cacheStore, node.getFqn());
      }
      else {
        jc = new JBossCache(this.cacheStore, node.getFqn())
      }
     
      jc.setCacheConfiguration(config);
      return jc;
    }
View Full Code Here

    * @param optimistic should the cache be configured for optimistic locking
    * @throws Exception
    */
   private void nodeResurrectionTest2() throws Exception
   {
      Node root1 = cache1.getRoot();
      Node root2 = cache2.getRoot();

      // this fqn is relative, but since it is from the root it may as well be absolute
      Fqn fqn = Fqn.fromString("/test/fqn");
      cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
      root1.addChild(fqn);
      assertEquals(true, root1.hasChild(fqn));
      cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
      root1.addChild(fqn);
      assertEquals(true, root1.hasChild(fqn));

      Fqn child = Fqn.fromRelativeElements(fqn, "child");
      cache1.putForExternalRead(child, "key", "value");
      cache2.putForExternalRead(child, "key", "value");
      assertEquals("value", cache1.get(child, "key"));
      assertEquals("value", cache2.get(child, "key"));

      assertEquals(true, cache1.removeNode(fqn));
      assertFalse(root1.hasChild(fqn));

      cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
      root1.addChild(fqn);
      assertEquals(true, root1.hasChild(fqn));

      Node remoteNode = root2.getChild(fqn);
      CacheLoaderInvalidationTest.checkRemoteNodeIsRemoved(remoteNode);
      cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
      root2.addChild(fqn);
      assertEquals(true, root2.hasChild(fqn));
   }
View Full Code Here

      assertNull("Should be null", caches.get(0).getNode(fqn));
      assertNull("Should be null", caches.get(1).getNode(fqn));

      caches.get(0).put(fqn, "key", "value");
      assertEquals("expecting value", "value", caches.get(0).get(fqn, "key"));
      Node n = caches.get(1).getNode(fqn);
      CacheLoaderInvalidationTest.assertHasBeenInvalidated(n, "Should have been invalidated");

      // now put in caches.get(1), should fire an eviction
      caches.get(1).put(fqn, "key", "value2");
      assertEquals("expecting value2", "value2", caches.get(1).get(fqn, "key"));
View Full Code Here

   }

   public void testLazyLoadingOnNodeGet() throws Exception
   {
      cache.getTransactionManager().begin();
      Node node = cache.getRoot().getChild(parent);
      assert node.getData().size() == 1 : "Node should have data";
      WorkspaceNode n = getWorkspaceNode(parent);
      assert !n.isChildrenLoaded() : "Should not have loaded children";
      cache.getTransactionManager().commit();
   }
View Full Code Here

   }

   public void testLazyLoadingOnNodeRemove() throws Exception
   {
      cache.getTransactionManager().begin();
      Node node = cache.getRoot().getChild(parent);
      node.clearData();
      assert node.getData().size() == 0 : "Node should have removed data";
      WorkspaceNode n = getWorkspaceNode(parent);
      assert !n.isChildrenLoaded() : "Should not have loaded children";
      cache.getTransactionManager().commit();
   }
View Full Code Here

   }

   public void testLazyLoadingOnNodePut() throws Exception
   {
      cache.getTransactionManager().begin();
      Node node = cache.getRoot().getChild(parent);
      node.put("k2", "v2");
      assert node.getData().size() == 2 : "Node should have added data";
      WorkspaceNode n = getWorkspaceNode(parent);
      assert !n.isChildrenLoaded() : "Should not have loaded children";
      cache.getTransactionManager().commit();
   }
View Full Code Here

   }

   public void testLazyLoadingOnNodeGetChildrenNames() throws Exception
   {
      cache.getTransactionManager().begin();
      Node node = cache.getRoot().getChild(parent);
      assert node.getChildrenNames().size() == 1 : "Node should have 1 child";
      WorkspaceNode n = getWorkspaceNode(parent);
      assert n.isChildrenLoaded() : "Should have loaded children";
      cache.getTransactionManager().commit();
   }
View Full Code Here

TOP

Related Classes of org.jboss.cache.Node

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.