Ejemplo n.º 1
0
  /** {@inheritDoc} */
  @Override()
  protected boolean testNonLDAPJobParameters(
      final ParameterList parameters,
      final LDAPConnection connection,
      final ArrayList<String> outputMessages) {
    boolean successful = true;

    // Ensure that the parent DN exists.
    StringParameter parentDNParam = parameters.getStringParameter(parentDNParameter.getName());
    if ((parentDNParam != null) && parentDNParam.hasValue()) {
      try {
        String base = parentDNParam.getStringValue();
        outputMessages.add("Ensuring that parent entry '" + base + "' exists....");
        SearchResultEntry e = connection.getEntry(base);
        if (e == null) {
          outputMessages.add("ERROR:  The parent entry does not exist.");
          successful = false;
        } else {
          outputMessages.add("The parent entry exists.");
        }
      } catch (Exception e) {
        successful = false;
        outputMessages.add("Unable to perform the search:  " + stackTraceToString(e));
      }

      outputMessages.add("");
    }

    return successful;
  }
Ejemplo n.º 2
0
  /** {@inheritDoc} */
  @Override()
  protected void validateNonLDAPJobInfo(
      final int numClients,
      final int threadsPerClient,
      final int threadStartupDelay,
      final Date startTime,
      final Date stopTime,
      final int duration,
      final int collectionInterval,
      final ParameterList parameters)
      throws InvalidValueException {
    // Make sure that neither a stop time nor a duration were specified.
    if ((stopTime != null) || (duration > 0)) {
      throw new InvalidValueException(
          "Neither a stop time nor a duration " + "may be defined when scheduling this job.");
    }

    // Make sure that the upper bound is greater than the lower bound.
    IntegerParameter lowerParam = parameters.getIntegerParameter(lowerBoundParameter.getName());
    IntegerParameter upperParam = parameters.getIntegerParameter(upperBoundParameter.getName());
    if (lowerParam.getIntValue() >= upperParam.getIntValue()) {
      throw new InvalidValueException("The upper bound must be greater than " + "the lower bound.");
    }
  }
  /**
   * Initializes this optimization algorithm with the provided set of parameters for the given
   * optimizing job.
   *
   * @param optimizingJob The optimizing job with which this optimization algorithm will be used.
   * @param parameters The parameter list containing the parameter values provided by the end user
   *     when scheduling the optimizing job.
   * @throws InvalidValueException If the contents of the provided parameter list are not valid for
   *     use with this optimization algorithm.
   */
  @Override()
  public void initializeOptimizationAlgorithm(OptimizingJob optimizingJob, ParameterList parameters)
      throws InvalidValueException {
    this.optimizingJob = optimizingJob;

    String[] monitorClients = optimizingJob.getResourceMonitorClients();
    if ((monitorClients == null) || (monitorClients.length == 0)) {
      throw new InvalidValueException(
          "No resource monitor clients have been "
              + "requested for this optimizing job.  "
              + "At least one is required to provide "
              + "replication latency data.");
    }

    // Get the optimization statistic parameter and name.
    optimizeStatParameter = parameters.getMultiChoiceParameter(PARAM_OPTIMIZE_STAT);
    if ((optimizeStatParameter == null) || (!optimizeStatParameter.hasValue())) {
      throw new InvalidValueException("No value provided for the statistic " + "to optimize");
    }
    optimizeStat = optimizeStatParameter.getStringValue();

    // Get the optimization type parameter and value.
    optimizeTypeParameter = parameters.getMultiChoiceParameter(PARAM_OPTIMIZE_TYPE);
    if ((optimizeTypeParameter == null) || (!optimizeTypeParameter.hasValue())) {
      throw new InvalidValueException("No value provided for the " + "optimization type");
    }
    String optimizeTypeStr = optimizeTypeParameter.getStringValue();
    if (optimizeTypeStr.equalsIgnoreCase(Constants.OPTIMIZE_TYPE_MAXIMIZE)) {
      optimizeType = OPTIMIZE_TYPE_MAXIMIZE;
    } else if (optimizeTypeStr.equalsIgnoreCase(Constants.OPTIMIZE_TYPE_MINIMIZE)) {
      optimizeType = OPTIMIZE_TYPE_MINIMIZE;
    } else {
      throw new InvalidValueException(
          "Invalid value \"" + optimizeTypeStr + "\" for optimization type.");
    }

    // Get the maximum percent increase parameter and value.
    maxIncreaseParameter = parameters.getFloatParameter(PARAM_MAX_PERCENT_INCREASE);
    if ((maxIncreaseParameter == null) || (!maxIncreaseParameter.hasValue())) {
      throw new InvalidValueException(
          "No value provided for the maximum "
              + "allowed percentage increase in "
              + "replication latency.");
    }
    maxIncrease = maxIncreaseParameter.getFloatValue();

    // Get the maximum latency parameter and value.
    maxLatencyParameter = parameters.getFloatParameter(PARAM_MAX_REPLICA_LATENCY);
    if ((maxLatencyParameter == null) || (!maxLatencyParameter.hasValue())) {
      maxLatency = -1.0;
    } else {
      maxLatency = maxLatencyParameter.getFloatValue();
    }

    // Get the minimum percent improvement required for a new best iteration.
    minPctImprovement = 0.0F;
    minPctImprovementParameter = parameters.getFloatParameter(PARAM_MIN_PCT_IMPROVEMENT);
    if ((minPctImprovementParameter != null) && minPctImprovementParameter.hasValue()) {
      minPctImprovement = minPctImprovementParameter.getFloatValue();
    }

    // See If the provided optimizing job has run any iterations so far.  If so,
    // then look through them to determine the best value so far.
    bestValueSoFar = Double.NaN;
    Job[] iterations = optimizingJob.getAssociatedJobs();
    if (iterations != null) {
      for (int i = 0; i < iterations.length; i++) {
        try {
          if (!isAcceptableReplicationLatency(iterations[i])) {
            continue;
          }
        } catch (Exception e) {
        }

        StatTracker[] trackers = iterations[i].getStatTrackers(optimizeStat);
        if ((trackers != null) && (trackers.length > 0)) {
          StatTracker tracker = trackers[0].newInstance();
          tracker.aggregate(trackers);
          double value = tracker.getSummaryValue();
          if (Double.isNaN(bestValueSoFar)) {
            bestValueSoFar = value;
          } else if ((optimizeType == OPTIMIZE_TYPE_MAXIMIZE)
              && (value > bestValueSoFar)
              && (value >= (bestValueSoFar + bestValueSoFar * minPctImprovement))) {
            bestValueSoFar = value;
          } else if ((optimizeType == OPTIMIZE_TYPE_MINIMIZE)
              && (value < bestValueSoFar)
              && (value <= (bestValueSoFar - bestValueSoFar * minPctImprovement))) {
            bestValueSoFar = value;
          }
        }
      }
    }

    SLAMDServer slamdServer = optimizingJob.slamdServer;
    slamdServer.logMessage(
        Constants.LOG_LEVEL_JOB_DEBUG,
        "SingleStatisticWithReplicationLatencyOptimization"
            + "Algorithm.initializeOptimizationAlgorith("
            + optimizingJob.getOptimizingJobID()
            + ") best so far is "
            + String.valueOf(bestValueSoFar));
  }
Ejemplo n.º 4
0
  /** {@inheritDoc} */
  @Override()
  protected void initializeClientNonLDAP(final String clientID, final ParameterList parameters)
      throws UnableToRunException {
    activeThreads = new AtomicInteger(getClientSideJob().getThreadsPerClient());

    rdnAttributeParameter = parameters.getStringParameter(rdnAttributeParameter.getName());
    rdnAttribute = rdnAttributeParameter.getStringValue();

    rdnValuePrefix = "";
    rdnPrefixParameter = parameters.getStringParameter(rdnPrefixParameter.getName());
    if ((rdnPrefixParameter != null) && rdnPrefixParameter.hasValue()) {
      rdnValuePrefix = rdnPrefixParameter.getStringValue();
    }

    lowerBoundParameter = parameters.getIntegerParameter(lowerBoundParameter.getName());
    lowerBound = lowerBoundParameter.getIntValue();
    entryNumber = new AtomicInteger(lowerBound);

    upperBoundParameter = parameters.getIntegerParameter(upperBoundParameter.getName());
    upperBound = upperBoundParameter.getIntValue();

    rdnValueSuffix = "";
    rdnSuffixParameter = parameters.getStringParameter(rdnSuffixParameter.getName());
    if ((rdnSuffixParameter != null) && rdnSuffixParameter.hasValue()) {
      rdnValueSuffix = rdnSuffixParameter.getStringValue();
    }

    parentDNParameter = parameters.getStringParameter(parentDNParameter.getName());
    parentDN = parentDNParameter.getStringValue();

    responseTimeThreshold = -1;
    thresholdParameter = parameters.getIntegerParameter(thresholdParameter.getName());
    if ((thresholdParameter != null) && thresholdParameter.hasValue()) {
      responseTimeThreshold = thresholdParameter.getIntValue();
    }

    timeBetweenRequests = 0L;
    timeBetweenRequestsParameter =
        parameters.getIntegerParameter(timeBetweenRequestsParameter.getName());
    if ((timeBetweenRequestsParameter != null) && timeBetweenRequestsParameter.hasValue()) {
      timeBetweenRequests = timeBetweenRequestsParameter.getIntValue();
    }

    rateLimiter = null;
    maxRateParameter = parameters.getIntegerParameter(maxRateParameter.getName());
    if ((maxRateParameter != null) && maxRateParameter.hasValue()) {
      int maxRate = maxRateParameter.getIntValue();
      if (maxRate > 0) {
        int rateIntervalSeconds = 0;
        rateLimitDurationParameter =
            parameters.getIntegerParameter(rateLimitDurationParameter.getName());
        if ((rateLimitDurationParameter != null) && rateLimitDurationParameter.hasValue()) {
          rateIntervalSeconds = rateLimitDurationParameter.getIntValue();
        }

        if (rateIntervalSeconds <= 0) {
          rateIntervalSeconds = getClientSideJob().getCollectionInterval();
        }

        rateLimiter =
            new FixedRateBarrier(rateIntervalSeconds * 1000L, maxRate * rateIntervalSeconds);
      }
    }
  }