public class StockQuotesRMIForwarding extends StockQuotes
StockQuotesexample. Instead of rejecting update requests made at a Replica's console, it illustrates how RMI could be used to forward write requests to a Master. The example is otherwise identical to
StockQuotesand you should read the javadoc associated with it before proceeding with this example. The discussion that follows thus focusses entirely on the RMI based write-forwarding aspects of this example.
Each node in this example is an RMI server and hosts an RMI registry. The
registry contains exactly one binding associated with the name:
RMI_NAME. The object associated
with the RMI binding (an instance of
available all the high level database write operations that are part of the
application. When this node is the
Replicas will use the remote methods to invoke write operations
on it. All nodes are RMI servers, but only the current
is actually used to serve write requests while it is in the
Master state. The Replicas play the role of RMI clients making
remote method calls to the Master to foward their write requests.
Please review the javadoc in
StockQuotes 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.
For example, the first node can be started as follows:
java je.rep.quote.StockQuotesWriteForwarding -env /tmp/stockQuotes1 \ -nodeName n1 \ -nodeHost node.acme.com:5001 \ -helperHost node.acme.com:5001
This instance of the application will therefore use port 5001 for HA, and,
by convention, port 5101 (5001 +
the RMI registry. If you are running on multiple machines you may (depending
upon your DNS setup) need to specify the
java.rmi.server.hostname property to ensure that RMI does not
associate loopback addresses with entries in its registry.
|Modifier and Type||Class and Description|
The class supplies the RMI implementation of the write methods.
|Modifier and Type||Field and Description|
|Modifier and Type||Method and Description|
Performs the RMI associated cleanup so that the RMI serve can be shutdown cleanly.
public static final java.lang.String RMI_NAME
Copyright (c) 2002, 2017 Oracle and/or its affiliates. All rights reserved.