%%weblogic cluster iview q

[b] = [[ weblogic bible ]]
12-month iview questions

Q: give some cluster-techniques for java programmers in your real projects. P 802 [b]

Q: in a cluster, how do session attributes differ from context attributes@@ p 803 [b]

Q: how do u verify session transfer without a web app@@ No answer

Q: how do u know when session transfer fails (without running a web app) @@ No answer.
A: logs?

Q: can u get email alert if a cluster node fails@@

Q: how does the “system” know a node is dead or alive? What’s the “system”, exactly? P798 [b]

Q: replication frq@@ How do u verify@@ logs@@

Q: failover of active jdbc session@@ I doubt it

nitty-gritty:

Q: how do u start the cluster and verify node1 and 2 are linked up@@ log@@

Q: when u deploy an app, u can choose which nodes, but can u choose whether to deploy to the admin server of the cluster? (Hint: the admin server is for the domain, not only for the cluster)

Q: deploying a webapp. do u have to copy to node1 then copy to node2@@ In that case how does the system ensure the 2 copies are identical@@
A: u copy to admin server?

java exception q&&a – nontrivial

A minimum custom exception : “class e1 extends Exception {}”
Q: Where’s the constructor? where’s is the e1(String) constructor?
a: a constructor is needed for the exception obj’s “new” operation

q3: when an exception is thrown, control passes to…?

a1: wrap the exception-prone statements in a try-catch

A: constructor is the invisible e1(){super();} There’s no e1(String)
constructor in this case, since u didn’t define it.

q: is there a constructor for each exception obj?
A: i think so, including the no-arg

a4: on the heap

q1: how do u keep your method “alive” if u know an exception can be thrown
prior to a normal return?

a2: inside the exception obj and the exception type (ie the full class
name), but often there’s nothing inside the obj

q4: is exception obj created with new()? on the heap?

A3: exception handler for this particular (type of) exception

q2: there is specific information about each exception. who needs this
info? where is this info stored?

struts^spring-mvc: 1-controller@@

Struts also has an “specialized” controller per action — the LoginAction/SignupAction/DetailsAction… classes, even though they only constitute part of the controller. The singular ActionServlet is the other part of the controller.

In summary, For Each action u need 0 or 1 form, 0 or more views, a 2-part controller, 1 mapping to tie them together

As you can see, the Model thingy is elusive.

illustrating minimal DB index

–an analogy to illustrate index concept (master copy on recoll->tref): a pile of receipts sorted by shipping date

one record number on each receipt => row-id
one non-unique customer name on each page.
one unique but unsorted order number on each page

Goal: given names or order numbers, quickly get to the relevant receipts without Scan.

To build an index on the unique order number is easy — use a spreadsheet or a stack of cards to record the order-numbers vs receipt-numbers, and sort by order-number. (B*-tree is slightly diff)

To build an index on names… After sorting, cards with same names would come together. U need to consolidate them on 1 card.

sql normenclature

Clarity and brevity are the #1 and #2 goals of technical communication.

A stored function can serve as a “select ITEM”, an “order-by-ATTRIBUTE”, a “group-by-FIELD”, or part of a “where-CRITERIA” or “having-PREDICATE” — “criteria/predicate” are more precise than “condition”.

A view and a sub-select can serve as a “from TARGET”

A forkey entry/value “references” a prikey entry/value.
3 forkeys (columns) can “refererence/point-to/refer-to” the same prikey.
A table can have 2 forkeys (columns) pointing to 2 prikeys, in 2 tables.

“20 rows, each containg 4 FIELDS” —- Avoid “column” .

A column can “hold 14 ENTRIES / values ” (Avoid “values” ) but only 9 “distinct values” including the special “null value”.

The 14 entries include 2 “null ENTRIES / values” (Avoid “values” ) , so there are only 12 KNOWN-VALUES.

“Entry” has a more specific meaning. “2 null entries” sound better than “2 null values”.

Many say “These 2 values are identical.”, but It’s clearer to say “These 2 RECORDS are identical” when you select several non-key columns.

“duplicate ENTRIES / RECORDS” —- Avoid “values”

%% iview quiz #9 — pl/sql

I wrote countless PL/SQL programs over 5 years but my limited recall of details isn’t convincing to interviewers. There are big volumes devoted to pl/sql. I think some big companies rely heavily on pl/sql and would value deep pl/sql experience, including lots of important details.

Sugg: put your findings on the internet and attract exposure
Sugg: develop simple learning aids such as binary frameworks
Sugg: self-quiz. Here’s a largely unordered list of mock iview questions.

– top 5 concepts: cursor, exception, perf/volume
– Keep for 2 years.
– answers? no need

a7: 2 extremely powerful uses of functions with views
1) use a function in a view definition, as a select field
2) instead-of triggers on a view can employ a function
A34: largest pl/sql procedure in our system has a few thousand lines. Largest package has millions of lines. Not sure what they do. Perhaps billing or reporting.

q: can u use a function in a view definition?
q: what if a select-into returns 0 or more than 1 row? What’s the best practice
q: a pl/sql trigger can be defined for a ROW or a TABLE. meaning?
q: what builtin packages have you used?
A: DBMS_XSLprocessor, dbms_output, utl_file, dbms_job

q34: what’s your largest pl/sql package
q7: have you used pl/sql functions with views?
q: how did you choose between global var and param-passing@@
q: common exceptions@@
A: “when no_data_found then ..”, “when zero_divide then ..” Note that %NOTFOUND is a cursor attribute and not an exception used in “when..then”

pl/sql exception ^ java exception

— raise == re-throw that same exception you caught
Unlikely java, “raise” is a one-word statement. No need to mention the exception name.

–propagation
An uncaught exception is thrown to the enclosing caller on the call stack.

–when when when == catch catch catch

–when other == catch (Exception ex)

–oracle standard exception == java standard exception
–pl/sql user-defined exception == java custom exception
error message = toString() of the custom exception

biz rules ] DB

What are Business rules? They are set by the business. These guys have written rules. Don’t ask me exactly what qualify and what don’t qualify as business rules. Business rules can be implemented in java, javascript or batch.

Many business rules are best implemented inside the DB. Reason? The concept of biz rule is popularized and heavily influenced by DB industry, vendors and practitioners. Most things that /pass as/ biz rules are defined in terms of DB records (real world objects represented by records). As a result, these biz rules can be and often are best described, saved, encoded in a DB format.

Below are just a few buzzwords, not meant to be an orthogonal, mutually exclusive list of things.

– unique constraint — eg: member id must be unique
– not-null — eg: “We can’t leave this field blank”
– RI — May not be a rule set by business, but closely related to other business rules. eg: “When this salesperson resigns, all her customers must be assigned a replacement salesperson.”
– check constraint — Can be complex. I think (??? confirmed) they should be applied at modification time.
– triggers — can implement RI, check constraints,
– – > input-validation trigger is an important, well-defined type of
– derived data — insert or update “derived data” via triggers, to let java classes select them without “deriving”. The derivation formula contain business rules.
– authorization and access control via views and stored-procs. May not qualify as business rules.
– stored proc — most flexible. Can implement the most complex rules set by business, involving multiple objects.
– – > multi-table correlated modification via stored programs
– cascade delete
– views — can contain business rules in the view’s definition query. eg: “These class of users can only read/modify this subset of data — not those protected columns or irrelevant rows. They should always see the details of each purchase — by a table join.”

An architect should learn this list of techniques. Move business rules from java classes into DB whenever possible, to reduce the complexity of java classes. A large system usually has 60-90% of the business logic implemented in application source code (like java). That’s too much to manage. It’s good to move some to javascript or DB.

[[ pl/sql for dummies ]] advocates putting most “business logic” in DB rather than java. The most complex business logic would need big guns like
* procedures
* functions
* triggers
* complex views, perhaps containing functions in their definitions and have instead-of triggers defined on them.

pl/sql exception — template

A basic template (anon or named) is —
DECLARE
BEGIN
EXCEPTION
WHEN
WHEN

WHEN
END;

A longer template is

DECLARE -- sometimes u don't see DECLARE
some_var NUMBER
some_var2 DATE
...
user_defined_exception8 EXCEPTION; -- create a name for your custom exception
BEGIN
statements -- a lot
...
EXCEPTION -- one occurence only
WHEN standard_exception1 THEN
statement82
...
RAISE; -- you don't have to raise.

WHEN standard_exception25 THEN
NULL -- do nothing. Just jump to END.
-- If there's an enclosing block, continue with it

WHEN standard_exception7 THEN
statement28
...
RETURN NULL

WHEN user_defined_exception8 THEN
statement7
...

WHEN OTHER THEN -- catch-all
statement61
...
-- no other statements between END and the last WHEN
END;

DataSource==database-conn-source

DataSource=database conn source, a source of Connection objects (or conn poolsss)

Increase your retention rate by putting aside all the noise beside the top 2 [two] things about a data source:

1) each data source has a name in a jndi tree
2) a data source is a conduit to a conn pool. Think of it as a pipe to get the stuff (h2o or physical connections) from the pool

[[ oreilly weblogic ]] has a short and sharp coverage of datasource ^ conn pool in a weblogic cluster

a data source and a connectionFactory are both registered on jndi tree

Q: a data source is similar to a connectionFactory in jms and other areas. Any real difference?

THEN && END – in shell and pl/sql

Most block constructs need an “End …” since they don’t use “{” for blocks.
Most conditionals need a “Then” , since they don’t use “{” for blocks.

Applicable to most stored procedure and shell scripts.

1) First, let’s internalize these simple, approximate rules. You will get ahead, since many people don’t even notice these simple patterns.

2) When we have the resources and the need, we can list the exceptions, but don’t need to memorize 100% or even 80%. Just memorize some.

3) When we have more resources and need, we try to memorize more.