Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-cloud
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
data-hook
gic-cloud
Commits
b90e27e8
Commit
b90e27e8
authored
Apr 06, 2023
by
fudahua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新版本的下载
parent
4da4c154
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
11 deletions
+15
-11
HDFSUtil.java
...c/main/java/com/gic/cloud/data/hook/service/HDFSUtil.java
+3
-2
hdfs.java
gic-cloud-data-hook-service/src/test/java/hdfs.java
+12
-9
No files found.
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/HDFSUtil.java
View file @
b90e27e8
...
...
@@ -9,6 +9,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
java.io.IOException
;
import
java.net.URI
;
public
class
HDFSUtil
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
HDFSUtil
.
class
);
...
...
@@ -32,8 +33,8 @@ public class HDFSUtil {
Configuration
configuration
=
new
Configuration
();
configuration
.
set
(
"fs.defaultFS"
,
hdfsUrl
);
try
{
fileSystem
=
FileSystem
.
get
(
configuration
);
}
catch
(
IO
Exception
e
)
{
fileSystem
=
FileSystem
.
get
(
new
URI
(
hdfsUrl
),
configuration
,
"hadoop"
);
}
catch
(
Exception
e
)
{
logger
.
info
(
"hdfs初始化失败-{}"
,
e
);
}
}
...
...
gic-cloud-data-hook-service/src/test/java/hdfs.java
View file @
b90e27e8
import
com.gic.cloud.data.hook.service.HDFSUtil
;
import
org.apache.hadoop.conf.Configuration
;
import
org.apache.hadoop.fs.FileSystem
;
import
org.apache.hadoop.fs.Path
;
...
...
@@ -6,14 +7,16 @@ import java.io.IOException;
public
class
hdfs
{
public
static
void
main
(
String
[]
args
)
{
Configuration
configuration
=
new
Configuration
();
configuration
.
set
(
"fs.defaultFS"
,
"hdfs://10.0.1.13:4007"
);
try
{
FileSystem
fileSystem
=
FileSystem
.
get
(
configuration
);
fileSystem
.
copyToLocalFile
(
false
,
new
Path
(
"/data/emr/order-1.csv"
),
new
Path
(
"D:\\testorder"
));
fileSystem
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
// Configuration configuration = new Configuration();
// configuration.set("fs.defaultFS","hdfs://10.0.1.13:4007");
// try {
// FileSystem fileSystem = FileSystem.get(configuration);
// fileSystem.copyToLocalFile(false,new Path("/data/emr/order-1.csv"),new Path("D:\\testorder"));
// fileSystem.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
HDFSUtil
.
getInstance
().
downloadFile
(
"/data/emr/order-1.csv"
,
"D:\\testorder"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment