Author: fapeeler
Date: Fri Dec 19 09:05:37 2008
New Revision: 728067

URL: http://svn.apache.org/viewvc?rev=728067&view=rev
Log:
Datastructure: added routine to refresh env variables for predictive
load module, then load and call that modules get_next_image routine.
This functionality allows for dynamically changing which predictive load
module  to use, currently only two predictive load modules under
Module/Predictive: Level_0.pm Level_1.pm each with different algorithms

State: deleted eval for predictive load module, since this only needs to
happen for reclaims. there is no need to load the module for every
state, new, inuse, etc. State.pm gets loaded on every request and then
creates additional objects by loading the respective modules.

reclaim: changed to call get_next_image_dataStructure from the
DataStructure module.


Modified:
    incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm
    incubator/vcl/trunk/managementnode/lib/VCL/Module/State.pm
    incubator/vcl/trunk/managementnode/lib/VCL/reclaim.pm

Modified: incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm?rev=728067&r1=728066&r2=728067&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm Fri Dec 19 
09:05:37 2008
@@ -75,6 +75,7 @@
 use strict;
 use warnings;
 use diagnostics;
+use English '-no_match_vars';
 
 use Object::InsideOut;
 use List::Util qw(min max);
@@ -899,6 +900,63 @@
 
 #/////////////////////////////////////////////////////////////////////////////
 
+=head2 get_next_image
+
+ Parameters  : none
+ Returns     : array 
+ Description : called mainly from reclaim module. Refreshes predictive load 
+                                       module information from database, loads 
module and calls next_image. 
+
+=cut
+
+sub get_next_image_dataStructure {
+       my $self = shift;
+
+       #collect predictive reload information from database.
+       my $management_predictive_info = get_management_predictive_info();
+       if(!$management_predictive_info->{predictivemoduleid}){
+               notify($ERRORS{'CRITICAL'}, 0, "unable to obtain management 
node info for this node");
+      return 0;
+       }
+
+       #update ENV in case other modules need to know
+       $ENV{management_node_info}{predictivemoduleid} = 
$management_predictive_info->{predictivemoduleid};
+       $ENV{management_node_info}{predictive_name} = 
$management_predictive_info->{predictive_name};
+       $ENV{management_node_info}{predictive_prettyname} = 
$management_predictive_info->{predictive_prettyname};
+       $ENV{management_node_info}{predictive_description} = 
$management_predictive_info->{predictive_description};
+       $ENV{management_node_info}{predictive_perlpackage} = 
$management_predictive_info->{predictive_perlpackage};
+
+       my $predictive_perl_package = 
$management_predictive_info->{predictive_perlpackage};
+       my @nextimage;
+
+       if ($predictive_perl_package) {
+               notify($ERRORS{'OK'}, 0, "attempting to load predictive loading 
module: $predictive_perl_package");
+
+               eval "use $predictive_perl_package";
+
+               if ($EVAL_ERROR) {
+                       notify($ERRORS{'WARNING'}, 0, "$predictive_perl_package 
module could not be loaded");
+                       notify($ERRORS{'OK'},      0, "returning 0");
+                       return 0;
+               }
+               if (my $predictor = 
($predictive_perl_package)->new({data_structure => $self})) {
+                       notify($ERRORS{'OK'}, 0, ref($predictor) . " predictive 
loading object successfully created");
+                       @nextimage = $predictor->get_next_image();
+                       return @nextimage;
+               }
+               else {
+                       notify($ERRORS{'WARNING'}, 0, "predictive loading 
object could not be created, returning 0");
+                       return 0;
+               }
+       } ## end if ($predictive_perl_package)
+       else {
+               notify($ERRORS{'OK'}, 0, "predictive loading module not loaded, 
Perl package is not defined");
+               return 0
+       }
+
+}
+#/////////////////////////////////////////////////////////////////////////////
+
 =head2 print_data
 
  Parameters  :

Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/State.pm
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/State.pm?rev=728067&r1=728066&r2=728067&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/State.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/State.pm Fri Dec 19 
09:05:37 2008
@@ -101,7 +101,7 @@
        my $reservation_id            = $self->data->get_reservation_id();
        my $provisioning_perl_package = 
$self->data->get_computer_provisioning_module_perl_package();
        my $os_perl_package           = 
$self->data->get_image_os_module_perl_package();
-       my $predictive_perl_package   = 
$self->data->get_management_node_predictive_module_perl_package();
+       #my $predictive_perl_package   = 
$self->data->get_management_node_predictive_module_perl_package();
 
        # Store the name of this class in an environment variable
        $ENV{class_name} = ref($self);
@@ -165,26 +165,26 @@
        }
 
        # Attempt to load the predictive loading module
-       if ($predictive_perl_package) {
-               notify($ERRORS{'OK'}, 0, "attempting to load predictive loading 
module: $predictive_perl_package");
-               eval "use $predictive_perl_package";
-               if ($EVAL_ERROR) {
-                       notify($ERRORS{'WARNING'}, 0, "$predictive_perl_package 
module could not be loaded");
-                       notify($ERRORS{'OK'},      0, "returning 0");
-                       return 0;
-               }
-               if (my $predictor = 
($predictive_perl_package)->new({data_structure => $self->data})) {
-                       notify($ERRORS{'OK'}, 0, ref($predictor) . " predictive 
loading object successfully created");
-                       $self->{predictor} = $predictor;
-               }
-               else {
-                       notify($ERRORS{'WARNING'}, 0, "predictive loading 
object could not be created, returning 0");
-                       return 0;
-               }
-       } ## end if ($predictive_perl_package)
-       else {
-               notify($ERRORS{'OK'}, 0, "predictive loading module not loaded, 
Perl package is not defined");
-       }
+       #if ($predictive_perl_package) {
+       #       notify($ERRORS{'OK'}, 0, "attempting to load predictive loading 
module: $predictive_perl_package");
+       #       eval "use $predictive_perl_package";
+       #       if ($EVAL_ERROR) {
+       #               notify($ERRORS{'WARNING'}, 0, "$predictive_perl_package 
module could not be loaded");
+       #               notify($ERRORS{'OK'},      0, "returning 0");
+       #               return 0;
+       #       }
+       #       if (my $predictor = 
($predictive_perl_package)->new({data_structure => $self->data})) {
+       #               notify($ERRORS{'OK'}, 0, ref($predictor) . " predictive 
loading object successfully created");
+       #               $self->{predictor} = $predictor;
+       #       }
+       #       else {
+       #               notify($ERRORS{'WARNING'}, 0, "predictive loading 
object could not be created, returning 0");
+       #               return 0;
+       #       }
+       #} ## end if ($predictive_perl_package)
+       #else {
+       #       notify($ERRORS{'OK'}, 0, "predictive loading module not loaded, 
Perl package is not defined");
+       #}
 
        notify($ERRORS{'OK'}, 0, "returning 1");
        return 1;

Modified: incubator/vcl/trunk/managementnode/lib/VCL/reclaim.pm
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/reclaim.pm?rev=728067&r1=728066&r2=728067&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/reclaim.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/reclaim.pm Fri Dec 19 09:05:37 
2008
@@ -115,8 +115,8 @@
        # It's possible the results may not get used based on the state of the 
reservation 
        my @nextimage;
 
-       if($self->predictor->can("get_next_image")){
-               @nextimage = $self->predictor->get_next_image();
+       if($self->data->can("get_next_image_dataStructure")){
+               @nextimage = $self->data->get_next_image_dataStructure();
        }
        else{
                notify($ERRORS{'WARNING'}, 0, "$notify_prefix predictor module 
does not support get_next_image, calling default get_next_image from utils");


Reply via email to