public class LinuxMachine extends Machine
Modifier and Type | Class and Description |
---|---|
protected static class |
LinuxMachine.osInstallScriptTpl |
protected static class |
LinuxMachine.osKillScriptTpl |
protected static class |
LinuxMachine.osStartScriptTpl |
Modifier and Type | Field and Description |
---|---|
protected LinkedHashMap<String,String> |
bundles |
protected LinkedHashMap<String,String> |
certificates |
static String |
HERITRIX_1_CLASSNAME |
applications, arcDatabaseFile, databaseFile, hostname, inheritedSecurityPolicyFile, inheritedSlf4jConfigFile, jarFolder, log, machineDirectory, machineParameters, machineRoot, netarchiveSuiteFileName, operatingSystem, resetTempDir, scriptExtension, settings, targetEncoding
Constructor and Description |
---|
LinuxMachine(org.dom4j.Element subTreeRoot,
XmlStructure parentSettings,
Parameters param,
String netarchiveSuiteSource,
File slf4JConfig,
File securityPolicy,
File dbFile,
File arcdbFile,
boolean resetDir,
File externalJarFolder,
DeployConfiguration deployConfiguration)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
protected String |
callKillArchiveDatabase()
Method for generating the command for running the external_database_kill script.
|
protected String |
callKillHarvestDatabase()
Method for generating the command for running the external_database_kill script.
|
protected String |
callStartArchiveDatabase()
Method for generating the command for running the external_admin_database_start script.
|
protected String |
callStartHarvestDatabase()
Method for generating the command for running the external_harvest_database_start script.
|
protected String |
changeFileDirPathForSecurity(String path)
Changes the file directory path to the format used in the security policy.
|
protected void |
createApplicationKillScripts(File directory)
Creates the kill scripts for all the applications.
|
protected void |
createApplicationStartScripts(File directory)
Creates the start scripts for all the applications.
|
protected void |
createArchiveDatabaseKillScript(File dir)
Creates a script for killing the archive database on a given machine.
|
protected void |
createArchiveDatabaseStartScript(File dir)
Creates a script for starting the archive database on a given machine.
|
protected void |
createHarvestDatabaseKillScript(File dir)
Creates a script for killing the harvest database on a given machine.
|
protected void |
createHarvestDatabaseStartScript(File dir)
Creates a script for starting the harvest database on a given machine.
|
protected void |
createHarvestDatabaseUpdateScript(File dir)
create a harvestDatabaseUpdatescript in the given machineDirectory.
|
protected void |
createInstallDirScript(File dir)
Dummy function on linux machine.
|
protected void |
createOSLocalKillAllScript(File directory)
This function creates the script to kill all applications on this machine.
|
protected void |
createOSLocalStartAllScript(File directory)
This function creates the script to start all applications on this machine.
|
protected String |
createPathToDir(String dir)
Function for creating the directories along the path until the end directory.
|
protected void |
createRestartScript(File dir)
Creates script for restarting all the applications on a machine.
|
protected String |
getAppDirectories()
Creates the script for creating the application specified directories.
|
protected String |
getConfDirPath()
The operation system specific path to the conf directory.
|
protected String |
getInstallDirPath()
The operation system specific path to the installation directory.
|
protected String |
getJMXremoteFilesCommand()
This method does the following: Retrieves the path to the jmxremote.access and jmxremote.password files.
|
protected String |
getLibDirPath()
The operation system specific path to the lib directory.
|
protected String |
getLocalLibDirPath()
Creates the local path to the lib dir.
|
protected String |
osGetClassPath(Application app)
Makes all the class paths into the operation system specific syntax, and puts them into a string where they are
separated by the operation system specific separator (':' for linux, ';' for windows).
|
protected String |
osInstallArchiveDatabase()
Checks if a specific directory for the archive database is given in the settings, and thus if the archive
database should be installed on this machine.
|
protected String |
osInstallDatabase()
Checks if a specific directory for the database is given in the settings, and thus if the database should be
installed on this machine.
|
protected String |
osInstallExternalJarFiles()
This function makes the part of the install script for installing the external jar files from within the
jarFolder.
|
protected String |
osInstallScript()
Creates the operation system specific installation script for this machine.
|
protected String |
osInstallScriptCreateDir()
Creates the specified directories in the deploy-configuration file.
|
protected String |
osKillScript()
Creates the operation system specific killing script for this machine.
|
protected String |
osStartScript()
Creates the operation system specific starting script for this machine.
|
protected String |
scriptCreateDir(String dir,
boolean clean)
This functions makes the script for creating the new directories.
|
createJmxRemoteAccessFile, createJmxRemotePasswordFile, createSecurityPolicyFile, createSlf4jConfigFiles, getEnvironmentName, getHeritrixLogin, getHeritrixUsername, getMonitorLogin, getMonitorUsername, getTargetEncoding, machineUserLogin, modifyLogProperties, write, writeToGlobalInstallScript, writeToGlobalKillScript, writeToGlobalStartScript
public static final String HERITRIX_1_CLASSNAME
protected LinkedHashMap<String,String> bundles
protected LinkedHashMap<String,String> certificates
public LinuxMachine(org.dom4j.Element subTreeRoot, XmlStructure parentSettings, Parameters param, String netarchiveSuiteSource, File slf4JConfig, File securityPolicy, File dbFile, File arcdbFile, boolean resetDir, File externalJarFolder, DeployConfiguration deployConfiguration)
subTreeRoot
- The XML root element.parentSettings
- The Settings to be inherited from the PhysicalLocation, where this machine is placed.param
- The machine parameters to be inherited from the PhysicalLocation.netarchiveSuiteSource
- The name of the NetarchiveSuite package file. Must end with '.zip'.securityPolicy
- The security policy file, to be copied into machine directory.dbFile
- The name of the database file.arcdbFile
- The name of the archive file.resetDir
- Whether the temporary directory should be reset.externalJarFolder
- The folder containing the external jar library files.deployConfiguration
- The general deployment configuration.protected String osInstallScript()
Machine
osInstallScript
in class Machine
protected String osKillScript()
Machine
osKillScript
in class Machine
protected String osStartScript()
pseudo code: - ssh maclogin ". /etc/profile; conf/startall.sh; sleep 5; cat install/*.log"
where: maclogin = login for machine (username@machine). conf = path to /conf directory. install = path to install directory.
osStartScript
in class Machine
protected String getInstallDirPath()
Machine
getInstallDirPath
in class Machine
protected String getConfDirPath()
Machine
getConfDirPath
in class Machine
protected String getLocalLibDirPath()
protected void createOSLocalKillAllScript(File directory) throws IOFailure
pseudo code: - echo Killing all applications at machine: mac - if [ -e ./kill_app.sh ] - ./kill_app.sh - fi - ...
where: mac = machine name. app = application name. ... = the same for other applications.
createOSLocalKillAllScript
in class Machine
directory
- The directory for this machine (use global variable?).IOFailure
- If an error occurred during the creation of the local killall script.protected void createOSLocalStartAllScript(File directory) throws IOFailure
pseudo code: - echo Starting all applications at machine: mac - if [ -e ./start_app.sh ] - ./start_app.sh - fi - ...
where: mac = machine name. app = application name. ... = the same for other applications.
createOSLocalStartAllScript
in class Machine
directory
- The directory for this machine (use global variable?).IOFailure
- If an error occurred during the creation of the local startall script.protected void createApplicationKillScripts(File directory) throws IOFailure
The script starts by finding all running processes of the application. If it finds any processes, it kills them.
The kill_app.sh should have the following structure:
- echo Killing linux application. - #!/bin/bash - PIDS = $(ps -wwfe | grep fullapp | grep -v grep | grep path\settings_app.xml | awk "{print \\$2}") - if [ -n "$PIDS" ]; then - kill -9 $PIDS; - fi
Also, if a heritrix process is started, the following is added: - PIDS = $(ps -wwfe | grep heritrix | grep -v grep | grep path\settings_app.xml | awk "{print \\$2}") - if [ -n "$PIDS" ]; then - kill -9 $PIDS; - fi
where: path = the path to the ./conf directory. fullapp = the full application name with class path. app = the id of the application (name + instanceId). heritrix = the heritrix class path.
createApplicationKillScripts
in class Machine
directory
- The directory for this machine (use global variable?).IOFailure
- If an error occured during the creation of the kill application script file.protected void createApplicationStartScripts(File directory) throws IOFailure
The application should only be started, if it is not running already. The script starts by finding all running processes of the application. If any processes are found, a new application should not be started. Otherwise start the application.
The start_app.sh should have the following structure:
- echo Starting linux application: app - cd path - #!/bin/bash - PIDS = $(ps -wwfe | grep fullapp | grep -v grep | grep path\settings_app.xml | awk "{print \\$2}") - if [ -n "$PIDS" ]; then - echo Application already running. - else - export CLASSPATH = cp:$CLASSPATH; - JAVA - fi
where: path = the path to the install directory. fullapp = the full name application with java path. app = the name of the application. cp = the classpaths for the application. JAVA = the command to run the java application.
createApplicationStartScripts
in class Machine
directory
- The directory for this machine (use global variable?).IOFailure
- If an error occurred during the creation of the start application script file.protected String osGetClassPath(Application app)
Machine
osGetClassPath
in class Machine
app
- The application which has the class paths.protected String osInstallDatabase()
Machine
If no specific database is given as deploy argument (databaseFileName = null) then use the standard database extracted from NetarchiveSuite.zip. Else send the given new database to the standard database location.
Extract the database in the standard database location to the specified database directory.
osInstallDatabase
in class Machine
protected String osInstallExternalJarFiles()
Machine
osInstallExternalJarFiles
in class Machine
protected String osInstallArchiveDatabase()
Machine
If not specific database is given (adminDatabaseFileName = null) then use the default in the NetarchiveSuite.zip package. Else send the new archive database to the standard database location, and extract it to the given location.
osInstallArchiveDatabase
in class Machine
protected String osInstallScriptCreateDir()
Structure - ssh login cd path; DIRS; CLEANDIR; exit;
where: login = username@machine. path = path to install directory. DIRS = the way to create directories. CLEANDIR = the command to clean the tempDir (if chosen as optional)
The install creation of DIR has the following structure for directory dir: if [ ! -d dir ]; then mkdir dir; fi;
osInstallScriptCreateDir
in class Machine
protected String scriptCreateDir(String dir, boolean clean)
Machine
Linux creates directories directly through ssh. Windows creates an install a script file for installing the directories, which has to be sent to the machine, then executed and finally deleted.
scriptCreateDir
in class Machine
dir
- The name of the directory to create.clean
- Whether the directory should be cleaned\reset.Machine.createInstallDirScript(File)
protected String createPathToDir(String dir)
dir
- The path to the directory.protected String getAppDirectories()
Machine
getAppDirectories
in class Machine
protected void createInstallDirScript(File dir)
createInstallDirScript
in class Machine
dir
- The directory to put the file.protected String changeFileDirPathForSecurity(String path)
Machine
changeFileDirPathForSecurity
in class Machine
path
- The current path.protected String getJMXremoteFilesCommand()
Machine
getJMXremoteFilesCommand
in class Machine
protected void createRestartScript(File dir) throws IOFailure
First the killall scripts is called, then wait for 5 seconds for the applications to be fully terminated, and finally the startall script is called.
createRestartScript
in class Machine
dir
- The directory where the script file will be placed.IOFailure
- If the restart script cannot be created.protected void createArchiveDatabaseStartScript(File dir) throws IOFailure
> #!/bin/bash
> cd InstallDir
> java -cp 'DB-CLASSPATH' org.apache.derby.drda.NetworkServerControl start < /dev/null >
start_external_database.log 2>&1 &
createArchiveDatabaseStartScript
in class Machine
dir
- The directory where the script will be placed.IOFailure
- If the script cannot be written.protected String callStartArchiveDatabase()
> echo Starting external database
> if [ -e ./start_external_admin_database.sh ]; then
> ./start_external_admin_database.sh &
> sleep 5
> fi
protected void createArchiveDatabaseKillScript(File dir) throws IOFailure
The output is appended to the log, thus the '>>' instead of the standard '>' when redirecting the output.
> #!/bin/bash
> cd InstallDir
> java -cp 'DB-CLASSPATH' org.apache.derby.drda.NetworkServerControl shutdown < /dev/null >>
start_external_database.log 2>&1 &
where 'PORT' is in the setting: settings.archive.admin.database.port
createArchiveDatabaseKillScript
in class Machine
dir
- The directory where the script will be placed.IOFailure
- If the script cannot be created.protected String callKillArchiveDatabase()
> echo Killing external database
> if [ -e ./kill_external_database.sh ]; then
> ./kill_external_database.sh
> fi
protected void createHarvestDatabaseStartScript(File dir) throws IOFailure
> #!/bin/bash
> cd InstallDir
> java -cp 'DB-CLASSPATH' org.apache.derby.drda.NetworkServerControl start < /dev/null >
start_external_harvest_database.log 2>&1 &
createHarvestDatabaseStartScript
in class Machine
dir
- The directory where the script will be placed.IOFailure
- If the script cannot be written.protected String callStartHarvestDatabase()
> echo Starting external harvest database
> if [ -e ./start_external_harvest_database.sh ]; then
> ./start_external_harvest_database.sh &
> sleep 5
> fi
protected void createHarvestDatabaseKillScript(File dir) throws IOFailure
The output is appended to the log, thus the '>>' instead of the standard '>' when redirecting the output.
> #!/bin/bash
> cd InstallDir
> java -cp 'DB-CLASSPATH' org.apache.derby.drda.NetworkServerControl shutdown < /dev/null >>
start_external_harvest_database.log 2>&1 &
where 'PORT' is in the setting: settings.common.database.port
createHarvestDatabaseKillScript
in class Machine
dir
- The directory where the script will be placed.IOFailure
- If the script cannot be created.protected String callKillHarvestDatabase()
> echo Killing external harvest database
> if [ -e ./kill_external_harvest_database.sh ]; then
> ./kill_external_harvest_database.sh
> fi
protected void createHarvestDatabaseUpdateScript(File dir)
Machine
createHarvestDatabaseUpdateScript
in class Machine
dir
- a given MachineDirectory.protected String getLibDirPath()
Machine
getLibDirPath
in class Machine
Copyright © 2005–2015 The Royal Danish Library, the Danish State and University Library, the National Library of France and the Austrian National Library.. All rights reserved.