Skip to content

Commit 4135d34

Browse files
committed
Merge branch 'master' of https://github.com/gluster/glusterfs-hadoop into version-defense
2 parents 746dbdb + 012d5d4 commit 4135d34

File tree

6 files changed

+171
-96
lines changed

6 files changed

+171
-96
lines changed

pom.xml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<packaging>jar</packaging>
77
<!-- from now, we will update version manually and ignore maven snapshot
88
features -->
9-
<version>2.1.8</version>
9+
<version>2.3.2</version>
1010
<name>glusterfs-hadoop</name>
1111
<url>http://maven.apache.org</url>
1212

@@ -19,6 +19,13 @@
1919
</distributionManagement>
2020

2121
<dependencies>
22+
23+
<dependency>
24+
<groupId>org.apache.hadoop</groupId>
25+
<artifactId>hadoop-yarn-server-nodemanager</artifactId>
26+
<version>2.3.0</version>
27+
</dependency>
28+
2229
<dependency>
2330
<groupId>junit</groupId>
2431
<artifactId>junit</artifactId>
@@ -28,7 +35,7 @@
2835
<dependency>
2936
<groupId>org.apache.hadoop</groupId>
3037
<artifactId>hadoop-common</artifactId>
31-
<version>2.0.5-alpha</version>
38+
<version>2.3.0</version>
3239
</dependency>
3340
<dependency>
3441
<groupId>org.apache.hadoop</groupId>
@@ -170,4 +177,4 @@
170177

171178
</plugins>
172179
</build>
173-
</project>
180+
</project>

src/main/java/org/apache/hadoop/fs/glusterfs/GlusterFileSystem.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.apache.hadoop.fs.FileSystem;
3737
import org.apache.hadoop.fs.FileUtil;
3838
import org.apache.hadoop.fs.FilterFileSystem;
39+
import org.apache.hadoop.fs.permission.FsPermission;
3940
import org.apache.hadoop.fs.Path;
4041
import org.slf4j.Logger;
4142
import org.slf4j.LoggerFactory;
@@ -92,6 +93,11 @@ public void copyToLocalFile(boolean delSrc,Path src,Path dst) throws IOException
9293
FileUtil.copy(srcFs, src, dstFs, dst, delSrc, getConf());
9394
}
9495

96+
@Override
97+
public boolean mkdirs(Path f) throws IOException {
98+
return mkdirs(f, FsPermission.getDirDefault().applyUMask(FsPermission.getUMask(getConf())));
99+
}
100+
95101
public String toString(){
96102
return "Gluster File System, no CRC.";
97103
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.hadoop.yarn.server.nodemanager;
20+
21+
import java.io.File;
22+
import java.io.IOException;
23+
import java.net.InetSocketAddress;
24+
import java.util.ArrayList;
25+
import java.util.Arrays;
26+
import java.util.List;
27+
import java.util.regex.Pattern;
28+
29+
import org.apache.commons.logging.Log;
30+
import org.apache.commons.logging.LogFactory;
31+
import org.apache.hadoop.conf.Configuration;
32+
import org.apache.hadoop.fs.Path;
33+
import org.apache.hadoop.security.UserGroupInformation;
34+
import org.apache.hadoop.util.ReflectionUtils;
35+
import org.apache.hadoop.util.Shell.ExitCodeException;
36+
import org.apache.hadoop.util.Shell.ShellCommandExecutor;
37+
import org.apache.hadoop.util.StringUtils;
38+
import org.apache.hadoop.yarn.api.ApplicationConstants;
39+
import org.apache.hadoop.yarn.api.records.ContainerId;
40+
import org.apache.hadoop.yarn.conf.YarnConfiguration;
41+
import org.apache.hadoop.yarn.server.nodemanager.ContainerExecutor.ExitCode;
42+
import org.apache.hadoop.yarn.server.nodemanager.ContainerExecutor.Signal;
43+
import org.apache.hadoop.yarn.server.nodemanager.LinuxContainerExecutor;
44+
import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container;
45+
import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerDiagnosticsUpdateEvent;
46+
import org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.ContainerLocalizer;
47+
import org.apache.hadoop.yarn.server.nodemanager.util.DefaultLCEResourcesHandler;
48+
import org.apache.hadoop.yarn.server.nodemanager.util.LCEResourcesHandler;
49+
import org.apache.hadoop.yarn.util.ConverterUtils;
50+
import org.apache.log4j.spi.LoggerFactory;
51+
import org.slf4j.Logger;
52+
public class GlusterContainerExecutor extends LinuxContainerExecutor {
53+
54+
static Logger log = org.slf4j.LoggerFactory.getLogger(GlusterContainerExecutor.class);
55+
/**
56+
* We override the YARN-1235 patch here.
57+
* @param user
58+
* @return
59+
*/
60+
@Override
61+
String getRunAsUser(String user) {
62+
log.info("Container EXEC overrid: returning user " + user);
63+
//return UserGroupInformation.isSecurityEnabled() ? user : nonsecureLocalUser;
64+
return user;
65+
}
66+
@Override
67+
public void deleteAsUser(String arg0,Path arg1,Path...arg2){
68+
log.info("DELETE AS USER " + arg0 + " " + arg1 +" " + arg2);
69+
super.deleteAsUser(arg0, arg1, arg2);
70+
}
71+
}
72+

src/test/java/org/apache/hadoop/fs/test/unit/HcfsFileSystemContractBaseTest.java

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

src/test/java/org/apache/hadoop/fs/test/unit/HcfsFileSystemTest.java

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.junit.AfterClass;
4646
import org.junit.Assert;
4747
import org.junit.BeforeClass;
48+
import org.junit.Ignore;
4849
import org.junit.Test;
4950

5051
/**
@@ -131,29 +132,6 @@ public void testTextWriteAndRead() throws Exception{
131132
assertFalse(fs.exists(new Path("test1")));
132133
}
133134

134-
@Test
135-
public void testGroupOwnership() throws Exception{
136-
Path myFile=new Path("filePerm.txt");
137-
//Create a file
138-
fs.create(myFile);
139-
140-
//Set the initial owner
141-
fs.setOwner(myFile, "daemon", "root");
142-
String oldOwner = fs.getFileStatus(myFile).getOwner();
143-
String oldGroup = fs.getFileStatus(myFile).getGroup();
144-
Assert.assertEquals("daemon",oldOwner);
145-
Assert.assertEquals("root",oldGroup);
146-
147-
//Now, change it to "root" "wheel"
148-
fs.setOwner(myFile, "root", "wheel");
149-
String newOwner = fs.getFileStatus(myFile).getOwner();
150-
String newGroup = fs.getFileStatus(myFile).getGroup();
151-
Assert.assertEquals("root",newOwner);
152-
Assert.assertEquals("wheel",newGroup);
153-
154-
fs.delete(myFile,true);
155-
}
156-
157135
@org.junit.Test
158136
public void testPermissions() throws Exception{
159137

@@ -360,5 +338,4 @@ public void testPermissionsChanging() throws Exception{
360338
fs.delete(new Path("mnt"),true);
361339

362340
}
363-
364341
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/**
2+
*
3+
* Copyright (c) 2014 Gluster, Inc. <http://www.gluster.com>
4+
* This file is part of GlusterFS.
5+
*
6+
* Licensed under the Apache License, Version 2.0
7+
* (the "License"); you may not use this file except in compliance with
8+
* the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15+
* implied. See the License for the specific language governing
16+
* permissions and limitations under the License.
17+
*
18+
*/
19+
20+
package org.apache.hadoop.fs.test.unit;
21+
22+
import static org.apache.hadoop.fs.FileSystemTestHelper.getTestRootPath;
23+
import static org.junit.Assert.assertEquals;
24+
import static org.junit.Assert.assertFalse;
25+
import static org.junit.Assert.assertTrue;
26+
27+
import java.io.IOException;
28+
29+
import org.apache.hadoop.fs.FSDataInputStream;
30+
import org.apache.hadoop.fs.FSDataOutputStream;
31+
import org.apache.hadoop.fs.FileStatus;
32+
import org.apache.hadoop.fs.FileSystem;
33+
import org.apache.hadoop.fs.Path;
34+
import org.apache.hadoop.conf.Configuration;
35+
import org.apache.hadoop.fs.permission.FsAction;
36+
import org.apache.hadoop.fs.permission.FsPermission;
37+
import org.apache.hadoop.fs.test.connector.HcfsTestConnectorFactory;
38+
import org.apache.hadoop.fs.test.connector.HcfsTestConnectorInterface;
39+
import org.junit.After;
40+
import org.junit.AfterClass;
41+
import org.junit.Assert;
42+
import org.junit.BeforeClass;
43+
import org.junit.Test;
44+
45+
/**
46+
* Unit test for HCFS classes.
47+
*
48+
*/
49+
public class HcfsUmaskTest{
50+
51+
static FileSystem fs ;
52+
53+
@BeforeClass
54+
public static void setup() throws Exception {
55+
HcfsTestConnectorInterface connector = HcfsTestConnectorFactory.getHcfsTestConnector();
56+
fs= connector.create();
57+
}
58+
59+
@AfterClass
60+
public static void after() throws IOException{
61+
fs.close();
62+
}
63+
64+
@After
65+
public void tearDown() throws Exception {
66+
fs.delete(getTestRootPath(fs, "test"),true);
67+
}
68+
69+
@org.junit.Test
70+
public void testMkdirsWithUmask() throws Exception {
71+
Configuration conf = fs.getConf();
72+
String oldUmask = conf.get("fs.permissions.umask-mode");
73+
Path dir = new Path("dirUmask022");
74+
conf.set("fs.permissions.umask-mode", "022");
75+
assertTrue(fs.mkdirs(dir));
76+
conf.set("fs.permissions.umask-mode", oldUmask);
77+
FileStatus status = fs.getFileStatus(dir);
78+
assertTrue(status.isDirectory());
79+
assertEquals((short)0755, status.getPermission().toShort());
80+
81+
}
82+
}

0 commit comments

Comments
 (0)