Commit 5bc434f3 authored by Leo Gordon's avatar Leo Gordon
Browse files

renamed shortened DBC parameters to their longer versions; made sure they are...

renamed shortened DBC parameters to their longer versions; made sure they are all passed to the constructor
parent 2e4fc92a
......@@ -149,15 +149,15 @@ sub new {
my %flags = @_;
my ($driver, $user, $password, $host, $port, $dbname,
$dbconn, $disconnect_when_inactive, $wait_timeout, $reconnect_when_connection_lost)
$dbconn, $disconnect_when_inactive, $wait_timeout, $reconnect_when_lost)
= @flags{qw(-driver -user -pass -host -port -dbname -dbconn
-disconnect_when_inactive -wait_timeout -reconnect_when_connection_lost)};
-disconnect_when_inactive -wait_timeout -reconnect_when_lost)};
my $self = {};
bless $self, $class;
if($dbconn) {
if($dbname || $host || $driver || $password || $port || $disconnect_when_inactive || $reconnect_when_connection_lost) {
if($dbname || $host || $driver || $password || $port || $disconnect_when_inactive || $reconnect_when_lost) {
throw("Cannot specify other arguments when -DBCONN argument used.");
}
......@@ -206,8 +206,8 @@ sub new {
if($disconnect_when_inactive) {
$self->disconnect_when_inactive($disconnect_when_inactive);
}
if($reconnect_when_connection_lost) {
$self->reconnect_when_lost($reconnect_when_connection_lost);
if($reconnect_when_lost) {
$self->reconnect_when_lost($reconnect_when_lost);
}
}
......
......@@ -58,7 +58,7 @@ sub new {
my ($dbc, $url, $reg_conf, $reg_type, $reg_alias, $species, $no_sql_schema_version_check)
= @flags{qw(-dbconn -url -reg_conf -reg_type -reg_alias -species -no_sql_schema_version_check)};
$url .= ';nosqlvc=1' if($url && $no_sql_schema_version_check);
$url .= ';no_sql_schema_version_check=1' if($url && $no_sql_schema_version_check);
if($reg_conf or $reg_alias) { # need to initialize Registry even if $reg_conf is not really given
require Bio::EnsEMBL::Registry;
......
......@@ -51,15 +51,11 @@ sub new {
if(my $parsed_url = Bio::EnsEMBL::Hive::Utils::URL::parse( $url )) {
return $class->SUPER::new(
%flags,
-driver => $parsed_url->{'driver'},
-host => $parsed_url->{'host'},
-port => $parsed_url->{'port'},
-user => $parsed_url->{'user'},
-pass => $parsed_url->{'pass'},
-dbname => $parsed_url->{'dbname'},
-disconnect_when_inactive => $parsed_url->{'conn_params'}->{'discon'},
-reconnect_when_connection_lost => $parsed_url->{'conn_params'}->{'recon'},
%flags, # they act as overridable defaults
( map { ("-$_" => $parsed_url->{$_}) } ( 'driver', 'host', 'port', 'user', 'pass', 'dbname' ) ), # parentheses are essential
( map { ("-$_" => $parsed_url->{'conn_params'}->{$_}) } keys %{$parsed_url->{'conn_params'}} ), # parentheses are essential
);
} else {
......
......@@ -74,7 +74,7 @@ sub DESTROY {
=head2 fetch
Arg[1] : string $url
Example : $url = 'mysql://user:pass@host:3306/dbname/table_name?tparam_name=tparam_value;type=compara;discon=1'
Example : $url = 'mysql://user:pass@host:3306/dbname/table_name?tparam_name=tparam_value;type=compara;disconnect_when_inactive=1'
my $object = Bio::EnsEMBL::Hive::URLFactory->fetch($url);
Description: parses the URL, connects to appropriate DBAdaptor,
determines appropriate object_adaptor, fetches the object
......@@ -135,6 +135,7 @@ sub fetch {
return;
}
sub create_cached_dba {
my ($class, $dbconn_part, $driver, $user, $pass, $host, $port, $dbname, $conn_params) = @_;
......@@ -145,9 +146,9 @@ sub create_cached_dba {
$port ||= 3306;
}
my $type = $conn_params->{'type'};
my $discon = $conn_params->{'discon'};
my $nosqlvc = $conn_params->{'nosqlvc'};
my $type = $conn_params->{'type'};
my $disconnect_when_inactive = $conn_params->{'disconnect_when_inactive'};
my $no_sql_schema_version_check = $conn_params->{'no_sql_schema_version_check'};
my $connectionKey = "$driver://$user:$pass\@$host:$port/$dbname;$type";
my $dba = $_URLFactory_global_instance->{$connectionKey};
......@@ -166,9 +167,9 @@ sub create_cached_dba {
$_URLFactory_global_instance->{$connectionKey} = $dba =
$type eq 'hive'
? $module->new(
-url => $dbconn_part,
-disconnect_when_inactive => $discon,
-no_sql_schema_version_check => $nosqlvc,
-url => $dbconn_part,
-disconnect_when_inactive => $disconnect_when_inactive,
-no_sql_schema_version_check=> $no_sql_schema_version_check,
) : $module->new(
-driver => $driver,
-host => $host,
......@@ -177,7 +178,7 @@ sub create_cached_dba {
-pass => $pass,
-dbname => $dbname,
-species => $dbname,
-disconnect_when_inactive => $discon,
-disconnect_when_inactive => $disconnect_when_inactive,
);
}
return $dba;
......
......@@ -42,7 +42,7 @@ sub parse {
if( my ($dbconn_part, $driver, $user, $pass, $host, $port, $dbname, $table_name, $tparam_name, $tparam_value, $conn_param_string) =
$url =~ m{^((\w*)://(?:(\w+)(?:\:([^/\@]*))?\@)?(?:([\w\-\.]+)(?:\:(\d*))?)?/([\w\-]*))(?:/(\w+)(?:\?(\w+)=([\w\[\]\{\}]*))?)?((?:;(\w+)=(\w+))*)$} ) {
my %conn_params = split(/[;=]/, 'type=hive;discon=0'.$conn_param_string );
my %conn_params = split(/[;=]/, 'type=hive;disconnect_when_inactive=0'.$conn_param_string );
my $parsed_url = {
'dbconn_part' => $dbconn_part,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment