Skip to content

Commit

Permalink
Merge pull request #18 from wucheng/master
Browse files Browse the repository at this point in the history
fix single instance bug
  • Loading branch information
wucheng committed Feb 11, 2022
2 parents cd166e0 + 91cd772 commit 2d2faab
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 44 deletions.
Binary file removed jar/chdfs_hadoop_plugin_network-2.5.jar
Binary file not shown.
Binary file added jar/chdfs_hadoop_plugin_network-2.6.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion jar/jar.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MD5 (chdfs_hadoop_plugin_network-2.5.jar) = 65d3bc5a7510ac18d7c48648cf2a6d5a
MD5 (chdfs_hadoop_plugin_network-2.6.jar) = 135f11c92d99abbe1807d0b749a1fcc9
48 changes: 46 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,27 @@

<groupId>com.qcloud</groupId>
<artifactId>chdfs_hadoop_plugin_network</artifactId>
<version>2.5</version>
<version>2.6</version>
<packaging>jar</packaging>

<name>chdfs_hadoop_plugin_network</name>
<url>http://maven.apache.org</url>
<description>Tencent Qcloud chdfs hadoop plugins.</description>
<url>https://cloud.tencent.com/document/product/1105/36368</url>

<licenses>
<license>
<name>chdfs-hadoop-plugin</name>
<url>https://github.com/tencentyun/chdfs-hadoop-plugin</url>
</license>
</licenses>

<developers>
<developer>
<name>chengwu</name>
<email>chengwu@tencent.com</email>
</developer>
</developers>


<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -18,6 +34,16 @@
<hadoop.version>2.8.5</hadoop.version>
</properties>

<scm>
<connection>scm:git:https://github.com/tencentyun/chdfs-hadoop-plugin.git
</connection>
<developerConnection>
scm:git:https://github.com/tencentyun/chdfs-hadoop-plugin.git
</developerConnection>
<url>https://github.com/tencentyun/chdfs-hadoop-plugin</url>
</scm>


<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
Expand All @@ -34,6 +60,24 @@
</dependency>
</dependencies>

<distributionManagement>
<repository>
<id>oss</id>
<name>chdfs_hadoop_plugin_network</name>
<url>
https://oss.sonatype.org/service/local/staging/deploy/maven2
</url>
</repository>

<snapshotRepository>
<id>oss</id>
<name>chdfs_hadoop_plugin_network</name>
<url>
https://oss.sonatype.org/content/repositories/snapshots
</url>
</snapshotRepository>
</distributionManagement>

<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ public class AlreadyLoadedFileSystemInfo {
String versionId;
String jarPath;
String jarMd5;
FileSystemWithLockCleaner actualFileSystem;
Class chdfsFSClass;

public AlreadyLoadedFileSystemInfo(String versionId, String jarPath, String jarMd5,
FileSystemWithLockCleaner actualFileSystem) {
Class chdfsFSClass) {
this.versionId = versionId;
this.jarPath = jarPath;
this.jarMd5 = jarMd5;
this.actualFileSystem = actualFileSystem;
this.chdfsFSClass = chdfsFSClass;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.hadoop.security.AccessControlException;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.util.Progressable;
import org.apache.hadoop.util.hash.Hash;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -27,6 +28,7 @@
import java.io.IOException;
import java.net.URI;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ private void queryJarPluginInfo(String mountPointAddr, long appid, int jarPlugin
if (hadoopVersion == null) {
hadoopVersion = "unknown";
}

URL queryJarUrl = null;
String queryJarUrlStr = "";
try {
Expand Down Expand Up @@ -153,7 +154,14 @@ private static synchronized FileSystemWithLockCleaner getAlreadyLoadedClassInfo(
if (alreadyLoadedFileSystemInfo != null && alreadyLoadedFileSystemInfo.jarPath.equals(jarPath)
&& alreadyLoadedFileSystemInfo.versionId.equals(versionId) && alreadyLoadedFileSystemInfo.jarMd5.equals(
jarMd5)) {
return alreadyLoadedFileSystemInfo.actualFileSystem;
try {
return (FileSystemWithLockCleaner) alreadyLoadedFileSystemInfo.chdfsFSClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
String errMsg = String.format("load chdfs class failed, className: %s",
alreadyLoadedFileSystemInfo.chdfsFSClass.getName());
log.error(errMsg, e);
throw new IOException(errMsg, e);
}
}

File jarFile = downloadJarPath(jarPath, versionId, jarMd5, tmpDirPath);
Expand All @@ -170,7 +178,7 @@ private static synchronized FileSystemWithLockCleaner getAlreadyLoadedClassInfo(
try {
Class chdfsFSClass = chdfsJarClassLoader.loadClass(className);
FileSystemWithLockCleaner actualFileSystem = (FileSystemWithLockCleaner) chdfsFSClass.newInstance();
alreadyLoadedFileSystemInfo = new AlreadyLoadedFileSystemInfo(versionId, jarPath, jarMd5, actualFileSystem);
alreadyLoadedFileSystemInfo = new AlreadyLoadedFileSystemInfo(versionId, jarPath, jarMd5, chdfsFSClass);
return actualFileSystem;
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
String errMsg = String.format("load class failed, className: %s", className);
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 2d2faab

Please sign in to comment.