Skip to content

Commit 6c7dae2

Browse files
authored
Merge branch 'apache:trunk' into HADOOP-19136
2 parents c1e9ec7 + a386ac1 commit 6c7dae2

File tree

79 files changed

+1604
-391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1604
-391
lines changed

BUILDING.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,20 @@ container.
653653
-Dwindows.cmake.toolchain.file=C:\vcpkg\scripts\buildsystems\vcpkg.cmake -Dwindows.cmake.build.type=RelWithDebInfo^
654654
-Dwindows.build.hdfspp.dll=off -Dwindows.no.sasl=on -Duse.platformToolsetVersion=v142
655655

656+
Building the release tarball:
657+
Assuming that we're still running in the Docker container hadoop-windows-10-builder, run the
658+
following command to create the Apache Hadoop release tarball -
659+
660+
> set IS_WINDOWS=1
661+
> set MVN_ARGS="-Dshell-executable=C:\Git\bin\bash.exe -Dhttps.protocols=TLSv1.2 -Pnative-win -Drequire.openssl -Dopenssl.prefix=C:\vcpkg\installed\x64-windows -Dcmake.prefix.path=C:\vcpkg\installed\x64-windows -Dwindows.cmake.toolchain.file=C:\vcpkg\scripts\buildsystems\vcpkg.cmake -Dwindows.cmake.build.type=RelWithDebInfo -Dwindows.build.hdfspp.dll=off -Duse.platformToolsetVersion=v142 -Dwindows.no.sasl=on -DskipTests -DskipDocs -Drequire.test.libhadoop"
662+
> C:\Git\bin\bash.exe C:\hadoop\dev-support\bin\create-release --mvnargs=%MVN_ARGS%
663+
664+
Note:
665+
If the building fails due to an issue with long paths, rename the Hadoop root directory to just a
666+
letter (like 'h') and rebuild -
667+
668+
> C:\Git\bin\bash.exe C:\h\dev-support\bin\create-release --mvnargs=%MVN_ARGS%
669+
656670
----------------------------------------------------------------------------------
657671
Building distributions:
658672

dev-support/bin/create-release

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,8 @@ function option_parse
418418
fi
419419
fi
420420
if [ -n "$MVNEXTRAARGS" ]; then
421-
MVN_ARGS+=("$MVNEXTRAARGS")
421+
# shellcheck disable=SC2206
422+
MVN_ARGS+=(${MVNEXTRAARGS[*]})
422423
fi
423424

424425
if [[ "${SECURITYRELEASE}" = true ]]; then
@@ -552,18 +553,21 @@ function makearelease
552553
mkdir -p "${LOGDIR}"
553554

554555
# Install the Hadoop maven plugins first
555-
run_and_redirect "${LOGDIR}/mvn_install_maven_plugins.log" "${MVN}" "${MVN_ARGS[@]}" -pl hadoop-maven-plugins -am clean install
556+
# shellcheck disable=SC2086
557+
run_and_redirect "${LOGDIR}/mvn_install_maven_plugins.log" "${MVN}" ${MVN_ARGS[*]} -pl hadoop-maven-plugins -am clean install
556558

557559
# mvn clean for sanity
558-
run_and_redirect "${LOGDIR}/mvn_clean.log" "${MVN}" "${MVN_ARGS[@]}" clean
560+
# shellcheck disable=SC2086
561+
run_and_redirect "${LOGDIR}/mvn_clean.log" "${MVN}" ${MVN_ARGS[*]} clean
559562

560563
# Create staging dir for release artifacts
561564
run mkdir -p "${ARTIFACTS_DIR}"
562565

563566
big_console_header "Apache RAT Check"
564567

565568
# Create RAT report
566-
run_and_redirect "${LOGDIR}/mvn_apache_rat.log" "${MVN}" "${MVN_ARGS[@]}" apache-rat:check
569+
# shellcheck disable=SC2086
570+
run_and_redirect "${LOGDIR}/mvn_apache_rat.log" "${MVN}" ${MVN_ARGS[*]} apache-rat:check
567571

568572
big_console_header "Maven Build and Install"
569573

@@ -577,9 +581,9 @@ function makearelease
577581
fi
578582

579583
# Create SRC and BIN tarballs for release,
580-
# shellcheck disable=SC2046
584+
# shellcheck disable=SC2046,SC2086
581585
run_and_redirect "${LOGDIR}/mvn_${target}.log" \
582-
"${MVN}" "${MVN_ARGS[@]}" ${target} \
586+
"${MVN}" ${MVN_ARGS[*]} ${target} \
583587
-Pdist,src,yarn-ui \
584588
"${signflags[@]}" \
585589
-DskipTests -Dtar $(hadoop_native_flags)
@@ -608,8 +612,9 @@ function makearelease
608612
# we need to do install again so that jdiff and
609613
# a few other things get registered in the maven
610614
# universe correctly
615+
# shellcheck disable=SC2206,SC2086
611616
run_and_redirect "${LOGDIR}/mvn_site.log" \
612-
"${MVN}" "${MVN_ARGS[@]}" install \
617+
"${MVN}" ${MVN_ARGS[*]} install \
613618
site site:stage \
614619
-DskipTests \
615620
-DskipShade \

dev-support/docker/Dockerfile_windows_10

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,21 @@ RUN powershell Copy-Item -Path "C:\LibXXHash\usr\bin\*.dll" -Destination "C:\Pro
102102
RUN powershell Copy-Item -Path "C:\LibZStd\usr\bin\*.dll" -Destination "C:\Program` Files\Git\usr\bin"
103103
RUN powershell Copy-Item -Path "C:\RSync\usr\bin\*" -Destination "C:\Program` Files\Git\usr\bin"
104104

105-
# Install Python 3.10.11.
106-
RUN powershell Invoke-WebRequest -Uri https://www.python.org/ftp/python/3.10.11/python-3.10.11-embed-amd64.zip -OutFile $Env:TEMP\python-3.10.11-embed-amd64.zip
107-
RUN powershell Expand-Archive -Path $Env:TEMP\python-3.10.11-embed-amd64.zip -DestinationPath "C:\Python3"
108-
RUN powershell New-Item -ItemType HardLink -Value "C:\Python3\python.exe" -Path "C:\Python3\python3.exe"
105+
COPY pkg-resolver pkg-resolver
106+
107+
## Install Python 3.11.8.
108+
# The Python installation steps below are derived from -
109+
# https://github.com/docker-library/python/blob/105d6f34e7d70aad6f8c3e249b8208efa591916a/3.11/windows/windowsservercore-ltsc2022/Dockerfile
110+
ENV PYTHONIOENCODING UTF-8
111+
ENV PYTHON_VERSION 3.11.8
112+
ENV PYTHON_PIP_VERSION 24.0
113+
ENV PYTHON_SETUPTOOLS_VERSION 65.5.1
114+
ENV PYTHON_GET_PIP_URL https://github.com/pypa/get-pip/raw/dbf0c85f76fb6e1ab42aa672ffca6f0a675d9ee4/public/get-pip.py
115+
ENV PYTHON_GET_PIP_SHA256 dfe9fd5c28dc98b5ac17979a953ea550cec37ae1b47a5116007395bfacff2ab9
116+
RUN powershell Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
117+
RUN powershell pkg-resolver\install-python.ps1
118+
RUN powershell pkg-resolver\install-pip.ps1
119+
RUN powershell pip install python-dateutil
109120

110121
# Create a user HadoopBuilder with basic privileges and use it for building Hadoop on Windows.
111122
RUN powershell New-LocalUser -Name 'HadoopBuilder' -Description 'User account for building Apache Hadoop' -Password ([securestring]::new()) -AccountNeverExpires -PasswordNeverExpires
@@ -121,12 +132,12 @@ USER HadoopBuilder
121132
ENV PROTOBUF_HOME "C:\vcpkg\installed\x64-windows"
122133
ENV JAVA_HOME "C:\Java\zulu8.62.0.19-ca-jdk8.0.332-win_x64"
123134
ENV MAVEN_OPTS '-Xmx2048M -Xss128M'
135+
ENV IS_WINDOWS 1
124136
RUN setx PATH "%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
125137
RUN setx PATH "%PATH%;%JAVA_HOME%\bin"
126138
RUN setx PATH "%PATH%;C:\Maven\apache-maven-3.8.6\bin"
127139
RUN setx PATH "%PATH%;C:\CMake\cmake-3.19.0-win64-x64\bin"
128140
RUN setx PATH "%PATH%;C:\ZStd"
129-
RUN setx path "%PATH%;C:\Python3"
130141
RUN setx PATH "%PATH%;C:\Program Files\Git\usr\bin"
131142

132143
# We get strange Javadoc errors without this.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# The code lines below are derived from -
18+
# https://github.com/docker-library/python/blob/105d6f34e7d70aad6f8c3e249b8208efa591916a/3.11/windows/windowsservercore-ltsc2022/Dockerfile
19+
20+
Write-Host ('Downloading get-pip.py ({0}) ...' -f $Env:PYTHON_GET_PIP_URL)
21+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
22+
Invoke-WebRequest -Uri $Env:PYTHON_GET_PIP_URL -OutFile 'get-pip.py'
23+
Write-Host ('Verifying sha256 ({0}) ...' -f $Env:PYTHON_GET_PIP_SHA256)
24+
if ((Get-FileHash 'get-pip.py' -Algorithm sha256).Hash -ne $Env:PYTHON_GET_PIP_SHA256) {
25+
Write-Host 'FAILED!'
26+
exit 1
27+
}
28+
29+
$Env:PYTHONDONTWRITEBYTECODE = '1'
30+
31+
Write-Host ('Installing pip=={0} ...' -f $Env:PYTHON_PIP_VERSION)
32+
python get-pip.py `
33+
--disable-pip-version-check `
34+
--no-cache-dir `
35+
--no-compile `
36+
('pip=={0}' -f $Env:PYTHON_PIP_VERSION) `
37+
('setuptools=={0}' -f $Env:PYTHON_SETUPTOOLS_VERSION)
38+
39+
Remove-Item get-pip.py -Force
40+
41+
Write-Host 'Verifying pip install ...'
42+
pip --version
43+
44+
Write-Host 'Complete.'
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# The code lines below are derived from -
18+
# https://github.com/docker-library/python/blob/105d6f34e7d70aad6f8c3e249b8208efa591916a/3.11/windows/windowsservercore-ltsc2022/Dockerfile
19+
20+
$url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f ($Env:PYTHON_VERSION -replace '[a-z]+[0-9]*$', ''), $Env:PYTHON_VERSION)
21+
Write-Host ('Downloading {0} ...' -f $url)
22+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
23+
Invoke-WebRequest -Uri $url -OutFile 'python.exe'
24+
25+
Write-Host 'Installing ...'
26+
$exitCode = (Start-Process python.exe -Wait -NoNewWindow -PassThru `
27+
-ArgumentList @(
28+
'/quiet',
29+
'InstallAllUsers=1',
30+
'TargetDir=C:\Python',
31+
'PrependPath=1',
32+
'Shortcuts=0',
33+
'Include_doc=0',
34+
'Include_pip=0',
35+
'Include_test=0'
36+
)
37+
).ExitCode
38+
if ($exitCode -ne 0) {
39+
Write-Host ('Running python installer failed with exit code: {0}' -f $exitCode)
40+
Get-ChildItem $Env:TEMP | Sort-Object -Descending -Property LastWriteTime | Select-Object -First 1 | Get-Content
41+
exit $exitCode
42+
}
43+
44+
# the installer updated PATH, so we should refresh our local value
45+
$Env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine)
46+
47+
Write-Host 'Verifying install ...'
48+
Write-Host "python --version $(python --version)"
49+
50+
Write-Host 'Removing ...'
51+
Remove-Item python.exe -Force
52+
Remove-Item $Env:TEMP\Python*.log -Force
53+
54+
Write-Host 'Complete.'

hadoop-client-modules/hadoop-client-api/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@
9494
<plugin>
9595
<groupId>org.apache.maven.plugins</groupId>
9696
<artifactId>maven-shade-plugin</artifactId>
97-
<configuration>
98-
<createSourcesJar>true</createSourcesJar>
99-
<shadeSourcesContent>true</shadeSourcesContent>
100-
</configuration>
10197
<executions>
10298
<execution>
10399
<phase>package</phase>

hadoop-common-project/hadoop-common/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,8 +1095,9 @@
10951095
<goal>exec</goal>
10961096
</goals>
10971097
<configuration>
1098-
<executable>${basedir}/../../dev-support/bin/releasedocmaker</executable>
1098+
<executable>${shell-executable}</executable>
10991099
<arguments>
1100+
<argument>${basedir}/../../dev-support/bin/releasedocmaker</argument>
11001101
<argument>--index</argument>
11011102
<argument>--license</argument>
11021103
<argument>--outputdir</argument>

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPFileSystem.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -685,21 +685,21 @@ private boolean rename(FTPClient client, Path src, Path dst)
685685
throw new FileAlreadyExistsException("Destination path " + dst
686686
+ " already exists");
687687
}
688-
String parentSrc = absoluteSrc.getParent().toUri().toString();
689-
String parentDst = absoluteDst.getParent().toUri().toString();
688+
URI parentSrc = absoluteSrc.getParent().toUri();
689+
URI parentDst = absoluteDst.getParent().toUri();
690690
if (isParentOf(absoluteSrc, absoluteDst)) {
691691
throw new IOException("Cannot rename " + absoluteSrc + " under itself"
692692
+ " : "+ absoluteDst);
693693
}
694694

695-
if (!parentSrc.equals(parentDst)) {
695+
if (!parentSrc.toString().equals(parentDst.toString())) {
696696
throw new IOException("Cannot rename source: " + absoluteSrc
697697
+ " to " + absoluteDst
698698
+ " -"+ E_SAME_DIRECTORY_ONLY);
699699
}
700700
String from = absoluteSrc.getName();
701701
String to = absoluteDst.getName();
702-
client.changeWorkingDirectory(parentSrc);
702+
client.changeWorkingDirectory(parentSrc.getPath());
703703
boolean renamed = client.rename(from, to);
704704
return renamed;
705705
}

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/HttpExceptionUtils.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
import java.io.IOException;
2727
import java.io.InputStream;
2828
import java.io.Writer;
29-
import java.lang.reflect.Constructor;
29+
import java.lang.invoke.MethodHandle;
30+
import java.lang.invoke.MethodHandles;
31+
import java.lang.invoke.MethodType;
3032
import java.net.HttpURLConnection;
3133
import java.util.Collections;
3234
import java.util.LinkedHashMap;
@@ -54,6 +56,10 @@ public class HttpExceptionUtils {
5456

5557
private static final String ENTER = System.getProperty("line.separator");
5658

59+
private static final MethodHandles.Lookup PUBLIC_LOOKUP = MethodHandles.publicLookup();
60+
private static final MethodType EXCEPTION_CONSTRUCTOR_TYPE =
61+
MethodType.methodType(void.class, String.class);
62+
5763
/**
5864
* Creates a HTTP servlet response serializing the exception in it as JSON.
5965
*
@@ -150,9 +156,12 @@ public static void validateResponse(HttpURLConnection conn,
150156
try {
151157
ClassLoader cl = HttpExceptionUtils.class.getClassLoader();
152158
Class klass = cl.loadClass(exClass);
153-
Constructor constr = klass.getConstructor(String.class);
154-
toThrow = (Exception) constr.newInstance(exMsg);
155-
} catch (Exception ex) {
159+
Preconditions.checkState(Exception.class.isAssignableFrom(klass),
160+
"Class [%s] is not a subclass of Exception", klass);
161+
MethodHandle methodHandle = PUBLIC_LOOKUP.findConstructor(
162+
klass, EXCEPTION_CONSTRUCTOR_TYPE);
163+
toThrow = (Exception) methodHandle.invoke(exMsg);
164+
} catch (Throwable t) {
156165
toThrow = new IOException(String.format(
157166
"HTTP status [%d], exception [%s], message [%s], URL [%s]",
158167
conn.getResponseCode(), exClass, exMsg, conn.getURL()));

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/ftp/TestFTPFileSystem.java

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import static org.hamcrest.CoreMatchers.equalTo;
4949
import static org.hamcrest.MatcherAssert.assertThat;
5050
import static org.junit.Assert.assertEquals;
51+
import static org.junit.Assert.assertTrue;
5152

5253
/**
5354
* Test basic @{link FTPFileSystem} class methods. Contract tests are in
@@ -236,4 +237,50 @@ public void testFTPSetTimeout() {
236237
ftp.setTimeout(client, conf);
237238
assertEquals(client.getControlKeepAliveTimeout(), timeout);
238239
}
239-
}
240+
241+
private static void touch(FileSystem fs, Path filePath)
242+
throws IOException {
243+
touch(fs, filePath, null);
244+
}
245+
246+
private static void touch(FileSystem fs, Path path, byte[] data)
247+
throws IOException {
248+
FSDataOutputStream out = null;
249+
try {
250+
out = fs.create(path);
251+
if (data != null) {
252+
out.write(data);
253+
}
254+
} finally {
255+
if (out != null) {
256+
out.close();
257+
}
258+
}
259+
}
260+
261+
/**
262+
* Test renaming a file.
263+
*
264+
* @throws Exception
265+
*/
266+
@Test
267+
public void testRenameFileWithFullQualifiedPath() throws Exception {
268+
BaseUser user = server.addUser("test", "password", new WritePermission());
269+
Configuration configuration = new Configuration();
270+
configuration.set("fs.defaultFS", "ftp:///");
271+
configuration.set("fs.ftp.host", "localhost");
272+
configuration.setInt("fs.ftp.host.port", server.getPort());
273+
configuration.set("fs.ftp.user.localhost", user.getName());
274+
configuration.set("fs.ftp.password.localhost", user.getPassword());
275+
configuration.setBoolean("fs.ftp.impl.disable.cache", true);
276+
277+
FileSystem fs = FileSystem.get(configuration);
278+
279+
280+
Path ftpDir = fs.makeQualified(new Path(testDir.toAbsolutePath().toString()));
281+
Path file1 = fs.makeQualified(new Path(ftpDir, "renamefile" + "1"));
282+
Path file2 = fs.makeQualified(new Path(ftpDir, "renamefile" + "2"));
283+
touch(fs, file1);
284+
assertTrue(fs.rename(file1, file2));
285+
}
286+
}

0 commit comments

Comments
 (0)