Package org.jboss.cache.marshall

Examples of org.jboss.cache.marshall.NodeData


         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


      {
         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);
      }

      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())
            {
               Map attributes = nd.getAttributes();

               target.setInternalState(attributes);

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

      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 = Fqn.fromRelativeFqn(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

      return n != null && n.hasChildrenDirect();
   }

   public List<NodeData> buildNodeData(List<NodeData> list, NodeSPI node)
   {
      NodeData data = new NodeData(buddyFqnTransformer.getActualFqn(node.getFqn()), node.getDataDirect());
      list.add(data);
      for (Object childNode : node.getChildrenDirect())
      {
         buildNodeData(list, (NodeSPI) childNode);
      }
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
   {
      List<Modification> mod = new ArrayList<Modification>(nodeData.size());
      for (Object aNodeData : nodeData)
      {
         NodeData nd = (NodeData) aNodeData;
         if (nd.isMarker())
         {
            if (trace) log.trace("Reached delimiter; exiting loop");
            break;
         }
         Fqn fqn;
         if (moveToBuddy)
         {
            fqn = buddyFqnTransformer.getBackupFqn(subtree, nd.getFqn());
         }
         else
         {
            fqn = nd.getFqn();
         }
         if (trace) log.trace("Storing state in Fqn " + fqn);
         mod.add(new Modification(ModificationType.PUT_DATA_ERASE, fqn, nd.getAttributes()));
      }
      prepare(null, mod, true);
   }
View Full Code Here

   {
      Map<Object, Object> attrs;
      Set<?> childrenNames;
      Object childName;
      Fqn tmpFqn;
      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, true);
      }
      //out.writeObject(nd);
      list.add(nd);

      // then visit the children
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

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.