Package org.jboss.cache.marshall

Examples of org.jboss.cache.marshall.NodeData


      nodes.abNode.put("ab", "ab");
      nodes.abcNode.put("abc", "abc");
      List<NodeData> result = new ArrayList<NodeData>();
      container.buildNodeData(result, nodes.abNode, true);
      assert result.size() == 2;
      assert result.contains(new NodeData(nodes.ab, nodes.abNode.getData(), true));
      assert result.contains(new NodeData(nodes.abc, nodes.abcNode.getData(), true));
   }
View Full Code Here


         autocommitPrev = con.getAutoCommit();
         if (config.isBatchEnabled()) con.setAutoCommit(false);
         ps = prepareAndLogStatement(con, config.getInsertNodeSql());
         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();
            }

            Map attributes = nd.getAttributes() == null ? null : new HashMap(nd.getAttributes());
            populatePreparedStatementForInsert(fqn, attributes, ps);
            if (!config.isBatchEnabled())
            {
               if (ps.executeUpdate() != 1)
               {
View Full Code Here

         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, true);
            list.add(nodeData);
         }
      }
      catch (SQLException e)
      {
View Full Code Here

      {
         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

      {
         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

         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

   {
      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 (trace) log.trace("Integrating state for children: " + fqn);
         // 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());
      }
View Full Code Here

      }
   }

   private List<NodeData> buildNodeData(List<NodeData> list, InternalNode<?, ?> node, Map dataInNode, boolean mapSafe)
   {
      NodeData data = new NodeData(buddyFqnTransformer.getActualFqn(node.getFqn()), dataInNode, mapSafe);
      list.add(data);
      for (InternalNode childNode : node.getChildrenMap().values())
      {
         buildNodeData(list, childNode, childNode.getData(), true);
      }
View Full Code Here

   }

   @Deprecated
   private List<NodeData> buildNodeDataLegacy(List<NodeData> list, NodeSPI node, boolean mapSafe)
   {
      NodeData data = new NodeData(buddyFqnTransformer.getActualFqn(node.getFqn()), node.getDataDirect(), mapSafe);
      list.add(data);
      for (Object childNode : node.getChildrenDirect())
      {
         buildNodeData(list, (NodeSPI) childNode, true);
      }
View Full Code Here

   @Override
   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.