Skip to content

Commit 1402c7e

Browse files
committed
* fix in core-site.xml property
* change hcfs test harnace to load filesystem based on hadoop configuration files (now loads per settings in conf/core-site.xml vs env variables). * removed dead code
1 parent bc73332 commit 1402c7e

File tree

6 files changed

+28
-83
lines changed

6 files changed

+28
-83
lines changed

conf/core-site.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
<property>
2323
<name>fs.default.name</name>
24-
<value>glusterfs:///<</value>
24+
<value>glusterfs:///</value>
2525
</property>
2626

2727

pom.xml

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,12 @@
4646
</dependency>
4747
</dependencies>
4848
<build>
49+
<testResources>
50+
<testResource>
51+
<directory>conf</directory>
52+
</testResource>
53+
</testResources>
4954
<plugins>
50-
<plugin>
51-
<groupId>org.apache.maven.plugins</groupId>
52-
<artifactId>maven-surefire-plugin</artifactId>
53-
<version>2.4.3</version>
54-
<configuration>
55-
<!--
56-
run "export GLUSTER_MOUNT=/mnt/glusterfs
57-
export HCFS_FILE_SYSTEM_CONNECTOR=org.gluster.test.GlusterFileSystemTestConnector
58-
export HCFS_CLASSNAME=org.apache.hadoop.fs.glusterfs.GlusterFileSystem"
59-
-->
60-
<systemProperties>
61-
<property>
62-
<name>GLUSTER_MOUNT</name>
63-
<value>${GLUSTER_MOUNT}</value>
64-
</property>
65-
<property>
66-
<name>HCFS_CLASSNAME</name>
67-
<value>${HCFS_CLASSNAME}</value>
68-
</property>
69-
<property>
70-
<name>HCFS_FILE_SYSTEM_CONNECTOR</name>
71-
<value>${HCFS_FILE_SYSTEM_CONNECTOR}</value>
72-
</property>
73-
74-
</systemProperties>
75-
</configuration>
76-
</plugin>
77-
7855
<plugin>
7956
<groupId>org.apache.maven.plugins</groupId>
8057
<artifactId>maven-compiler-plugin</artifactId>
@@ -85,7 +62,7 @@
8562
</configuration>
8663
</plugin>
8764

88-
<plugin>
65+
<plugin>
8966
<groupId>pl.project13.maven</groupId>
9067
<artifactId>git-commit-id-plugin</artifactId>
9168
<version>2.1.4</version>
Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,29 @@
11
package org.apache.hadoop.fs.test.connector;
22

33
import java.io.IOException;
4+
import java.io.InputStream;
45

56
import org.apache.hadoop.conf.Configuration;
67
import org.apache.hadoop.fs.FileSystem;
78

9+
810
/*
911
* Generic HCFS file system test connector.
1012
* This test connector takes a fully qualified o.a.h.f.FileSystem implementor class
1113
* as an environment variable.
1214
*
1315
*/
14-
public class HcfsTestConnector implements HcfsTestConnectorInterface{
15-
16-
public Configuration createConfiguration(){
17-
return new Configuration();
18-
}
19-
20-
public FileSystem create(String HcfsClassName) throws IOException{
21-
try {
22-
FileSystem hcfs = (FileSystem)Class.forName(HcfsClassName).newInstance();
23-
hcfs.initialize(hcfs.getUri(), createConfiguration());
24-
return hcfs;
25-
} catch (Exception e) {
26-
throw new RuntimeException("Cannont instatiate HCFS. Error:\n " + e);
27-
}
28-
}
16+
public class HcfsTestConnector implements HcfsTestConnectorInterface {
17+
18+
public Configuration createConfiguration(){
19+
Configuration c = new Configuration();
20+
InputStream config = HcfsTestConnector.class.getClassLoader().getResourceAsStream("core-site.xml");
21+
c.addResource(config);
22+
23+
return c;
24+
}
2925

30-
public FileSystem create() throws IOException {
31-
return create(System.getProperty("HCFS_CLASSNAME"));
32-
}
26+
public FileSystem create() throws IOException{
27+
return FileSystem.get(createConfiguration());
28+
}
3329
}

src/test/java/org/apache/hadoop/fs/test/connector/HcfsTestConnectorFactory.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ public class HcfsTestConnectorFactory {
55

66
/* Loads an HCFS file system adapter via environment variable */
77
public static HcfsTestConnectorInterface getHcfsTestConnector() throws RuntimeException{
8-
return getHcfsTestConnector(System.getProperty("HCFS_FILE_SYSTEM_CONNECTOR"));
8+
String testConnector = System.getProperty("HCFS_FILE_SYSTEM_CONNECTOR");
9+
if(testConnector==null || "".equals(testConnector)){
10+
testConnector = HcfsTestConnector.class.getCanonicalName();
11+
}
12+
13+
return getHcfsTestConnector(testConnector);
914
}
1015

1116
public static HcfsTestConnectorInterface getHcfsTestConnector(String hcfsName) throws RuntimeException{

src/test/java/org/apache/hadoop/fs/test/connector/glusterfs/GlusterFileSystemTestConnector.java

Lines changed: 0 additions & 21 deletions
This file was deleted.

test.sh

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,7 @@
22

33
# this could be conditionally set. it may be set higher up as part of the global env variables.
44
rm -rf target/
5-
export GLUSTER_MOUNT=/mnt/glusterfs
6-
export HCFS_FILE_SYSTEM_CONNECTOR=org.apache.hadoop.fs.test.connector.glusterfs.GlusterFileSystemTestConnector
7-
export HCFS_CLASSNAME=org.apache.hadoop.fs.glusterfs.GlusterFileSystem
8-
rm -rf target/
9-
rm -rf /mnt/glusterfs/*
105
# runs in debug mode.
11-
# mvn package -Dmaven.surefire.debug
12-
mvn package
13-
# export HCFS_CLASSNAME=org.apache.hadoop.fs.glusterfs.GlusterFileSystemCRC
14-
15-
mvn package
16-
17-
unset HCFS_FILE_SYSTEM_CONNECTOR
18-
unset HCFS_CLASSNAME
6+
mvn package -Dmaven.surefire.debug
197

208

0 commit comments

Comments
 (0)