From 07572b1a1f310425277e769bc497f2256121f192 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Tue, 15 May 2007 20:32:42 +0000
Subject: [PATCH] This commit removes the Web Start version of the upgrader's ability to download arbitrary builds to be used for upgrading. Instead, the Web Start version of upgrade will be tied to the build version of upgrader. This is necessary after discovering that attemping to perform internal communication with the directory server when the DS bit and the upgraders bits are of different versions is problematic.
---
opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java | 75 +++++++++++++++++++++++++++++++++++++
1 files changed, 75 insertions(+), 0 deletions(-)
diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java b/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java
index 6b4689f..e31701e 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java
@@ -40,6 +40,7 @@
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
+import java.io.File;
/**
* Class used to manipulate an OpenDS server.
@@ -397,6 +398,47 @@
}
/**
+ * Backs up all the databases to a specified directory.
+ * @param backupDir File representing the directory where the backups will
+ * be stored
+ * @return OperationOutput containing information about the operation
+ * @throws IOException if the process could not be started
+ * @throws InterruptedException if the process was prematurely interrupted
+ */
+ public OperationOutput backupDatabases(File backupDir)
+ throws IOException, InterruptedException {
+ final OperationOutput output = new OperationOutput();
+ List<String> args = new ArrayList<String>();
+ args.add(Utils.getPath(installation.getCommandFile("backup")));
+ args.add("-a"); // backup all
+ args.add("-d"); // backup to directory
+ args.add(Utils.getPath(backupDir));
+ ProcessBuilder pb = new ProcessBuilder(args);
+ Process p = pb.start();
+
+ BufferedReader out =
+ new BufferedReader(new InputStreamReader(p.getErrorStream()));
+ new OutputReader(out) {
+ public void processLine(String line) {
+ output.addErrorMessage(line);
+ LOG.log(Level.INFO, "backup operation: " + line);
+ }
+ };
+
+ BufferedReader err =
+ new BufferedReader(new InputStreamReader(p.getInputStream()));
+ new OutputReader(err) {
+ public void processLine(String line) {
+ output.addOutputMessage(line);
+ LOG.log(Level.INFO, "backup operation: " + line);
+ }
+ };
+
+ output.setReturnCode(p.waitFor());
+ return output;
+ }
+
+ /**
* This class is used to read the standard error and standard output of the
* Stop process.
* <p/>
@@ -456,6 +498,39 @@
}
/**
+ * This class is used to read an input stream and process ouput.
+ */
+ abstract private class OutputReader {
+
+ /**
+ * Called whenever new input is read from the reader.
+ * @param line String representing new input
+ */
+ public abstract void processLine(String line);
+
+ /**
+ * The protected constructor.
+ *
+ * @param reader the BufferedReader of the stop process.
+ */
+ public OutputReader(final BufferedReader reader) {
+ Thread t = new Thread(new Runnable() {
+ public void run() {
+ try {
+ String line;
+ while (null != (line = reader.readLine())) {
+ processLine(line);
+ }
+ } catch (Throwable t) {
+ LOG.log(Level.INFO, "error reading output", t);
+ }
+ }
+ });
+ t.start();
+ }
+ }
+
+ /**
* Returns the Message ID indicating that the server has started.
* @return the Message ID indicating that the server has started.
*/
--
Gitblit v1.10.0