Package com.sun.sgs.app

Examples of com.sun.sgs.app.DataManager


         *
         * @code prev the {@code Element} after this {@code Element}
         *       in the deque
         */
        void setNext(Element<E> next) {
            DataManager dm = AppContext.getDataManager();
            ManagedReference<Element<E>> ref =
                    (next == null) ? null : dm.createReference(next);

            dm.markForUpdate(this);
            nextElement = ref;
        }
View Full Code Here


         *
         * @code prev the {@code Element} before this {@code Element}
         *       in the deque
         */
        void setPrev(Element<E> prev) {
            DataManager dm = AppContext.getDataManager();
            ManagedReference<Element<E>> ref =
                    (prev == null) ? null : dm.createReference(prev);

            dm.markForUpdate(this);
            prevElement = ref;
        }
View Full Code Here

  // Schedule asynchronous task here
  // which will delete the list
  AppContext.getTaskManager().scheduleTask(clearTask);

  // Remove the dummy connectors
  DataManager dm = AppContext.getDataManager();
  dm.removeObject(headRef.get());
  dm.removeObject(tailRef.get());
    }
View Full Code Here

      assert (e != null);

      ListNode<E> n = new ListNode<E>(this, bucketSize, e);
      size = n.size();
      childrenCount = 1;
      DataManager dm = AppContext.getDataManager();
      childRef = dm.createReference((Node<E>) n);
      parentRef = createReferenceIfNecessary(parent);
  }
View Full Code Here

  TreeNode(ScalableList<E> list, TreeNode<E> parent, boolean isSplit) {
      this(list);

      if (!isSplit) {
    ListNode<E> n = new ListNode<E>(this, bucketSize);
    DataManager dm = AppContext.getDataManager();
    size = n.size();
    childRef = dm.createReference((Node<E>) n);
      } else {
    size = 0;
    childRef = null;
      }
      parentRef = createReferenceIfNecessary(parent);
View Full Code Here

   *
   * @param root the root node of the entire tree structure
   */
  AsynchronousClearTask(ScalableList<E> list) {
      assert (list != null);
      DataManager dm = AppContext.getDataManager();
      current = dm.createReference(list.getHead());
  }
View Full Code Here

  /**
   * The entry point of the task to perform the clear.
   */
  public void run() {
      // Perform some work and check if we need to reschedule
      DataManager dm = AppContext.getDataManager();
      dm.markForUpdate(this);

      if (doWork()) {
    AppContext.getTaskManager().scheduleTask(this);
      } else {
    dm.removeObject(this);

    Runnable r = noteDoneRemoving;
    if (r != null) {
        r.run();
    }
View Full Code Here

  int index = highBits(prefix, dirBits);

  // the leaf is under this node, so just look it up using the directory
        ScalableHashMap<K, V> leaf = getChildNode(index);

  DataManager dm = AppContext.getDataManager();

        // mark this node for update since we will be changing its directory
  dm.markForUpdate(this);
  // remove the old leaf node
  dm.removeObject(leaf);

  // update the new children nodes to point to this directory node as
  // their parent
        ManagedReference<ScalableHashMap<K, V>> thisRef =
      dm.createReference(this);
  rightChildRef.get().parentRef = thisRef;
  leftChildRef.get().parentRef = thisRef;

  // how many bits in the prefix are significant for looking up the
  // old leaf
View Full Code Here

  private final Stack<Integer> offsets = new Stack<Integer>();

  /** Creates an instance for the specified directory node. */
        private RemoveNodesTask(ScalableHashMap<K, V> node) {
      assert !node.isLeafNode();
      DataManager dm = AppContext.getDataManager();
            ManagedReference<ScalableHashMap<K, V>> lastRef = null;
      for (int i = 0; i < node.nodeDirectory.length; i++) {
                ManagedReference<ScalableHashMap<K, V>> ref =
        uncheckedCast(node.nodeDirectory[i]);
    /* Skip clearing duplicate nodes in the directory */
    if (ref != lastRef) {
                    ScalableHashMap<K, V> child = ref.get();
        /*
         * Clear the parent reference so we don't walk up to the
         * root node, which is being reused.
         */
        dm.markForUpdate(child);
        child.parentRef = null;
        if (lastRef == null) {
      currentNodeRef = ref;
        } else {
      nodeRefs.add(ref);
View Full Code Here

      }
  }

  /** Removes some entries, returning true if there is more to do. */
  private boolean doWork() {
      DataManager dataManager = AppContext.getDataManager();
      dataManager.markForUpdate(this);
            ScalableHashMap<K, V> node = currentNodeRef.get();
      /* Find the leaf node */
      if (!node.isLeafNode()) {
    while (true) {
        currentNodeRef =
      uncheckedCast(node.nodeDirectory[offsets.peek()]);
        node = currentNodeRef.get();
        if (node.isLeafNode()) {
      break;
        }
        offsets.push(0);
    }
      }
      if (!node.removeSomeLeafEntries()) {
    /* More entries in this node */
    return true;
      }
      /* Search the parents for a non-empty node, removing empty ones */
      while (true) {
    currentNodeRef = node.parentRef;
    dataManager.removeObject(node);
    if (currentNodeRef == null) {
        break;
    }
    int offset = offsets.pop();
    node = currentNodeRef.get();
View Full Code Here

TOP

Related Classes of com.sun.sgs.app.DataManager

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.