Package org.jboss.cache.marshall

Examples of org.jboss.cache.marshall.NodeData


      int parent_level = parent.getFqn().size();
      int target_level = parent_level + 1;
      Fqn fqn;
      int size;
      Object name;
      NodeData nd = nodeDataIterator.hasNext() ? nodeDataIterator.next() : null;
      while (nd != null && !nd.isMarker())
      {
         fqn = nd.getFqn();
         // If we need to integrate into the buddy backup subtree,
         // change the Fqn to fit under it
         if (offset > 0)
         {
            fqn = new Fqn(parent.getFqn().getAncestor(offset), fqn);
         }
         size = fqn.size();
         if (size <= parent_level)
         {
            return nd;
         }
         else if (size > target_level)
         {
            throw new IllegalStateException("NodeData " + fqn + " is not a direct child of " + parent.getFqn());
         }

         name = fqn.get(size - 1);

         Map attrs = nd.getAttributes();

         // We handle this NodeData.  Create a TreeNode and
         // integrate its data
         NodeSPI target = factory.createDataNode(name, fqn, parent, attrs, false);
         parent.addChild(name, target);

         // JBCACHE-913
         Region region = cache.getRegion(fqn, false);
         if (region != null && region.getEvictionPolicy() != null)
         {
            region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT,
                  attrs == null ? 0 : attrs.size()));
         }

         // Recursively call, which will walk down the tree
         // and return the next NodeData that's a child of our parent
         nd = integrateStateTransferChildren(target, offset, nodeDataIterator);
      }
      if (nd != null && nd.isExceptionMarker())
      {
         NodeDataExceptionMarker ndem = (NodeDataExceptionMarker) nd;
         throw new CacheException("State provider node " + ndem.getCacheNodeIdentity()
               + " threw exception during loadState", ndem.getCause());
      }
View Full Code Here


         rs = ps.executeQuery();
         while (rs.next())
         {
            Map<Object, Object> attributes = readAttributes(rs, 2);
            Fqn path = Fqn.fromString(rs.getString(1));
            NodeData nodeData = (attributes == null || attributes.isEmpty()) ? new NodeData(path) : new NodeData(path, attributes);
            list.add(nodeData);
         }
      }
      catch (SQLException e)
      {
View Full Code Here

      List nodeData = (List) objectFromStream;

      //for (nd = (NodeData) in.readObject(); nd != null && !nd.isMarker(); nd = (NodeData) in.readObject())
      for (Object o : nodeData)
      {
         NodeData nd = (NodeData) o;
         if (nd.isMarker()) break;

         if (nd.isExceptionMarker())
         {
            NodeDataExceptionMarker ndem = (NodeDataExceptionMarker) nd;
            throw new CacheException("State provider cacheloader at node " + ndem.getCacheNodeIdentity()
                  + " threw exception during loadState (see Caused by)", ndem.getCause());
         }

         if (moveToBuddy)
         {
            fqn = BuddyManager.getBackupFqn(subtree, nd.getFqn());
         }
         else
         {
            fqn = nd.getFqn();
         }

         if (nd.getAttributes() != null)
         {
            this.put(fqn, nd.getAttributes(), true);// creates a node with 0 or more attributes
         }
         else
         {
            this.put(fqn, null);// creates a node with null attributes
         }
View Full Code Here

   {
      Map<Object, Object> attrs;
      Set<?> children_names;
      String child_name;
      Fqn tmp_fqn;
      NodeData nd;

      // first handle the current node
      attrs = get(fqn);
      if (attrs == null || attrs.size() == 0)
      {
         nd = new NodeData(fqn);
      }
      else
      {
         nd = new NodeData(fqn, attrs);
      }
      //out.writeObject(nd);
      list.add(nd);

      // then visit the children
View Full Code Here

      }
   }

   private List<NodeData> getNodeData(List<NodeData> list, NodeSPI node)
   {
      NodeData data = new NodeData(BuddyManager.getActualFqn(node.getFqn()), node.getDataDirect());
      list.add(data);
      for (Object childNode : node.getChildrenDirect())
      {
         getNodeData(list, (NodeSPI) childNode);
      }
View Full Code Here

      if (internalFqns.contains(node.getFqn())) {
         return;
      }

      Map attrs;
      NodeData nd;

      // first handle the current node
      attrs = node.getInternalState(false);

      if (attrs.size() == 0) {
         nd = new NodeData(node.getFqn());
      } else {
         nd = new NodeData(node.getFqn(), attrs, true);
      }

      list.add(nd);

      // then visit the children
View Full Code Here

         // if the list was null we read an EOF marker!!  So don't bother popping it off the stack later.
         Iterator<NodeData> nodeDataIterator = list.iterator();

         // Read the first NodeData and integrate into our target
         if (nodeDataIterator.hasNext()) {
            NodeData nd = nodeDataIterator.next();

            //are there any transient nodes at all?
            if (nd != null && !nd.isMarker()) {
               // with MVCC these calls should ALWAYS go up the interceptor chain since no other locking
               // takes place elsewhere.
               prepareContextOptions();
               cache.clearData(target);
               prepareContextOptions();
               cache.put(target, nd.getAttributes());

               // Check whether this is an integration into the buddy backup
               // subtree
               Fqn tferFqn = nd.getFqn();
               boolean move = target.isChildOrEquals(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN)
                     && !tferFqn.isChildOrEquals(target);
               // If it is an integration, calculate how many levels of offset
               int offset = move ? target.size() - tferFqn.size() : 0;
View Full Code Here

         throws IOException, ClassNotFoundException {
      int parentLevel = parentFqn.size();
      int targetLevel = parentLevel + 1;
      Fqn fqn;
      int size;
      NodeData nd = nodeDataIterator.hasNext() ? nodeDataIterator.next() : null;
      while (nd != null && !nd.isMarker()) {
         fqn = nd.getFqn();
         // If we need to integrate into the buddy backup subtree,
         // change the Fqn to fit under it
         if (offset > 0) {
            fqn = Fqn.fromRelativeFqn(parentFqn.getAncestor(offset), fqn);
         }
         size = fqn.size();
         if (size <= parentLevel) {
            return nd;
         } else if (size > targetLevel) {
            throw new IllegalStateException("NodeData " + fqn + " is not a direct child of " + parentFqn);
         }

         Map attrs = nd.getAttributes();

         prepareContextOptions();
         cache.clearData(fqn);
         prepareContextOptions();
         cache.put(fqn, attrs);
         cache.getNode(fqn).setDataLoaded(false);
         cache.getNode(fqn).setChildrenLoaded(false);

         // Recursively call, which will walk down the tree
         // and return the next NodeData that's a child of our parent
         nd = integrateStateTransferChildren(fqn, offset, nodeDataIterator);
      }
      if (nd != null && nd.isExceptionMarker()) {
         NodeDataExceptionMarker ndem = (NodeDataExceptionMarker) nd;
         throw new CacheException("State provider node " + ndem.getCacheNodeIdentity()
               + " threw exception during loadState", ndem.getCause());
      }
      return null;
View Full Code Here

      }

      List nodeData = (List) objectFromStream;
      for (Object aNodeData : nodeData)
      {
         NodeData nd = (NodeData) aNodeData;
         if (nd.isExceptionMarker())
         {
            NodeDataExceptionMarker ndem = (NodeDataExceptionMarker) nd;
            throw new CacheException("State provider cacheloader at node " + ndem.getCacheNodeIdentity()
                  + " threw exception during loadState (see Caused by)", ndem.getCause());
         }
View Full Code Here

   protected void storeStateHelper(Fqn subtree, List nodeData, boolean moveToBuddy) throws Exception
   {
      for (Object aNodeData : nodeData)
      {
         NodeData nd = (NodeData) aNodeData;
         if (nd.isMarker()) break;
         Fqn fqn;
         if (moveToBuddy)
         {
            fqn = buddyFqnTransformer.getBackupFqn(subtree, nd.getFqn());
         }
         else
         {
            fqn = nd.getFqn();
         }

         if (nd.getAttributes() != null)
         {
            this.put(fqn, nd.getAttributes(), true);// creates a node with 0 or more attributes
         }
         else
         {
            this.put(fqn, null);// creates a node with null attributes
         }
View Full Code Here

TOP

Related Classes of org.jboss.cache.marshall.NodeData

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.