Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
702
HADOOP
tar
Commits
5814160f
Commit
5814160f
authored
Oct 14, 2021
by
František Dvořák
Browse files
Options
Downloads
Patches
Plain Diff
Warning and deprecation fixes
parent
2529dff1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#761
passed
Oct 14, 2021
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/apache/hadoop/tar/HadoopTar.java
+15
-18
15 additions, 18 deletions
src/main/java/org/apache/hadoop/tar/HadoopTar.java
with
15 additions
and
18 deletions
src/main/java/org/apache/hadoop/tar/HadoopTar.java
+
15
−
18
View file @
5814160f
...
@@ -23,8 +23,8 @@ import java.io.InputStream;
...
@@ -23,8 +23,8 @@ import java.io.InputStream;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.io.PrintStream
;
import
java.io.PrintStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.URI
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Arrays
;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
import
org.apache.commons.cli.PosixParser
;
import
org.apache.commons.cli.PosixParser
;
...
@@ -33,18 +33,13 @@ import org.apache.commons.cli.CommandLineParser;
...
@@ -33,18 +33,13 @@ import org.apache.commons.cli.CommandLineParser;
import
org.apache.commons.cli.HelpFormatter
;
import
org.apache.commons.cli.HelpFormatter
;
import
org.apache.commons.cli.Option
;
import
org.apache.commons.cli.Option
;
import
org.apache.commons.cli.OptionBuilder
;
import
org.apache.commons.cli.OptionBuilder
;
import
org.apache.commons.cli.OptionGroup
;
import
org.apache.commons.cli.Options
;
import
org.apache.commons.cli.Options
;
import
org.apache.commons.cli.Parser
;
import
org.apache.commons.logging.*
;
import
org.apache.commons.logging.*
;
import
org.apache.hadoop.io.compress.CompressionCodec
;
import
org.apache.hadoop.io.compress.CompressionCodec
;
import
org.apache.hadoop.io.compress.GzipCodec
;
import
org.apache.hadoop.io.compress.GzipCodec
;
import
org.apache.hadoop.io.LongWritable
;
import
org.apache.hadoop.io.Text
;
import
org.apache.hadoop.conf.Configuration
;
import
org.apache.hadoop.conf.Configured
;
import
org.apache.hadoop.conf.Configured
;
import
org.apache.hadoop.util.ReflectionUtils
;
import
org.apache.hadoop.util.ReflectionUtils
;
import
org.apache.hadoop.util.Tool
;
import
org.apache.hadoop.util.Tool
;
...
@@ -52,7 +47,6 @@ import org.apache.hadoop.util.ToolRunner;
...
@@ -52,7 +47,6 @@ import org.apache.hadoop.util.ToolRunner;
import
org.apache.hadoop.fs.FileStatus
;
import
org.apache.hadoop.fs.FileStatus
;
import
org.apache.hadoop.fs.FileSystem
;
import
org.apache.hadoop.fs.FileSystem
;
import
org.apache.hadoop.fs.FSDataOutputStream
;
import
org.apache.hadoop.fs.Path
;
import
org.apache.hadoop.fs.Path
;
import
org.apache.hadoop.fs.permission.FsPermission
;
import
org.apache.hadoop.fs.permission.FsPermission
;
...
@@ -68,6 +62,7 @@ public class HadoopTar extends Configured implements Tool {
...
@@ -68,6 +62,7 @@ public class HadoopTar extends Configured implements Tool {
public
static
final
Log
LOG
=
LogFactory
.
getLog
(
HadoopTar
.
class
);
public
static
final
Log
LOG
=
LogFactory
.
getLog
(
HadoopTar
.
class
);
@SuppressWarnings
(
"static-access"
)
private
Option
createBoolOption
(
String
name
,
String
longopt
,
String
desc
){
private
Option
createBoolOption
(
String
name
,
String
longopt
,
String
desc
){
if
(
name
.
isEmpty
()
){
if
(
name
.
isEmpty
()
){
return
OptionBuilder
.
withDescription
(
desc
)
return
OptionBuilder
.
withDescription
(
desc
)
...
@@ -79,6 +74,8 @@ public class HadoopTar extends Configured implements Tool {
...
@@ -79,6 +74,8 @@ public class HadoopTar extends Configured implements Tool {
.
create
(
name
);
.
create
(
name
);
}
}
}
}
@SuppressWarnings
(
"static-access"
)
private
Option
createOption
(
String
name
,
String
longopt
,
private
Option
createOption
(
String
name
,
String
longopt
,
String
desc
,
String
desc
,
String
argName
,
int
max
,
String
argName
,
int
max
,
...
@@ -101,6 +98,7 @@ public class HadoopTar extends Configured implements Tool {
...
@@ -101,6 +98,7 @@ public class HadoopTar extends Configured implements Tool {
.
create
(
name
);
.
create
(
name
);
}
}
}
}
private
void
setupOptions
()
{
private
void
setupOptions
()
{
Option
verbose
=
createBoolOption
(
"v"
,
"verbose"
,
"print verbose output"
);
Option
verbose
=
createBoolOption
(
"v"
,
"verbose"
,
"print verbose output"
);
Option
create
=
createBoolOption
(
"c"
,
"create"
,
"create a new archive"
);
Option
create
=
createBoolOption
(
"c"
,
"create"
,
"create a new archive"
);
...
@@ -156,7 +154,7 @@ public class HadoopTar extends Configured implements Tool {
...
@@ -156,7 +154,7 @@ public class HadoopTar extends Configured implements Tool {
}
}
//Almost a copy of IOUtils.java:copyBytes
//Almost a copy of IOUtils.java:copyBytes
//except it explicitly
s
set how many bytes to copy
//except it explicitly set how many bytes to copy
private
void
copyBytes
(
InputStream
in
,
OutputStream
out
,
private
void
copyBytes
(
InputStream
in
,
OutputStream
out
,
int
buffSize
,
long
size
)
throws
IOException
{
int
buffSize
,
long
size
)
throws
IOException
{
if
(
size
==
0
)
{
if
(
size
==
0
)
{
...
@@ -200,7 +198,7 @@ public class HadoopTar extends Configured implements Tool {
...
@@ -200,7 +198,7 @@ public class HadoopTar extends Configured implements Tool {
name
.
charAt
(
0
)
==
'/'
)
{
name
.
charAt
(
0
)
==
'/'
)
{
name
=
name
.
substring
(
1
);
name
=
name
.
substring
(
1
);
}
}
if
(
fileStatus
.
isDir
()
)
{
if
(
fileStatus
.
isDir
ectory
()
)
{
entry
.
setName
(
name
+
"/"
);
entry
.
setName
(
name
+
"/"
);
entry
.
setSize
(
0
);
entry
.
setSize
(
0
);
os
.
putNextEntry
(
entry
);
os
.
putNextEntry
(
entry
);
...
@@ -234,12 +232,11 @@ public class HadoopTar extends Configured implements Tool {
...
@@ -234,12 +232,11 @@ public class HadoopTar extends Configured implements Tool {
return
p
;
return
p
;
}
}
private
Path
[]
getTopSrcPaths
(
Path
curDirPath
,
List
args
,
private
Path
[]
getTopSrcPaths
(
Path
curDirPath
,
List
<
String
>
args
,
boolean
keepAbsolutePath
)
throws
IOException
{
boolean
keepAbsolutePath
)
throws
IOException
{
List
<
Path
>
listOfPath
=
new
LinkedList
<
Path
>();
List
<
Path
>
listOfPath
=
new
LinkedList
<
Path
>();
for
(
Object
arg
:
args
)
{
for
(
String
arg
:
args
)
{
String
str
=
(
String
)
arg
;
Path
p
=
new
Path
(
arg
);
Path
p
=
new
Path
(
str
);
if
(
p
.
isAbsolute
()
&&
!
keepAbsolutePath
)
{
if
(
p
.
isAbsolute
()
&&
!
keepAbsolutePath
)
{
System
.
err
.
println
(
"Removing leading '/' from member names"
);
System
.
err
.
println
(
"Removing leading '/' from member names"
);
}
}
...
@@ -260,7 +257,7 @@ public class HadoopTar extends Configured implements Tool {
...
@@ -260,7 +257,7 @@ public class HadoopTar extends Configured implements Tool {
return
listOfPath
.
toArray
(
new
Path
[
0
]
);
return
listOfPath
.
toArray
(
new
Path
[
0
]
);
}
}
private
void
create
(
OutputStream
os
,
Path
curDirPath
,
List
args
,
private
void
create
(
OutputStream
os
,
Path
curDirPath
,
List
<
String
>
args
,
boolean
keepAbsolutePath
,
boolean
optionVerbose
)
boolean
keepAbsolutePath
,
boolean
optionVerbose
)
throws
IOException
{
throws
IOException
{
...
@@ -295,8 +292,8 @@ public class HadoopTar extends Configured implements Tool {
...
@@ -295,8 +292,8 @@ public class HadoopTar extends Configured implements Tool {
FileSystem
ofs
=
curDirPath
.
getFileSystem
(
getConf
());
FileSystem
ofs
=
curDirPath
.
getFileSystem
(
getConf
());
if
(
!
dryrun
)
{
if
(
!
dryrun
)
{
if
(
!
ofs
.
isDirectory
(
curDirPath
)
)
{
if
(
!
ofs
.
getFileStatus
(
curDirPath
).
isDirectory
()
)
{
fail
(
"No such directory ["
+
curDirPath
.
makeQualified
(
ofs
)
+
"]"
);
fail
(
"No such directory ["
+
ofs
.
makeQualified
(
curDirPath
)
+
"]"
);
}
}
}
}
...
@@ -399,9 +396,9 @@ public class HadoopTar extends Configured implements Tool {
...
@@ -399,9 +396,9 @@ public class HadoopTar extends Configured implements Tool {
String
curDir
=
(
String
)
cmdLine
.
getOptionValue
(
"directory"
,
"."
);
String
curDir
=
(
String
)
cmdLine
.
getOptionValue
(
"directory"
,
"."
);
Path
curDirPath
=
new
Path
(
curDir
);
Path
curDirPath
=
new
Path
(
curDir
);
curDirPath
=
curDirPath
.
makeQualified
(
curDirPath
.
getFileSystem
(
getConf
())
);
curDirPath
=
curDirPath
.
getFileSystem
(
getConf
()).
makeQualified
(
curDirPath
);
List
list
=
cmdLine
.
getArg
List
()
;
List
<
String
>
list
=
Arrays
.
asList
(
cmdLine
.
getArg
s
()
)
;
CompressionCodec
codec
=
null
;
CompressionCodec
codec
=
null
;
if
(
cmdLine
.
hasOption
(
"compress"
))
{
if
(
cmdLine
.
hasOption
(
"compress"
))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment