WDK Applications Query Modification for...
Transcript of WDK Applications Query Modification for...
1
11
WDK Applications Query Modification for Performance
Performance Engineering Group
2
22
Agenda
Background– Is it the Query?
Conceptual solution– What can we do?
Steps to follow– How can we fix it?
The performance problem can occur right off, or after time with higher concurrency or larger repository.The fact that the instructions are inside a compiled class, make it impossible to fix without coding.Luckily, the coding is not that difficult so WDK novices can still fit it.
3
33
The Challenges with Queries in WDK
WDK is a framework of pre-built componentsGeneric queries are generated to perform on all databases
– Oracle, SQL Server, Sybase and DB2
Sometimes out-of-the-box queries may not perform as well– Data model or data skew– Database behavior
How do we change pre-built component logic?– Query is in a compiled java class – Appears to be no way to modify it….
WDK is a framework with reusable, pre-built components and controls that perform common Documentum content management functions. Reality – The generic code is written to work for most of the situations, most of the time.Some database are more prone to “issues”. Data models and Data skew can also complicate the matter.
4
44
Something in Webtop performs poorly
2. Request converted to DQL queryWebtop WDK
Query Constructor
DFC
DQL
Q ue r
y
Content Server
Database
1. URL sent from browser
SQL
Que
ry
3. DQL sent to Content Server
4. DQL converted to SQL and sent to Database
DQL
Resu
lt sSQ
LRe
s ult s 5. Results pulled back
(as app server calls dmcl ‘next’ method)
6. Results formatted as HTML page, sent to browser
5
55
Our Focus: When Webtop generates ‘sub-optimal DQL’
We’ll focus on the query constructor;Not the browser page building or the content server processing
6
66
Different ways to Change or Optimize Queries
Append DQL hintsModifying the WHERE clause
– remove of case-insensitivity functions
7
77
Conceptual Solution
We want to modify the generated query– Only for a particular application – Only modify the scenario that is sub-optimal
We don’t want to recode– decode, modify and recode the class
We want upgrades to work– and patches to still apply
8
88
What we’ll need?
Webtop Installation on Test System!WDK Installed over Webtop to be customizedInstall IDE environment to compile java classes
– Netbeans.org– Eclipse.org
Some help in WDK Documentation– WDK and Client Application Development Guide– WDK and Applications Tutorial
integrated development environmentSomething to compile our java into a classWDK install will detect the webtop install and build a customization area
9
99
Methodology
6. Modify query string
1. Define the Problem
2. Find ‘the’ Component
3. Find managing Method
4. Create Extension for Component
5. Call super class in extension
Reproduce poorly performing Webtop functionGet dmcl trace of the function queryGet session trace finding the WDK Component that handles that query stringCreate custom code that calls Super class then modifies the queryShow results of the customization in dmcl traceReproduce Webtop function and its performance
10
1010
Methodology
1. Define the problem
11
1111
Example: Cabinet Displayhttp://localhost:8088/webtop/component/main?Reload=10&__......
SELECT SELECT upper(object_nameupper(object_name), ), r_object_idr_object_id, , ……FROM FROM dm_cabinetdm_cabinetWHERE (WHERE (is_privateis_private = 0 or = 0 or owner_nameowner_name = = USER) andUSER) anda_hiddena_hidden = false = false ORDER BY 1ORDER BY 1
1. Define the problem
We know there is a query behind a poorly performing function
12
1212
DMCL Trace of the Function
Trace.log File# [ 27 ] Tue Sep 28 14:59:22 2004
927999 ( 1.400 sec) ( 1998 rpc) API> query_cmd, s2,T,F,,,,,select upper(object_name),r_object_id,r_object_type,object_name,owner_name from dm_folderwhere folder('/Folders') and a_is_hidden=false order by 1
Application Server
1. Define the problem
First start Webtop, then open a new window and start the trace. Then we take the focus back to the webtop window.This is the time to return the query to the app server. It doesn’t include the time to build the page that issued the query.
13
1313
Methodology
1. Define the Problem
2. Find ‘the’ Component
14
1414
Session Trace of the Component
App Server Log
/80956219 [http8080-Processor3] DEBUG com.documentum.web.common.Trace - Component: Form ImplClass = com.documentum.webtop.webcomponent.streamline.streamlineView
Application Server
2. Find Component
15
1515
Session Component Trace Output
80956219 [http8080-Processor3] DEBUG com.documentum.web.common.Trace - Component: Resolved Start Page = /webtop/webtop/streamline/streamlineview.jsp
80956219 [http8080-Processor3] DEBUG com.documentum.web.common.Trace-Component: Form Impl Class = com.documentum.webtop.webcomponent.streamline.StreamlineView
2. Find Component
16
1616
Application Layers of WDK
wdk layer:– <AppServerRoot>\webapps\<virtualroot>\wdk\
webcomponent layer:– <AppServerRootr>\webapps\<virtualroot>\webcomponent\
webtop layer:– <AppServerRoot>\webapps\<virtualroot>\webtop\
2. Find Component
A WDK-based application has a root directory that contains WEB-INF directory and application layer directories such as ‘wdk’ and ‘/webcomponent’. Documentum WDK client applications add the application layer ‘/webtop’, ‘/wp’, ‘/dam’, ‘/da’. The ‘/custom’ application layer is provided for your customizations. Your custom application layer should extend the applications definition of the top-level application and then add or override functionality.
17
1717
com.documentum.webtop.webcomponent.streamline.StreamlineView
2. Find Component
18
1818
Class Component Extensions
MyComponent
Component
Method-1()
Method-2()
Method-1()
We’ll leverage Java functionality to call another method
This method overrides the one in the super class, however it can call the super class method
19
1919
Methodology
1. Define the Problem
2. Find ‘the’ Component
3. Find managing Method
20
2020
Managing Methods in the Class
StreamlineView extends DrillDown {
You will need WDK expertise hereYou will need WDK expertise here……....
() { ….. }
ItsGreektoMe() { ….. }
}
3. Find Managing Method
21
2121
Managing Methods in the Class
StreamlineView extends DrillDown {
Are any of the methods involved with creating the query?It’s not in the StreamlineView class directly
onInit() { ….. }
updateControlsFromPath() { ….. }
}
3. Find Managing Method
22
2222
Does this class extend any other class?
StreamlineView extends DrillDown {
It might not be obvious..
If its not, then its likely the class that this extends, has the logic
onInit() { ….. }
updateControlsFromPath() { ….. }
}
3. Find Managing Method
23
2323
StreamlineView extends Drilldown
StreamlineView
DrillDown
Where can I find DrillDown.java?
3. Find Managing Method
24
2424
Look for path of DrillDown…
StreamlineView extends DrillDown {
Import statement is a fully qualified path
onInit() { ….. }
updateControlsFromPath() { ….. }
}
Import com.documentum……drilldown.DrillDown;
3. Find Managing Method
Sometime fully-qualified class name, but not always
25
2525
com.documentum.webcomponent.navigation.drilldown.DrillDown
3. Find Managing Method
26
2626
Check the Class that was Extended
DrillDown {
onInit() { ….. }onRefreshData() { ….. }
onClickBreadcrumb() { ….. }
updateControlsFromPath() { ….. }readConfig() { ….. }
}
3. Find Managing Method
Now we check out the methods in this class, that were referenced in the StreamlineView class
27
2727
Are any Methods Creating the Query?
DrillDown {
In this example, updateControlsFromPath method was constructing the query and putting it into a datagrid
Now we know we need to ‘override’ updateControlsFromPath
onInit() { ….. }
updateControlsFromPath() { ….. }readConfig() { ….. }
}
3. Find Managing Method
28
2828
Methodology
1. Define the Problem
2. Find ‘the’ Component
3. Find managing Method
4. Create Extension for Component
29
2929
Create our Extension of StreamlineView
StreamlineView
DrillDown
MyStreamlineView extends StreamlineView which extends DrillDownWe only need to add a method called: updateControlsFromPath()
MyStreamlineView
4. Extend Component
We want to: Copy StreamlineView.java to custom areaRemoved all unneeded referencesExtended the updateControlsFromPath() method
30
3030
4. Extend Component
com.documentum.custom.mystreamlineview.MyStreamlineView
Create a custom java class in WDK
Create custom area as described in the WDK Application Development GuidePut MyStreanlineView.java in the custom area
31
3131
Methodology
1. Define the Problem
2. Find ‘the’ Component
3. Find managing Method
4. Create Extension for Component
5. Call super class in extension
32
3232
How to get the original logic?
In MyStreamlineView.java– Don’t want to have to duplicate all of the original logic– Need to ensure all previous logic is called ‘as is’
Achieve this by calling super class:
super.overridden_method_name(variable);
Example:
super.updateControlsFromPath( strpath )
5. Call Super Class
In MyStreamlineView.java
33
3333
Create custom Class to extend StreamlineView
StreamlineView
DrillDown
MyStreamlineView
updateControlsFromPath( strpath ) { …. super.updateControlsFromPath( strpath ); ….. /* Own custom logic */ …
}
updateControlsFromPath( strpath ) { …. super.updateControlsFromPath( strpath ); ….. /* custom logic */ …
}
updateControlsFromPath( strpath ) { …. }
5. Call Super Class
34
3434
Methodology
6. Modify query string
1. Define the Problem
2. Find ‘the’ Component
3. Find managing Method
4. Create Extension for Component
5. Call super class in extension
35
3535
Modify Code
Get the stringIn most cases just “append” query hint to stringPut new query into datagrid (if required)Compile your classReboot application server
select object_namefrom dm_sysobject
6. Modify Query String
enable (RETURN_TOP 100)
bufDql.appendbufDql.append
(" (" enable(RETURN_TOPenable(RETURN_TOP 100)");100)");
import com.documentum.webcomponent.library.messages.MessageService;public class MyStreamlineView extends com.documentum.webtop.webcomponent.streamline.StreamlineView
{bufDql.append(QUERY_DOC_6);
}// DQL Hint AddedbufDql.append(" enable(RETURN_TOP 100)");// DQL Hint EndMessageService.addMessage( this, "document query: " + bufDql.toString()); Datagrid dgrid = (Datagrid)getControl(CONTROL_DOCGRID, Datagrid.class);DataProvider dproviderFile = dgrid.getDataProvider();dproviderFile.setQuery(bufDql.toString());
}
36
3636
Other uses…
Advanced Search (will be revamped in 5.3)– Strip Lower()
Query using an Oracle hintChange a query to use default_result_set instead of keyset cursors to avoid blocking issues.
6. Modify Query String
Anything you can do in DQL and API
37
3737
Questions?
Look for FAQs published at http://developer.documentum.com
– Sometimes FAQs in Performance Section– Sometimes FAQs under individual product areas