336 lines
13 KiB
HTML
336 lines
13 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
|
<!-- NewPage -->
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<!-- Generated by javadoc (1.8.0_151) on Tue Oct 31 17:36:52 EDT 2017 -->
|
||
|
<title>RouterDrivenStockQuotes (Oracle - Berkeley DB Java Edition Examples)</title>
|
||
|
<meta name="date" content="2017-10-31">
|
||
|
<link rel="stylesheet" type="text/css" href="../../../style.css" title="Style">
|
||
|
<script type="text/javascript" src="../../../script.js"></script>
|
||
|
</head>
|
||
|
<body>
|
||
|
<script type="text/javascript"><!--
|
||
|
try {
|
||
|
if (location.href.indexOf('is-external=true') == -1) {
|
||
|
parent.document.title="RouterDrivenStockQuotes (Oracle - Berkeley DB Java Edition Examples)";
|
||
|
}
|
||
|
}
|
||
|
catch(err) {
|
||
|
}
|
||
|
//-->
|
||
|
var methods = {"i0":9};
|
||
|
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete Methods"]};
|
||
|
var altColor = "altColor";
|
||
|
var rowColor = "rowColor";
|
||
|
var tableTab = "tableTab";
|
||
|
var activeTableTab = "activeTableTab";
|
||
|
</script>
|
||
|
<noscript>
|
||
|
<div>JavaScript is disabled on your browser.</div>
|
||
|
</noscript>
|
||
|
<!-- ========= START OF TOP NAVBAR ======= -->
|
||
|
<div class="topNav"><a name="navbar.top">
|
||
|
<!-- -->
|
||
|
</a>
|
||
|
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
|
||
|
<a name="navbar.top.firstrow">
|
||
|
<!-- -->
|
||
|
</a>
|
||
|
<ul class="navList" title="Navigation">
|
||
|
<li><a href="../../../je/rep/quote/package-summary.html">Package</a></li>
|
||
|
<li class="navBarCell1Rev">Class</li>
|
||
|
<li><a href="package-tree.html">Tree</a></li>
|
||
|
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
|
||
|
<li><a href="../../../index-all.html">Index</a></li>
|
||
|
<li><a href="../../../help-doc.html">Help</a></li>
|
||
|
</ul>
|
||
|
<div class="aboutLanguage"><b>Berkeley DB Java Edition Examples</b><br><font size=\"-1\"> version 7.5.11</font>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="subNav">
|
||
|
<ul class="navList">
|
||
|
<li><a href="../../../je/rep/quote/HARouter.html" title="class in je.rep.quote"><span class="typeNameLink">Prev Class</span></a></li>
|
||
|
<li><a href="../../../je/rep/quote/RunTransaction.html" title="class in je.rep.quote"><span class="typeNameLink">Next Class</span></a></li>
|
||
|
</ul>
|
||
|
<ul class="navList">
|
||
|
<li><a href="../../../index.html?je/rep/quote/RouterDrivenStockQuotes.html" target="_top">Frames</a></li>
|
||
|
<li><a href="RouterDrivenStockQuotes.html" target="_top">No Frames</a></li>
|
||
|
</ul>
|
||
|
<ul class="navList" id="allclasses_navbar_top">
|
||
|
<li><a href="../../../allclasses-noframe.html">All Classes</a></li>
|
||
|
</ul>
|
||
|
<div>
|
||
|
<script type="text/javascript"><!--
|
||
|
allClassesLink = document.getElementById("allclasses_navbar_top");
|
||
|
if(window==top) {
|
||
|
allClassesLink.style.display = "block";
|
||
|
}
|
||
|
else {
|
||
|
allClassesLink.style.display = "none";
|
||
|
}
|
||
|
//-->
|
||
|
</script>
|
||
|
</div>
|
||
|
<div>
|
||
|
<ul class="subNavList">
|
||
|
<li>Summary: </li>
|
||
|
<li>Nested | </li>
|
||
|
<li>Field | </li>
|
||
|
<li>Constr | </li>
|
||
|
<li><a href="#method.summary">Method</a></li>
|
||
|
</ul>
|
||
|
<ul class="subNavList">
|
||
|
<li>Detail: </li>
|
||
|
<li>Field | </li>
|
||
|
<li>Constr | </li>
|
||
|
<li><a href="#method.detail">Method</a></li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<a name="skip.navbar.top">
|
||
|
<!-- -->
|
||
|
</a></div>
|
||
|
<!-- ========= END OF TOP NAVBAR ========= -->
|
||
|
<!-- ======== START OF CLASS DATA ======== -->
|
||
|
<div class="header">
|
||
|
<div class="subTitle">je.rep.quote</div>
|
||
|
<h2 title="Class RouterDrivenStockQuotes" class="title">Class RouterDrivenStockQuotes</h2>
|
||
|
</div>
|
||
|
<div class="contentContainer">
|
||
|
<ul class="inheritance">
|
||
|
<li>java.lang.Object</li>
|
||
|
<li>
|
||
|
<ul class="inheritance">
|
||
|
<li><a href="../../../je/rep/quote/StockQuotes.html" title="class in je.rep.quote">je.rep.quote.StockQuotes</a></li>
|
||
|
<li>
|
||
|
<ul class="inheritance">
|
||
|
<li>je.rep.quote.RouterDrivenStockQuotes</li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
</ul>
|
||
|
<div class="description">
|
||
|
<ul class="blockList">
|
||
|
<li class="blockList">
|
||
|
<dl>
|
||
|
<dt>Direct Known Subclasses:</dt>
|
||
|
<dd><a href="../../../je/rep/quote/UpdateForwardingStockQuotes.html" title="class in je.rep.quote">UpdateForwardingStockQuotes</a></dd>
|
||
|
</dl>
|
||
|
<hr>
|
||
|
<br>
|
||
|
<pre>public class <span class="typeNameLabel">RouterDrivenStockQuotes</span>
|
||
|
extends <a href="../../../je/rep/quote/StockQuotes.html" title="class in je.rep.quote">StockQuotes</a></pre>
|
||
|
<div class="block">This class is based on <a href="../../../je/rep/quote/StockQuotes.html" title="class in je.rep.quote"><code>StockQuotes</code></a> and illustrates use of an
|
||
|
HA-aware router (implemented by <a href="../../../je/rep/quote/HARouter.html" title="class in je.rep.quote"><code>HARouter</code></a>), in conjunction with the
|
||
|
<a href="../../../../java/com/sleepycat/je/rep/monitor/Monitor.html?is-external=true" title="class or interface in com.sleepycat.je.rep.monitor"><code>Monitor</code></a> class, to direct
|
||
|
application requests, based upon the type of request (read or write) and the
|
||
|
state (Master or Replica) of a node in the replication group. This example
|
||
|
is meant to illustrate how a software load balancer might be integrated with
|
||
|
JE HA, where <code>HARouter</code> plays the role of the load balancer for
|
||
|
purposes of the example.
|
||
|
<p>
|
||
|
Be sure to read the <a href="../../../je/rep/quote/package-summary.html"><code>Example Overview</code></a> first to put this
|
||
|
example into context.
|
||
|
<p>
|
||
|
In this example, unlike <code>StockQuotes</code>, only the HARouter has a
|
||
|
console associated with it. It accepts commands typed into its console and
|
||
|
forwards them as appropriate to the Master and Replicas in the group. The
|
||
|
logic for tracking the Master resides in <code>HARouter</code>, and
|
||
|
information about the state of the replication group is supplied by the
|
||
|
<a href="../../../../java/com/sleepycat/je/rep/monitor/Monitor.html?is-external=true" title="class or interface in com.sleepycat.je.rep.monitor"><code>Monitor</code></a>. While this example
|
||
|
uses just one HARouter instance for the entire group, production
|
||
|
applications could use multiple router instances to avoid single points of
|
||
|
failure.
|
||
|
<p>
|
||
|
Each node, which in this example is an instance of
|
||
|
<code>RouterDrivenStockQuotes</code>, establishes a server socket on which
|
||
|
it can listen for requests from HARouter. The node that is currently the
|
||
|
Master will expect both write and read requests from HARouter, while nodes
|
||
|
that are Replicas will only expect read requests from the router.
|
||
|
<p>
|
||
|
The request flow between nodes in this example is shown below.
|
||
|
<pre>
|
||
|
------------ Read requests
|
||
|
| HARouter |------------------------------------||
|
||
|
| Instance |---------------------|| ||
|
||
|
------------ || ||
|
||
|
|| || ||
|
||
|
|| Write requests || ||
|
||
|
\/ || ||
|
||
|
--------------------------- || ||
|
||
|
| RouterDrivenStockQuotes | || ||
|
||
|
| Instance 1: Master | || ||
|
||
|
--------------------------- \/ ||
|
||
|
--------------------------- ||
|
||
|
| RouterDrivenStockQuotes | ||
|
||
|
| Instance 2: Replica | ||
|
||
|
--------------------------- \/
|
||
|
---------------------------
|
||
|
| RouterDrivenStockQuotes |
|
||
|
| Instance 3: Replica |
|
||
|
---------------------------
|
||
|
|
||
|
...more Replica instances...
|
||
|
</pre>
|
||
|
<p>
|
||
|
This example is intended to be illustrative. It forwards requests as text,
|
||
|
and receives responses in text form. Actual applications may for example,
|
||
|
forward HTTP requests, or use some other application level network protocol
|
||
|
to forward such requests.
|
||
|
<p>
|
||
|
Please review the javadoc in <a href="../../../je/rep/quote/StockQuotes.html" title="class in je.rep.quote"><code>StockQuotes</code></a> for a detailed description
|
||
|
of the arguments that must be supplied at startup. The only difference is
|
||
|
that you must use the name of this class when invoking the JVM. For example,
|
||
|
the first node can be started as follows:
|
||
|
|
||
|
<pre>
|
||
|
java je.rep.quote.RouterDrivenStockQuotes -env /tmp/stockQuotes1 \
|
||
|
-nodeName n1 \
|
||
|
-nodeHost node.acme.com:5001 \
|
||
|
-helperHost node.acme.com:5001
|
||
|
</pre>
|
||
|
|
||
|
In addition to starting the nodes, you will also need to start the
|
||
|
<a href="../../../je/rep/quote/HARouter.html" title="class in je.rep.quote"><code>HARouter</code></a> as described in its javadoc.</div>
|
||
|
<dl>
|
||
|
<dt><span class="seeLabel">See Also:</span></dt>
|
||
|
<dd><a href="../../../je/rep/quote/HARouter.html" title="class in je.rep.quote"><code>HARouter</code></a></dd>
|
||
|
</dl>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<div class="summary">
|
||
|
<ul class="blockList">
|
||
|
<li class="blockList">
|
||
|
<!-- ========== METHOD SUMMARY =========== -->
|
||
|
<ul class="blockList">
|
||
|
<li class="blockList"><a name="method.summary">
|
||
|
<!-- -->
|
||
|
</a>
|
||
|
<h3>Method Summary</h3>
|
||
|
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
|
||
|
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd"> </span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd"> </span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd"> </span></span></caption>
|
||
|
<tr>
|
||
|
<th class="colFirst" scope="col">Modifier and Type</th>
|
||
|
<th class="colLast" scope="col">Method and Description</th>
|
||
|
</tr>
|
||
|
<tr id="i0" class="altColor">
|
||
|
<td class="colFirst"><code>static void</code></td>
|
||
|
<td class="colLast"><code><span class="memberNameLink"><a href="../../../je/rep/quote/RouterDrivenStockQuotes.html#main-java.lang.String:A-">main</a></span>(java.lang.String[] argv)</code> </td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
<ul class="blockList">
|
||
|
<li class="blockList"><a name="methods.inherited.from.class.je.rep.quote.StockQuotes">
|
||
|
<!-- -->
|
||
|
</a>
|
||
|
<h3>Methods inherited from class je.rep.quote.<a href="../../../je/rep/quote/StockQuotes.html" title="class in je.rep.quote">StockQuotes</a></h3>
|
||
|
<code><a href="../../../je/rep/quote/StockQuotes.html#quit-java.io.PrintStream-">quit</a></code></li>
|
||
|
</ul>
|
||
|
<ul class="blockList">
|
||
|
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
|
||
|
<!-- -->
|
||
|
</a>
|
||
|
<h3>Methods inherited from class java.lang.Object</h3>
|
||
|
<code>equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<div class="details">
|
||
|
<ul class="blockList">
|
||
|
<li class="blockList">
|
||
|
<!-- ============ METHOD DETAIL ========== -->
|
||
|
<ul class="blockList">
|
||
|
<li class="blockList"><a name="method.detail">
|
||
|
<!-- -->
|
||
|
</a>
|
||
|
<h3>Method Detail</h3>
|
||
|
<a name="main-java.lang.String:A-">
|
||
|
<!-- -->
|
||
|
</a>
|
||
|
<ul class="blockListLast">
|
||
|
<li class="blockList">
|
||
|
<h4>main</h4>
|
||
|
<pre>public static void main(java.lang.String[] argv)
|
||
|
throws java.lang.Exception</pre>
|
||
|
<dl>
|
||
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
||
|
<dd><code>java.lang.Exception</code></dd>
|
||
|
</dl>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
</div>
|
||
|
<!-- ========= END OF CLASS DATA ========= -->
|
||
|
<!-- ======= START OF BOTTOM NAVBAR ====== -->
|
||
|
<div class="bottomNav"><a name="navbar.bottom">
|
||
|
<!-- -->
|
||
|
</a>
|
||
|
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
|
||
|
<a name="navbar.bottom.firstrow">
|
||
|
<!-- -->
|
||
|
</a>
|
||
|
<ul class="navList" title="Navigation">
|
||
|
<li><a href="../../../je/rep/quote/package-summary.html">Package</a></li>
|
||
|
<li class="navBarCell1Rev">Class</li>
|
||
|
<li><a href="package-tree.html">Tree</a></li>
|
||
|
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
|
||
|
<li><a href="../../../index-all.html">Index</a></li>
|
||
|
<li><a href="../../../help-doc.html">Help</a></li>
|
||
|
</ul>
|
||
|
<div class="aboutLanguage"><b>Berkeley DB Java Edition Examples</b><br><font size=\"-1\"> version 7.5.11</font>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="subNav">
|
||
|
<ul class="navList">
|
||
|
<li><a href="../../../je/rep/quote/HARouter.html" title="class in je.rep.quote"><span class="typeNameLink">Prev Class</span></a></li>
|
||
|
<li><a href="../../../je/rep/quote/RunTransaction.html" title="class in je.rep.quote"><span class="typeNameLink">Next Class</span></a></li>
|
||
|
</ul>
|
||
|
<ul class="navList">
|
||
|
<li><a href="../../../index.html?je/rep/quote/RouterDrivenStockQuotes.html" target="_top">Frames</a></li>
|
||
|
<li><a href="RouterDrivenStockQuotes.html" target="_top">No Frames</a></li>
|
||
|
</ul>
|
||
|
<ul class="navList" id="allclasses_navbar_bottom">
|
||
|
<li><a href="../../../allclasses-noframe.html">All Classes</a></li>
|
||
|
</ul>
|
||
|
<div>
|
||
|
<script type="text/javascript"><!--
|
||
|
allClassesLink = document.getElementById("allclasses_navbar_bottom");
|
||
|
if(window==top) {
|
||
|
allClassesLink.style.display = "block";
|
||
|
}
|
||
|
else {
|
||
|
allClassesLink.style.display = "none";
|
||
|
}
|
||
|
//-->
|
||
|
</script>
|
||
|
</div>
|
||
|
<div>
|
||
|
<ul class="subNavList">
|
||
|
<li>Summary: </li>
|
||
|
<li>Nested | </li>
|
||
|
<li>Field | </li>
|
||
|
<li>Constr | </li>
|
||
|
<li><a href="#method.summary">Method</a></li>
|
||
|
</ul>
|
||
|
<ul class="subNavList">
|
||
|
<li>Detail: </li>
|
||
|
<li>Field | </li>
|
||
|
<li>Constr | </li>
|
||
|
<li><a href="#method.detail">Method</a></li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<a name="skip.navbar.bottom">
|
||
|
<!-- -->
|
||
|
</a></div>
|
||
|
<!-- ======== END OF BOTTOM NAVBAR ======= -->
|
||
|
<p class="legalCopy"><small><font size=1>Copyright (c) 2002, 2017 Oracle and/or its affiliates. All rights reserved.</font> </small></p>
|
||
|
</body>
|
||
|
</html>
|