Examples of WorkspaceNode


Examples of com.google.collide.shared.util.WorkspaceUtils.WorkspaceNode

    assertEquals(b, roots.get(1).getWorkspace());
    assertEquals(c, roots.get(2).getWorkspace());
  }

  public void testWorkspaceNodeAddChild() {
    WorkspaceNode parentNode = makeWorkspaceNode("parent", null);
    assertEquals(0, parentNode.getChildCount());

    WorkspaceInfo child0 = makeWorkspace("child0", parentNode.getWorkspace());
    WorkspaceNode childNode0 = new WorkspaceNode(child0);
    parentNode.addChild(childNode0);
    assertEquals(1, parentNode.getChildCount());
    assertEquals(childNode0, parentNode.getChild(0));

    WorkspaceInfo child1 = makeWorkspace("child1", parentNode.getWorkspace());
    WorkspaceNode childNode1 = new WorkspaceNode(child1);
    parentNode.addChild(childNode1);
    assertEquals(2, parentNode.getChildCount());
    assertEquals(childNode0, parentNode.getChild(0));
    assertEquals(childNode1, parentNode.getChild(1));
  }
View Full Code Here

Examples of com.google.collide.shared.util.WorkspaceUtils.WorkspaceNode

    assertEquals(childNode1, parentNode.getChild(1));
  }

  public void testWorkspaceNodeSortChildren() {
    // Create a hierarchy.
    WorkspaceNode a = makeWorkspaceNode("a", null);

    WorkspaceNode ab = makeWorkspaceNode("ab", a);
    WorkspaceNode aa = makeWorkspaceNode("aa", a);
    WorkspaceNode ac = makeWorkspaceNode("ac", a);

    WorkspaceNode aaa = makeWorkspaceNode("aaa", aa);
    WorkspaceNode aac = makeWorkspaceNode("aac", aa);
    WorkspaceNode aab = makeWorkspaceNode("aab", aa);

    // Sort non-recursively.
    a.sortChildren(new Comparator<WorkspaceNode>() {
      @Override
      public int compare(WorkspaceNode o1, WorkspaceNode o2) {
View Full Code Here

Examples of com.google.collide.shared.util.WorkspaceUtils.WorkspaceNode

    assertEquals(aab, aa.getChild(2));
  }

  public void testWorkspaceNodeSortChildrenRecursive() {
    // Create a hierarchy.
    WorkspaceNode a = makeWorkspaceNode("a", null);

    WorkspaceNode ab = makeWorkspaceNode("ab", a);
    WorkspaceNode aa = makeWorkspaceNode("aa", a);
    WorkspaceNode ac = makeWorkspaceNode("ac", a);

    WorkspaceNode aaa = makeWorkspaceNode("aaa", aa);
    WorkspaceNode aac = makeWorkspaceNode("aac", aa);
    WorkspaceNode aab = makeWorkspaceNode("aab", aa);

    // Sort non-recursively.
    a.sortChildren(new Comparator<WorkspaceNode>() {
      @Override
      public int compare(WorkspaceNode o1, WorkspaceNode o2) {
View Full Code Here

Examples of com.google.collide.shared.util.WorkspaceUtils.WorkspaceNode

  }

  private WorkspaceNode makeWorkspaceNode(String id, WorkspaceNode parent) {
    WorkspaceInfo parentWs = (parent == null) ? null : parent.getWorkspace();
    WorkspaceInfo ws = makeWorkspace(id, parentWs);
    WorkspaceNode node = new WorkspaceNode(ws);
    if (parent != null) {
      parent.addChild(node);
    }
    return node;
  }
View Full Code Here

Examples of org.jboss.cache.optimistic.WorkspaceNode

      boolean debug = log.isDebugEnabled();

      GlobalTransaction gtx = getGlobalTransaction(ctx);
      TransactionWorkspace workspace = getTransactionWorkspace(ctx);

      WorkspaceNode workspaceNode;

      List<Fqn> nodesCreated = new ArrayList<Fqn>();

      DataVersion version = null;
      if (ctx.getOptionOverrides() != null && ctx.getOptionOverrides().getDataVersion() != null)
      {
         version = ctx.getOptionOverrides().getDataVersion();
         workspace.setVersioningImplicit(false);
      }

      // start with the ROOT node and then work our way down to the node necessary, creating nodes along the way.
      workspaceNode = workspace.getNode(Fqn.ROOT);
      if (debug) log.debug("GlobalTransaction: " + gtx + "; Root: " + workspaceNode);

      // we do not have the root in the workspace!  Put it into thr workspace now.
      if (workspaceNode == null)
      {
         NodeSPI node = dataContainer.getRoot();
         workspaceNode = lockAndCreateWorkspaceNode(nodeFactory, node, workspace, gtx, lockAcquisitionTimeout);
         workspace.addNode(workspaceNode);
         log.debug("Created root node in workspace.");
      }
      else
      {
         log.debug("Found root node in workspace.");
      }

      // iterate through the target Fqn's elements.
      int targetFqnSize = targetFqn.size(), currentDepth = 1;
      for (Object childName : targetFqn.peekElements())
      {
         boolean isTargetFqn = (currentDepth == targetFqnSize);
         currentDepth++;

         // current workspace node canot be null.
         // try and get the child of current node

         if (debug) log.debug("Attempting to get child " + childName);
         NodeSPI currentNode = workspaceNode.getNode().getChildDirect(childName);

         if (currentNode == null)
         {
            // first test that it exists in the workspace and has been created in thix tx!
            WorkspaceNode peekInWorkspace = workspace.getNode(Fqn.fromRelativeElements(workspaceNode.getFqn(), childName));
            if (peekInWorkspace != null && peekInWorkspace.isCreated())
            {
               // exists in workspace and has just been created.
               currentNode = peekInWorkspace.getNode();
               if (peekInWorkspace.isRemoved())
               {
                  peekInWorkspace.setRemoved(false);
                  // add in parent again
                  workspaceNode.addChild(peekInWorkspace);
               }
            }
         }
View Full Code Here

Examples of org.jboss.cache.optimistic.WorkspaceNode

       * Digs out the DataVersion for a given Fqn.  If the versioning is explicit, it is passed as-is.  If implicit, it is
       * cloned and then incremented, and the clone is returned.
       */
      private DataVersion getVersionToBroadcast(TransactionWorkspace w, Fqn f)
      {
         WorkspaceNode n = w.getNode(f);
         if (n == null)
         {
            if (trace) log.trace("Fqn " + f + " not found in workspace; not using a data version.");
            return null;
         }
         if (n.isVersioningImplicit())
         {
            DefaultDataVersion v = (DefaultDataVersion) n.getVersion();
            if (trace)
               log.trace("Fqn " + f + " has implicit versioning.  Broadcasting an incremented version.");

            // potential bug here - need to check if we *need* to increment at all, because of Configuration.isLockParentForChildInsertRemove()
            return v.increment();
         }
         else
         {
            if (trace) log.trace("Fqn " + f + " has explicit versioning.  Broadcasting the version as-is.");
            return n.getVersion();
         }
      }
View Full Code Here

Examples of org.jboss.cache.optimistic.WorkspaceNode

   @Override
   public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
   {
      TransactionWorkspace workspace = getTransactionWorkspace(ctx);
      WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, false, true);
      if (workspaceNode != null)
      {
         setVersioning(ctx, workspace, workspaceNode);
      }
      Object result = removeNode(workspace, workspaceNode, true, ctx);
View Full Code Here

Examples of org.jboss.cache.optimistic.WorkspaceNode

   @Override
   public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
   {
      TransactionWorkspace workspace = getTransactionWorkspace(ctx);
      WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, true, true);
      if (workspaceNode != null)
      {
         setVersioning(ctx, workspace, workspaceNode);
      }
      else
View Full Code Here

Examples of org.jboss.cache.optimistic.WorkspaceNode

   @Override
   public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
   {
      TransactionWorkspace workspace = getTransactionWorkspace(ctx);
      WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, true, true);
      if (workspaceNode != null)
      {
         setVersioning(ctx, workspace, workspaceNode);
      }
      else
View Full Code Here

Examples of org.jboss.cache.optimistic.WorkspaceNode

   @Override
   public Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
   {
      TransactionWorkspace workspace = getTransactionWorkspace(ctx);
      WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, true, true);
      if (ctx.isOriginLocal() && ctx.getOptionOverrides() != null && ctx.getOptionOverrides().getDataVersion() != null)
      {
         throw new CacheException("Setting a data version while performing a move() is not supported!!");
      }
      if (workspaceNode != null)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.