Ejemplo n.º 1
0
function create_scribe_client()
{
    try {
        // Set up the socket connections
        $scribe_servers = array('localhost');
        $scribe_ports = array(1463);
        print "creating socket pool\n";
        $sock = new TSocketPool($scribe_servers, $scribe_ports);
        $sock->setDebug(0);
        $sock->setSendTimeout(1000);
        $sock->setRecvTimeout(2500);
        $sock->setNumRetries(1);
        $sock->setRandomize(false);
        $sock->setAlwaysTryLast(true);
        $trans = new TFramedTransport($sock);
        $prot = new TBinaryProtocol($trans);
        // Create the client
        print "creating scribe client\n";
        $scribe_client = new scribeClient($prot);
        // Open the transport (we rely on PHP to close it at script termination)
        print "opening transport\n";
        $trans->open();
    } catch (Exception $x) {
        print "Unable to create global scribe client, received exception: {$x} \n";
        return null;
    }
    return $scribe_client;
}
Ejemplo n.º 2
0
function scribe_Log_test($messages)
{
    if (!isset($GLOBALS['SCRIBE']['SCRIBE_CLIENT_TEST'])) {
        try {
            // Set up the socket connections
            $scribe_servers = array('localhost');
            $scribe_ports = array(1463);
            print "creating socket pool\n";
            $sock = new TSocketPool($scribe_servers, $scribe_ports);
            $sock->setDebug(0);
            $sock->setSendTimeout(100);
            $sock->setRecvTimeout(250);
            $sock->setNumRetries(1);
            $sock->setRandomize(false);
            $sock->setAlwaysTryLast(true);
            $trans = new TFramedTransport($sock);
            $prot = new TBinaryProtocol($trans);
            // Create the client
            print "creating scribe client\n";
            $scribe_client = new scribeClient($prot);
            // Open the transport (we rely on PHP to close it at script termination)
            print "opening transport\n";
            $trans->open();
            // save it for future calls
            $GLOBALS['SCRIBE']['SCRIBE_CLIENT_TEST'] = $scribe_client;
        } catch (Exception $x) {
            print "Unable to create global scribe client, received exception: {$x} \n";
            return;
        }
    } else {
        print "using existing scribe client\n";
        $scribe_client = $GLOBALS['SCRIBE']['SCRIBE_CLIENT_TEST'];
    }
    try {
        print "sending messages\n";
        $result = $scribe_client->Log($messages);
        if ($result != OK) {
            print "Warning: Log returned {$result} \n";
        }
        return $result;
    } catch (Exception $x) {
        print "Scribe client failed logging " . count($messages) . " messages with exception: {$x} \n";
    }
}
Ejemplo n.º 3
0
require_once $GEN_DIR . '/ThriftTest_types.php';
echo '===============================' . "\n";
echo ' END OF SAFE ERRORS SECTION' . "\n";
echo '===============================' . "\n\n";
$host = 'localhost';
$port = 9090;
if ($argc > 1) {
    $host = $argv[0];
}
if ($argc > 2) {
    $host = $argv[1];
}
$hosts = array('localhost');
$socket = new TSocket($host, $port);
$socket = new TSocketPool($hosts, $port);
$socket->setDebug(TRUE);
if ($MODE == 'inline') {
    $transport = $socket;
    $testClient = new ThriftTestClient($transport);
} else {
    $bufferedSocket = new TBufferedTransport($socket, 1024, 1024);
    $transport = $bufferedSocket;
    $protocol = new TBinaryProtocol($transport);
    $testClient = new ThriftTestClient($protocol);
}
$transport->open();
$start = microtime(true);
/**
 * VOID TEST
 */
print_r("testVoid()");