示例#1
0
 private View searchViewList(int target_id) {
   View viewObj;
   int size = viewList.size();
   for (int j = 0; j < size; j++) {
     viewObj = (View) viewList.get(j);
     if (viewObj.getSnap_target_id() == target_id) {
       return viewObj;
     }
   }
   return null;
 }
示例#2
0
  private void getSnapAndViewFromVolInfo(ArrayList svList, int rootid, int tid) {
    int j, k, l, size1, size2, size3, local_snap_id;
    SnapWrapper snap;
    Snapshot newSnap;
    View viewObj;
    BasicVDisk directChild;

    ArrayList snapList = view.initor.mdb.getSnapWrapperListFromQuerySql(rootid);
    size1 = snapList.size();
    for (j = 0; j < size1; j++) {
      snap = (SnapWrapper) snapList.get(j);
      SanBootView.log.debug(
          getClass().getName(),
          " snap:["
              + snap.snap.getSnap_root_id()
              + "."
              + snap.snap.getSnap_local_snapid()
              + "] tid: "
              + tid);
      // 先更新一下snap's child list
      newSnap =
          view.initor.mdb.getSnapshotFromQuerySql(
              snap.snap.getSnap_root_id(), snap.snap.getSnap_local_snapid());
      if (newSnap != null) {
        snap.snap.setSnap_child_list(newSnap.getSnap_child_list());
      } else {
        SanBootView.log.error(
            getClass().getName(),
            "Not found snapshot from vsnap db: ["
                + snap.snap.getSnap_root_id()
                + "."
                + snap.snap.getSnap_local_snapid()
                + "]");
      }

      // 获取树上从该快照开始所有的 view 节点
      viewList.clear();
      getViewChild(snap.snap.getSnap_root_id(), snap.snap);
      size2 = viewList.size();
      SanBootView.log.debug(
          getClass().getName(),
          " Child of view from this snap node on tree: ["
              + snap.snap.getSnap_root_id()
              + "."
              + snap.snap.getSnap_local_snapid()
              + "]");
      SanBootView.log.debug(getClass().getName(), "===========================");
      for (k = 0; k < size2; k++) {
        viewObj = (View) viewList.get(k);
        SanBootView.log.debug(
            getClass().getName(),
            " view local_snap_id: "
                + viewObj.getSnap_local_snapid()
                + " view target_id: "
                + viewObj.getSnap_target_id());
      }
      SanBootView.log.debug(getClass().getName(), "===========================\r\n");

      svList.add(snap);

      // 根据该快照的子节点来判断直属于它的view
      ArrayList directChildList = snap.snap.getChildList();
      size3 = directChildList.size();
      for (l = 0; l < size3; l++) {
        local_snap_id = ((Integer) directChildList.get(l)).intValue();
        directChild = view.initor.mdb.getVDisk(snap.snap.getSnap_root_id(), local_snap_id);
        if (directChild != null) {
          viewObj = null;
          if (directChild.isSnap()) {
            viewObj = searchViewList(directChild.getSnap_target_id());
          } else { // direct child is view or disk
            if (directChild.isView()) {
              if (directChild.getSnap_target_id() != snap.snap.getSnap_target_id()) {
                viewObj = new View(directChild);
              }
            }
          }

          if (viewObj != null) {
            svList.add(new ViewWrapper(viewObj));
            SanBootView.log.debug(
                getClass().getName(),
                " Found direct view: ["
                    + viewObj.getSnap_root_id()
                    + "."
                    + viewObj.getSnap_local_snapid()
                    + "]");
          }
        } else {
          SanBootView.log.error(
              getClass().getName(),
              " Not found disk from vsnap db: ["
                  + snap.snap.getSnap_root_id()
                  + "."
                  + local_snap_id
                  + "]");
        }
      }
    }
  }