342 lines
14 KiB
HTML
342 lines
14 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>UpdateForwardingStockQuotes (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="UpdateForwardingStockQuotes (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/StockQuotesRMIForwarding.WriteServicesImpl.html" title="class in je.rep.quote"><span class="typeNameLink">Prev Class</span></a></li>
|
||
|
<li>Next Class</li>
|
||
|
</ul>
|
||
|
<ul class="navList">
|
||
|
<li><a href="../../../index.html?je/rep/quote/UpdateForwardingStockQuotes.html" target="_top">Frames</a></li>
|
||
|
<li><a href="UpdateForwardingStockQuotes.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 UpdateForwardingStockQuotes" class="title">Class UpdateForwardingStockQuotes</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><a href="../../../je/rep/quote/RouterDrivenStockQuotes.html" title="class in je.rep.quote">je.rep.quote.RouterDrivenStockQuotes</a></li>
|
||
|
<li>
|
||
|
<ul class="inheritance">
|
||
|
<li>je.rep.quote.UpdateForwardingStockQuotes</li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
</ul>
|
||
|
<div class="description">
|
||
|
<ul class="blockList">
|
||
|
<li class="blockList">
|
||
|
<hr>
|
||
|
<br>
|
||
|
<pre>public class <span class="typeNameLabel">UpdateForwardingStockQuotes</span>
|
||
|
extends <a href="../../../je/rep/quote/RouterDrivenStockQuotes.html" title="class in je.rep.quote">RouterDrivenStockQuotes</a></pre>
|
||
|
<div class="block">This class is based on <a href="../../../je/rep/quote/RouterDrivenStockQuotes.html" title="class in je.rep.quote"><code>RouterDrivenStockQuotes</code></a> and illustrates use
|
||
|
of an HA unaware router (implemented by <a href="../../../je/rep/quote/SimpleRouter.html" title="class in je.rep.quote"><code>SimpleRouter</code></a>), that load
|
||
|
balances requests (both read and write) across all the nodes in a
|
||
|
replication group. This example is meant to illustrate how a load balancer
|
||
|
appliance might fit into the JE HA architecture, where <code>SimpleRouter</code>
|
||
|
plays the role of the load balancer appliance 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>
|
||
|
The router is unaware of the state (Master or Replica) of each node, or the
|
||
|
type (read or write) of the request. Nodes use the <a href="../../../../java/com/sleepycat/je/rep/StateChangeListener.html?is-external=true" title="class or interface in com.sleepycat.je.rep"><code>StateChangeListener</code></a> to track the
|
||
|
node that is currently the master and redirect write requests to it. That
|
||
|
is, unlike the <a href="../../../je/rep/quote/RouterDrivenStockQuotes.html" title="class in je.rep.quote"><code>RouterDrivenStockQuotes</code></a> example, it's the nodes and
|
||
|
not the router that keeps track of the current master.
|
||
|
<p>
|
||
|
In this example, unlike <code>StockQuotes</code>, only the
|
||
|
<a href="../../../je/rep/quote/SimpleRouter.html" title="class in je.rep.quote"><code>SimpleRouter</code></a> has a console associated with it. It accepts commands
|
||
|
typed into its console and forwards them as appropriate to the nodes in the
|
||
|
group. The logic for tracking the Master resides in each node, and is
|
||
|
supplied by the <a href="../../../../java/com/sleepycat/je/rep/StateChangeListener.html?is-external=true" title="class or interface in com.sleepycat.je.rep"><code>StateChangeListener</code></a>.
|
||
|
<p>
|
||
|
Each node, which in this example is an instance of
|
||
|
<code>UpdateForwardingStockQuotes</code>, establishes a server socket on
|
||
|
which it can listen for requests from <code>SimpleRouter</code>. Read
|
||
|
requests are processed directly by the node. Write requests are redirected
|
||
|
to the current master and the result is communicated back to
|
||
|
<code>SimpleRouter</code>.
|
||
|
<p>
|
||
|
The request flow between nodes in this example is shown below.
|
||
|
<pre>
|
||
|
---------------- Read and Write requests
|
||
|
| SimpleRouter |------------------------------------||
|
||
|
| Instance |---------------------|| ||
|
||
|
---------------- || || ||
|
||
|
|| || ||
|
||
|
\/ || ||
|
||
|
------------------------------- || ||
|
||
|
| UpdateForwardingStockQuotes | || ||
|
||
|
| Instance 1: Master | || ||
|
||
|
------------------------------- \/ ||
|
||
|
/\ ------------------------------- ||
|
||
|
|| | UpdateForwardingStockQuotes | ||
|
||
|
||---------- | Instance 2: Replica | ||
|
||
|
|| Write ------------------------------- \/
|
||
|
|| requests -------------------------------
|
||
|
|| | UpdateForwardingStockQuotes |
|
||
|
||--------------------------| 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 java vm.
|
||
|
<p>
|
||
|
For example, the first node can be started as follows:
|
||
|
|
||
|
<pre>
|
||
|
java je.rep.quote.UpdateForwardingStockQuotes -env /tmp/stockQuotes1 \
|
||
|
-nodeName n1 \
|
||
|
-nodeHost node.acme.com:5001 \
|
||
|
-helperHost node.acme.com:5001
|
||
|
</pre>
|
||
|
<p>
|
||
|
This instance of the application will therefore use port 5001 for HA, and,
|
||
|
by convention, port 5101 (5001 + <code>HARouter.APP_PORT_DISPLACEMENT</code>)
|
||
|
for application messages sent to it.
|
||
|
<p>
|
||
|
In addition to starting the nodes, you will also need to start the
|
||
|
<a href="../../../je/rep/quote/SimpleRouter.html" title="class in je.rep.quote"><code>SimpleRouter</code></a> as described in its javadoc.</div>
|
||
|
<dl>
|
||
|
<dt><span class="seeLabel">See Also:</span></dt>
|
||
|
<dd><a href="../../../je/rep/quote/SimpleRouter.html" title="class in je.rep.quote"><code>SimpleRouter</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/UpdateForwardingStockQuotes.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/StockQuotesRMIForwarding.WriteServicesImpl.html" title="class in je.rep.quote"><span class="typeNameLink">Prev Class</span></a></li>
|
||
|
<li>Next Class</li>
|
||
|
</ul>
|
||
|
<ul class="navList">
|
||
|
<li><a href="../../../index.html?je/rep/quote/UpdateForwardingStockQuotes.html" target="_top">Frames</a></li>
|
||
|
<li><a href="UpdateForwardingStockQuotes.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>
|