001 /* 002 * $RCSfile: SimpleDispatcherChooser.java,v $ 003 * 004 * Created on September 3, 2003, 11:36 AM 005 * 006 * This file is part of the STAR Scheduler. 007 * Copyright (c) 2002-2006 STAR Collaboration - Brookhaven National Laboratory 008 * 009 * STAR Scheduler is free software; you can redistribute it and/or modify 010 * it under the terms of the GNU General Public License as published by 011 * the Free Software Foundation; either version 2 of the License, or 012 * (at your option) any later version. 013 * 014 * STAR Scheduler is distributed in the hope that it will be useful, 015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 017 * GNU General Public License for more details. 018 * 019 * You should have received a copy of the GNU General Public License 020 * along with STAR Scheduler; if not, write to the Free Software 021 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 022 */ 023 024 package gov.bnl.star.offline.scheduler.bnl; 025 026 import gov.bnl.star.offline.scheduler.*; 027 import gov.bnl.star.offline.scheduler.Dispatchers.condorg.*; 028 import gov.bnl.star.offline.scheduler.Dispatchers.lsf.*; 029 030 import gov.bnl.star.offline.scheduler.request.Request; 031 032 import java.util.*; 033 import java.util.logging.Level; 034 import java.util.logging.Logger; 035 036 /** DEPRECATED: use ClusterAssignmentByPercentagePolicy instead. 037 * 038 * @author carcassi 039 * @version $Revision: 1.7 $ $Date: 2006/11/21 00:41:31 $ 040 */ 041 public class SimpleDispatcherChooser implements DispatcherChooser { 042 static private Logger log = Logger.getLogger(SimpleDispatcherChooser.class.getName()); 043 044 private Random rand = new Random(); 045 046 private String queueToRedirect; 047 private String cluster; 048 private String redirectedCluster; 049 private double redirectedPercentage; 050 051 public String chooseDispatcher(Request request, Job job) { 052 // TODO: This is a hack. The queue should be chosen at a different stage, 053 // in the LSFDispatcher parameters 054 if (getQueueToRedirect().equals(job.getQueue())) { 055 if (rand.nextFloat() < getRedirectedPercentage()) { 056 job.setCluster(getRedirectedCluster()); 057 return getRedirectedCluster(); 058 } else { 059 job.setCluster(getCluster()); 060 return getCluster(); 061 } 062 } 063 job.setCluster(getCluster()); 064 return getCluster(); 065 } 066 067 /** Getter for property queueToRedirect. 068 * @return Value of property queueToRedirect. 069 * 070 */ 071 public String getQueueToRedirect() { 072 return this.queueToRedirect; 073 } 074 075 /** Setter for property queueToRedirect. 076 * @param queueToRedirect New value of property queueToRedirect. 077 * 078 */ 079 public void setQueueToRedirect(String queueToRedirect) { 080 this.queueToRedirect = queueToRedirect; 081 } 082 083 /** Getter for property cluster. 084 * @return Value of property cluster. 085 * 086 */ 087 public String getCluster() { 088 return this.cluster; 089 } 090 091 /** Setter for property cluster. 092 * @param cluster New value of property cluster. 093 * 094 */ 095 public void setCluster(String cluster) { 096 this.cluster = cluster; 097 } 098 099 /** Getter for property redirectedCluster. 100 * @return Value of property redirectedCluster. 101 * 102 */ 103 public String getRedirectedCluster() { 104 return this.redirectedCluster; 105 } 106 107 /** Setter for property redirectedCluster. 108 * @param redirectedCluster New value of property redirectedCluster. 109 * 110 */ 111 public void setRedirectedCluster(String redirectedCluster) { 112 this.redirectedCluster = redirectedCluster; 113 } 114 115 /** Getter for property redirectedPercentage. 116 * @return Value of property redirectedPercentage. 117 * 118 */ 119 public double getRedirectedPercentage() { 120 return this.redirectedPercentage; 121 } 122 123 /** Setter for property redirectedPercentage. 124 * @param redirectedPercentage New value of property redirectedPercentage. 125 * 126 */ 127 public void setRedirectedPercentage(double redirectedPercentage) { 128 this.redirectedPercentage = redirectedPercentage; 129 } 130 131 }