Beispiel #1
0
  public static InternalView openViewWithLockArea(
      InternalSession session,
      InternalLockManager lockManager,
      CDOBranch viewedBranch,
      String lockAreaID) {
    LockArea lockArea;
    InternalView view;

    try {
      lockArea = lockManager.getLockArea(lockAreaID);

      // If we get here, the lockArea already exists.
      view =
          (InternalView)
              lockManager.openView(session, InternalSession.TEMP_VIEW_ID, true, lockAreaID);
    } catch (LockAreaNotFoundException e) {
      // If we get here, the lockArea does not yet exist, so we open
      // a view without a lockArea first, then create a lockArea with the given ID,
      // and associate it with the view.
      view = session.openView(InternalSession.TEMP_VIEW_ID, viewedBranch.getHead());
      lockArea = lockManager.createLockArea(view, lockAreaID);
      view.setDurableLockingID(lockAreaID);
    }

    CheckUtil.checkNull(lockAreaID, "lockAreaID");
    CheckUtil.checkNull(lockArea, "lockArea");
    CheckUtil.checkState(
        lockAreaID.equals(lockArea.getDurableLockingID()), "lockAreaID has incorrect value");

    return view;
  }
  public CDOIDAndBranchImpl(CDOID id, CDOBranch branch) {
    CheckUtil.checkArg(id, "id");
    CheckUtil.checkArg(branch, "branch");

    this.id = id;
    this.branch = branch;
  }
 /** @ADDED */
 @Override
 protected void validateDefinition() {
   CheckUtil.checkState(
       eIsSet(CDODefsPackage.EPACKAGE_DEF__NS_URI) //
           && URI.create(getNsURI()) != null,
       "nsURI not set or invalid!");
 }
Beispiel #4
0
 /** @since 4.2 */
 public DefaultCDOMerger(ResolutionPreference resolutionPreference) {
   CheckUtil.checkArg(resolutionPreference, "resolutionPreference");
   this.resolutionPreference = resolutionPreference;
 }
Beispiel #5
0
  public final <CONTEXT> void run(
      ProgressDistributable<CONTEXT>[] distributables, CONTEXT context, OMMonitor monitor)
      throws RuntimeException, WrappedException {
    double[] distributionCopy;
    synchronized (this) {
      if (distribution == null) {
        distribution = new double[distributables.length];
        Arrays.fill(distribution, OMMonitor.ONE);
      } else {
        CheckUtil.checkArg(
            distribution.length == distributables.length, "distributables.length"); // $NON-NLS-1$
      }

      distributionCopy = new double[distribution.length];
      System.arraycopy(distribution, 0, distributionCopy, 0, distribution.length);
    }

    double total = OMMonitor.ZERO;
    for (int i = 0; i < distributionCopy.length; i++) {
      total += distributionCopy[i];
    }

    if (TRACER.isEnabled()) {
      StringBuilder builder = new StringBuilder("Distribution: "); // $NON-NLS-1$
      for (int i = 0; i < distributionCopy.length; i++) {
        builder.append(distributionCopy[i] * OMMonitor.HUNDRED / total);
        builder.append("%, "); // $NON-NLS-1$
      }

      builder.append("("); // $NON-NLS-1$
      builder.append(this);
      builder.append(")"); // $NON-NLS-1$
      TRACER.trace(builder.toString());
    }

    monitor.begin(total);

    try {
      double[] times = new double[distributables.length];
      for (int i = 0; i < distributables.length; i++) {
        ProgressDistributable<CONTEXT> distributable = distributables[i];
        int count = distributable.getLoopCount(context);
        double work = distributable.getLoopWork(context);

        OMMonitor distributableMonitor = monitor.fork(distributionCopy[i]);
        distributableMonitor.begin(work * count);

        try {
          long start = System.currentTimeMillis();
          for (int loop = 0; loop < count; loop++) {
            try {
              distributable.runLoop(loop, context, distributableMonitor);
            } catch (Exception ex) {
              throw WrappedException.wrap(ex);
            }
          }

          times[i] = (double) (System.currentTimeMillis() - start) / count;
        } finally {
          distributableMonitor.done();
        }
      }

      synchronized (this) {
        distribute(distribution, times);
      }
    } finally {
      monitor.done();
    }
  }
Beispiel #6
0
 public ID(int value) {
   CheckUtil.checkArg(value != INFO_FOLLOWS, "value");
   this.value = value;
 }