001/*
002 * JPPF.
003 * Copyright (C) 2005-2018 JPPF Team.
004 * http://www.jppf.org
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019package org.jppf.load.balancer.impl;
020
021import org.jppf.load.balancer.*;
022import org.jppf.utils.TypedProperties;
023
024/**
025 * Profile for the "nodethreads" load-balancing algorithm.
026 * @author Laurent Cohen
027 */
028public class NodeThreadsProfile extends AbstractLoadBalancingProfile {
029  /**
030   * Explicit serialVersionUID.
031   */
032  private static final long serialVersionUID = 1L;
033  /**
034   * The multiplicator for the number of threads in the node.
035   * The max number of tasks sent to the node will be <code>multiplicator * number_of_threads</code>.
036   */
037  private int multiplicator = 1;
038
039  /**
040   * Default constructor.
041   */
042  public NodeThreadsProfile() {
043  }
044
045  /**
046   * Initialize this profile with values read from the specified configuration.
047   * @param config contains a mapping of the profile parameters to their value.
048   */
049  public NodeThreadsProfile(final TypedProperties config) {
050    multiplicator = config.getInt("multiplicator", 1);
051    if (multiplicator < 1) multiplicator = 1;
052  }
053
054  /**
055   * Get the multiplicator for the number of threads in the node.
056   * @return the multiplicator size as an int.
057   */
058  public int getMultiplicator() {
059    return multiplicator;
060  }
061
062  /**
063   * Set the multiplicator for the number of threads in the node.
064   * @param multiplicator the bundle size as an int.
065   */
066  public void setMultiplicator(final int multiplicator) {
067    if (multiplicator >= 1) this.multiplicator = multiplicator;
068  }
069}