Skip to content

Commit

Permalink
The user name will be remembered when logging in
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangminke committed Oct 10, 2022
1 parent cde828e commit 554894a
Show file tree
Hide file tree
Showing 16 changed files with 1,346 additions and 1,362 deletions.
273 changes: 116 additions & 157 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,160 +1,119 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>cn.mastercom.bigdata</groupId>
<artifactId>HdfsManager</artifactId>
<version>0.0.3-SNAPSHOT</version>

<properties>
<haddop.version>3.2.3</haddop.version>
</properties>

<dependencies>

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
<version>${haddop.version}</version>
</dependency>

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>${haddop.version}</version>
</dependency>

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>${haddop.version}</version>
</dependency>

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-yarn-client</artifactId>
<version>${haddop.version}</version>
</dependency>

<dependency>
<groupId>io.vavr</groupId>
<artifactId>vavr</artifactId>
<version>0.9.2</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>

<!--<dependency>-->
<!--<groupId>org.apache.hive</groupId>-->
<!--<artifactId>hive-jdbc</artifactId>-->
<!--<version>1.2.1</version>-->
<!--</dependency>-->

<!--<dependency>-->
<!--<groupId>org.apache.hive</groupId>-->
<!--<artifactId>hive-metastore</artifactId>-->
<!--<version>1.2.1</version>-->
<!--</dependency>-->

<!--<dependency>-->
<!--<groupId>org.apache.hive</groupId>-->
<!--<artifactId>hive-exec</artifactId>-->
<!--<version>1.2.1</version>-->
<!--</dependency>-->

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source> <!-- 源代码使用的开发版本 -->
<target>1.8</target> <!-- 需要生成的目标class文件的编译版本 -->
<encoding>utf8</encoding>
</configuration>
</plugin>

<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-shade-plugin</artifactId>-->
<!-- <version>2.1</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <phase>package</phase>-->
<!-- <goals>-->
<!-- <goal>shade</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <createDependencyReducedPom>true</createDependencyReducedPom>-->
<!-- <transformers>-->
<!-- <transformer-->
<!-- implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">-->
<!-- <mainClass>hdfsmanager.App</mainClass>-->
<!-- </transformer>-->
<!-- </transformers>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>${project.artifactId}_lib/</classpathPrefix>
<mainClass>hdfsmanager.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/${project.artifactId}_lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

<!-- IDEA Gui Designer Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>ideauidesigner-maven-plugin</artifactId>
<version>1.0-beta-1</version>
<executions>
<execution>
<goals>
<goal>javac2</goal>
</goals>
</execution>
</executions>
<configuration>
<fork>true</fork>
<debug>true</debug>
<failOnError>true</failOnError>
</configuration>
</plugin>
</plugins>
</build>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>cn.mastercom.bigdata</groupId>
<artifactId>HdfsManager</artifactId>
<version>0.0.3-SNAPSHOT</version>

<properties>
<haddop.version>3.2.3</haddop.version>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
<version>${haddop.version}</version>
</dependency>

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>${haddop.version}</version>
</dependency>

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>${haddop.version}</version>
</dependency>

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-yarn-client</artifactId>
<version>${haddop.version}</version>
</dependency>

<dependency>
<groupId>io.vavr</groupId>
<artifactId>vavr</artifactId>
<version>0.9.2</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>utf8</encoding>
</configuration>
</plugin>
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-jar-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <archive>-->
<!-- <manifest>-->
<!-- <addClasspath>true</addClasspath>-->
<!-- <classpathPrefix>${project.artifactId}_lib/</classpathPrefix>-->
<!-- <mainClass>hdfsmanager.App</mainClass>-->
<!-- </manifest>-->
<!-- </archive>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-dependency-plugin</artifactId>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>copy</id>-->
<!-- <phase>package</phase>-->
<!-- <goals>-->
<!-- <goal>copy-dependencies</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <outputDirectory>${project.build.directory}/${project.artifactId}_lib</outputDirectory>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<shadedArtifactAttached>true</shadedArtifactAttached>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>hdfsmanager.App</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
1 change: 0 additions & 1 deletion src/main/java/hdfsmanager/controller/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import javax.swing.*;

import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.permission.FsPermission;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/hdfsmanager/model/BatchRenameModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.io.IOException;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.Path;
import org.apache.log4j.Logger;
Expand Down
25 changes: 21 additions & 4 deletions src/main/java/hdfsmanager/model/LoginModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.hadoop.fs.Path;
Expand All @@ -13,25 +14,35 @@
public class LoginModel extends Model {

private static final String HISTORY_URLS_PATH = "/hdfsmanager.historyurls";
private static final String HISTORY_NAME_PATH = "/hdfsmanager.name";

private String name;
private List<String> historyUrls;

@Override
public void initialize() {
// 从临时目录中读取历史url
File historyUrlsFile = new File(fetchHistoryUrlsPath());
File historyUrlsFile = new File(fetchHistoryUrlsPath(HISTORY_URLS_PATH));
historyUrls = new ArrayList<>();
if (!historyUrlsFile.exists()) {
return;
}
// 通知视图,更新url
historyUrls.addAll(FileUtil.readFileAsLine(historyUrlsFile));
// 从临时目录中读取用户名
File historyNameFile = new File(fetchHistoryUrlsPath(HISTORY_NAME_PATH));
if (!historyUrlsFile.exists()) {
return;
}
// 通知视图,更新name
final List<String> names = FileUtil.readFileAsLine(historyNameFile);
this.name = names.isEmpty() ? "hdfs" : names.get(0);
notifyObservers();
}

private String fetchHistoryUrlsPath() {
private String fetchHistoryUrlsPath(String fileName) {
String tmpdir = System.getProperty("java.io.tmpdir");
Path path = Path.mergePaths(new Path(tmpdir), new Path(HISTORY_URLS_PATH));
Path path = Path.mergePaths(new Path(tmpdir), new Path(fileName));
return path.toString();
}

Expand All @@ -43,7 +54,13 @@ public void login(String loginUrl, String loginUser) {
// 将选项框里的数据存入本地
historyUrls.remove(loginUrl);
historyUrls.add(0, loginUrl);
FileUtil.writeToFile(historyUrls, fetchHistoryUrlsPath());
FileUtil.writeToFile(historyUrls, fetchHistoryUrlsPath(HISTORY_URLS_PATH));
name = loginUser;
FileUtil.writeToFile(Collections.singleton(name), fetchHistoryUrlsPath(HISTORY_NAME_PATH));
}

public String getName() {
return name;
}

public List<String> getHistoryUrls() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/hdfsmanager/util/MessageBus.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private MessageBus() {
}

private synchronized static BlockingQueue<Object> getOrCreateQueue(String topic) {
if (org.apache.commons.lang.StringUtils.isEmpty(topic)) {
if (org.apache.commons.lang3.StringUtils.isEmpty(topic)) {
throw new NullPointerException("传入的 topic 不能为空");
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/hdfsmanager/util/StringUtil.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package hdfsmanager.util;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;

import java.io.File;
import java.util.Arrays;
Expand Down
Loading

0 comments on commit 554894a

Please sign in to comment.