Ellucian Live 2013 Presentation Template PPT 97-2003

Download Report

Transcript Ellucian Live 2013 Presentation Template PPT 97-2003

Turbo-Charging
Advance Web
Response
with Forward Caching
Presented by: Presenter Tom Jamate,
University of Massachusetts
April 10, 2013
Session ID 2524
Session ID 2524
1
Introduction
• The challenge with any web-based application is delivering content to
the user in a timely manner.
• Long-running SQL and repeated server-client round trips can seriously
degrade response time and lead to user frustration as they wait for page
loads.
• Having application content pre-loaded on the web server dramatically
increases response time. This can include reports, web pages, charts
and graphics
• This presentation will demonstrate the technical details with some
examples of setting up forward caching on an Advance Web server
using the Java runtime environment.
Session ID 2524
2
The Problem
• We exist in a competitive IT environment. Users
expect to have information at their fingertips.
• Large scales web applications, such as Google,
Gmail, Facebook and Twitter feed this
expectation of instant information.
• Using SQL to generated content, with db server
round trips can be expensive time-wise.
Session ID 2524
3
Current approaches
• Hardware engineering: hard drives and video systems
make heavy use of buffering.
Local
Cache
Local
Cache
Local
Cache
Content
Originator
Local
Cache
Local
Cache
Local
Cache
• Internet Content Delivery Networks (CDNs) move
content closer to users.
Session ID 2524
4
One approach
• This presentation will show you how to setup a batchdriven forward cache on an Advance Web server using
commonly available tools:
• Java/JDBC
• Window job scheduler
• Oracle pl/sql
• Javascript
• jQuery
• ASP/VB.Net
• A few moving parts, but not a lot of code, a page or two per
stage.
Session ID 2524
5
Gift summary forward cache example
• A Gift summary report, or JSON data for a web chart (or
any content), would take too long to pull ‘live’ to a web
page. The data to generate the gift summary is located
on a database table. We can batch load the report data
to the web server once a night:
Session ID 2524
6
Process overview
Generate and Deliver
Session ID 2524
7
Generate local cache.
1. Web Server
AW / IIS
2. Batch job runs
Overnight
(Java/jdbc program
pull from db)
3. Oracle HTML
wrapper SP
calls report SP.
Refcursor output
wrapped in HTML
snippet.
4. File saved to
local web server.
Session ID 2524
8
Cache delivery
1. User’s web browser
web server
2. HTML Cache ‘retriever’ process
AW Web form
Custom ASP.Net to handle request
Gift Campaign
Summary
Javascript
jQuery / Ajax
loads snippet into HTML
<div> tag.
3. Local file System
HTML/JSON snippet directory.
Database
Server
Session ID 2524
9
Generate cache details
Setting up web server batch pull, java
jdbc utility programs, Oracle store
procedure.
Session ID 2524
10
Generate local cache details.
1. Web Server
AW / IIS
2. Batch job runs
Overnight
(Java/jdbc program
pull from db)
3. Oracle HTML
wrapper SP
calls report SP.
Refcursor output
wrapped in HTML
snippet.
4. File saved to
local web server.
Session ID 2524
11
1. Schedule job (web server)
The Windows scheduling tool is located under:
..Accessories/System Tools/Scheduled Tasks
The batch job runs
a java program on
the web server.
Session ID 2524
12
2. Web server pull (Java/jdbc connector)
Most Oracle client-installs include the Java JRE and the jdbc library. Javac is the
bytecode compiler used to turn your Java code into class files that Java can run.
Jdbc is widely supported with many example available:
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection
( "jdbc:oracle:thin:@"+“ORA_SERVER:PORT:SID"
,user_provider[1],pass_provider[2] );
// Call Oracle SP
CallableStatement cstmt3 =
conn.prepareCall("begin advschema.cp_program_step_sp_htm(?); end;");
cstmt3.registerOutParameter
(1, oracle.jdbc.driver.OracleTypes.VARCHAR);
cstmt3.execute();
String output2 = (String)cstmt3.getObject(1);
// Write html snippet from string to local file.
FileWriter fr = new FileWriter( fcache_dir + “foo_out.html");
PrintWriter pw = new PrintWriter(fr, true);
pw.println(output2);
// … Create as many request/cache files as needed.
Session ID 2524
13
2. (Cont) Java/jdbc ( Refcursor example)
Another Java / jdbc example, input parameters with refcursor output.
CallableStatement cstmt
= conn.prepareCall("begin advschema.cp_program_step_sp_htm(?,?); end;");
cstmt.setString(1, in_value_01);
cstmt.registerOutParameter(2, oracle.jdbc.driver.OracleTypes.CURSOR);
cstmt.execute();
ResultSet rs = (ResultSet) cstmt.getObject(2);
ResultSetMetaData rsm = rs.getMetaData();
int columnCount = rsm.getColumnCount();
while (rs.next()){
System.out.println(“Cols Test: "
+ rs.getString(1) + ", " + rs.getString(2) );
for (int j=0;j< columnCount;j++){
output2 = rs.getObject(j+1) + output2;
}
}
Session ID 2524
14
3. Database side: Stored Procedure (pl/sql )
type rec_out is record
(
SCHOOL varchar2(50),
…
DATE_ADDED date
);
rc rec_out;
Generating HTML content
on the database side is not
ideal but does work well
enough for this purpose.
There is another approach
we’ll get too.
// Gift summary report SP.
cp_program_step_report(rc1 => c_inter);
loop
fetch c_inter into rc;
exit when c_inter%notfound;
o_string := chr(10)||'<tr><td> '||rc.SCHOOL||'<td> '||
…
'<td>'||TO_CHAR(round(rc.GOAL), '$999,999,999')||
o_string;
end loop;
close c_inter;
o_out_string := chr(10)||'<TABLE width=100% border=0>' ||
o_string||chr(10)||'</table>';
Session ID 2524
15
4. Gift Summary snippet-file on local server.
1.
2.
3.
Scheduler launches java batch program.
Java program runs Gift Summary stored procedure html wrapper.
Output saved to local file:
<table width=60% border=0>
<tr><th align=center colspan=4>Quarterly Step Progress
<tr><th>School<th>Current Total<th>Goal<th> %Goal
<tr><td >Behavioral Sciences<td align=right >
$5,000,000<td
align=right >
$5,000,000<td align=right > 100%
<tr><td >Librarary Science<td align=right >
$1,000,000<td
align=right >
$5,000,000<td align=right > 20%
<tr><td >Engineering<td align=right >
$3,123,456<td
align=right >
$5,000,000<td align=right > 62%
</table>
Session ID 2524
16
Cache delivery
details
Deliver the local cached content when
an Advance Web form is requested for
display.
Session ID 2524
17
Cache delivery details.
1. User’s web browser
2. HTML Cache ‘retriever’ process
Small custom ASP.Net to handle request
AW Web form loads
Javascript
jQuery / Ajax
loads snippet into HTML
<div> tag.
URL Request
3. Local file System
HTML snippet directory.
Request is handled locally, no round trip to the database,
appears to load instantly.
Session ID 2524
18
1. AW form references JS jQuery/AJAX to populate <DIV>
Advance Web
HTML
Form Control
Maintenance:
<script src="/ext/js/jquery.min.js"
(not needed on current AW versions)
type="text/javascript"></script>
<div id="um_foo_v4"> </div>
<!– Container to be updated. -->
<script type="text/javascript">
$(document).ready(function () {
//$ is jQuery’s access
$('#um_foo_v4').load('um/test/um_fc.aspx?s=g_step_sum');
});
</script>
Small VB.Net handler
Session ID 2524
19
jQuery client-side Javascript library
• jQuery is an open source library that greatly simplifies a
number of otherwise onerous Javascript tasks, such as
DOM (web page elements) manipulation and (browserindependent) AJAX calls.
• jQuery with AJAX makes it relatively easy to update a
single element on a web page from an external source or
URL, without the need for a full page refresh.
• jQuery is fast becoming a universal tool used on many
websites. jQuery’s motto is: write less, do more.
• Official website: http://jquery.com/
Session ID 2524
20
2. Cache ‘retriever’ handler, IIS/VB.net/aspx file
Custom VB.Net cgi to handle jQuery load request (not vendor supported). aspx
files execute from a IIS Web directory in response to a web URL request. Read
cache-request parameter, write cache file to web response.
‘ File access init.
Dim oFile as System.IO.File
Dim oRead
Dim LineIn = " "
‘ Read web get input.
Dim s_cache_req = “-”
s_cache_req = web_sanitize(Request.QueryString(“s”))
‘ Read Cache file and write out to web response.
‘ Setup for as many as needed…
if req_valid(s_cache_req) then
oRead = oFile.OpenText( fcache_dir + s_cache_req )
While oRead.Peek <> -1
LineIn = oRead.ReadLine()
Response.Write( LineIn + NL )
End While
oRead.Close()
end if ‘s_cache_req = g_step_sum
Session ID 2524
21
2. Cache ‘retriever’ handler, IIS/vb.net/aspx file (Cont.)
From the VB.Net handler it’s possible to get access to the Advance Web user login context using
the AdvanceWebPageInformation object. You can use it to test for access and authentication,
not vendor supported:
Protected Function GetAdvPInfo() As AdvanceWebPageInformation
Dim _AdvPInfo = New AdvanceWebPageInformation
With _AdvPInfo
.InitCollections(Me.Controls, Me.Request.Form, Me.Request.QueryString,
Me.Session, Me.Validators)
.User = DirectCast(Session("AdvUser"), IAdvanceUser)
.Request = Me.Request
.Response = Me.Response
.PageType = Page.GetType()
.InstanceId = _instanceId
End With
Return _AdvPInfo
End Function
‘ Simple access example, zz_user info:
Response.Write("<BR><SMALL>You are: " + Me.GetAdvPInfo().User.Name)
Response.Write(" UserGroup: " + Me.GetAdvPInfo().User.UserGroup)
Response.Write(" .e-id: " + Cstr(Me.GetAdvPInfo().User.EntityID) +
"</SMALL>")
Session ID 2524
22
3. Locally cached file loads summary snippet into AW form:
1.
2.
3.
AW form loads, javascript jQuery call requests cached content.
Cache ‘retriever’ handler loads local file into <DIV> tags
Cached snippet displays (almost instantly) inside web form.
Session ID 2524
23
Further Refinements
Use Javascript, DOM
and JSON for the
presentation layer.
Session ID 2524
24
Further Refinement, using JS and JSON
• Eliminate the Oracle HTML wrapper step.
• Instead, the overnight batch process will
write JSON formatted data to the cache
file.
• JSON is fed to the browser-side Javascript
engine, using HTML5, DOM and CSS for
display logic.
Session ID 2524
25
JSON and client-side Javascript
• JSON = Javascript Object Notation
• Data interchange format, similar, yet lighter than XML. It
has become the lingua franca for internet applications
and web services.
• There’s an astonishingly wide array of tools and libraries
that use JSON to process and display web content,
including the open source DataTables
(http://datatables.net) library.
• The DataTables javascript library accepts JSON input
from a URL to render an HTML table inside a page.
Session ID 2524
26
JSON example, Gift summary data
{ "aaData": [
["Architecture","
$3,002,122","
["Behavioral Sci","
["Engineering","
$3,123,456","
["Librarary Sci","
["Marketing","
$500,000","
$2,000,000","
$5,000,000","
$5,000,000","
$1,000,000","
$2,002,122","
$1,000,000","
27
10%","01/01/2013"],
62%","01/01/2013"],
$5,000,000","
] }
Session ID 2524
150%", "01/01/2013"],
20%","01/01/2013"],
200%","01/01/2013“ ]
Generate JSON formatted local cache.
1. Web Server
AW / IIS
2. Batch job runs
Overnight
(Java/jdbc program
pull from db)
3. Oracle HTML
wrapper SP
calls report SP.
Refcursor output
wrapped in JSON
snippet.
4. JSON File saved to
local web server.
Session ID 2524
28
Cache delivery using JSON
1. User’s web browser
AW Web form
2. HTML Cache ‘retriever’ process
Javascript
jQuery / Ajax
calls JSON file to
Datatables JS function.
Custom ASP.Net to handle request
3. Local file System
JSON file format.
Session ID 2524
29
Java/jdbc JSON output
Web server overnight batch: Java / jdbc JSON generator:
cstmt = conn.prepareCall
("begin advschem.cust_t,temp_cp_program_step_sp_js(?); end;");
cstmt.registerOutParameter(1, oracle.jdbc.driver.OracleTypes.CURSOR);
cstmt.execute();
rs = (ResultSet) cstmt.getObject(1);
rsm = rs.getMetaData();
columnCount = rsm.getColumnCount();
output2 = "{ \"aaData\": [ ";
// Loop through refcursor output
while (rs.next()){
output2 = output2 + "\n [";
for (int j=0;j< columnCount;j++){
output2 = output2 + "\"" + rs.getObject(j+1)+"\"," ;
}
output2 = output2 + " \"\" ]," ;
}
// Write to local file
fr = new FileWriter(fcache_dir + “gsumm_js.json");
Session ID 2524
30
Setup AW form to pull JSON into JS
AW form control, use Javascript and DataTables to create formatted table inside
<DIV>.
Session ID 2524
31
Setup AW form, JS DataTable function.
<script language="JavaScript"
src=“../js/jquery.dataTables.js"> </script>
<script language="JavaScript" src=“../js/TableTools.js">
</script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var oTable = $('#example').dataTable( {
" bJQueryUI": true,
"bProcessing": true,
"sPaginationType": "two_button",
"sDom": '<"H"Tfr>t<"F"ip>',
"sAjaxSource": '../..//um_fc.aspx?s=gsumm_js'
} );
} );
</script>
Session ID 2524
32
JSON example, loaded DataTable in AW.
Session ID 2524
33
Summary
• Problem: expectation of instant information.
• Forward Cache, moving content closer to users,
eliminates the need for a round trip to the
database.
• Overnight batch to the web server via Java using
HTML snippet output.
• Overnight batch to the web server using JSON
and Javascript to render when requested.
Session ID 2524
34
Questions? Answers?
?
Session ID 2524
35
Thank You!
Presenter Tom Jamate, UMass Amherst
[email protected]
Please complete the online session evaluation form
Session ID 2524
.
Session ID 2524
© 2013 Ellucian. All rights reserved.
36