001 /* 002 * $RCSfile: QueryStrategyFactory.java,v $ 003 * 004 * Created on March 13, 2003, 10:08 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.catalog; 025 026 import gov.bnl.star.offline.scheduler.CatalogQuery; 027 import org.apache.log4j.Logger; 028 029 /** @deprecated please see gov.bnl.star.offline.scheduler.dataset.* for replacements. 030 * 031 * @author Gabriele Carcassi 032 * @version $Revision: 1.7 $ $Date: 2006/11/21 00:41:31 $ 033 */ 034 public class QueryStrategyFactory { 035 static private Logger log = Logger.getLogger(QueryStrategyFactory.class.getName()); 036 037 public static QueryStrategy createStrategy(CatalogQuery query) { 038 switch (query.getCountingType()) { 039 case CatalogQuery.NO_COUNTING: 040 log.debug("NO_COUNTING: using StopWhenSatisfiedStrategy with 100 files"); 041 query.setNFiles(new Integer(100)); 042 return new StopWhenSatisfiedStrategy(); 043 case CatalogQuery.START_LIMIT_COUNTING: 044 log.debug("START_LIMIT_COUNTING: using StartLimitSatisfiedStrategy"); 045 return new StartLimitStrategy(); 046 case CatalogQuery.NFILES_COUNTING: 047 if (query.getNFiles().intValue() == -1) { 048 log.debug("NFILES_COUNTING with all: using AllFilesStrategy"); 049 return new AllFilesStrategy(); 050 } else { 051 log.debug("NFILES_COUNTING: using StopWhenSatisfiedStrategy"); 052 return new StopWhenSatisfiedStrategy(); 053 } 054 default: 055 log.warn("The query didn't have a valid counting type: " + query.getCountingType()); 056 log.info("Number of files found : 0"); 057 return null; 058 } 059 } 060 061 }