Egit User Guide….
The Egit User Guide….
Difference between a Branch and a View…
in Git…. vs other SCM’s.
What is Struts….in a nut nutshell.
Thanks to Mark Gorokhov and Mahesh Lavannis for this explanation…
Well Struts is nothing but a mapping layer… think about what happens when one goes to a URL?
Our URL in this case is http://www.foo.com/blah.do?param1=a¶m2=b¶m3=c
.
Now because blah.do is not a request for a regular HTML page, our Webserver does not know how to render it…. but it knows that it is supposed to forward the HTTP GET request to the Application Server.
Our application server gets this request and it in turn looks up in the struts.xml
file for a mapping between blah.do
and an “action
” class. The struts.xml could have lines as below:
<URL>blah.do</URL>
<action>BlahClass</action>
<form>BlahParameterClass</form>
<Forward name="some_return_string">some_view.jsp</Forward>
<Forward name="some_other_return_string">some_other_view.jsp</Forward>
So the application server now instantiates BlahClass
; but how do we now pass those parameters to it? Well this is where the <form
> comes into play. This tag defines a class that is something as follows:
public class BlahParameterClass {
String param1;
String param2;
String param3;
public String getParam1() {
return param1;
}
public void setParam1(String param1) {
this.param1 = param1;
}
public String getParam2() {
return param2;
}
public void setParam2(String param2) {
this.param2 = param2;
}
public String getParam3() {
return param3;
}
public void setParam3(String param3) {
this.param3 = param3;
}
}
So as we can see, this code is nothing special. It is merely a set of properties with their associated accessors. And since struts is aware of both of these classes, they are beans as well. (Remember a class becomes a bean when the framework is aware of it's existence and works directly with it). OK so when the struts framework instantiates the BlahParameterClass
and sets the values of its parameters from the URL. The BlahParameterClass
is then passed to BlahClass
with the HTTPRequest
and HTTPResponse
objects. This BlahClass
implements the execute ()
method as mandated by the struts JSR and the application server merely execute's the method. Internally it does whatever it has to and in its return code, it returns a string lets say some_string
…. this string is mapped to the forward tag and then the appropriate jsp
code / templating engine code (viz Velocity, Template::Toolkit etc) is called. It get's converted to HTML and returned to the Web Server. The web server then returns this information in a HTTP RESPONSE packet back to the client. Hooray you now know the base of struts… This is struts 1.0.
The real struts.xml file is as follows:
<action name="peersForm" path="/peers" scope="request" type="packageName.PeersAction"
validate="false" parameter="state">
<forward name="success" path="/peers.jsp"/>
</action>
- The path maps to the URL.
- The name maps to the action tag.
- The type maps to the form tag.
Now what if instead of returning control to a form, we need to call another class to do its job, well; then we need to create parameters within the original class before forwarding the request to the other class. This is bad to say the least but this is struts 2.0.
Enjoy.....
RRD Tool Graphing
One can never select the specific RRA directly but one can do so indirectly by manipulating the start and end times of the graph.
The end time should be:
$End = $Now - ($Now % $Step);
$Start = $Now - ($Width * $Step);
- The next question becomes how can we provide graphs with differing resolutions… so far my understanding is that since 1 column of the RRA maps to 1 pixel, if we are defining an image that is 400 pixels wide, we go back 400 RRA records. But what if we want to provide an image that is 800 pixels wide but go back on 400 RRA records?
- Another tangential question becomes what if we define a start time that is so far back that the number of pixels / columns go beyond the first available record in the RRA, what would be displayed on the graph? Am testing this theory out…
So now lets create a sample RRD Database:
rrdtool create test.rrd test_graphing.rrd \
--start 1314360000 \
--step 300 \
DS:Temperature:GAUGE:600:0:100 \
DS:InBytesPort0:COUNTER:600:U:U \
DS:OutBytesPort0:COUNTER:600:U:U \
RRA:AVERAGE:0.5:1:576 \
RRA:AVERAGE:0.5:144:62 \
RRA:AVERAGE:0.5:288:366
Please refer to the unix time calculator website to get the UTC timestamps.
This gives us the following RRD:
We now go ahead and update the RRD.
rrdtool update test_graphing.rrd 1314360300:20:1000:100000
rrdtool update test_graphing.rrd 1314360600:30:1005:100005
rrdtool update test_graphing.rrd 1314360900:30:1015:100015
rrdtool update test_graphing.rrd 1314361200:30:1115:101015
In fact lets get a script to do it…(Yes it is not generic)….
#!/usr/bin/perl
use strict;
use warnings;
use constant STEP => 300;
my $initial_utc_time = 1314361500;
my $min_temp = 0;
my $max_temp = 100;
my $final_utc_time = time();
my $rrd_file =
"$ENV{HOME}/Documents/Playground/RRDTool/test_graphing.rrd";
my $temp;
my $in_count = 1116;
my $out_count = 101016;
#------------------------------------
# Insert stuff in the RRD.
#------------------------------------
for (
my $for_time = $initial_utc_time ;
$for_time < $final_utc_time ;
$for_time += STEP
)
{
#-------------------------------------
# Get a valid temperature value.
#-------------------------------------
if ( ( $temp = sprintf( "%2.2f", ( rand($max_temp) ) ) ) < $min_temp ) {
$temp = $min_temp;
}
#----------------------------------------
# Get a valid counter value for the
# input and output counters.
#----------------------------------------
$in_count += int( rand(1000) );
$out_count += int( rand(1000) );
system(
'rrdtool',
'update' , $rrd_file,
"${for_time}:${temp}:${in_count}:${out_count}"
);
}
The data generated for your RRD file would be different than mine so expect the graph to be different. That should not impact the discussion in anyway.
The file that was generated by the script above is hosted here.
Now let’s carry out the graphing …