stasis/je-7.5.11/docs/examples/je/rep/quote/HARouter.html

302 lines
11 KiB
HTML
Raw Permalink Normal View History

2019-06-25 20:12:40 +00:00
<!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>HARouter (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="HARouter (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>Prev&nbsp;Class</li>
<li><a href="../../../je/rep/quote/RouterDrivenStockQuotes.html" title="class in je.rep.quote"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?je/rep/quote/HARouter.html" target="_top">Frames</a></li>
<li><a href="HARouter.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../allclasses-noframe.html">All&nbsp;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:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</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 HARouter" class="title">Class HARouter</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>je.rep.quote.HARouter</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public class <span class="typeNameLabel">HARouter</span>
extends java.lang.Object</pre>
<div class="block">This example illustrates use of an HA aware Router used to forward high
level requests to replication nodes implemented by
<a href="../../../je/rep/quote/RouterDrivenStockQuotes.html" title="class in je.rep.quote"><code>RouterDrivenStockQuotes</code></a>. The router is built using the APIs provided
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>; it's a
standalone application and does not itself access a JE Environment. The
router forwards logical requests, that represent some service provided by
the application. It only has knowledge of whether a request will potentially
require an write to the database, but does not have any other application
level logic, nor does it access a JE environment. The HARouter accepts a
request from the console and dispatches it to the application running on the
master, if it's a write request, or to one of the replicas if it's a read
request. The HARouter keeps track of the current Master via the events that
are delivered to the Monitor.
<p>
It's the HARouter instead of each individual node (as in the
<a href="../../../je/rep/quote/UpdateForwardingStockQuotes.html" title="class in je.rep.quote"><code>UpdateForwardingStockQuotes</code></a> example) that tracks the current Master
via 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>. Since the
router ensures that writes are directed to the master node, the logic in
the node itself is simpler: the node simply services the requests forwarded
to it by the router on a port dedicated for this purpose.
<p>
The protocol used to communicate between the router and the nodes has been
deliberately kept very simple. In particular, it makes limited provisions
for error reporting back to the router.
<p>
The router requires the following arguments:
<pre>
java je.rep.quote.HARouter -nodeName &lt;nodeName&gt; \
-nodeHost &lt;host:port&gt; \
-helperHost &lt;host:port&gt;&quot;
The arguments are described below:
-nodeName identifies the monitor name associated with this Router
-nodeHost the hostname:port combination used by the Monitor to listen for
election results and group level changes.
-helperHost one or more nodes that may be used by the Monitor to locate the
Master and register the Monitor with the Master.
</pre>
Note that the arguments are similar to the ones used to start a replication
node. A key difference is that the -env option is absent, since the router
is standalone and is not associated with one.
<p>
The router can be started as follows:
<pre>
java je.rep.quote.HARouter -nodeName n1 \
-nodeHost node.acme.com:6000 \
-helperHost node.acme.com:5001
</pre>
The replication nodes involved in the routing can be started as described in
<a href="../../../je/rep/quote/RouterDrivenStockQuotes.html" title="class in je.rep.quote"><code>RouterDrivenStockQuotes</code></a>. The Router and the nodes can be started in
any convenient order.</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../je/rep/quote/RouterDrivenStockQuotes.html" title="class in je.rep.quote"><code>RouterDrivenStockQuotes</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">&nbsp;</span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</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/HARouter.html#main-java.lang.String:A-">main</a></span>(java.lang.String[]&nbsp;argv)</code>&nbsp;</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;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&nbsp;void&nbsp;main(java.lang.String[]&nbsp;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>Prev&nbsp;Class</li>
<li><a href="../../../je/rep/quote/RouterDrivenStockQuotes.html" title="class in je.rep.quote"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?je/rep/quote/HARouter.html" target="_top">Frames</a></li>
<li><a href="HARouter.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../allclasses-noframe.html">All&nbsp;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:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</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>