Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #4 from jcbf/master

Support for add_pool_from_ring() #1 self->{pool}Support for add_pool_from_ring() #1
  • Loading branch information...
commit 51872e199fd835759a2d3afa4155b74636c35543 2 parents 537f768 + d0175e2
@fmgoncalves authored
Showing with 17 additions and 4 deletions.
  1. +17 −4 lib/Cassandra/Pool.pm
View
21 lib/Cassandra/Pool.pm
@@ -47,19 +47,31 @@ sub new {
$loadbalancer->add_pool(
ResourcePool->new( Cassandra::Pool::CassandraServerFactory->new($opt) )
);
+ $self->{pool} = $loadbalancer;
+ $self->{rcp_opts} = $opt;
+
+ $self = bless( $self, $class );
+
+ return $self;
+}
+
+sub add_pool_from_ring {
+ my $self = shift;
+ my $keyspace = $self->{rcp_opts}->{keyspace};
if ($keyspace) {
- my @nodes = @{ $loadbalancer->get()->describe_ring($keyspace) };
+ my @nodes = @{ $self->{pool}->get()->describe_ring($keyspace) };
foreach (
map {
map { split( /\//, $_ ) } @{ $_->{rpc_endpoints} }
} @nodes
)
{
- next if $opt->{server_name} eq $_;
- my %params = %$opt;
+ next if $self->{rcp_opts}->{server_name} eq $_;
+ my %params = %{$self->{rcp_opts}};
+
$params{server_name} = $_;
- $loadbalancer->add_pool(
+ $self->{pool}->add_pool(
ResourcePool->new(
Cassandra::Pool::CassandraServerFactory->new( \%params ),
PreCreate => 2
@@ -67,6 +79,7 @@ sub new {
);
}
}
+
$self->{pool} = $loadbalancer;
$self = bless( $self, $class );

0 comments on commit 51872e1

Please sign in to comment.
Something went wrong with that request. Please try again.