You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by oy...@apache.org on 2007/09/05 14:51:54 UTC
svn commit: r572944 - in /db/derby/code/trunk/java:
drda/org/apache/derby/impl/drda/ drda/org/apache/derby/loc/drda/
testing/org/apache/derbyTesting/functionTests/master/
Author: oysteing
Date: Wed Sep 5 05:51:53 2007
New Revision: 572944
URL: http://svn.apache.org/viewvc?rev=572944&view=rev
Log:
DERBY-2954: Add commands to NetworkServerControl for interacting with
the replication functionality
Contributed by Narayanan
Modified:
db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/derbyrunjartest.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/maxthreads.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/timeslice.out
Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=572944&r1=572943&r2=572944&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java Wed Sep 5 05:51:53 2007
@@ -83,13 +83,25 @@
*/
public final class NetworkServerControlImpl {
- private final static int NO_USAGE_MSGS= 12;
+ private final static int NO_USAGE_MSGS= 16;
+
+ //The COMMANDS array stores the list of commands that the
+ //NetworkServerControl class understands. Each index in
+ //this array contains a particular command.
+
+ //Index 10 in this array is a command that is not present in the
+ //COMMAND array. It refers to COMMAND_PROPERTIES which refers to
+ //the command the network server receives from the client.
+
+ //Hence index 10 is replaced by an empty string and the replication
+ //related commands start from index 11.
private final static String [] COMMANDS =
{"start","shutdown","trace","tracedirectory","ping",
- "logconnections", "sysinfo", "runtimeinfo", "maxthreads", "timeslice"};
+ "logconnections", "sysinfo", "runtimeinfo", "maxthreads", "timeslice",
+ "", "startreplication", "startslave", "failover", "stopreplication"};
// number of required arguments for each command
private final static int [] COMMAND_ARGS =
- {0, 0, 1, 1, 0, 1, 0, 0, 1, 1};
+ {0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1};
public final static int COMMAND_START = 0;
public final static int COMMAND_SHUTDOWN = 1;
public final static int COMMAND_TRACE = 2;
@@ -101,9 +113,14 @@
public final static int COMMAND_MAXTHREADS = 8;
public final static int COMMAND_TIMESLICE = 9;
public final static int COMMAND_PROPERTIES = 10;
+ public final static int COMMAND_START_MASTER = 11;
+ public final static int COMMAND_START_SLAVE = 12;
+ public final static int COMMAND_START_FAILOVER = 13;
+ public final static int COMMAND_STOP_REPLICATION = 14;
public final static int COMMAND_UNKNOWN = -1;
public final static String [] DASHARGS =
- {"p","d","u","ld","ea","ep", "b", "h", "s", "noSecurityManager", "ssl"};
+ {"p","d","u","ld","ea","ep", "b", "h", "s", "noSecurityManager", "ssl",
+ "slavehost", "slaveport"};
public final static int DASHARG_PORT = 0;
public final static int DASHARG_DATABASE = 1;
public final static int DASHARG_USER = 2;
@@ -115,6 +132,8 @@
public final static int DASHARG_SESSION = 8;
public final static int DASHARG_UNSECURE = 9;
private final static int DASHARG_SSL = 10;
+ private final static int DASHARG_SLAVEHOST = 11;
+ private final static int DASHARG_SLAVEPORT = 12;
// command protocol version - you need to increase this number each time
// the command protocol changes
@@ -215,6 +234,8 @@
private InetAddress hostAddress;
private int sessionArg;
private boolean unsecureArg;
+ private String slavehost;
+ private int slaveport;
// Used to debug memory in SanityManager.DEBUG mode
private memCheck mc;
@@ -257,6 +278,8 @@
private boolean cleanupOnStart = false; // Should we clean up when starting the server?
private boolean restartFlag = false;
+ private String replicationdb; //The name of the database that is replicated.
+
protected final static int INVALID_OR_NOTSET_SECURITYMECHANISM = -1;
// variable to store value set to derby.drda.securityMechanism
// default value is -1 which indicates that this property isnt set or
@@ -1990,6 +2013,26 @@
netSetTimeSlice(timeslice);
break;
+ case COMMAND_START_MASTER: {
+ setReplicationDB((String) commandArgs.elementAt(0));
+ consolePropertyMessage("DRDA_ReplicationImplementation.I");
+ break;
+ }
+ case COMMAND_START_SLAVE: {
+ setReplicationDB((String) commandArgs.elementAt(0));
+ consolePropertyMessage("DRDA_ReplicationImplementation.I");
+ break;
+ }
+ case COMMAND_START_FAILOVER: {
+ setReplicationDB((String) commandArgs.elementAt(0));
+ consolePropertyMessage("DRDA_ReplicationImplementation.I");
+ break;
+ }
+ case COMMAND_STOP_REPLICATION: {
+ setReplicationDB((String) commandArgs.elementAt(0));
+ consolePropertyMessage("DRDA_ReplicationImplementation.I");
+ break;
+ }
default:
//shouldn't get here
if (SanityManager.DEBUG)
@@ -2045,8 +2088,10 @@
{
for (i = 0; i < COMMANDS.length; i++)
{
- if (StringUtil.SQLEqualsIgnoreCase(COMMANDS[i],
- (String)commandArgs.firstElement()))
+ if (COMMANDS[i].length () > 0 &&
+ StringUtil.SQLEqualsIgnoreCase(
+ COMMANDS[i],
+ (String) commandArgs.firstElement()))
{
commandArgs.removeElementAt(0);
return i;
@@ -2175,6 +2220,37 @@
}
break;
+ case DASHARG_SLAVEHOST:
+ if (pos < args.length) {
+ slavehost = args[pos];
+ }
+ else {
+ consolePropertyMessage("DRDA_MissingValue.U",
+ "DRDA_Slavehost.I");
+ }
+ break;
+
+ case DASHARG_SLAVEPORT:
+ if (pos < args.length) {
+ try {
+ slaveport = Integer.parseInt(args[pos]);
+ }
+ catch(NumberFormatException nfe) {
+ //An invalid value has been assigned
+ //to the slaveport.
+ consolePropertyMessage
+ ("DRDA_InvalidValue.U",
+ new String [] {args[pos],
+ "DRDA_Slaveport.I"});
+ }
+ }
+ else {
+ consolePropertyMessage
+ ("DRDA_MissingValue.U",
+ "DRDA_Slaveport.I");
+ }
+ break;
+
default:
//shouldn't get here
}
@@ -3221,6 +3297,16 @@
thread.setLogConnections(value);
}
}
+ }
+
+ /**
+ * Set the current value for the Replication Database.
+ *
+ * @param db a String representing the name of the database being
+ * replicated.
+ */
+ private void setReplicationDB(String db) {
+ replicationdb = db;
}
/**
Modified: db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties?rev=572944&r1=572943&r2=572944&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties Wed Sep 5 05:51:53 2007
@@ -86,6 +86,10 @@
DRDA_MissingNetworkJar.S=Cannot find derbynet.jar on the classpath.
DRDA_NoAuthentication.S=Network Server startup failed. User authentication must be enabled before the Network Server installs a security manager. You must either enable user authentication or disable the installation of a security manager. For information on enabling user authentication, see the section of the Derby Developer's Guide entitled "Working with user authentication". Disabling the installation of a security manager is strongly discouraged in a client/server environment. However, if you must do this, you can disable the installation of a security manager by specifying the "-noSecurityManager" command line option when you bring up the Network Server.
DRDA_SecurityInstalled.I=Security manager installed using the Basic server security policy.
+DRDA_Slavehost.I=slave host
+DRDA_Slaveport.I=slave port number
+DRDA_ReplicationDB.I=replication database
+DRDA_ReplicationImplementation.I=Replication Not Implemented Yet
# Derby Network Server SYSINFO stuff
#
@@ -124,7 +128,10 @@
DRDA_Usage10.I=timeslice <milliseconds>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
DRDA_Usage11.I=trace {on|off} [-s <session id>][-h <host>][-p <portnumber>] [-ssl <sslmode>]
DRDA_Usage12.I=tracedirectory <traceDirectory>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
-
+DRDA_Usage13.I=startreplication <dbname> [-slavehost <host>] [-slaveport <portnumber>] [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+DRDA_Usage14.I=startslave <dbname> [-slavehost <host>] [-slaveport <portnumber>] [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+DRDA_Usage15.I=failover <dbname> [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+DRDA_Usage16.I=stopreplication <dbname> [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/derbyrunjartest.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/derbyrunjartest.out?rev=572944&r1=572943&r2=572944&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/derbyrunjartest.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/derbyrunjartest.out Wed Sep 5 05:51:53 2007
@@ -38,4 +38,8 @@
maxthreads <max>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
timeslice <milliseconds>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
trace {on|off} [-s <session id>][-h <host>][-p <portnumber>] [-ssl <sslmode>]
-tracedirectory <traceDirectory>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
\ No newline at end of file
+tracedirectory <traceDirectory>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
+startreplication <dbname> [-slavehost <host>] [-slaveport <portnumber>] [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+startslave <dbname> [-slavehost <host>] [-slaveport <portnumber>] [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+failover <dbname> [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+stopreplication <dbname> [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/maxthreads.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/maxthreads.out?rev=572944&r1=572943&r2=572944&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/maxthreads.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/maxthreads.out Wed Sep 5 05:51:53 2007
@@ -19,6 +19,10 @@
timeslice <milliseconds>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
trace {on |off} [-s <session id>][-h <host>][-p <portnumber>] [-ssl <sslmode>]
tracedirectory <traceDirectory>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
+startreplication <dbname> [-slavehost <host>] [-slaveport <portnumber>] [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+startslave <dbname> [-slavehost <host>] [-slaveport <portnumber>] [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+failover <dbname> [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+stopreplication <dbname> [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
PASS - max threads value, 0 is correct
org.apache.derby.drda.NetworkServerControl maxthreads 2147483647
Max threads changed to 2147483647.
@@ -40,6 +44,10 @@
timeslice <milliseconds>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
trace {on |off} [-s <session id>][-h <host>][-p <portnumber>] [-ssl <sslmode>]
tracedirectory <traceDirectory>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
+startreplication <dbname> [-slavehost <host>] [-slaveport <portnumber>] [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+startslave <dbname> [-slavehost <host>] [-slaveport <portnumber>] [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+failover <dbname> [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+stopreplication <dbname> [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
PASS - max threads value, 0 is correct
PASS - max threads value, 0 is correct
DRDA_InvalidValue.U:Invalid value, -2, for maxthreads.
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out?rev=572944&r1=572943&r2=572944&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out Wed Sep 5 05:51:53 2007
@@ -76,6 +76,10 @@
timeslice <milliseconds>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
trace {on |off} [-s <session id>][-h <host>][-p <portnumber>] [-ssl <sslmode>]
tracedirectory <traceDirectory>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
+startreplication <dbname> [-slavehost <host>] [-slaveport <portnumber>] [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+startslave <dbname> [-slavehost <host>] [-slaveport <portnumber>] [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+failover <dbname> [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+stopreplication <dbname> [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
org.apache.derby.drda.NetworkServerControl unknowncmd
Command unknowncmd is unknown.
Usage: NetworkServerControl <commands>
@@ -90,6 +94,10 @@
timeslice <milliseconds>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
trace {on |off} [-s <session id>][-h <host>][-p <portnumber>] [-ssl <sslmode>]
tracedirectory <traceDirectory>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
+startreplication <dbname> [-slavehost <host>] [-slaveport <portnumber>] [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+startslave <dbname> [-slavehost <host>] [-slaveport <portnumber>] [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+failover <dbname> [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+stopreplication <dbname> [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
org.apache.derby.drda.NetworkServerControl ping arg1
Invalid number of arguments for command ping.
Usage: NetworkServerControl <commands>
@@ -104,4 +112,8 @@
timeslice <milliseconds>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
trace {on |off} [-s <session id>][-h <host>][-p <portnumber>] [-ssl <sslmode>]
tracedirectory <traceDirectory>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
+startreplication <dbname> [-slavehost <host>] [-slaveport <portnumber>] [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+startslave <dbname> [-slavehost <host>] [-slaveport <portnumber>] [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+failover <dbname> [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+stopreplication <dbname> [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
End test
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/timeslice.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/timeslice.out?rev=572944&r1=572943&r2=572944&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/timeslice.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/timeslice.out Wed Sep 5 05:51:53 2007
@@ -19,6 +19,10 @@
timeslice <milliseconds>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
trace {on |off} [-s <session id>][-h <host>][-p <portnumber>] [-ssl <sslmode>]
tracedirectory <traceDirectory>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
+startreplication <dbname> [-slavehost <host>] [-slaveport <portnumber>] [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+startslave <dbname> [-slavehost <host>] [-slaveport <portnumber>] [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+failover <dbname> [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+stopreplication <dbname> [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
PASS - time slice value, 0 is correct
org.apache.derby.drda.NetworkServerControl timeslice 2147483647
Time slice changed to 2147483647.
@@ -40,6 +44,10 @@
timeslice <milliseconds>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
trace {on |off} [-s <session id>][-h <host>][-p <portnumber>] [-ssl <sslmode>]
tracedirectory <traceDirectory>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
+startreplication <dbname> [-slavehost <host>] [-slaveport <portnumber>] [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+startslave <dbname> [-slavehost <host>] [-slaveport <portnumber>] [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+failover <dbname> [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
+stopreplication <dbname> [-h <host>] [-p <portnumber>] [-ssl <sslmode>]
PASS - time slice value, 0 is correct
PASS - time slice value, 0 is correct
Expecting exception:DRDA_InvalidValue.U:Invalid value, -2, for timeslice.