|
|
Choosing A Webhost: |
CVS update of sequoia/src/org/continuent/sequoia/controller/backup/backuper: msg#00023db.sequoia.cvs
Date: Monday, October 9, 2006 @ 18:29:26 Author: olivier Path: .../sequoia/src/org/continuent/sequoia/controller/backup/backupers Added: AbstractBackuper.java (1.1) Modified: MySQLBackuper.java (1.19 -> 1.20) * AbstractBackuper.java: * MySQLBackuper.java: - created abstract class AbstractBackuper - moved getOptions(), setOptions() and related protected fields into abstract class - moved setupDumpServer() and fetchDump() into abstract class - implemented dumpServer option aware setupDumpServer() method -----------------------+ AbstractBackuper.java | 94 ++++++++++++++++++++++++++++++++++++++++++++++++ MySQLBackuper.java | 65 +-------------------------------- 2 files changed, 97 insertions(+), 62 deletions(-) Index: sequoia/src/org/continuent/sequoia/controller/backup/backupers/AbstractBackuper.java diff -u /dev/null sequoia/src/org/continuent/sequoia/controller/backup/backupers/AbstractBackuper.java:1.1 --- /dev/null Mon Oct 9 18:29:26 2006 +++ sequoia/src/org/continuent/sequoia/controller/backup/backupers/AbstractBackuper.java Mon Oct 9 18:29:26 2006 @@ -0,0 +1,94 @@ +/** + * Sequoia: Database clustering technology. + * Copyright (C) 2006 Continuent Inc. + * Contact: sequoia-NAAfj4rwCWAYtQj7fl1lsA@xxxxxxxxxxxxxxxx + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.continuent.sequoia.controller.backup.backupers; + +import java.io.IOException; +import java.util.HashMap; +import java.util.StringTokenizer; + +import org.continuent.sequoia.common.exceptions.BackupException; +import org.continuent.sequoia.controller.backup.BackupManager; +import org.continuent.sequoia.controller.backup.Backuper; +import org.continuent.sequoia.controller.backup.DumpTransferInfo; + +/** + * This class defines a AbstractBackuper, which can be used as a base class for + * most backupers. This class provides a default implementation for options + * parsing/setting and an implementation for dump serving/fetching that + * understands the dumpServer option. + */ +public abstract class AbstractBackuper implements Backuper +{ + + protected HashMap optionsMap = new HashMap(); + protected String optionsString = null; + + /** + * @see Backuper#getOptions() + */ + public String getOptions() + { + return optionsString; + } + + /** + * @see Backuper#setOptions(java.lang.String) + */ + public void setOptions(String options) + { + if (options != null) + { + StringTokenizer strTok = new StringTokenizer(options, ","); + String option = null; + String name = null; + String value = null; + + // Parse the string of options, add them to the HashMap + while (strTok.hasMoreTokens()) + { + option = strTok.nextToken(); + name = option.substring(0, option.indexOf("=")); + value = option.substring(option.indexOf("=") + 1, option.length()); + optionsMap.put(name, value); + } + + optionsString = options; + } + } + + public DumpTransferInfo setupDumpServer() throws IOException + { + if (optionsMap.containsKey("dumpServer")) + return BackupManager.setupDumpFileServer((String) optionsMap + .get("dumpServer")); + + return BackupManager.setupDumpFileServer(); + } + + /** + * @see Backuper#fetchDump(org.continuent.sequoia.controller.backup.DumpTransferInfo, + * java.lang.String, java.lang.String) + */ + public void fetchDump(DumpTransferInfo dumpTransferInfo, String path, + String dumpName) throws BackupException, IOException + { + BackupManager.fetchDumpFile(dumpTransferInfo, path, dumpName); + } + +} Index: sequoia/src/org/continuent/sequoia/controller/backup/backupers/MySQLBackuper.java diff -u sequoia/src/org/continuent/sequoia/controller/backup/backupers/MySQLBackuper.java:1.19 sequoia/src/org/continuent/sequoia/controller/backup/backupers/MySQLBackuper.java:1.20 --- sequoia/src/org/continuent/sequoia/controller/backup/backupers/MySQLBackuper.java:1.19 Mon Oct 9 16:03:16 2006 +++ sequoia/src/org/continuent/sequoia/controller/backup/backupers/MySQLBackuper.java Mon Oct 9 18:29:26 2006 @@ -29,18 +29,13 @@ import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Date; -import java.util.HashMap; import java.util.Iterator; -import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.continuent.sequoia.common.exceptions.BackupException; import org.continuent.sequoia.common.log.Trace; import org.continuent.sequoia.controller.backend.DatabaseBackend; -import org.continuent.sequoia.controller.backup.BackupManager; -import org.continuent.sequoia.controller.backup.Backuper; -import org.continuent.sequoia.controller.backup.DumpTransferInfo; /** * MySQL backuper inspired from the PostgreSQL backuper. @@ -49,19 +44,16 @@ * * <pre> * - bindir: path to mysqldump binary + * - dumpServer: address to bind the dump server * </pre> * * @author <a href="mailto:mpaliyenko-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx">Mykola Paliyenko</a> * @author <a href="mailto:emmanuel.cecchet-NAAfj4rwCWC8rjiVs5Nzzw@xxxxxxxxxxxxxxxx">Emmanuel Cecchet</a> * @author <a href="mailto:stephane.giron-NAAfj4rwCWC8rjiVs5Nzzw@xxxxxxxxxxxxxxxx">Stephane Giron</a> */ -public class MySQLBackuper implements Backuper +public class MySQLBackuper extends AbstractBackuper { - protected HashMap optionsMap = new HashMap(); - - protected String optionsString = null; - private static final String DEFAULT_MYSQL_PORT = "3306"; private static final String DEFAULT_MYSQL_HOST = "localhost"; @@ -92,39 +84,6 @@ } /** - * @see Backuper#getOptions() - */ - public String getOptions() - { - return optionsString; - } - - /** - * @see Backuper#setOptions(java.lang.String) - */ - public void setOptions(String options) - { - if (options != null) - { - StringTokenizer strTok = new StringTokenizer(options, ","); - String option = null; - String name = null; - String value = null; - - // Parse the string of options, add them to the HashMap - while (strTok.hasMoreTokens()) - { - option = strTok.nextToken(); - name = option.substring(0, option.indexOf("=")); - value = option.substring(option.indexOf("=") + 1, option.length()); - optionsMap.put(name, value); - } - - optionsString = options; - } - } - - /** * @see org.continuent.sequoia.controller.backup.Backuper#backup(org.continuent.sequoia.controller.backend.DatabaseBackend, * java.lang.String, java.lang.String, java.lang.String, * java.lang.String, java.util.ArrayList) @@ -414,24 +373,6 @@ } /** - * @see org.continuent.sequoia.controller.backup.Backuper#fetchDump(org.continuent.sequoia.controller.backup.DumpTransferInfo, - * java.lang.String, java.lang.String) - */ - public void fetchDump(DumpTransferInfo dumpTransferInfo, String path, - String dumpName) throws BackupException, IOException - { - BackupManager.fetchDumpFile(dumpTransferInfo, path, dumpName); - } - - /** - * @see org.continuent.sequoia.controller.backup.Backuper#setupDumpServer() - */ - public DumpTransferInfo setupDumpServer() throws IOException - { - return BackupManager.setupDumpFileServer(); - } - - /** * Allow to parse PostgreSQL URL. */ protected class MySQLUrlInfo @@ -616,4 +557,4 @@ endUserLogger.error(msg); } } -} +} \ No newline at end of file
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | CVS update of sequoia/src/org/continuent/sequoia/controller/virtualdatabase (1 file), emmanuel-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
|---|---|
| Next by Date: | CVS update of sequoia/src/org/continuent/sequoia/controller/backup/backupers (1 file), olivier-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Previous by Thread: | CVS update of sequoia/src/org/continuent/sequoia/driver (1 file), stephane-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Next by Thread: | CVS update of sequoia/src/org/continuent/sequoia/controller/backup/backupers (2 files), olivier-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |