Changeset: 1e5e77292344 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1e5e77292344
Modified Files:
        java/ChangeLog
        java/src/nl/cwi/monetdb/client/JdbcClient.java
        java/src/nl/cwi/monetdb/jdbc/MonetConnection.java
Branch: default
Log Message:

MonetConnection: remove old MonetEmbeddedInstance cruft

Using the embedded instance likely didn't work any more, and the
functionality isn't really necessary any more with monetdbd around these
days.


diffs (280 lines):

diff --git a/java/ChangeLog b/java/ChangeLog
--- a/java/ChangeLog
+++ b/java/ChangeLog
@@ -2,6 +2,7 @@
 # This file is updated with Maddlog
 
 * Fri Oct 14 2011 Fabian Groffen <[email protected]>
+- The embedded monet instance capability of MonetConnection was removed.
 - Bump JDBC version to 2.0 (Liberica).  JDBC now implements JDBC4 which
   makes it possible to be built with Java 6 and up.  Java 5 and before
   are no longer supported, and can use the 1.x releases of the driver.
diff --git a/java/src/nl/cwi/monetdb/client/JdbcClient.java 
b/java/src/nl/cwi/monetdb/client/JdbcClient.java
--- a/java/src/nl/cwi/monetdb/client/JdbcClient.java
+++ b/java/src/nl/cwi/monetdb/client/JdbcClient.java
@@ -92,10 +92,6 @@ public class JdbcClient {
                copts.addOption(null, "Xoutput", CmdLineOpts.CAR_ONE, null,
                                "The output mode when dumping.  Default is sql, 
xml may " +
                                "be used for an experimental XML output.");
-               copts.addOption(null, "Xembedded", CmdLineOpts.CAR_ONE, null,
-                               "Uses an \"embedded\" Mserver instance.  The 
argument to " +
-                               "this option should be in the form of 
path/to/mserver:dbname" +
-                               "[:dbfarm[:dbinit]].");
                copts.addOption(null, "Xhash", CmdLineOpts.CAR_ONE, null,
                                "Use the given hash algorithm during challenge 
response.  " +
                                "Supported algorithm names: SHA1, MD5, plain.");
@@ -189,11 +185,6 @@ copts.produceHelpMessage()
                boolean scolonterm = true;
                boolean xmlMode =
                                
"xml".equals(copts.getOption("Xoutput").getArgument());
-               boolean isEmbedded = copts.getOption("Xembedded").isPresent();
-               if (isEmbedded) {
-                       // user and password don't matter for embedded
-                       pass = "";
-               }
 
                // we need the password from the user, fetch it with a pseudo
                // password protector
@@ -248,31 +239,11 @@ copts.produceHelpMessage()
                con = null;
                String database = copts.getOption("database").getArgument();
                try {
-                       if (!isEmbedded) {
-                               con = DriverManager.getConnection(
-                                               "jdbc:monetdb://" + host + "/" 
+ database + attr,
-                                               user,
-                                               pass
-                               );
-                       } else {
-                               String[] eargs =
-                                       
copts.getOption("Xembedded").getArgument().split(":");
-                               if (eargs.length < 2 || eargs.length > 4) {
-                                       System.err.println("Expecting 
path/to/mserver:dbname" +
-                                                       "[:dbfarm[:dbinit]]");
-                                       System.exit(-1);
-                               }
-                               Properties p = new Properties();
-                               p.setProperty("executable", eargs[0]);
-                               p.setProperty("dbname", eargs[1]);
-                               if (args.length > 2) p.setProperty("dbfarm", 
eargs[2]);
-                               if (args.length > 3) p.setProperty("dbinit", 
eargs[3]);
-                               
nl.cwi.monetdb.jdbc.MonetConnection.setEmbeddedProperties(p);
-                               // what do you mean? "descriptive names suck" 
?!?
-                               out.println("Starting embedded instance...");
-                               out.flush();
-                               con = 
nl.cwi.monetdb.jdbc.MonetConnection.getEmbeddedInstanceConnection();
-                       }
+                       con = DriverManager.getConnection(
+                                       "jdbc:monetdb://" + host + "/" + 
database + attr,
+                                       user,
+                                       pass
+                       );
                        SQLWarning warn = con.getWarnings();
                        while (warn != null) {
                                System.err.println("Connection warning: " +
diff --git a/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java 
b/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java
--- a/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java
+++ b/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java
@@ -110,11 +110,6 @@ public class MonetConnection extends Mon
        /** The language which is used */
        final int lang;
 
-       /** Embedded instance */
-       private static MonetEmbeddedInstance embeddedInstance = null;
-       /** Embedded properties */
-       private static Properties embeddedProps = null;
-
        /** Whether or not BLOB is mapped to BINARY within the driver */
        private final boolean blobIsBinary;
 
@@ -2523,190 +2518,6 @@ public class MonetConnection extends Mon
                }
        }
        // }}}
-
-       //=== embedded stuff (shouldn't hurt normal use)
-       
-       /**
-        * Sets the properties for the embedded connection.  The properties
-        * can only be set as long as there is no embedded connection made,
-        * afterwards calling this method will result in an SQLException.
-        *
-        * @param props the properties for the embedded server
-        * @throws SQLException if the embedded connection has already been
-        *         started
-        */
-       public static synchronized void setEmbeddedProperties(Properties props)
-               throws SQLException
-       {
-               if (embeddedInstance != null) throw
-                       new SQLException("embedded connection has already been 
started");
-
-               embeddedProps = props;
-       }
-
-       /**
-        * Returns a Connection to an embedded Mserver instance.  The
-        * embedded instance is started if not running yet.  The
-        * specification for the to be started embedded Mserver instance can
-        * given via the setEmbeddedProperties() method.  Note that this
-        * method is synchronized to avoid race conditions.
-        *
-        * @return a Connection to an embedded instance
-        * @throws SQLException if a problem occurred while making the
-        *         connection
-        */
-       public static synchronized Connection getEmbeddedInstanceConnection()
-               throws SQLException
-       {
-               if (embeddedInstance == null || !embeddedInstance.isAlive())
-                       embeddedInstance = new 
MonetEmbeddedInstance(embeddedProps);
-
-               return(embeddedInstance.getConnection());
-       }
-
 }
 
-/**
- * The MonetEmbeddedInstance is a Thread wrapper around an Mserver
- * process, that is started by this Thread.  When the process dies, the
- * thread dies as well, printing the reason for dying to the standard
- * error stream.
- */
-// {{{
-class MonetEmbeddedInstance extends Thread {
-       private String error;
-       private final String[] cmdarray;
-       private final String dbname;
-       private final Process mserver;
-
-       /**
-        * Constructor of a MonetEmbeddedInstance that requires a property
-        * value map to be given.  The properties are used to start the
-        * Mserver, and required.  The following two properties need to be
-        * available in the Properties map: <tt>executable</tt> and
-        * <tt>dbname</tt>.  The first one should be an (absolute) path to
-        * the Mserver executable, while the latter one should be a database
-        * name that will be used.  Optionally, the <tt>dbfarm</tt> and
-        * <tt>dbinit</tt> arguments can be present and will be passed to
-        * the Mserver invocation.
-        *
-        * @param props the Properties map
-        * @throws SQLException if executable or dbname is not present
-        */
-       public MonetEmbeddedInstance(Properties props) throws SQLException {
-               // check we get what we want
-               String executable = props.getProperty("executable");
-               if (executable == null) throw
-                       new SQLException("executable missing");
-               dbname = props.getProperty("dbname");
-               if (dbname == null) throw
-                       new SQLException("dbname missing");
-
-               // see what we got more
-               int cnt = 2;
-               String dbfarm = props.getProperty("dbfarm");
-               if (dbfarm != null) cnt++;
-               String dbinit = props.getProperty("dbinit");
-               if (dbinit != null) cnt++;
-
-               cmdarray = new String[cnt];
-               switch (cnt) {
-                       case 4:
-                               cmdarray[3] = "--dbinit=" + dbinit;
-                       case 3: 
-                               if (dbfarm != null) {
-                                       cmdarray[2] = "--dbfarm=" + dbfarm;
-                               } else {
-                                       cmdarray[2] = "--dbinit=" + dbinit;
-                               }
-                       default:
-                               cmdarray[1] = "--dbname=" + dbname;
-                               cmdarray[0] = executable;
-               }
-
-               // start the server and wait for its hello
-               try {
-                       mserver = Runtime.getRuntime().exec(cmdarray);
-                       BufferedReader in =
-                               new BufferedReader(
-                                               new 
InputStreamReader(mserver.getInputStream()));
-                       if (in.readLine() == null) throw
-                               new SQLException("embedded process died 
immediately");
-               } catch (Exception e) {
-                       throw new SQLException(e.toString());
-               }
-               setDaemon(true);
-               start();
-               try {
-                       // hopefully this enough for the server to set up its 
socket
-                       Thread.sleep(1000);
-               } catch (InterruptedException e) {
-                       // ok, too bad
-               }
-       }
-
-       /**
-        * Main execution.  This function starts the Mserver using the given
-        * command array, and waits for it to terminate.  If there are
-        * errors written to the standard error pipe, they are written to
-        * the standard error channel of the console.
-        */
-       public void run() {
-               try {
-                       BufferedReader err =
-                               new BufferedReader(
-                                               new 
InputStreamReader(mserver.getErrorStream()));
-                       
-                       // wait for the beast to die
-                       mserver.waitFor();
-                       String msg;
-                       while ((msg = err.readLine()) != null) {
-                               if (error == null) {
-                                       error = msg + "\n";
-                               } else {
-                                       error += msg + "\n";
-                               }
-                       }
-               } catch (InterruptedException e) {
-                       // waitFor
-                       error = "caught interrupt while waiting for Mserver to 
crash";
-               } catch (Exception e) {
-                       if (error == null) error = "";
-                       error += e.toString();
-               }
-
-               // Where to go with the error?
-               System.err.println("embedded Mserver died:\n" + error);
-       }
-
-       /**
-        * Returns a Connection for the embedded Mserver instance.  This
-        * method "just" creates a TCP connection to the running Mserver,
-        * using administrator privileges.
-        *
-        * @return a Connection for the embedded Mserver instance
-        * @throws SQLException if making a connection fails
-        */
-       public Connection getConnection() throws SQLException {
-               try {
-                       Properties conProps = new Properties();
-                       conProps.setProperty("host", "localhost");
-                       conProps.setProperty("port", "50000");
-                       conProps.setProperty("language", "sql");
-                       conProps.setProperty("database", dbname);
-                       conProps.setProperty("user", "monetdb");
-                       conProps.setProperty("password", "monetdb");
-
-                       return(new MonetConnection(conProps));
-               } catch (SQLException e) {
-                       // this is just to avoid the SQLException to be
-                       // rewrapped into another SQLException
-                       throw e;
-               } catch (Exception e) {
-                       throw new SQLException(e.toString());
-               }
-       }
-}
-// }}}
-
 // vim: foldmethod=marker:
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to