Subject: | cannot retrieve complete object data |
Greetings,
I'm using MooseX::Storage to store() and load() some classes of mine. I
was able to use those methods without any problem, but for the class
Siebel::Srvrmgr::Daemon::Action::ListParams the load method is not
working as expected.
The stored object has a hash reference called "data_parsed" that should
have multiple keys. I attached the stored object and the data in the
file is OK. The problem is, once I load the object with the load()
method, the "data_parsed" becames an empty hash.
After debugging a bit, I was able to the see that before the object is
returned (in MooseX::Storage::Engine::expand_object), the "data_parsed"
is instact (as returned by "return $self->storage") after that, the
"data_parsed" references an empty hash.
Another thing is that the hexadecimal number of the hash reference is
one before the "return $self->storage" is one, after that the hexa is
different. For example:
1 - BEFORE:
MooseX::Storage::Engine::expand_object(C:/Perl/site/lib/MooseX/Storage/Engine.pm:53):
53: return $self->storage;
DB<9> x $self->storage
0 HASH(0x36bacec)
'cmd_line' => 'list params for server saoasdctt1 component DbXtract'
'comp_alias' => 'DbXtract'
'comp_params' => ARRAY(0x36baa1c)
0 'PA_ALIAS'
1 'PA_VALUE'
2 'PA_DATATYPE'
3 'PA_SCOPE'
4 'PA_SUBSYSTEM'
5 'PA_SETLEVEL'
6 'PA_DISP_SETLEVEL'
7 'PA_NAME'
'data_parsed' => HASH(0x3724cbc)
'16KTblSpace' => HASH(0x35e8184)
'PA_DATATYPE' => 'String'
'PA_DISP_SETLEVEL' => 'SIS_NEVER_SET'
'PA_NAME' => '16K Tablespace Name'
'PA_SCOPE' => 'Subsystem'
'PA_SETLEVEL' => 'SIS_NEVER_SET'
'PA_SUBSYSTEM' => 'Database Access'
'PA_VALUE' => ''
2 - AFTER:
DB<10> x $comp_params
0 Siebel::Srvrmgr::ListParser::Output::ListParams=HASH(0x37266b4)
'cmd_line' => 'list params for server saoasdctt1 component DbXtract'
'comp_alias' => 'DbXtract'
'comp_params' => ARRAY(0x36baa1c)
0 'PA_ALIAS'
1 'PA_VALUE'
2 'PA_DATATYPE'
3 'PA_SCOPE'
4 'PA_SUBSYSTEM'
5 'PA_SETLEVEL'
6 'PA_DISP_SETLEVEL'
7 'PA_NAME'
'data_parsed' => HASH(0x3730fcc)
empty hash
'data_type' => 'list_params'
'fields_pattern' => 'A22A19A13A11A29A23A23A46'
'raw_data' => ARRAY(0x36bae0c)
empty array
'server' => 'saoasdctt1'
This can be reproduced if the storable.pl attached (at least in the
machine I'm using for development).
If I quite using MooseX-Storabe and fall back to Storable module, I can
retrieve the complete data of the object (but all methods will fail).
I'
Subject: | storable.pl |
use warnings;
use strict;
#use Siebel::Srvrmgr::ListParser::Output::ListParams;
use Storable qw(retrieve);
my $file = shift;
#my $comp = Siebel::Srvrmgr::ListParser::Output::ListParams->load($file);
my $comp = retrieve($file);
print $comp->get_comp_alias(), "\n";
Subject: | EIM-listParams.sto |
Message body not shown because it is not plain text.
Subject: | Output.pm |
package Siebel::Srvrmgr::ListParser::Output;
use Moose;
use MooseX::Storage;
use namespace::autoclean;
with Storage( io => 'StorableFile' );
has 'data_type' =>
( is => 'ro', isa => 'Str', reader => 'get_data_type', required => 1 );
has 'raw_data' => (
is => 'rw',
isa => 'ArrayRef',
reader => 'get_raw_data',
writer => 'set_raw_data',
required => 1
);
has 'data_parsed' => (
is => 'rw',
isa => 'HashRef',
reader => 'get_data_parsed',
writer => 'set_data_parsed'
);
has 'cmd_line' =>
( isa => 'Str', is => 'ro', reader => 'get_cmd_line', required => 1 );
no Moose;
__PACKAGE__->meta->make_immutable;
Subject: | ListParams.pm |
package Siebel::Srvrmgr::ListParser::Output::ListParams;
use Moose;
use namespace::autoclean;
extends 'Siebel::Srvrmgr::ListParser::Output';
has 'comp_params' => (
is => 'rw',
isa => 'ArrayRef',
reader => 'get_comp_params',
writer => 'set_comp_params'
);
has 'fields_pattern' => (
is => 'rw',
isa => 'Str',
reader => 'get_fields_pattern',
writer => 'set_fields_pattern'
);
has server =>
( isa => 'Str', is => 'ro', writer => '_set_server', reader => 'get_server' );
has comp_alias => (
isa => 'Str',
is => 'ro',
writer => '_set_comp_alias',
reader => 'get_comp_alias'
);
# for POD, this is the list configuration considered by the module
#srvrmgr> configure list params
# PA_ALIAS (31): Parameter alias
# PA_VALUE (101): Parameter value
# PA_DATATYPE (31): Parameter value datatype
# PA_SCOPE (31): Parameter level
# PA_SUBSYSTEM (31): Parameter subsystem
# PA_SETLEVEL (31): Internal level at which value was set
# PA_DISP_SETLEVEL (61): Display level at which value was set (translatable)
# PA_NAME (76): Parameter name
#
# Data extructure return
# 'data_parsed' => {
# 'Parameter' => {
# 'PA_NAME' => 'Private key file name',
# 'PA_DATATYPE' => 'String',
# 'PA_SCOPE' => 'Subsystem',
# 'PA_VALUE' => '',
# 'PA_ALIAS' => 'KeyFileName',
# 'PA_SETLEVEL' => 'SIS_NEVER_SET',
# 'PA_DISP_SETLEVEL' => 'SIS_NEVER_SET',
# 'PA_SUBSYSTEM' => 'Networking'
# },
#
sub set_details {
my $self = shift;
if ( defined( $self->get_cmd_line() ) ) {
#list params for server SERVERNAME component COMPONENT_ALIAS
my @values = split( /\s/, $self->get_cmd_line() );
if ( ( scalar(@values) ) == 7 ) {
$self->_set_server( $values[4] );
$self->_set_comp_alias( $values[6] );
}
}
return 1;
}
sub BUILD {
my $self = shift;
$self->parse();
$self->set_details();
}
sub parse {
my $self = shift;
my $data_ref = $self->get_raw_data();
my %parsed_lines;
# removing the three last lines Siebel 7.5.3 (one blank line followed by a line amount of lines returned followed by a blank line)
for ( 1 .. 3 ) {
pop( @{$data_ref} );
}
foreach my $line ( @{$data_ref} ) {
chomp($line);
SWITCH: {
if ( $line =~ /^\-+\s/ ) { # this is the header line
my @columns = split( /\s{2}/, $line );
my $pattern;
foreach my $column (@columns) {
$pattern .= 'A'
. ( length($column) + 2 )
; # + 2 because of the spaces after the "---" that will be trimmed
}
$self->set_fields_pattern($pattern);
last SWITCH;
}
if ( $line eq '' ) {
last SWITCH;
}
#SV_NAME CC_ALIAS
if ( $line =~ /^PA_ALIAS\s.*\sPA_NAME/ ) { # this is the header
my @columns = split( /\s{2,}/, $line );
$self->set_comp_params( \@columns );
last SWITCH;
}
else {
my @fields_values =
unpack( $self->get_fields_pattern(), $line );
if (@fields_values) {
my $pa_alias = $fields_values[0];
my $list_len = scalar(@fields_values);
my $columns_ref = $self->get_comp_params();
for ( my $i = 1 ; $i < $list_len ; $i++ )
{ # starting from 1 to skip the field PA_ALIAS
$parsed_lines{$pa_alias}->{ $columns_ref->[$i] } =
$fields_values[$i];
}
}
else {
warn "got nothing\n";
}
}
}
}
$self->set_data_parsed( \%parsed_lines );
$self->set_raw_data( [] );
}
no Moose;
__PACKAGE__->meta->make_immutable;