00001 /* 00002 // $Id: //open/dev/fennel/device/DeviceAccessSchedulerParams.cpp#11 $ 00003 // Fennel is a library of data storage and processing components. 00004 // Copyright (C) 2005-2009 The Eigenbase Project 00005 // Copyright (C) 2005-2009 SQLstream, Inc. 00006 // Copyright (C) 2005-2009 LucidEra, Inc. 00007 // Portions Copyright (C) 1999-2009 John V. Sichi 00008 // 00009 // This program is free software; you can redistribute it and/or modify it 00010 // under the terms of the GNU General Public License as published by the Free 00011 // Software Foundation; either version 2 of the License, or (at your option) 00012 // any later version approved by The Eigenbase Project. 00013 // 00014 // This program is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 // GNU General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU General Public License 00020 // along with this program; if not, write to the Free Software 00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 */ 00023 00024 #include "fennel/common/CommonPreamble.h" 00025 #include "fennel/device/DeviceAccessSchedulerParams.h" 00026 #include "fennel/common/ConfigMap.h" 00027 #include "fennel/common/FennelExcn.h" 00028 #include "fennel/common/FennelResource.h" 00029 00030 FENNEL_BEGIN_CPPFILE("$Id: //open/dev/fennel/device/DeviceAccessSchedulerParams.cpp#11 $"); 00031 00032 ParamName DeviceAccessSchedulerParams::paramSchedulerType = 00033 "deviceSchedulerType"; 00034 ParamName DeviceAccessSchedulerParams::paramThreadCount = 00035 "deviceSchedulerThreadCount"; 00036 ParamName DeviceAccessSchedulerParams::paramMaxRequests = 00037 "deviceSchedulerMaxRequests"; 00038 00039 ParamVal DeviceAccessSchedulerParams::valThreadPoolScheduler = "threadPool"; 00040 ParamVal DeviceAccessSchedulerParams::valIoCompletionPortScheduler = 00041 "ioCompletionPort"; 00042 ParamVal DeviceAccessSchedulerParams::valAioPollingScheduler = "aioPolling"; 00043 ParamVal DeviceAccessSchedulerParams::valAioSignalScheduler = "aioSignal"; 00044 ParamVal DeviceAccessSchedulerParams::valAioLinuxScheduler = "aioLinux"; 00045 00046 DeviceAccessSchedulerParams::DeviceAccessSchedulerParams() 00047 { 00048 #ifdef __MSVC__ 00049 schedulerType = IO_COMPLETION_PORT_SCHEDULER; 00050 #elif defined(USE_LIBAIO_H) 00051 schedulerType = AIO_LINUX_SCHEDULER; 00052 #else 00053 schedulerType = THREAD_POOL_SCHEDULER; 00054 #endif 00055 nThreads = 1; 00056 maxRequests = 1024; 00057 usingDefaultSchedulerType = true; 00058 } 00059 00060 void DeviceAccessSchedulerParams::readConfig(ConfigMap const &configMap) 00061 { 00062 usingDefaultSchedulerType = false; 00063 std::string s = configMap.getStringParam(paramSchedulerType); 00064 if (s == valThreadPoolScheduler) { 00065 schedulerType = THREAD_POOL_SCHEDULER; 00066 } else if (s == valAioPollingScheduler) { 00067 schedulerType = AIO_POLLING_SCHEDULER; 00068 } else if (s == valAioSignalScheduler) { 00069 schedulerType = AIO_SIGNAL_SCHEDULER; 00070 } else if (s == valAioLinuxScheduler) { 00071 schedulerType = AIO_LINUX_SCHEDULER; 00072 } else if (s == valIoCompletionPortScheduler) { 00073 schedulerType = IO_COMPLETION_PORT_SCHEDULER; 00074 } else { 00075 // treat unrecognized as default 00076 usingDefaultSchedulerType = true; 00077 } 00078 nThreads = configMap.getIntParam( 00079 paramThreadCount,nThreads); 00080 maxRequests = configMap.getIntParam( 00081 paramMaxRequests,maxRequests); 00082 } 00083 00084 FENNEL_END_CPPFILE("$Id: //open/dev/fennel/device/DeviceAccessSchedulerParams.cpp#11 $"); 00085 00086 // End DeviceAccessSchedulerParams.cpp