Ejemplo n.º 1
0
  public CDOIDAndBranchImpl(CDOID id, CDOBranch branch) {
    CheckUtil.checkArg(id, "id");
    CheckUtil.checkArg(branch, "branch");

    this.id = id;
    this.branch = branch;
  }
Ejemplo n.º 2
0
 /** @since 4.2 */
 public DefaultCDOMerger(ResolutionPreference resolutionPreference) {
   CheckUtil.checkArg(resolutionPreference, "resolutionPreference");
   this.resolutionPreference = resolutionPreference;
 }
Ejemplo n.º 3
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();
    }
  }
Ejemplo n.º 4
0
 public ID(int value) {
   CheckUtil.checkArg(value != INFO_FOLLOWS, "value");
   this.value = value;
 }