Create Predis\Cluster namespace and move related classes / interfaces.

This commit is contained in:
Daniele Alessandri
2012-07-30 20:10:14 +02:00
parent 7683f97ff2
commit e54bc31212
19 changed files with 33 additions and 34 deletions
+2 -2
View File
@@ -16,8 +16,8 @@ require 'SharedConfigurations.php';
// that implements Predis\Distribution\DistributionStrategyInterface.
use Predis\Connection\PredisCluster;
use Predis\Distribution\DistributionStrategyInterface;
use Predis\Distribution\HashGeneratorInterface;
use Predis\Cluster\Distribution\DistributionStrategyInterface;
use Predis\Cluster\Hash\HashGeneratorInterface;
class NaiveDistributionStrategy implements DistributionStrategyInterface, HashGeneratorInterface
{
@@ -9,10 +9,9 @@
* file that was distributed with this source code.
*/
namespace Predis\Command\Hash;
namespace Predis\Cluster;
use Predis\Command\CommandInterface;
use Predis\Distribution\HashGeneratorInterface;
/**
* Interface for classes defining the strategy used to calculate an hash
@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Predis\Distribution;
namespace Predis\Cluster\Distribution;
/**
* A distributor implements the logic to automatically distribute
@@ -44,7 +44,7 @@ interface DistributionStrategyInterface
/**
* Returns the underlying hash generator instance.
*
* @return HashGeneratorInterface
* @return Predis\Cluster\Hash\HashGeneratorInterface
*/
public function getHashGenerator();
}
@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Predis\Distribution;
namespace Predis\Cluster\Distribution;
/**
* Exception class that identifies empty rings.
@@ -9,7 +9,9 @@
* file that was distributed with this source code.
*/
namespace Predis\Distribution;
namespace Predis\Cluster\Distribution;
use Predis\Cluster\Hash\HashGeneratorInterface;
/**
* This class implements an hashring-based distributor that uses the same
@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Predis\Distribution;
namespace Predis\Cluster\Distribution;
/**
* This class implements an hashring-based distributor that uses the same
@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Predis\Distribution;
namespace Predis\Cluster\Hash;
/**
* This class implements the CRC-CCITT-16 algorithm used by redis-cluster.
@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Predis\Distribution;
namespace Predis\Cluster\Hash;
/**
* A generator of node keys implements the logic used to calculate the hash of
@@ -9,10 +9,10 @@
* file that was distributed with this source code.
*/
namespace Predis\Command\Hash;
namespace Predis\Cluster;
use Predis\Cluster\Hash\HashGeneratorInterface;
use Predis\Command\CommandInterface;
use Predis\Distribution\HashGeneratorInterface;
/**
* Default class used by Predis for client-side sharding to calculate
@@ -9,10 +9,10 @@
* file that was distributed with this source code.
*/
namespace Predis\Command\Hash;
namespace Predis\Cluster;
use Predis\Cluster\Hash\CRC16HashGenerator;
use Predis\Command\CommandInterface;
use Predis\Distribution\CRC16HashGenerator;
/**
* Default class used by Predis to calculate hashes out of keys of
+4 -4
View File
@@ -13,10 +13,10 @@ namespace Predis\Connection;
use Predis\ClientException;
use Predis\NotSupportedException;
use Predis\Cluster\PredisClusterHashStrategy;
use Predis\Cluster\Distribution\DistributionStrategyInterface;
use Predis\Cluster\Distribution\HashRing;
use Predis\Command\CommandInterface;
use Predis\Command\Hash\PredisClusterHashStrategy;
use Predis\Distribution\HashRing;
use Predis\Distribution\DistributionStrategyInterface;
/**
* Abstraction for a cluster of aggregated connections to various Redis servers
@@ -168,7 +168,7 @@ class PredisCluster implements ClusterConnectionInterface, \IteratorAggregate, \
* Returns the underlying command hash strategy used to hash
* commands by their keys.
*
* @return CommandHashStrategy
* @return Predis\Cluster\CommandHashStrategyInterface
*/
public function getCommandHashStrategy()
{
+2 -4
View File
@@ -14,10 +14,8 @@ namespace Predis\Connection;
use Predis\ClientException;
use Predis\NotSupportedException;
use Predis\ResponseErrorInterface;
use Predis\Cluster\RedisClusterHashStrategy;
use Predis\Command\CommandInterface;
use Predis\Command\Hash\CommandHashStrategyInterface;
use Predis\Command\Hash\RedisClusterHashStrategy;
use Predis\Distribution\CRC16HashGenerator;
/**
* Abstraction for Redis cluster (Redis v3.0).
@@ -266,7 +264,7 @@ class RedisCluster implements ClusterConnectionInterface, \IteratorAggregate, \C
* Returns the underlying command hash strategy used to hash
* commands by their keys.
*
* @return CommandHashStrategy
* @return Predis\Cluster\CommandHashStrategyInterface
*/
public function getCommandHashStrategy()
{
@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Predis\Distribution;
namespace Predis\Cluster\Distribution;
use \PHPUnit_Framework_TestCase as StandardTestCase;
@@ -21,7 +21,7 @@ abstract class DistributionStrategyTestCase extends StandardTestCase
/**
* Returns a new instance of the tested distributor.
*
* @return Predis\Distribution\DistributionStrategyInterface
* @return Predis\Cluster\Distribution\DistributionStrategyInterface
*/
protected abstract function getDistributorInstance();
@@ -49,7 +49,7 @@ abstract class DistributionStrategyTestCase extends StandardTestCase
*/
public function testEmptyRingThrowsException()
{
$this->setExpectedException('Predis\Distribution\EmptyRingException');
$this->setExpectedException('Predis\Cluster\Distribution\EmptyRingException');
$ring = $this->getDistributorInstance();
$ring->get('nodekey');
@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Predis\Distribution;
namespace Predis\Cluster\Distribution;
use \PHPUnit_Framework_TestCase as StandardTestCase;
@@ -24,7 +24,7 @@ class EmptyRingExceptionTest extends StandardTestCase
public function testExceptionMessage()
{
$message = 'Empty Ring';
$this->setExpectedException('Predis\Distribution\EmptyRingException', $message);
$this->setExpectedException('Predis\Cluster\Distribution\EmptyRingException', $message);
throw new EmptyRingException($message);
}
@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Predis\Distribution;
namespace Predis\Cluster\Distribution;
/**
* @todo To be improved.
@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Predis\Distribution;
namespace Predis\Cluster\Distribution;
/**
* @todo To be improved.
@@ -9,11 +9,11 @@
* file that was distributed with this source code.
*/
namespace Predis\Command\Hash;
namespace Predis\Cluster;
use \PHPUnit_Framework_TestCase as StandardTestCase;
use Predis\Distribution\HashRing;
use Predis\Cluster\Distribution\HashRing;
use Predis\Profile\ServerProfile;
/**
@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Predis\Command\Hash;
namespace Predis\Cluster;
use \PHPUnit_Framework_TestCase as StandardTestCase;
@@ -26,7 +26,7 @@ class PredisClusterTest extends StandardTestCase
public function testExposesCommandHashStrategy()
{
$cluster = new PredisCluster();
$this->assertInstanceOf('Predis\Command\Hash\PredisClusterHashStrategy', $cluster->getCommandHashStrategy());
$this->assertInstanceOf('Predis\Cluster\PredisClusterHashStrategy', $cluster->getCommandHashStrategy());
}
/**