Ejemplo n.º 1
0
    echo "Test failure: [{$errno}] {$errstr}\non line {$errline} in file {$errfile}";
    echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
    echo "Aborting...<br />\n";
    exit(1);
    //}
}
set_error_handler("test_failure");
/* basic functionality testing.  could be much improved
   with something like PHPunit
*/
require_once '../src/Instrumentation.php';
echo "This script uses the default mysql connection settings from the php.ini file.\n";
echo "The only query which will be executed is 'SELECT 1'\n\n";
echo "-- BEGIN --\n";
$instance = false;
$instance = Instrumentation::get_instance();
assert($instance !== false);
$instance->start_request();
echo " * Test setting a counter to a value\n";
$instance->set('test_counter', 'abc');
assert($instance->get('test_counter') == 'abc');
echo "* Incrementing an non-existing counter sets the counter to 1\n";
$instance->increment('empty_counter');
assert($instance->get('empty_counter') == 1);
echo "* Test setting to empty string and appending a string\n";
$instance->set('test_counter', '');
$instance->append('test_counter', 'abc');
assert($instance->get('test_counter') == 'abc');
echo "* Test the timer functionality\n";
$instance->timer();
sleep(1);
 public static function mysql_unbuffered_query($sql, $conn = false)
 {
     $instance = Instrumentation::get_instance();
     $retry_count = 0;
     while ($retry_count < MySQL_perf::$deadlock_try_limit) {
         $instance->increment('mysql_query_count', 1);
         $sql = $instance->instrument_query($sql, $retry_count);
         $result = false;
         $errno = -1;
         $instance->timer();
         if ($conn !== false) {
             $result = mysql_unbuffered_query($sql, $conn);
             $errno = mysql_errno($conn);
         } else {
             $result = mysql_unbuffered_query($sql);
             $errno = mysql_errno($conn);
         }
         $time = $instance->timer();
         $instance->increment('mysql_query_exec_time', $time);
         $instance->push_query_log($sql, $time);
         if ($errno == 1213) {
             // 1213 (ER_LOCK_DEADLOCK)
             //Deadlock detected retry operation
             ++$retry_count;
             continue;
             // loop to the start of the while loop
         }
         break;
         /* exit loop to return result */
     }
     return $result;
 }
Ejemplo n.º 3
0
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*This script requires PEAR Net_Gearman */
/*It also requires Console_Getopt, but this should be installed by default with pear */
require_once 'instrumentation.php';
#new bsd Instrumentation-for-PHP
Instrumentation::get_instance()->start_request();
require 'const.php';
require_once 'Console/Getopt.php';
require_once 'Net/Gearman/Client.php';
require_once 'DAL/simple-dal.php';
require_once 'PHP-SQL-Parser/src/PHPSQLParser.php';
require_once 'shard-key-mapper.php';
require_once 'custom_functions.php';
function &get_commandline($more_longopts = array())
{
    $cg = new Console_Getopt();
    $args = $cg->readPHPArgv();
    array_shift($args);
    $shortOpts = 'h::v::';
    $longOpts = array('user='******'ini=', 'password='******'host=', 'db=', 'port=', 'help==', 'verbose==', 'method=', 'gearman=', 'inlist=', 'between=', 'directory=', 'push_where', 'inlist_merge_threshold==', 'inlist_merge_size==', 'coord_engine==', 'schema=', 'batch');
    $longOpts = array_merge($longOpts, $more_longopts);