-//
-// @file schedule_module_lc.h
-// @brief shared object schedule module class
-//
-// copyright (c) xxx corporation. 2009
-// mail:
-//
-// Distributed under the Boost Software License, Version 1.0.(See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
-//
+/*
+ * @file schedule_module_lc.h
+ * @brief shared object schedule module class
+ *\r
+ * L7VSD: Linux Virtual Server for Layer7 Load Balancing\r
+ * Copyright (C) 2009 NTT COMWARE Corporation.\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Lesser General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2.1 of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Lesser General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Lesser General Public\r
+ * License along with this library; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\r
+ * 02110-1301 USA\r
+ *\r
+ **********************************************************************/\r
#include "schedule_module_lc.h"
+#include <boost/format.hpp>
namespace l7vs{
//! initialize function
void schedule_module_least_connection::initialize(){
+ if ( !getloglevel.empty() ){
+ if ( LOG_LV_DEBUG == getloglevel() ){
+ if ( !putLogDebug.empty() ){
+ putLogDebug( 1, "Function in : schedule_module_least_connection::initialize", __FILE__, __LINE__);
+ }
+ }
+ }
+
if ( !putLogInfo.empty() )
{
putLogInfo( 1, "Function was initialized.", __FILE__, __LINE__);
}
+
+ if ( !getloglevel.empty() ){
+ if ( LOG_LV_DEBUG == getloglevel() ){
+ if ( !putLogDebug.empty() ){
+ putLogDebug( 1, "Function out : schedule_module_least_connection::initialize", __FILE__, __LINE__);
+ }
+ }
+ }
}
//! tcp protocol support check
rslist_iterator_end_func_type inlist_end,
rslist_iterator_next_func_type inlist_next,
boost::asio::ip::tcp::endpoint& outendpoint ){
+ if ( !getloglevel.empty() ){
+ if ( LOG_LV_DEBUG == getloglevel() ){
+ if ( !putLogDebug.empty() ){
+ putLogDebug( 1, "Function in : schedule_module_least_connection::handle_schedule", __FILE__, __LINE__);
+ }
+ }
+ }
+
boost::asio::ip::tcp::endpoint tcp_local_endpoint ;
int active = INT_MAX;
rslist_type::iterator itr;
+ std::string buf;
+ int loop;
//! set clear data as NULL
outendpoint = tcp_local_endpoint;
{
putLogFatal( 1, "Iterator function is empty.", __FILE__, __LINE__);
}
- return;
+ goto END;
}
+ //! Debug log
+ if ( !getloglevel.empty() ){
+ if ( LOG_LV_DEBUG == getloglevel() ){
+ if ( !putLogDebug.empty() ){
+ for ( loop = 1, itr = inlist_begin(); itr != inlist_end(); itr = inlist_next( itr ), loop++ ){
+ buf = boost::io::str( boost::format( "realserver[%d] : %s:%d weight(%d)" )
+ % loop
+ % itr->tcp_endpoint.address()
+ % itr->tcp_endpoint.port()
+ % itr->weight );
+ putLogDebug( 1, buf, __FILE__, __LINE__);
+ }
+ }
+ }
+ }
+ //! Debug log END
+
for ( itr = inlist_begin(); itr != inlist_end(); itr = inlist_next(itr) ){
if ( itr->weight > 0 && active > itr->get_active() ){
//! set found data
{
putLogError( 1, "There is no realserver on list.", __FILE__, __LINE__);
}
- return;
+ goto END;
+ }
+
+END:
+ if ( !getloglevel.empty() ){
+ if ( LOG_LV_DEBUG == getloglevel() ){
+ if ( !putLogDebug.empty() ){
+ putLogDebug( 1, "Function out : schedule_module_least_connection::handle_schedule", __FILE__, __LINE__);
+ }
+ }
}
}
rslist_iterator_end_func_type inlist_end,
rslist_iterator_next_func_type inlist_next,
boost::asio::ip::udp::endpoint& outendpoint ){
+ if ( !getloglevel.empty() ){
+ if ( LOG_LV_DEBUG == getloglevel() ){
+ if ( !putLogDebug.empty() ){
+ putLogDebug( 1, "Function in : schedule_module_least_connection::handle_schedule", __FILE__, __LINE__);
+ }
+ }
+ }
+
if ( !putLogWarn.empty() )
{
putLogWarn( 1, "UDP function was not supported.", __FILE__, __LINE__);
}
+
+ if ( !getloglevel.empty() ){
+ if ( LOG_LV_DEBUG == getloglevel() ){
+ if ( !putLogDebug.empty() ){
+ putLogDebug( 1, "Function out : schedule_module_least_connection::handle_schedule", __FILE__, __LINE__);
+ }
+ }
+ }
}
//! replication interval interrrupt
-//
-// @file schedule_module_rr.cpp
-// @brief shared object schedule module class
-//
-// copyright (c) xxx corporation. 2009
-// mail:
-//
-// Distributed under the Boost Software License, Version 1.0.(See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
-//
+/*
+ * @file schedule_module_rr.cpp
+ * @brief shared object schedule module class
+ *
+ * L7VSD: Linux Virtual Server for Layer7 Load Balancing\r
+ * Copyright (C) 2009 NTT COMWARE Corporation.\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Lesser General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2.1 of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Lesser General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Lesser General Public\r
+ * License along with this library; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\r
+ * 02110-1301 USA\r
+ *\r
+ **********************************************************************/\r
#include "schedule_module_rr.h"
+#include <boost/format.hpp>
namespace l7vs{
//! initialize function
void schedule_module_round_robin::initialize(){
+ if ( !getloglevel.empty() ){
+ if ( LOG_LV_DEBUG == getloglevel() ){
+ if ( !putLogDebug.empty() ){
+ putLogDebug( 1, "Function in : schedule_module_round_robin::initialize", __FILE__, __LINE__);
+ }
+ }
+ }
+
boost::asio::ip::tcp::endpoint tcp_local_endpoint ;
boost::asio::ip::udp::endpoint udp_local_endpoint ;
{
putLogInfo( 1, "Saved endpoint was initialized.", __FILE__, __LINE__);
}
+
+ if ( !getloglevel.empty() ){
+ if ( LOG_LV_DEBUG == getloglevel() ){
+ if ( !putLogDebug.empty() ){
+ putLogDebug( 1, "Function out : schedule_module_round_robin::initialize", __FILE__, __LINE__);
+ }
+ }
+ }
}
//! tcp protocol support check
rslist_iterator_end_func_type inlist_end,
rslist_iterator_next_func_type inlist_next,
boost::asio::ip::tcp::endpoint& outendpoint ){
+ if ( !getloglevel.empty() ){
+ if ( LOG_LV_DEBUG == getloglevel() ){
+ if ( !putLogDebug.empty() ){
+ putLogDebug( 1, "Function in : schedule_module_round_robin::handle_schedule", __FILE__, __LINE__);
+ }
+ }
+ }
+
boost::asio::ip::tcp::endpoint tcp_local_endpoint ;
rslist_type::iterator itr;
+ std::string buf;
+ int loop;
//! set clear data as NULL
outendpoint = tcp_local_endpoint;
{
putLogFatal( 1, "Iterator function is empty.", __FILE__, __LINE__);
}
- return;
+ goto END;
}
+ //! Debug log
+ if ( !getloglevel.empty() ){
+ if ( LOG_LV_DEBUG == getloglevel() ){
+ if ( !putLogDebug.empty() ){
+ for ( loop = 1, itr = inlist_begin(); itr != inlist_end(); itr = inlist_next( itr ), loop++ ){
+ buf = boost::io::str( boost::format( "realserver[%d] : %s:%d weight(%d)" )
+ % loop
+ % itr->tcp_endpoint.address()
+ % itr->tcp_endpoint.port()
+ % itr->weight );
+ putLogDebug( 1, buf, __FILE__, __LINE__);
+ }
+ }
+ }
+ }
+ //! Debug log END
+
for ( itr = inlist_begin(); itr != inlist_end(); itr = inlist_next( itr ) ){
//! keep first data of list
if ( itr->weight > 0 ){
{
putLogError( 1, "There is no realserver on list.", __FILE__, __LINE__);
}
- return;
+ goto END;
}
//! first time
if ( tcp_local_endpoint == tcp_endpoint ){
//! set first data
tcp_endpoint = outendpoint;
- return;
+ goto END;
}
+ //! Debug log
+ if ( !getloglevel.empty() ){
+ if ( LOG_LV_DEBUG == getloglevel() ){
+ if ( !putLogDebug.empty() ){
+ buf = boost::io::str( boost::format( "previous endpoint : %s:%d" )
+ % tcp_endpoint.address()
+ % tcp_endpoint.port() );
+ putLogDebug( 1, buf, __FILE__, __LINE__);
+ }
+ }
+ }
+ //! Debug log END
+
for ( ; itr != inlist_end(); itr = inlist_next( itr ) ){
if ( itr->weight > 0 ){
//! prev endpoint
}
for ( ; itr != inlist_end(); itr = inlist_next( itr ) ){
if ( itr->weight > 0 ){
+
+ //! Debug log
+ if ( !getloglevel.empty() ){
+ if ( LOG_LV_DEBUG == getloglevel() ){
+ if ( !putLogDebug.empty() ){
+ buf = boost::io::str( boost::format( "itr : %s:%d weight(%d)" )
+ % itr->tcp_endpoint.address()
+ % itr->tcp_endpoint.port()
+ % itr->weight );
+ putLogDebug( 1, buf, __FILE__, __LINE__);
+ }
+ }
+ }
+ //! Debug log END
+
//! set found data
outendpoint = itr->tcp_endpoint;
break ;
//! set found or first data
tcp_endpoint = outendpoint;
+
+END:
+ if ( !getloglevel.empty() ){
+ if ( LOG_LV_DEBUG == getloglevel() ){
+ if ( !putLogDebug.empty() ){
+ putLogDebug( 1, "Function out : schedule_module_round_robin::handle_schedule", __FILE__, __LINE__);
+ }
+ }
+ }
}
//! handle schedule calles then schedule function for UDP endpoint
rslist_iterator_end_func_type inlist_end,
rslist_iterator_next_func_type inlist_next,
boost::asio::ip::udp::endpoint& outendpoint ){
+ if ( !getloglevel.empty() ){
+ if ( LOG_LV_DEBUG == getloglevel() ){
+ if ( !putLogDebug.empty() ){
+ putLogDebug( 1, "Function in : schedule_module_round_robin::handle_schedule", __FILE__, __LINE__);
+ }
+ }
+ }
+
boost::asio::ip::udp::endpoint udp_local_endpoint ;
rslist_type::iterator itr;
+ std::string buf;
+ int loop;
//! set clear data as NULL
outendpoint = udp_local_endpoint;
{
putLogFatal( 1, "Iterator function is empty.", __FILE__, __LINE__);
}
- return;
+ goto END;
+ }
+
+ //! Debug log
+ if ( !getloglevel.empty() ){
+ if ( LOG_LV_DEBUG == getloglevel() ){
+ if ( !putLogDebug.empty() ){
+ for ( loop = 1, itr = inlist_begin(); itr != inlist_end(); itr = inlist_next( itr ), loop++ ){
+ buf = boost::io::str( boost::format( "realserver[%d] : %s:%d weight(%d)" )
+ % loop
+ % itr->udp_endpoint.address()
+ % itr->udp_endpoint.port()
+ % itr->weight );
+ putLogDebug( 1, buf, __FILE__, __LINE__);
+ }
+ }
+ }
}
+ //! Debug log END
for ( itr = inlist_begin(); itr != inlist_end(); itr = inlist_next( itr ) ){
//! keep first data of list
{
putLogError( 1, "There is no realserver on list.", __FILE__, __LINE__);
}
- return;
+ goto END;
}
//! first time
if ( udp_local_endpoint == udp_endpoint ){
//! set first data
udp_endpoint = outendpoint;
- return;
+ goto END;
}
+ //! Debug log
+ if ( !getloglevel.empty() ){
+ if ( LOG_LV_DEBUG == getloglevel() ){
+ if ( !putLogDebug.empty() ){
+ buf = boost::io::str( boost::format( "previous endpoint : %s:%d" )
+ % udp_endpoint.address()
+ % udp_endpoint.port() );
+ putLogDebug( 1, buf, __FILE__, __LINE__);
+ }
+ }
+ }
+ //! Debug log END
+
for ( ; itr != inlist_end(); itr = inlist_next( itr ) ){
if ( itr->weight > 0 ){
//! prev endpoint
}
for ( ; itr != inlist_end(); itr = inlist_next( itr ) ){
if ( itr->weight > 0 ){
+
+ //! Debug log
+ if ( !getloglevel.empty() ){
+ if ( LOG_LV_DEBUG == getloglevel() ){
+ if ( !putLogDebug.empty() ){
+ buf = boost::io::str( boost::format( "itr : %s:%d weight(%d)" )
+ % itr->udp_endpoint.address()
+ % itr->udp_endpoint.port()
+ % itr->weight );
+ putLogDebug( 1, buf, __FILE__, __LINE__);
+ }
+ }
+ }
+ //! Debug log END
+
//! set found data
outendpoint = itr->udp_endpoint;
break ;
//! set found or first data
udp_endpoint = outendpoint;
+
+END:
+ if ( !getloglevel.empty() ){
+ if ( LOG_LV_DEBUG == getloglevel() ){
+ if ( !putLogDebug.empty() ){
+ putLogDebug( 1, "Function out : schedule_module_round_robin::handle_schedule", __FILE__, __LINE__);
+ }
+ }
+ }
}
//! replication interval interrrupt