You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by su...@apache.org on 2012/11/27 05:13:26 UTC
svn commit: r1413992 [1/3] - in /hadoop/common/branches/branch-1-win: ./
bin/ conf/ src/packages/win/ src/packages/win/HadoopServiceHost/
src/packages/win/HadoopServiceHost/Properties/ src/packages/win/resources/
src/packages/win/scripts/ src/packages/...
Author: suresh
Date: Tue Nov 27 04:13:19 2012
New Revision: 1413992
URL: http://svn.apache.org/viewvc?rev=1413992&view=rev
Log:
HADOOP-9074. Hadoop install scripts for Windows. Contributed by Steve Maine, Ramya Nimmagadda, Chuan Liu, Brad Sarsfield and Ivan Mitic.
Added:
hadoop/common/branches/branch-1-win/bin/hadoop-daemon.cmd
hadoop/common/branches/branch-1-win/src/packages/win/
hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/
hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/HadoopServiceHost.csproj
hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/HadoopServiceHost.sln
hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/Program.cs
hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/Properties/
hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/Properties/AssemblyInfo.cs
hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/ServiceHost.cs
hadoop/common/branches/branch-1-win/src/packages/win/resources/
hadoop/common/branches/branch-1-win/src/packages/win/resources/winpkg.utils.psm1
hadoop/common/branches/branch-1-win/src/packages/win/scripts/
hadoop/common/branches/branch-1-win/src/packages/win/scripts/InstallApi.psm1
hadoop/common/branches/branch-1-win/src/packages/win/scripts/TestInstallApi.ps1
hadoop/common/branches/branch-1-win/src/packages/win/scripts/install.cmd
hadoop/common/branches/branch-1-win/src/packages/win/scripts/install.ps1
hadoop/common/branches/branch-1-win/src/packages/win/scripts/uninstall.cmd
hadoop/common/branches/branch-1-win/src/packages/win/scripts/uninstall.ps1
hadoop/common/branches/branch-1-win/src/packages/win/template/
hadoop/common/branches/branch-1-win/src/packages/win/template/bin/
hadoop/common/branches/branch-1-win/src/packages/win/template/bin/start_daemons.cmd
hadoop/common/branches/branch-1-win/src/packages/win/template/bin/stop_daemons.cmd
hadoop/common/branches/branch-1-win/src/packages/win/template/conf/
hadoop/common/branches/branch-1-win/src/packages/win/template/conf/core-site.xml
hadoop/common/branches/branch-1-win/src/packages/win/template/conf/hadoop-metrics2.properties
hadoop/common/branches/branch-1-win/src/packages/win/template/conf/hdfs-site.xml
hadoop/common/branches/branch-1-win/src/packages/win/template/conf/log4j.properties
hadoop/common/branches/branch-1-win/src/packages/win/template/conf/mapred-site.xml
Modified:
hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt
hadoop/common/branches/branch-1-win/bin/hadoop.cmd
hadoop/common/branches/branch-1-win/bin/hdfs.cmd
hadoop/common/branches/branch-1-win/bin/mapred.cmd
hadoop/common/branches/branch-1-win/build.xml
hadoop/common/branches/branch-1-win/conf/hadoop-env.cmd
Modified: hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt?rev=1413992&r1=1413991&r2=1413992&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt (original)
+++ hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt Tue Nov 27 04:13:19 2012
@@ -228,3 +228,6 @@ Branch-hadoop-1-win - unreleased
HADOOP-9062. hadoop-env.cmd overwrites the value of *_OPTS set before
install. (Ganeshan Iyer via suresh)
+
+ HADOOP-9074. Hadoop install scripts for Windows. (Steve Maine,
+ Ramya Nimmagadda, Chuan Liu, Brad Sarsfield and Ivan Mitic via suresh)
Added: hadoop/common/branches/branch-1-win/bin/hadoop-daemon.cmd
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/bin/hadoop-daemon.cmd?rev=1413992&view=auto
==============================================================================
--- hadoop/common/branches/branch-1-win/bin/hadoop-daemon.cmd (added)
+++ hadoop/common/branches/branch-1-win/bin/hadoop-daemon.cmd Tue Nov 27 04:13:19 2012
@@ -0,0 +1,144 @@
+@echo off
+@rem Licensed to the Apache Software Foundation (ASF) under one or more
+@rem contributor license agreements. See the NOTICE file distributed with
+@rem this work for additional information regarding copyright ownership.
+@rem The ASF licenses this file to You under the Apache License, Version 2.0
+@rem (the "License"); you may not use this file except in compliance with
+@rem the License. You may obtain a copy of the License at
+@rem
+@rem http://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+
+
+@rem Runs a Hadoop command as a daemon.
+@rem
+@rem Environment Variables
+@rem
+@rem HADOOP_CONF_DIR Alternate conf dir. Default is %HADOOP_HOME%/conf.
+@rem HADOOP_LOG_DIR Where log files are stored. PWD by default.
+@rem HADOOP_MASTER host:path where hadoop code should be copied from
+@rem HADOOP_IDENT_STRING A string representing this instance of hadoop. %USERNAME% by default
+@rem
+
+setlocal
+set usage= "Usage: Pass arguments in the given order : hadoop-daemon.cmd [--config <conf-dir>] [--hosts hostlistfile] (start|stop) <hadoop-command> <args...>"
+
+@rem if no args specified, show usage
+if [%2] == [] (
+ echo %usage%
+ goto :eof
+)
+
+if not defined HADOOP_BIN_PATH (
+ set HADOOP_BIN_PATH=%~dp0
+)
+
+if "%HADOOP_BIN_PATH:~-1%" == "\" (
+ set HADOOP_BIN_PATH=%HADOOP_BIN_PATH:~0,-1%
+)
+
+call :updatepath %HADOOP_BIN_PATH%
+set hadoop-config-script=%HADOOP_BIN_PATH%\hadoop-config.cmd
+call %hadoop-config-script% %*
+if "%1" == "--config" (
+ shift
+ shift
+)
+
+if "%1" == "--hosts" (
+ shift
+ shift
+)
+
+@rem get remaining arguments
+
+set startStop=%1
+shift
+set command=%1
+shift
+
+if exist %HADOOP_CONF_DIR%\hadoop-env.cmd (
+ call %HADOOP_CONF_DIR%\hadoop-env.cmd
+)
+
+set hdfscommands=namenode secondarynamenode datanode
+for %%i in ( %hdfscommands% ) do (
+ if %command% == %%i set hdfscommand=true
+ )
+
+set mapredcommands=jobtracker tasktracker historyserver
+ for %%i in ( %mapredcommands% ) do (
+ if %command% == %%i set mapredcommand=true
+ )
+@rem if an alternate config directory is specified generate new service xml
+if defined %HADOOP_CONF_DIR% (
+ move /Y %command%.xml %command%.backup.xml
+ if defined hdfscommand (
+ %HADOOP_BIN_PATH%\hdfs.cmd --conf %HADOOP_CONF_DIR% makeServiceXml > %command%.xml
+ ) else (
+ if defined mapredcommand (
+ %HADOOP_BIN_PATH%\mapred.cmd --conf %HADOOP_CONF_DIR% makeServiceXml > %command%.xml
+ ) else (
+ @echo %usage%
+ exit /b 1
+ )
+ )
+ if not exist %command%.xml (
+ @echo Generating new conf failed, copying back old conf
+ move /Y %command%.backup.xml %command%.xml
+ exit /b 2
+ )
+)
+
+if %startStop% == start (
+ @echo Stopping any existing services before starting
+ sc stop %command%
+ @echo starting %command%
+ set errorlevel=
+ sc start %command%
+ if %errorlevel% NEQ 0 (
+ @echo Failed to start %command% service
+ exit /b 2
+ )
+ goto :end
+) else (
+ if %startStop% == stop (
+ @echo stopping %command%
+ set errorlevel=
+ sc stop %command%
+ if %errorlevel% NEQ 0 (
+ @echo Failed to stop %command% service
+ exit /b 2
+ )
+ goto :end
+ ) else (
+ @echo %usage%
+ exit /b 1
+ )
+)
+@rem Adds the path sent as argument to path variable
+:updatepath
+ set path_to_add=%*
+ set current_path_comparable=%path:(x86)=%
+ set current_path_comparable=%current_path_comparable: =_%
+ set path_to_add_comparable=%path_to_add:(x86)=%
+ set path_to_add_comparable=%path_to_add_comparable: =_%
+ for %%i in ( %current_path_comparable% ) do (
+ if /i "%%i" == "%path_to_add_comparable%" (
+ set path_to_add_exist=true
+ )
+ )
+ set system_path_comparable=
+ set path_to_add_comparable=
+ if not defined path_to_add_exist path=%path_to_add%;%path%
+ set path_to_add=
+ goto :eof
+
+:end
+
+endlocal
\ No newline at end of file
Modified: hadoop/common/branches/branch-1-win/bin/hadoop.cmd
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/bin/hadoop.cmd?rev=1413992&r1=1413991&r2=1413992&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/bin/hadoop.cmd (original)
+++ hadoop/common/branches/branch-1-win/bin/hadoop.cmd Tue Nov 27 04:13:19 2012
@@ -63,7 +63,11 @@ call :updatepath %HADOOP_BIN_PATH%
set hadoop-hdfs-script=%HADOOP_BIN_PATH%\hdfs.cmd
set hadoop-mapred-script=%HADOOP_BIN_PATH%\mapred.cmd
- call %hadoop-config-script%
+ call %hadoop-config-script% %*
+ if "%1" == "--config" (
+ shift
+ shift
+ )
set hadoop-command=%1
if not defined hadoop-command (
@@ -78,7 +82,7 @@ call :updatepath %HADOOP_BIN_PATH%
)
if defined hdfscommand (
if exist %hadoop-hdfs-script% (
- call %hadoop-hdfs-script% %*
+ call %hadoop-hdfs-script% %hadoop-command% %hadoop-command-arguments%
goto :eof
)
)
@@ -89,7 +93,7 @@ call :updatepath %HADOOP_BIN_PATH%
)
if defined mapredcommand (
if exist %hadoop-mapred-script% (
- call %hadoop-mapred-script% %*
+ call %hadoop-mapred-script% %hadoop-command% %hadoop-command-arguments%
goto :eof
)
)
@@ -109,8 +113,9 @@ call :updatepath %HADOOP_BIN_PATH%
set CLASSPATH=%CLASSPATH%;%CD%
set CLASS=%hadoop-command%
)
-
+
set path=%PATH%;%HADOOP_BIN_PATH%
+
call %JAVA% %JAVA_HEAP_MAX% %HADOOP_OPTS% -classpath %CLASSPATH% %CLASS% %hadoop-command-arguments%
goto :eof
@@ -165,7 +170,11 @@ call :updatepath %HADOOP_BIN_PATH%
@rem This changes %1, %2 etc. Hence those cannot be used after calling this.
:make_command_arguments
- if "%2" == "" goto :eof
+ if "%1" == "--config" (
+ shift
+ shift
+ )
+ if [%2] == [] goto :eof
shift
set _arguments=
:MakeCmdArgsLoop
@@ -184,7 +193,7 @@ call :updatepath %HADOOP_BIN_PATH%
:print_usage
- @echo Usage: hadoop COMMAND
+ @echo Usage: hadoop [--config confdir] COMMAND
@echo where COMMAND is one of:
@echo namenode -format format the DFS filesystem
@echo secondarynamenode run the DFS secondary namenode
Modified: hadoop/common/branches/branch-1-win/bin/hdfs.cmd
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/bin/hdfs.cmd?rev=1413992&r1=1413991&r2=1413992&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/bin/hdfs.cmd (original)
+++ hadoop/common/branches/branch-1-win/bin/hdfs.cmd Tue Nov 27 04:13:19 2012
@@ -24,7 +24,14 @@ if "%HADOOP_BIN_PATH:~-1%" == "\" (
set HADOOP_BIN_PATH=%HADOOP_BIN_PATH:~0,-1%
)
-set HADOOP_LOGFILE=hadoop-%1-%computername%.log
+@rem if we're being called by --service we need to use %2 otherwise use %1
+@rem for the command line so we log to the right file
+if "%2" == "" (
+ set HADOOP_LOGFILE=hadoop-%1-%computername%.log
+) else (
+ set HADOOP_LOGFILE=hadoop-%2-%computername%.log
+)
+
set hdfs-config-script=%HADOOP_BIN_PATH%\hadoop-config.cmd
call %hdfs-config-script% %*
@@ -125,7 +132,7 @@ goto :eof
@rem This changes %1, %2 etc. Hence those cannot be used after calling this.
:make_command_arguments
- if "%2" == "" goto :eof
+ if [%2] == [] goto :eof
set _count=0
set _hdfsarguments=
if defined service_entry (set _shift=2) else (set _shift=1)
Modified: hadoop/common/branches/branch-1-win/bin/mapred.cmd
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/bin/mapred.cmd?rev=1413992&r1=1413991&r2=1413992&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/bin/mapred.cmd (original)
+++ hadoop/common/branches/branch-1-win/bin/mapred.cmd Tue Nov 27 04:13:19 2012
@@ -23,7 +23,14 @@ if "%HADOOP_BIN_PATH:~-1%" == "\" (
set HADOOP_BIN_PATH=%HADOOP_BIN_PATH:~0,-1%
)
-set HADOOP_LOGFILE=hadoop-%1-%computername%.log
+@rem if we're being called by --service we need to use %2 otherwise use %1
+@rem for the command line so we log to the right file
+if "%2" == "" (
+ set HADOOP_LOGFILE=hadoop-%1-%computername%.log
+) else (
+ set HADOOP_LOGFILE=hadoop-%2-%computername%.log
+)
+
set mapred-config-script=%HADOOP_BIN_PATH%\hadoop-config.cmd
call %mapred-config-script% %*
@@ -114,7 +121,7 @@ goto :eof
@rem This changes %1, %2 etc. Hence those cannot be used after calling this.
:make_command_arguments
- if "%2" == "" goto :eof
+ if [%2] == [] goto :eof
set _count=0
set _mapredarguments=
if defined service_entry (set _shift=2) else (set _shift=1)
Modified: hadoop/common/branches/branch-1-win/build.xml
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/build.xml?rev=1413992&r1=1413991&r2=1413992&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/build.xml (original)
+++ hadoop/common/branches/branch-1-win/build.xml Tue Nov 27 04:13:19 2012
@@ -66,6 +66,8 @@
<property name="librecordio.src" value="${c++.src}/librecordio"/>
<property name="tools.src" value="${basedir}/src/tools"/>
<property name="winutils.src.dir" value="${basedir}/src/winutils"/>
+ <property name="wininstaller.root.dir" value="${basedir}/src/packages/win"/>
+ <property name="servicehost.src.dir" value="${basedir}/src/packages/win/HadoopServiceHost"/>
<property name="package.prefix" value="/usr"/>
<property name="package.conf.dir" value="/etc/hadoop"/>
@@ -94,6 +96,7 @@
<property name="jvm.arch"
value="${sun.arch.data.model}"/>
<property name="build.winutils" value="${build.dir}/winutils/${env.OS}-${env.Platform}"/>
+ <property name="build.servicehost" value="${build.dir}/servicehost"/>
<property name="build.native" value="${build.dir}/native/${build.platform}"/>
<!-- 'build.native.win' is the path under which Hadoop native libraries for Windows are built -->
<!-- We need a special path on Windows because we need a path that can be referenced from MSBuild -->
@@ -145,8 +148,7 @@
<property name="test.libhdfs.conf.dir" value="${c++.libhdfs.src}/tests/conf"/>
<property name="test.libhdfs.dir" value="${test.build.dir}/libhdfs"/>
-
- <property name="test.winutils.dir" value="${test.build.dir}/winutils/"/>
+ <property name="test.wininstaller.dir" value="${test.build.dir}/wininstaller"/>
<property name="librecordio.test.dir" value="${test.build.dir}/librecordio"/>
<property name="web.src.dir" value="${basedir}/src/web"/>
@@ -200,6 +202,12 @@
<os arch="x86" />
</or>
</condition>
+
+ <condition property="windows">
+ <os family="windows" />
+ </condition>
+
+
<property name="jsvc.location" value="http://archive.apache.org/dist/commons/daemon/binaries/1.0.2/linux/commons-daemon-1.0.2-bin-linux-${os-arch}.tar.gz" />
<property name="jsvc.dest.name" value="jsvc.${os.arch}.tar.gz" />
@@ -396,6 +404,16 @@
</tar>
</sequential>
</macrodef>
+
+ <macrodef name="macro_zip" description="Worker Macro for zip">
+ <attribute name="param.destfile"/>
+ <element name="param.listofitems"/>
+ <sequential>
+ <zip destfile="@{param.destfile}">
+ <param.listofitems/>
+ </zip>
+ </sequential>
+ </macrodef>
<!-- ====================================================== -->
<!-- Stuff needed by all targets -->
@@ -620,23 +638,26 @@
/>
</copy>
</target>
-
- <target name="compile-winutils">
- <antcall target="compile-ms-winutils">
- <param name="windows" value="true"/>
- </antcall>
- </target>
-
<target name="compile-ms-winutils" if="windows">
<mkdir dir="${build.winutils}"/>
<exec dir="${build.winutils}" executable="${msbuild.cmd}" failonerror="true">
- <arg line="${winutils.src.dir}/winutils.vcxproj /p:Configuration=Release;OutDir=${build.winutils}/"/>
+ <arg line="${winutils.src.dir}/winutils.sln /p:Configuration=Release;OutDir=${build.winutils}/"/>
</exec>
<copy file="${build.winutils}/winutils.exe" todir="${basedir}/bin"/>
</target>
+ <target name="compile-ms-servicehost" if="windows">
+ <mkdir dir="${build.servicehost}"/>
+
+ <exec dir="${build.servicehost}" executable="${msbuild.cmd}" failonerror="true">
+ <arg line="${servicehost.src.dir}/HadoopServiceHost.sln /target:clean;build /p:Platform="Any CPU" /p:Configuration=Release;OutDir=${build.servicehost}/"/>
+ </exec>
+
+ <copy file="${build.servicehost}/hadoopservicehost.exe" todir="${basedir}/bin"/>
+ </target>
+
<target name="compile-ms-winutils-debug" if="windows">
<mkdir dir="${build.winutils}"/>
@@ -688,7 +709,7 @@
<copy file="${build.native.win}/hadoop.dll" todir="${build.native}/lib"/>
</target>
- <target name="create-native-configure">
+ <target name="create-native-configure" unless="windows">
<exec executable="autoreconf" dir="${native.src.dir}" searchpath="yes"
failonerror="yes">
<arg value="-if"/>
@@ -776,7 +797,7 @@
<target name="compile-core"
depends="clover,compile-core-classes,compile-mapred-classes,
compile-hdfs-classes,compile-core-native,compile-c++,compile-ms-winutils,
- compile-win-core-native"
+ compile-win-core-native,compile-ms-servicehost"
description="Compile core only">
</target>
@@ -1295,6 +1316,44 @@
</antcall>
</target>
+ <target name="ms-win-installer-test-zip" description="Mini zip file used for test-ms-win-installer">
+ <delete dir="${test.wininstaller.dir}"/>
+ <mkdir dir="${test.wininstaller.dir}"/>
+ <macro_zip param.destfile="${test.wininstaller.dir}/resources/${final.name}.zip">
+ <param.listofitems>
+ <zipfileset dir="${build.dir}">
+ <include name="${final.name}/bin/*" />
+ <include name="${final.name}/conf/*" />
+ <include name="${final.name}/lib/hadoop-capacity-scheduler*" />
+ <include name="${final.name}/contrib/streaming/*" />
+ </zipfileset>
+ </param.listofitems>
+ </macro_zip>
+ </target>
+
+ <target name="test-ms-win-installer" depends="ms-win-installer-test-zip" if="windows">
+ <copy todir="${test.wininstaller.dir}">
+ <fileset dir="${wininstaller.root.dir}" includes="**/*">
+ <exclude name="servicehost/**/*"/>
+ </fileset>
+ <filterchain>
+ <replacetokens>
+ <token key="version" value="${version}" />
+ <token key="test.wininstaller.username" value="${testusername}" />
+ <token key="test.wininstaller.password" value="${testpassword}" />
+ </replacetokens>
+ </filterchain>
+ </copy>
+ <exec dir="${test.wininstaller.dir}"
+ executable="powershell.exe"
+ failonerror="true">
+ <env key="HADOOP_NODE_INSTALL_ROOT" value="${test.wininstaller.dir}/TestHadoop"/>
+ <env key="WINPKG_LOG" value="${test.wininstaller.dir}/TEST-test-ms-win-installer.log"/>
+ <env key="UNZIP_CMD" value="unzip.exe -o @SRC -d @DEST"/>
+ <arg line="${test.wininstaller.dir}/scripts/TestInstallApi.ps1"/>
+ </exec>
+ </target>
+
<target name="nightly" depends="test, tar">
</target>
@@ -1698,119 +1757,6 @@
</target>
- <target name="ms-package" depends="compile, jar, examples, tools-jar, jar-test"
- description="assembles isotope artifacts for distribution">
- <delete dir="${dist.dir}"/>
- <mkdir dir="${dist.dir}"/>
- <mkdir dir="${dist.dir}/bin"/>
- <mkdir dir="${dist.dir}/contrib"/>
- <mkdir dir="${dist.dir}/docs"/>
- <mkdir dir="${dist.dir}/docs/api"/>
- <mkdir dir="${dist.dir}/docs/jdiff"/>
- <mkdir dir="${dist.dir}/lib"/>
- <mkdir dir="${dist.dir}/libexec"/>
- <mkdir dir="${dist.dir}/sbin"/>
- <mkdir dir="${dist.dir}/share/${name}/templates/conf"/>
-
- <copy todir="${dist.dir}/share/${name}/templates/conf" includeEmptyDirs="false">
- <fileset dir="${basedir}/src/packages/templates/conf">
- <include name="*"/>
- </fileset>
- </copy>
-
- <copy todir="${dist.dir}/lib" includeEmptyDirs="false" flatten="true">
- <fileset dir="${common.ivy.lib.dir}"/>
- </copy>
-
- <copy todir="${dist.dir}/lib" includeEmptyDirs="false">
- <fileset dir="lib">
- <exclude name="**/native/**"/>
- </fileset>
- </copy>
-
- <exec dir="${dist.dir}" executable="python" failonerror="true">
- <env key="BASE_NATIVE_LIB_DIR" value="${lib.dir}/native"/>
- <env key="BUILD_NATIVE_DIR" value="${build.dir}/native"/>
- <env key="DIST_LIB_DIR" value="${dist.dir}/lib/native"/>
- <arg line="${native.src.dir}/packageNativeHadoop.py"/>
- </exec>
-
- <subant target="package">
- <!--Pass down the version in case its needed again and the target
- distribution directory so contribs know where to install to.-->
- <property name="version" value="${version}"/>
- <property name="dist.dir" value="${dist.dir}"/>
- <fileset file="${contrib.dir}/build.xml"/>
- </subant>
-
- <copy todir="${dist.dir}/webapps">
- <fileset dir="${build.webapps}"/>
- </copy>
-
- <copy todir="${dist.dir}">
- <fileset file="${build.dir}/${name}-*-${version}.jar"/>
- </copy>
-
- <copy todir="${dist.dir}/bin">
- <fileset dir="bin"/>
- </copy>
-
- <copy todir="${dist.dir}/libexec">
- <fileset dir="bin">
- <include name="hadoop-config.sh"/>
- </fileset>
- </copy>
-
- <copy todir="${dist.dir}/conf">
- <fileset dir="${conf.dir}" excludes="**/*.template"/>
- </copy>
-
- <copy file="ivy.xml" tofile="${dist.dir}/ivy.xml"/>
-
- <copy todir="${dist.dir}/ivy">
- <fileset dir="ivy"/>
- </copy>
-
- <copy todir="${dist.dir}">
- <fileset dir=".">
- <include name="*.txt" />
- </fileset>
- </copy>
-
- <copy todir="${dist.dir}/sbin">
- <fileset dir="${basedir}/src/packages">
- <include name="*.sh" />
- </fileset>
- </copy>
-
- <copy todir="${dist.dir}/src" includeEmptyDirs="true">
- <fileset dir="src" excludes="**/*.template **/docs/build/**/*"/>
- </copy>
-
- <copy todir="${dist.dir}/c++" includeEmptyDirs="false">
- <fileset dir="${build.dir}/c++"/>
- </copy>
-
- <copy todir="${dist.dir}/" file="build.xml"/>
-
- <copy todir="${dist.dir}/.eclipse.templates">
- <fileset dir="${basedir}/.eclipse.templates"/>
- </copy>
-
- <chmod perm="ugo+x" type="file" parallel="false">
- <fileset dir="${dist.dir}/bin"/>
- <fileset dir="${dist.dir}/sbin"/>
- <fileset dir="${dist.dir}/src/contrib/">
- <include name="*/bin/*" />
- </fileset>
- <fileset dir="${dist.dir}/src/contrib/ec2/bin/image"/>
- </chmod>
- <chmod perm="ugo+x" type="file">
- <fileset dir="${dist.dir}/src/c++/pipes/debug"/>
- </chmod>
-
- </target>
-
<!-- ================================================================== -->
<!-- Make release tarball -->
<!-- ================================================================== -->
@@ -1861,6 +1807,59 @@
</param.listofitems>
</macro_tar>
</target>
+
+
+ <!-- ================================================================== -->
+ <!-- Make release zip -->
+ <!-- ================================================================== -->
+ <target name="zip" depends="package" description="Make multi-platform release zip, both source and binary">
+ <!-- build source tarball -->
+ <macro_zip param.destfile="${build.dir}/${final.name}.zip">
+ <param.listofitems>
+ <zipfileset dir="${build.dir}" filemode="664">
+ <exclude name="${final.name}/bin/*" />
+ <exclude name="${final.name}/sbin/*" />
+ <exclude name="${final.name}/libexec/*" />
+ <exclude name="${final.name}/contrib/*/bin/*" />
+ <exclude name="${final.name}/src/contrib/ec2/bin/*" />
+ <exclude name="${final.name}/src/contrib/ec2/bin/image/*" />
+ <include name="${final.name}/**" />
+ <include name="${final.name}/eclipse.templates/**" />
+ </zipfileset>
+ <zipfileset dir="${build.dir}" filemode="755">
+ <include name="${final.name}/bin/*" />
+ <include name="${final.name}/sbin/*" />
+ <include name="${final.name}/libexec/*" />
+ <include name="${final.name}/contrib/*/bin/*" />
+ <include name="${final.name}/src/contrib/ec2/bin/*" />
+ <include name="${final.name}/src/contrib/ec2/bin/image/*" />
+ </zipfileset>
+ </param.listofitems>
+ </macro_zip>
+ <!-- build multi-platform binary tarball -->
+ <macro_zip param.destfile="${build.dir}/${final.name}-bin.zip">
+ <param.listofitems>
+ <zipfileset dir="${build.dir}" filemode="664">
+ <exclude name="${final.name}/src/**" />
+ <exclude name="${final.name}/docs/**" />
+ <exclude name="${final.name}/bin/*" />
+ <exclude name="${final.name}/sbin/*" />
+ <exclude name="${final.name}/libexec/*" />
+ <exclude name="${final.name}/contrib/*/bin/*" />
+ <include name="${final.name}/**" />
+ </zipfileset>
+ <zipfileset dir="${build.dir}" filemode="755">
+ <include name="${final.name}/bin/*" />
+ <include name="${final.name}/sbin/*" />
+ <include name="${final.name}/libexec/*" />
+ <include name="${final.name}/contrib/*/bin/*" />
+ <include name="${final.name}/src/contrib/ec2/bin/*" />
+ <include name="${final.name}/src/contrib/ec2/bin/image/*" />
+ </zipfileset>
+ </param.listofitems>
+ </macro_zip>
+ </target>
+
<target name="bin-package" depends="compile, jar, examples, tools-jar, jar-test, ant-tasks, package-librecordio"
description="assembles platform-specific artifacts for binary targets">
@@ -2140,6 +2139,51 @@
<delete dir="${package.buildroot}" quiet="true" verbose="false"/>
</target>
+ <target name="winpkg" depends="zip,just-winpkg" />
+ <target name="just-winpkg" description="Make a package for Windows">
+ <copy file="${build.dir}/${final.name}.zip" todir="${package.buildroot}/resources"/>
+ <copy todir="${package.buildroot}/scripts">
+ <fileset dir="${src.dir}/packages/win/scripts">
+ <include name="**" />
+ </fileset>
+ <filterchain>
+ <replacetokens>
+ <token key="final.name" value="${final.name}" />
+ <token key="build.arch" value="${os.arch}" />
+ <token key="version" value="${version}" />
+ <token key="package.release" value="${package.release}" />
+ <token key="package.zip" value="${final.name}.zip" />
+ </replacetokens>
+ </filterchain>
+ </copy>
+ <copy todir="${package.buildroot}/resources">
+ <fileset dir="${src.dir}/packages/win/resources">
+ <include name="**" />
+ </fileset>
+ </copy>
+ <copy todir="${package.buildroot}/template">
+ <fileset dir="${src.dir}/packages/win/template">
+ <include name="**" />
+ </fileset>
+ <filterchain>
+ <replacetokens>
+ <token key="final.name" value="${final.name}" />
+ <token key="build.arch" value="${os.arch}" />
+ <token key="version" value="${version}" />
+ <token key="package.release" value="${package.release}" />
+ <token key="package.zip" value="${final.name}.zip" />
+ </replacetokens>
+ </filterchain>
+ </copy>
+ <macro_zip param.destfile="${build.dir}/${final.name}.winpkg.zip">
+ <param.listofitems>
+ <zipfileset dir="${package.buildroot}">
+ <include name="**" />
+ </zipfileset>
+ </param.listofitems>
+ </macro_zip>
+ </target>
+
<!-- ================================================================== -->
<!-- Perform audit activities for the release -->
<!-- ================================================================== -->
@@ -2185,7 +2229,6 @@
<delete failonerror="false">
<fileset dir="${winutils.src.dir}" includes="**/*">
<exclude name="**/*.c"/>
- <exclude name="**/*.cpp"/>
<exclude name="**/*.h"/>
<exclude name="**/*.sln"/>
<exclude name="**/*.vcxproj"/>
@@ -2971,7 +3014,7 @@
</target>
<!-- taskcontroller targets -->
- <target name="task-controller" depends="init">
+ <target name="task-controller" depends="init" unless="windows">
<exec executable="autoreconf"
dir="${c++.task-controller.src}"
searchpath="yes" failonerror="yes">
Modified: hadoop/common/branches/branch-1-win/conf/hadoop-env.cmd
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/conf/hadoop-env.cmd?rev=1413992&r1=1413991&r2=1413992&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/conf/hadoop-env.cmd (original)
+++ hadoop/common/branches/branch-1-win/conf/hadoop-env.cmd Tue Nov 27 04:13:19 2012
@@ -7,9 +7,6 @@
@rem remote nodes.
@rem The java implementation to use. Required.
-if not defined JAVA_HOME (
- set JAVA_HOME=c:\apps\java\openjdk7
-)
@rem Extra Java CLASSPATH elements. Optional.
@rem set HADOOP_CLASSPATH=
Added: hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/HadoopServiceHost.csproj
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/HadoopServiceHost.csproj?rev=1413992&view=auto
==============================================================================
--- hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/HadoopServiceHost.csproj (added)
+++ hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/HadoopServiceHost.csproj Tue Nov 27 04:13:19 2012
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{DE479F78-4AA1-4454-8DCE-0D2DAAC5BD05}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>HadoopServiceHost</RootNamespace>
+ <AssemblyName>HadoopServiceHost</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <DebugType>full</DebugType>
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.ServiceProcess" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="ServiceHost.cs">
+ <SubType>Component</SubType>
+ </Compile>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
Added: hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/HadoopServiceHost.sln
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/HadoopServiceHost.sln?rev=1413992&view=auto
==============================================================================
--- hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/HadoopServiceHost.sln (added)
+++ hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/HadoopServiceHost.sln Tue Nov 27 04:13:19 2012
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HadoopServiceHost", "HadoopServiceHost.csproj", "{DE479F78-4AA1-4454-8DCE-0D2DAAC5BD05}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {DE479F78-4AA1-4454-8DCE-0D2DAAC5BD05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DE479F78-4AA1-4454-8DCE-0D2DAAC5BD05}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DE479F78-4AA1-4454-8DCE-0D2DAAC5BD05}.Debug|x86.ActiveCfg = Debug|x86
+ {DE479F78-4AA1-4454-8DCE-0D2DAAC5BD05}.Debug|x86.Build.0 = Debug|x86
+ {DE479F78-4AA1-4454-8DCE-0D2DAAC5BD05}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DE479F78-4AA1-4454-8DCE-0D2DAAC5BD05}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DE479F78-4AA1-4454-8DCE-0D2DAAC5BD05}.Release|x86.ActiveCfg = Release|x86
+ {DE479F78-4AA1-4454-8DCE-0D2DAAC5BD05}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
Added: hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/Program.cs
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/Program.cs?rev=1413992&view=auto
==============================================================================
--- hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/Program.cs (added)
+++ hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/Program.cs Tue Nov 27 04:13:19 2012
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.ServiceProcess;
+using System.Text;
+
+namespace HadoopServiceHost
+{
+ static class Program
+ {
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ static void Main()
+ {
+ ServiceBase[] ServicesToRun;
+ ServicesToRun = new ServiceBase[]
+ {
+ new ServiceHost()
+ };
+ ServiceBase.Run(ServicesToRun);
+ }
+ }
+}
Added: hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/Properties/AssemblyInfo.cs
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/Properties/AssemblyInfo.cs?rev=1413992&view=auto
==============================================================================
--- hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/Properties/AssemblyInfo.cs (added)
+++ hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/Properties/AssemblyInfo.cs Tue Nov 27 04:13:19 2012
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("HadoopServiceHost")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("HadoopServiceHost")]
+[assembly: AssemblyCopyright("Copyright -¬ Microsoft 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("fd4ab2db-e236-4b6b-8ee7-d07d9e52541c")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Added: hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/ServiceHost.cs
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/ServiceHost.cs?rev=1413992&view=auto
==============================================================================
--- hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/ServiceHost.cs (added)
+++ hadoop/common/branches/branch-1-win/src/packages/win/HadoopServiceHost/ServiceHost.cs Tue Nov 27 04:13:19 2012
@@ -0,0 +1,153 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Diagnostics;
+using System.Linq;
+using System.ServiceProcess;
+using System.Text;
+using System.Xml;
+using System.Threading;
+
+namespace HadoopServiceHost
+{
+ // Simple service host that allows running of Hadoop services in the context
+ // of Windows services. The service host is configured through a simple
+ // xml file named after the exe.
+ // Example xml:
+ // <service>
+ // <name>datanode</name>
+ // <executable>I:\git\tools\java\bin\java</executable>
+ // <arguments>-server org.apache.hadoop.hdfs.server.datanode.DataNode</arguments>
+ // </service>
+ public partial class ServiceHost : ServiceBase
+ {
+ private String serviceExe;
+ private String serviceArgs;
+ private volatile bool inShutdown = false;
+ Process process;
+ TraceSource trace = new TraceSource("HadoopServiceTraceSource");
+
+ private void InitInternal(String fileName)
+ {
+ try
+ {
+ XmlDocument doc = new XmlDocument();
+ trace.TraceEvent(TraceEventType.Information, 0,
+ "Loading service xml: " + fileName);
+ doc.Load(fileName);
+
+ this.ServiceName = doc.SelectSingleNode("//service/name").InnerText;
+ this.CanShutdown = true;
+ this.CanStop = true;
+ this.CanPauseAndContinue = false;
+
+ this.serviceExe = doc.SelectSingleNode("//service/executable").InnerText;
+ this.serviceArgs = doc.SelectSingleNode("//service/arguments").InnerText;
+ if (ServiceName == null || serviceExe == null || serviceArgs == null)
+ {
+ trace.TraceEvent(TraceEventType.Error, 0,
+ "Invalid service XML file format");
+ throw new Exception("Invalid service XML file format");
+ }
+ trace.TraceEvent(TraceEventType.Information, 0,
+ "Successfully parsed service xml for service " + ServiceName);
+ trace.TraceEvent(TraceEventType.Information, 0, "Command line: "
+ + serviceExe + " " + serviceArgs);
+ }
+ catch (Exception ex)
+ {
+ trace.TraceEvent(TraceEventType.Error, 0,
+ "Failed to parse the service xml with exception" + ex);
+ throw;
+ }
+ }
+
+ private void TerminateOurselves(int exitCode)
+ {
+ trace.Flush();
+ System.Environment.Exit(exitCode);
+ }
+
+ private void InitTracing()
+ {
+ TextWriterTraceListener tr = new TextWriterTraceListener(
+ System.Reflection.Assembly.GetExecutingAssembly().Location.Replace(".exe",
+ ".trace.log"));
+ trace.Switch = new SourceSwitch("Switch", "switch");
+ trace.Switch.Level = SourceLevels.Information;
+ tr.TraceOutputOptions = TraceOptions.DateTime | TraceOptions.Timestamp;
+ trace.Listeners.Clear();
+ trace.Listeners.Add(tr);
+ Trace.AutoFlush = true;
+
+ trace.TraceEvent(TraceEventType.Information, 0,
+ "Tracing successfully initialized");
+ }
+
+ public ServiceHost()
+ {
+ InitTracing();
+ String xmlFileName =
+ System.Reflection.Assembly.GetExecutingAssembly().Location.Replace(".exe",
+ ".xml");
+ InitInternal(xmlFileName);
+ process = new Process();
+ }
+
+ protected override void OnStart(string[] args)
+ {
+ trace.TraceEvent(TraceEventType.Information, 0, "ServiceHost#OnStart");
+
+ process.StartInfo.FileName = this.serviceExe;
+ process.StartInfo.Arguments = this.serviceArgs;
+
+ if (!process.Start())
+ {
+ trace.TraceEvent(TraceEventType.Error, 0,
+ "Process#Start failed, terminating service host");
+ TerminateOurselves(1);
+ }
+ else
+ {
+ trace.TraceEvent(TraceEventType.Information, 0,
+ "Child process started, PID: " + process.Id);
+
+ // Start a separate thread that will wait for child process to exit
+ new Thread(delegate()
+ {
+ process.WaitForExit();
+ trace.TraceEvent(TraceEventType.Information, 0,
+ "Child process exited with exit code: " + process.ExitCode);
+
+ if (!inShutdown)
+ {
+ // If not in shutdown state, child process terminated outside of
+ // our control, we should also stop ourselves
+ trace.TraceEvent(TraceEventType.Information, 0,
+ "Service host not in shutdown mode, terminating service host");
+ TerminateOurselves(process.ExitCode);
+ }
+ // else, we should be stopped anyways
+
+ }).Start();
+ }
+ }
+
+ protected override void OnStop()
+ {
+ trace.TraceEvent(TraceEventType.Information, 0,
+ "ServiceHost#OnStop, killing process " + process.Id);
+ inShutdown = true;
+ process.Kill();
+ }
+
+ protected override void OnShutdown()
+ {
+ trace.TraceEvent(TraceEventType.Information, 0,
+ "ServiceHost#OnShutdown, killing process " + process.Id);
+ inShutdown = true;
+ process.Kill();
+ }
+ }
+}
Added: hadoop/common/branches/branch-1-win/src/packages/win/resources/winpkg.utils.psm1
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/packages/win/resources/winpkg.utils.psm1?rev=1413992&view=auto
==============================================================================
--- hadoop/common/branches/branch-1-win/src/packages/win/resources/winpkg.utils.psm1 (added)
+++ hadoop/common/branches/branch-1-win/src/packages/win/resources/winpkg.utils.psm1 Tue Nov 27 04:13:19 2012
@@ -0,0 +1,203 @@
+### Licensed to the Apache Software Foundation (ASF) under one or more
+### contributor license agreements. See the NOTICE file distributed with
+### this work for additional information regarding copyright ownership.
+### The ASF licenses this file to You 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.
+
+
+### NOTE: This file is common across the Windows installer projects for Hadoop Core, Hive, and Pig.
+### This dependency is currently managed by convention.
+### If you find yourself needing to change something in this file, it's likely that you're
+### either doing something that's more easily done outside this file or is a bigger change
+### that likely has wider ramifications. Work intentionally.
+
+
+param( [parameter( Position=0, Mandatory=$true)]
+ [String] $ComponentName )
+
+function Write-Log ($message, $level, $pipelineObj )
+{
+ switch($level)
+ {
+ "Failure"
+ {
+ $message = "$ComponentName FAILURE: $message"
+ Write-Error $message
+ break;
+ }
+
+ "Info"
+ {
+ $message = "${ComponentName}: $message"
+ Write-Host $message
+ break;
+ }
+
+ default
+ {
+ $message = "${ComponentName}: $message"
+ Write-Host "$message"
+ }
+ }
+
+
+ Out-File -FilePath $ENV:WINPKG_LOG -InputObject "$message" -Append -Encoding "UTF8"
+
+ if( $pipelineObj -ne $null )
+ {
+ Out-File -FilePath $ENV:WINPKG_LOG -InputObject $pipelineObj.InvocationInfo.PositionMessage -Append -Encoding "UTF8"
+ }
+}
+
+function Write-LogRecord( $source, $record )
+{
+ if( $record -is [Management.Automation.ErrorRecord])
+ {
+ $message = "$ComponentName-$source FAILURE: " + $record.Exception.Message
+
+ if( $message.EndsWith( [Environment]::NewLine ))
+ {
+ Write-Host $message -NoNewline
+ [IO.File]::AppendAllText( "$ENV:WINPKG_LOG", "$message", [Text.Encoding]::UTF8 )
+ }
+ else
+ {
+ Write-Host $message
+ Out-File -FilePath $ENV:WINPKG_LOG -InputObject $message -Append -Encoding "UTF8"
+ }
+ }
+ else
+ {
+ $message = $record
+ Write-Host $message
+ Out-File -FilePath $ENV:WINPKG_LOG -InputObject "$message" -Append -Encoding "UTF8"
+ }
+}
+
+function Invoke-Cmd ($command)
+{
+ Write-Log $command
+ $out = cmd.exe /C "$command" 2>&1
+ $out | ForEach-Object { Write-LogRecord "CMD" $_ }
+ return $out
+}
+
+function Invoke-CmdChk ($command)
+{
+ Write-Log $command
+ $out = cmd.exe /C "$command" 2>&1
+ $out | ForEach-Object { Write-LogRecord "CMD" $_ }
+ if (-not ($LastExitCode -eq 0))
+ {
+ throw "Command `"$out`" failed with exit code $LastExitCode "
+ }
+ return $out
+}
+
+function Invoke-Ps ($command)
+{
+ Write-Log $command
+ $out = powershell.exe -InputFormat none -Command "$command" 2>&1
+ #$out | ForEach-Object { Write-LogRecord "PS" $_ }
+ return $out
+}
+
+function Invoke-PsChk ($command)
+{
+ Write-Log $command
+ $out = powershell.exe -InputFormat none -Command "$command" 2>&1
+ #$out | ForEach-Object { Write-LogRecord "PS" $_ }
+ if (-not ($LastExitCode -eq 0))
+ {
+ throw "Command `"$out`" failed with exit code $LastExitCode "
+ }
+ return $out
+}
+
+### Sets HADOOP_NODE_INSTALL_ROOT if unset
+### Initializes Winpkg Environment (ENV:WINPKG_LOG and ENV:WINPKG_BIN)
+### Tests for Admin
+
+function Initialize-InstallationEnv( $scriptDir, $logFilename )
+{
+ $HDP_INSTALL_PATH = $scriptDir
+ $HDP_RESOURCES_DIR = Resolve-Path "$HDP_INSTALL_PATH\..\resources"
+
+ if( -not (Test-Path ENV:HADOOP_NODE_INSTALL_ROOT))
+ {
+ $ENV:HADOOP_NODE_INSTALL_ROOT = "c:\hadoop"
+ }
+
+ if( -not (Test-Path ENV:WINPKG_LOG ))
+ {
+ throw "ENV:WINPKG_LOG not set"
+ }
+ else
+ {
+ Write-Log "Logging to existing log $ENV:WINPKG_LOG" "Info"
+ }
+
+ Write-Log "Logging to $ENV:WINPKG_LOG" "Info"
+ Write-Log "HDP_INSTALL_PATH: $HDP_INSTALL_PATH"
+ Write-Log "HDP_RESOURCES_DIR: $HDP_RESOURCES_DIR"
+
+ $currentPrincipal = New-Object Security.Principal.WindowsPrincipal( [Security.Principal.WindowsIdentity]::GetCurrent( ) )
+ if ( -not ($currentPrincipal.IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator ) ) )
+ {
+ throw "install script must be run elevated"
+ }
+
+ return $HDP_INSTALL_PATH, $HDP_RESOURCES_DIR
+}
+
+function Test-JavaHome
+{
+ if( -not (Test-Path $ENV:JAVA_HOME\bin\java.exe))
+ {
+ throw "JAVA_HOME not set properly; $ENV:JAVA_HOME\bin\java.exe does not exist"
+ }
+}
+
+### Add service control permissions to authenticated users.
+### Reference:
+### http://stackoverflow.com/questions/4436558/start-stop-a-windows-service-from-a-non-administrator-user-account
+### http://msmvps.com/blogs/erikr/archive/2007/09/26/set-permissions-on-a-specific-service-windows.aspx
+
+function Set-ServiceAcl ($service)
+{
+ $cmd = "sc sdshow $service"
+ $sd = Invoke-Cmd $cmd
+
+ Write-Log "Current SD: $sd"
+
+ ## A;; --- allow
+ ## RP ---- SERVICE_START
+ ## WP ---- SERVICE_STOP
+ ## CR ---- SERVICE_USER_DEFINED_CONTROL
+ ## ;;;AU - AUTHENTICATED_USERS
+
+ $sd = [String]$sd
+ $sd = $sd.Replace( "S:(", "(A;;RPWPCR;;;AU)S:(" )
+ Write-Log "Modifying SD to: $sd"
+
+ $cmd = "sc sdset $service $sd"
+ Invoke-Cmd $cmd
+}
+
+Export-ModuleMember -Function Initialize-InstallationEnv
+Export-ModuleMember -Function Invoke-Cmd
+Export-ModuleMember -Function Invoke-CmdChk
+Export-ModuleMember -Function Invoke-Ps
+Export-ModuleMember -Function Invoke-PsChk
+Export-ModuleMember -Function Set-ServiceAcl
+Export-ModuleMember -Function Test-JavaHome
+Export-ModuleMember -Function Write-Log