Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
ensembl-gh-mirror
ensembl-hive
Commits
037fef50
Commit
037fef50
authored
Jul 02, 2013
by
Leo Gordon
Browse files
separated the task of URL parsing out of the dba caching mechanism (needs more work)
parent
fb03ef1d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
10 deletions
+50
-10
modules/Bio/EnsEMBL/Hive/URLFactory.pm
modules/Bio/EnsEMBL/Hive/URLFactory.pm
+11
-10
modules/Bio/EnsEMBL/Hive/Utils/URL.pm
modules/Bio/EnsEMBL/Hive/Utils/URL.pm
+39
-0
No files found.
modules/Bio/EnsEMBL/Hive/URLFactory.pm
View file @
037fef50
...
...
@@ -44,6 +44,7 @@ use strict;
use
Bio::EnsEMBL::Utils::
Argument
;
use
Bio::EnsEMBL::Utils::
Exception
;
use
Bio::EnsEMBL::Hive::Utils::
URL
;
use
Bio::EnsEMBL::Hive::DBSQL::
DBAdaptor
;
use
Bio::EnsEMBL::Hive::
Extensions
;
use
Bio::EnsEMBL::Hive::
Accumulator
;
...
...
@@ -88,15 +89,15 @@ sub fetch {
Bio::EnsEMBL::Hive::
URLFactory
->
new
();
# make sure global instance is created
if
(
my
(
$conn
,
$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+))*)$}
)
{
if
(
my
$parsed_url
=
Bio::EnsEMBL::Hive::Utils::URL::
parse
(
$url
))
{
my
%conn_param
=
split
(
/[;=]/
,
'
type=hive;discon=0
'
.
$conn_param_string
);
my
$dba
=
(
$parsed_url
->
{'
dbconn_part
'}
=~
m{^\w*:///$}
)
?
$default_dba
:
$class
->
create_cached_dba
(
@$parsed_url
{
qw(driver user pass host port dbname conn_params)
}
);
#warn "URLPARSER: conn='$conn', driver='$driver', user='$user', pass='$pass', host='$host', port='$port', dbname='$dbname', table_name='$table_name', tparam_name='$tparam_name', tparam_value='$tparam_value'";
#warn "CONN_PARAMS: ".Dumper(\%conn_param);
my
$dba
=
(
$conn
=~
m{^\w*:///$}
)
?
$default_dba
:
$class
->
create_cached_dba
(
$driver
,
$user
,
$pass
,
$host
,
$port
,
$dbname
,
%conn_param
);
my
$table_name
=
$parsed_url
->
{'
table_name
'};
my
$tparam_name
=
$parsed_url
->
{'
tparam_name
'};
my
$tparam_value
=
$parsed_url
->
{'
tparam_value
'};
if
(
not
$table_name
)
{
...
...
@@ -131,7 +132,7 @@ sub fetch {
}
sub
create_cached_dba
{
my
(
$class
,
$driver
,
$user
,
$pass
,
$host
,
$port
,
$dbname
,
%
conn_param
)
=
@_
;
my
(
$class
,
$driver
,
$user
,
$pass
,
$host
,
$port
,
$dbname
,
$
conn_param
s
)
=
@_
;
if
(
$driver
eq
'
mysql
')
{
$user
||=
'
ensro
';
...
...
@@ -140,8 +141,8 @@ sub create_cached_dba {
$port
||=
3306
;
}
my
$type
=
$conn_param
{'
type
'};
my
$discon
=
$conn_param
{'
discon
'};
my
$type
=
$conn_param
s
->
{'
type
'};
my
$discon
=
$conn_param
s
->
{'
discon
'};
my
$connectionKey
=
"
$driver
://
$user
:
$pass
\@
$host
:
$port
/
$dbname
;
$type
";
my
$dba
=
$_URLFactory_global_instance
->
{
$connectionKey
};
...
...
modules/Bio/EnsEMBL/Hive/Utils/URL.pm
0 → 100644
View file @
037fef50
package
Bio::EnsEMBL::Hive::Utils::
URL
;
use
strict
;
use
warnings
;
use
Data::
Dumper
;
sub
parse
{
my
$url
=
shift
@
_
or
return
;
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
$parsed_url
=
{
'
dbconn_part
'
=>
$dbconn_part
,
'
driver
'
=>
$driver
,
'
user
'
=>
$user
,
'
pass
'
=>
$pass
,
'
host
'
=>
$host
,
'
port
'
=>
$port
,
'
dbname
'
=>
$dbname
,
'
table_name
'
=>
$table_name
,
'
tparam_name
'
=>
$tparam_name
,
'
tparam_value
'
=>
$tparam_value
,
'
conn_params
'
=>
\
%conn_params
,
};
return
$parsed_url
;
}
else
{
return
;
}
}
1
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment