001/*
002 * JPPF.
003 * Copyright (C) 2005-2019 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 fixed bundle size load-balancing algorithm.
026 * @author Laurent Cohen
027 */
028public class FixedSizeProfile extends AbstractLoadBalancingProfile {
029  /**
030   * Explicit serialVersionUID.
031   */
032  private static final long serialVersionUID = 1L;
033  /**
034   * The bundle size.
035   */
036  private final int size;
037
038  /**
039   * Initialize this profile with values read from the specified configuration.
040   * @param config contains a mapping of the profile parameters to their value.
041   */
042  public FixedSizeProfile(final TypedProperties config) {
043    final int n = config.getInt("size", 1);
044    this.size = (n < 1) ? 1 : n; 
045  }
046
047  /**
048   * Get the bundle size.
049   * @return the bundle size as an int.
050   */
051  public int getSize() {
052    return size;
053  }
054}