develooper Front page | perl.modules | Postings from July 2019

PAUSE ID request (SIRPSYCHO; Riccardo Marini)

From:
Perl Authors Upload Server
Date:
July 19, 2019 12:25
Subject:
PAUSE ID request (SIRPSYCHO; Riccardo Marini)
Message ID:
20190719122157.92CC1F78@pause.perl.org
Request to register new user

fullname: Riccardo Marini
  userid: SIRPSYCHO
    mail: CENSORED
homepage: 
     why:

    I would like to publish my own TSM module. I was not satisfied with
    DBD::TSM or TSM:: because of lack of performance in many situations
    since doing a new session for each statement. I wrote my own that is
    able to pack statements in a single session to boost performance in
    case of complex reports/activities. It is the most complete perl
    wrapper for dsmadmc. Note that even DBD implementation is not using
    C API for TSM but still acting as a wrapper around dsmadmc. Doing
    reports with this one is simple and fun, and fast. Does not pretend
    to be an extension of DBD, so I would publish as "Dsmadmc" package
    since TSM is already taken by a 2001 module. Here below a quick demo
    client program using Dsmadmc:

    -----CODE BEGIN HERE #!/usr/bin/perl use Dsmadmc; use strict; use
    warnings;

    my $stanza=shift; die unless ($stanza); my $obj =
    Dsmadmc->new(stanza => $stanza, sep => '%', validate => 0, macro =>
    "/var/tmp/$$.$$.$$") #This will allow multiple statement in one
    connection or die $!;

    $obj->add_statement('SELECT NODE_NAME,DOMAIN_NAME FROM NODES');
    $obj->add_statement('SELECT NODE_NAME,DOMAIN_NAME FRM NODES');
    $obj->do_query; #will silently chosse between single/macro conn.
    #will flush statement buffer, perform queries, charge data into
    answers

    print "Usage Example one...\n"; while(my $a=$obj->get_next_answer){
    my $tsm_rc=$obj->get_tsm_rc($a); if($tsm_rc==0){ while(my
    ($node,$dom)=$obj->get_next_row($a)){ print "node: $node\n"; print
    "domain: $dom\n"; } }else{ print STDERR
    "\n******************************\n"; print STDERR
    $obj->get_error_string($a); print STDERR
    "\n******************************\n"; } }

    print "Usage Example two(inconsistent number of field within
    queries)...\n"; $obj->add_statement('SELECT NODE_NAME,DOMAIN_NAME
    FROM NODES'); #---> will be statement 0 $obj->add_statement('SELECT
    VOLUME_NAME,STGPOOL_NAME,PCT_RECLAIM FROM VOLUMES'); #--> will be
    statement 1 and so on.. $obj->do_query; #see above.

    my $ans=$obj->get_next_answer; #get answer to statement 0 while(my
    ($node,$dom)=$obj->get_next_row($a)){ print "node: $node\n"; print
    "domain: $dom\n"; } $ans=$obj->get_next_answer; #get ans. to
    statement 1.. while(my ($node,$stg,$pct)=$obj->get_next_row($a)){
    print "volume: $node\n"; print "stgpool: $stg\n"; print "pctrec:
    $pct\n"; }

    print "Usage Example threee(Answers format)\n";
    $obj->add_statement('SELECT count(*) FROM NODES');
    $obj->add_statement('SELECT count(*) FROM VOLHISTORY');
    $obj->add_statement('TCELES count(*) FROM VOLHISTORY'); #-->ERROR
    $obj->do_query;

    use Data::Dumper; print Dumper \$obj->{answers}; #Will produce
    #$VAR1 = \[ # { # 'rc' => 0, # 'statement' => 'SELECT count(*) FROM
    NODES', # 'rows' => [ # '145' # ] # }, # { # 'rc' => 0, #
    'statement' => 'SELECT count(*) FROM VOLHISTORY', # 'rows' => [ #
    '44' # ] # }, # { # 'rc' => '2', # 'statement' => 'TCELES count(*)
    FROM VOLHISTORY', # 'error' => [ # 'ANR2000E Unknown command -
    TCELES.' # ], # 'rows' => [] # } # ];

    print "Version was: ". $obj->get_tsm_version."\n"; -----CODE ENDS
    HERE

    Another demo showing performance 10x gain using Dsmadmc over any
    other implementation using single statement per session (DBD::TSM,
    TSM)

    ------CODE STARTS HERE #!/usr/bin/perl use Data::Dumper; use
    Dsmadmc; use strict; use warnings;

    my $stanza=shift; my $macro=shift; die unless ($stanza); my $obj;
    if($macro){ $obj = Dsmadmc->new(stanza => $stanza, sep =>
    '%',validate => 0 , macro => '/var//tmp/test' ) or die $!; }else{
    $obj = Dsmadmc->new(stanza => $stanza, sep => '%',validate => 0 ) or
    die $!; }

    $obj->add_statement('SELECT NODE_NAME,DOMAIN_NAME FROM NODES');
    $obj->add_statement('SELECT NODE_NAME,DOMAIN_NAME FROM NODES');
    $obj->add_statement('SELECT NODE_NAME,DOMAIN_NAME FROM NODES');
    $obj->add_statement('SELECT NODE_NAME,DOMAIN_NAME FROM NODES');
    $obj->add_statement('SELECT NODE_NAME,DOMAIN_NAME FROM NODES');
    $obj->add_statement('SELECT NODE_NAME,DOMAIN_NAME FROM NODES');
    $obj->add_statement('SELECT NODE_NAME,DOMAIN_NAME FROM NODES');
    $obj->add_statement('SELECT NODE_NAME,DOMAIN_NAME FROM NODES');
    $obj->add_statement('SELECT NODE_NAME,DOMAIN_NAME FROM NODES');
    $obj->add_statement('SELECT NODE_NAME,DOMAIN_NAME FROM NODES');
    $obj->add_statement('SELECT NODE_NAME,DOMAIN_NAME FROM NODES');
    $obj->add_statement('SELECT NODE_NAME,DOMAIN_NAME FROM NODES');
    $obj->add_statement(q~SELECT * FROM NODES WHERE NODE_NAME =
    'CICCIO'~); $obj->add_statement('SELECT * FRM NODES');
    $obj->do_query;

    while(my $a=$obj->get_next_answer){ my
    $tsm_rc=$obj->get_tsm_rc($a); if($tsm_rc==0){ while(my
    ($node,$stg)=$obj->get_next_row($a)){ print "node: $node\n"; print
    "Stg: $stg\n"; } }else{ print STDERR $obj->get_error_string($a); } }
    ------CODE ENDS HERE

    Execution times for both single and macro mode, showing no
    differences in reported output:

    [root@tsmmon tsm]# time ./client_M.pl AGRTSMNAS > a 2>/dev/null

    real 0m5.161s user 0m3.742s sys 0m0.218s [root@tsmmon tsm]# time
    ./client_M.pl AGRTSMNAS macro_mode > b 2>/dev/null

    real 0m0.534s user 0m0.298s sys 0m0.025s [root@tsmmon tsm]# diff a
    b [root@tsmmon tsm]#


The following links are only valid for PAUSE maintainers:

Registration form with editing capabilities:
  https://pause.perl.org/pause/authenquery?ACTION=add_user&USERID=96310000_a31e4a5f56c6beb5&SUBMIT_pause99_add_user_sub=1
Immediate (one click) registration:
  https://pause.perl.org/pause/authenquery?ACTION=add_user&USERID=96310000_a31e4a5f56c6beb5&SUBMIT_pause99_add_user_Definitely=1



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About