CCM::setupUserDefinedFunctions PHP Method

setupUserDefinedFunctions() public method

    public function setupUserDefinedFunctions()
    {
        $this->ssl = false;
        $this->clientAuth = false;
        $this->internalSetup(1, 0);
        if (version_compare($this->version, "2.2.0", ">=")) {
            $this->run('updateconf', 'enable_user_defined_functions: true');
        }
        if (version_compare($this->version, "3.0.0", ">=")) {
            $this->run('updateconf', 'enable_scripted_user_defined_functions: true');
        }
    }

Usage Example

コード例 #1
0
ファイル: Integration.php プロジェクト: datastax/php-driver
 /**
  * Create the integration helper instance.
  *
  * @param $className Name of the class for the executed test.
  * @param string $testName Name of the test being executed.
  * @param int $numberDC1Nodes Number of nodes in data center one
  *                            (DEFAULT: 1).
  * @param int $numberDC2Nodes Number of nodes in data center two
  *                            (DEFAULT: 0).
  * @param int $replicationFactor Replication factor override; default is
  *                               calculated based on number of data center
  *                               nodes; single data center is (nodes / 2)
  *                               rounded up.
  * @param bool $isClientAuthentication True if client authentication
  *                                     should be enabled; false
  *                                     otherwise (DEFAULT: false).
  * @param bool $isSSL True if SSL should be enabled; false otherwise
  *                    (DEFAULT: false).
  * @param bool $isUserDefinedAggregatesFunctions True if UDA/UDF
  *                                               functionality should be
  *                                               enabled; false otherwise
  *                                               (DEFAULT: false).
  * @return Integration Instance of the Integration class created.
  */
 public function __construct($className, $testName = "", $numberDC1Nodes = 1, $numberDC2Nodes = 0, $replicationFactor = -1, $isClientAuthentication = false, $isSSL = false, $isUserDefinedAggregatesFunctions = false)
 {
     // Generate the keyspace name for the test
     $this->keyspaceName = $this->getShortName($className);
     if (!empty($testName)) {
         $this->keyspaceName = $this->keyspaceName . "_" . $testName;
     }
     // Make all strings lowercase for case insensitive O/S (e.g. Windows)
     $this->keyspaceName = strtolower($this->keyspaceName);
     //Ensure the keyspace does not contain more to many characters
     if (strlen($this->keyspaceName) > self::KEYSPACE_MAXIMUM_LENGTH) {
         // Update the keyspace name with a unique ID
         $uniqueID = uniqid();
         $this->keyspaceName = substr($this->keyspaceName, 0, self::KEYSPACE_MAXIMUM_LENGTH - strlen($uniqueID)) . $uniqueID;
     }
     // Create the Cassandra cluster for the test
     //TODO: Need to add the ability to switch the Cassandra version (command line)
     $this->ccm = new \CCM(self::DEFAULT_CASSANDRA_VERSION, self::DEFAULT_IS_CCM_SILENT);
     $this->ccm->setup($numberDC1Nodes, $numberDC2Nodes);
     if ($isClientAuthentication) {
         $this->ccm->setupClientVerification();
     }
     if ($isSSL) {
         $this->ccm->setupSSL();
     }
     if ($isUserDefinedAggregatesFunctions) {
         $this->ccm->setupUserDefinedFunctions();
     }
     $this->ccm->start();
     // Determine replication strategy and generate the query
     $replicationStrategy = "'SimpleStrategy', 'replication_factor': ";
     if ($numberDC2Nodes > 0) {
         $replicationStrategy = "'NetworkTopologyStrategy', 'dc1': " . $numberDC1Nodes . ", " . "'dc2': " . $numberDC2Nodes;
     } else {
         if ($replicationFactor < 0) {
             $replicationFactor = $numberDC1Nodes % 2 == 0 ? $numberDC1Nodes / 2 : ($numberDC1Nodes + 1) / 2;
         }
         $replicationStrategy .= $replicationFactor;
     }
     $query = sprintf(Integration::SIMPLE_KEYSPACE_FORMAT, $this->keyspaceName, $replicationStrategy);
     if (self::isDebug() && self::isVerbose()) {
         fprintf(STDOUT, "Creating Keyspace: %s" . PHP_EOL, $query);
     }
     // Create the session and keyspace for the integration test
     $this->cluster = \Cassandra::cluster()->withContactPoints($this->getContactPoints(Integration::IP_ADDRESS, $numberDC1Nodes + $numberDC2Nodes))->withPersistentSessions(false)->build();
     $this->session = $this->cluster->connect();
     $statement = new SimpleStatement($query);
     $this->session->execute($statement);
     // Update the session to use the new keyspace by default
     $statement = new SimpleStatement("USE " . $this->keyspaceName);
     $this->session->execute($statement);
     // Get the server version the session is connected to
     $statement = new SimpleStatement(self::SELECT_SERVER_VERSION);
     $rows = $this->session->execute($statement);
     $this->serverVersion = $rows->first()["release_version"];
 }