|
@@ -18,10 +18,6 @@
|
|
|
|
|
|
package org.apache.hadoop.lib.service.hadoop;
|
|
package org.apache.hadoop.lib.service.hadoop;
|
|
|
|
|
|
-import static org.junit.Assert.assertEquals;
|
|
|
|
-import static org.junit.Assert.assertNotNull;
|
|
|
|
-import static org.junit.Assert.fail;
|
|
|
|
-
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.FileOutputStream;
|
|
import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
@@ -37,6 +33,7 @@ import org.apache.hadoop.lib.server.ServiceException;
|
|
import org.apache.hadoop.lib.service.FileSystemAccess;
|
|
import org.apache.hadoop.lib.service.FileSystemAccess;
|
|
import org.apache.hadoop.lib.service.FileSystemAccessException;
|
|
import org.apache.hadoop.lib.service.FileSystemAccessException;
|
|
import org.apache.hadoop.lib.service.instrumentation.InstrumentationService;
|
|
import org.apache.hadoop.lib.service.instrumentation.InstrumentationService;
|
|
|
|
+import org.apache.hadoop.lib.service.scheduler.SchedulerService;
|
|
import org.apache.hadoop.test.HFSTestCase;
|
|
import org.apache.hadoop.test.HFSTestCase;
|
|
import org.apache.hadoop.test.TestDir;
|
|
import org.apache.hadoop.test.TestDir;
|
|
import org.apache.hadoop.test.TestDirHelper;
|
|
import org.apache.hadoop.test.TestDirHelper;
|
|
@@ -44,6 +41,7 @@ import org.apache.hadoop.test.TestException;
|
|
import org.apache.hadoop.test.TestHdfs;
|
|
import org.apache.hadoop.test.TestHdfs;
|
|
import org.apache.hadoop.test.TestHdfsHelper;
|
|
import org.apache.hadoop.test.TestHdfsHelper;
|
|
import org.apache.hadoop.util.StringUtils;
|
|
import org.apache.hadoop.util.StringUtils;
|
|
|
|
+import org.junit.Assert;
|
|
import org.junit.Before;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
|
|
|
|
@@ -68,13 +66,15 @@ public class TestFileSystemAccessService extends HFSTestCase {
|
|
@TestDir
|
|
@TestDir
|
|
public void simpleSecurity() throws Exception {
|
|
public void simpleSecurity() throws Exception {
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
- String services = StringUtils.join(",", Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
- FileSystemAccessService.class.getName()));
|
|
|
|
|
|
+ String services = StringUtils.join(",",
|
|
|
|
+ Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
+ SchedulerService.class.getName(),
|
|
|
|
+ FileSystemAccessService.class.getName()));
|
|
Configuration conf = new Configuration(false);
|
|
Configuration conf = new Configuration(false);
|
|
conf.set("server.services", services);
|
|
conf.set("server.services", services);
|
|
Server server = new Server("server", dir, dir, dir, dir, conf);
|
|
Server server = new Server("server", dir, dir, dir, dir, conf);
|
|
server.init();
|
|
server.init();
|
|
- assertNotNull(server.get(FileSystemAccess.class));
|
|
|
|
|
|
+ Assert.assertNotNull(server.get(FileSystemAccess.class));
|
|
server.destroy();
|
|
server.destroy();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -83,8 +83,10 @@ public class TestFileSystemAccessService extends HFSTestCase {
|
|
@TestDir
|
|
@TestDir
|
|
public void noKerberosKeytabProperty() throws Exception {
|
|
public void noKerberosKeytabProperty() throws Exception {
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
- String services = StringUtils.join(",", Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
- FileSystemAccessService.class.getName()));
|
|
|
|
|
|
+ String services = StringUtils.join(",",
|
|
|
|
+ Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
+ SchedulerService.class.getName(),
|
|
|
|
+ FileSystemAccessService.class.getName()));
|
|
Configuration conf = new Configuration(false);
|
|
Configuration conf = new Configuration(false);
|
|
conf.set("server.services", services);
|
|
conf.set("server.services", services);
|
|
conf.set("server.hadoop.authentication.type", "kerberos");
|
|
conf.set("server.hadoop.authentication.type", "kerberos");
|
|
@@ -98,8 +100,10 @@ public class TestFileSystemAccessService extends HFSTestCase {
|
|
@TestDir
|
|
@TestDir
|
|
public void noKerberosPrincipalProperty() throws Exception {
|
|
public void noKerberosPrincipalProperty() throws Exception {
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
- String services = StringUtils.join(",", Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
- FileSystemAccessService.class.getName()));
|
|
|
|
|
|
+ String services = StringUtils.join(",",
|
|
|
|
+ Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
+ SchedulerService.class.getName(),
|
|
|
|
+ FileSystemAccessService.class.getName()));
|
|
Configuration conf = new Configuration(false);
|
|
Configuration conf = new Configuration(false);
|
|
conf.set("server.services", services);
|
|
conf.set("server.services", services);
|
|
conf.set("server.hadoop.authentication.type", "kerberos");
|
|
conf.set("server.hadoop.authentication.type", "kerberos");
|
|
@@ -114,8 +118,10 @@ public class TestFileSystemAccessService extends HFSTestCase {
|
|
@TestDir
|
|
@TestDir
|
|
public void kerberosInitializationFailure() throws Exception {
|
|
public void kerberosInitializationFailure() throws Exception {
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
- String services = StringUtils.join(",", Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
- FileSystemAccessService.class.getName()));
|
|
|
|
|
|
+ String services = StringUtils.join(",",
|
|
|
|
+ Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
+ SchedulerService.class.getName(),
|
|
|
|
+ FileSystemAccessService.class.getName()));
|
|
Configuration conf = new Configuration(false);
|
|
Configuration conf = new Configuration(false);
|
|
conf.set("server.services", services);
|
|
conf.set("server.services", services);
|
|
conf.set("server.hadoop.authentication.type", "kerberos");
|
|
conf.set("server.hadoop.authentication.type", "kerberos");
|
|
@@ -130,8 +136,10 @@ public class TestFileSystemAccessService extends HFSTestCase {
|
|
@TestDir
|
|
@TestDir
|
|
public void invalidSecurity() throws Exception {
|
|
public void invalidSecurity() throws Exception {
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
- String services = StringUtils.join(",", Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
- FileSystemAccessService.class.getName()));
|
|
|
|
|
|
+ String services = StringUtils.join(",",
|
|
|
|
+ Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
+ SchedulerService.class.getName(),
|
|
|
|
+ FileSystemAccessService.class.getName()));
|
|
Configuration conf = new Configuration(false);
|
|
Configuration conf = new Configuration(false);
|
|
conf.set("server.services", services);
|
|
conf.set("server.services", services);
|
|
conf.set("server.hadoop.authentication.type", "foo");
|
|
conf.set("server.hadoop.authentication.type", "foo");
|
|
@@ -143,15 +151,17 @@ public class TestFileSystemAccessService extends HFSTestCase {
|
|
@TestDir
|
|
@TestDir
|
|
public void serviceHadoopConf() throws Exception {
|
|
public void serviceHadoopConf() throws Exception {
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
- String services = StringUtils.join(",", Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
- FileSystemAccessService.class.getName()));
|
|
|
|
|
|
+ String services = StringUtils.join(",",
|
|
|
|
+ Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
+ SchedulerService.class.getName(),
|
|
|
|
+ FileSystemAccessService.class.getName()));
|
|
Configuration conf = new Configuration(false);
|
|
Configuration conf = new Configuration(false);
|
|
conf.set("server.services", services);
|
|
conf.set("server.services", services);
|
|
|
|
|
|
Server server = new Server("server", dir, dir, dir, dir, conf);
|
|
Server server = new Server("server", dir, dir, dir, dir, conf);
|
|
server.init();
|
|
server.init();
|
|
FileSystemAccessService fsAccess = (FileSystemAccessService) server.get(FileSystemAccess.class);
|
|
FileSystemAccessService fsAccess = (FileSystemAccessService) server.get(FileSystemAccess.class);
|
|
- assertEquals(fsAccess.serviceHadoopConf.get("foo"), "FOO");
|
|
|
|
|
|
+ Assert.assertEquals(fsAccess.serviceHadoopConf.get("foo"), "FOO");
|
|
server.destroy();
|
|
server.destroy();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -161,8 +171,10 @@ public class TestFileSystemAccessService extends HFSTestCase {
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
String hadoopConfDir = new File(dir, "confx").getAbsolutePath();
|
|
String hadoopConfDir = new File(dir, "confx").getAbsolutePath();
|
|
new File(hadoopConfDir).mkdirs();
|
|
new File(hadoopConfDir).mkdirs();
|
|
- String services = StringUtils.join(",", Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
- FileSystemAccessService.class.getName()));
|
|
|
|
|
|
+ String services = StringUtils.join(",",
|
|
|
|
+ Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
+ SchedulerService.class.getName(),
|
|
|
|
+ FileSystemAccessService.class.getName()));
|
|
Configuration conf = new Configuration(false);
|
|
Configuration conf = new Configuration(false);
|
|
conf.set("server.services", services);
|
|
conf.set("server.services", services);
|
|
conf.set("server.hadoop.config.dir", hadoopConfDir);
|
|
conf.set("server.hadoop.config.dir", hadoopConfDir);
|
|
@@ -177,7 +189,7 @@ public class TestFileSystemAccessService extends HFSTestCase {
|
|
Server server = new Server("server", dir, dir, dir, dir, conf);
|
|
Server server = new Server("server", dir, dir, dir, dir, conf);
|
|
server.init();
|
|
server.init();
|
|
FileSystemAccessService fsAccess = (FileSystemAccessService) server.get(FileSystemAccess.class);
|
|
FileSystemAccessService fsAccess = (FileSystemAccessService) server.get(FileSystemAccess.class);
|
|
- assertEquals(fsAccess.serviceHadoopConf.get("foo"), "BAR");
|
|
|
|
|
|
+ Assert.assertEquals(fsAccess.serviceHadoopConf.get("foo"), "BAR");
|
|
server.destroy();
|
|
server.destroy();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -185,8 +197,10 @@ public class TestFileSystemAccessService extends HFSTestCase {
|
|
@TestDir
|
|
@TestDir
|
|
public void inWhitelists() throws Exception {
|
|
public void inWhitelists() throws Exception {
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
- String services = StringUtils.join(",", Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
- FileSystemAccessService.class.getName()));
|
|
|
|
|
|
+ String services = StringUtils.join(",",
|
|
|
|
+ Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
+ SchedulerService.class.getName(),
|
|
|
|
+ FileSystemAccessService.class.getName()));
|
|
Configuration conf = new Configuration(false);
|
|
Configuration conf = new Configuration(false);
|
|
conf.set("server.services", services);
|
|
conf.set("server.services", services);
|
|
Server server = new Server("server", dir, dir, dir, dir, conf);
|
|
Server server = new Server("server", dir, dir, dir, dir, conf);
|
|
@@ -219,8 +233,10 @@ public class TestFileSystemAccessService extends HFSTestCase {
|
|
@TestDir
|
|
@TestDir
|
|
public void NameNodeNotinWhitelists() throws Exception {
|
|
public void NameNodeNotinWhitelists() throws Exception {
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
- String services = StringUtils.join(",", Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
- FileSystemAccessService.class.getName()));
|
|
|
|
|
|
+ String services = StringUtils.join(",",
|
|
|
|
+ Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
+ SchedulerService.class.getName(),
|
|
|
|
+ FileSystemAccessService.class.getName()));
|
|
Configuration conf = new Configuration(false);
|
|
Configuration conf = new Configuration(false);
|
|
conf.set("server.services", services);
|
|
conf.set("server.services", services);
|
|
conf.set("server.hadoop.name.node.whitelist", "NN");
|
|
conf.set("server.hadoop.name.node.whitelist", "NN");
|
|
@@ -235,8 +251,10 @@ public class TestFileSystemAccessService extends HFSTestCase {
|
|
@TestHdfs
|
|
@TestHdfs
|
|
public void createFileSystem() throws Exception {
|
|
public void createFileSystem() throws Exception {
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
- String services = StringUtils.join(",", Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
- FileSystemAccessService.class.getName()));
|
|
|
|
|
|
+ String services = StringUtils.join(",",
|
|
|
|
+ Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
+ SchedulerService.class.getName(),
|
|
|
|
+ FileSystemAccessService.class.getName()));
|
|
|
|
|
|
Configuration hadoopConf = new Configuration(false);
|
|
Configuration hadoopConf = new Configuration(false);
|
|
hadoopConf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, TestHdfsHelper.getHdfsConf().get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY));
|
|
hadoopConf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, TestHdfsHelper.getHdfsConf().get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY));
|
|
@@ -244,19 +262,20 @@ public class TestFileSystemAccessService extends HFSTestCase {
|
|
|
|
|
|
Configuration conf = new Configuration(false);
|
|
Configuration conf = new Configuration(false);
|
|
conf.set("server.services", services);
|
|
conf.set("server.services", services);
|
|
|
|
+ conf.set("server.hadoop.filesystem.cache.purge.timeout", "0");
|
|
Server server = new Server("server", dir, dir, dir, dir, conf);
|
|
Server server = new Server("server", dir, dir, dir, dir, conf);
|
|
server.init();
|
|
server.init();
|
|
FileSystemAccess hadoop = server.get(FileSystemAccess.class);
|
|
FileSystemAccess hadoop = server.get(FileSystemAccess.class);
|
|
FileSystem fs = hadoop.createFileSystem("u", hadoop.getFileSystemConfiguration());
|
|
FileSystem fs = hadoop.createFileSystem("u", hadoop.getFileSystemConfiguration());
|
|
- assertNotNull(fs);
|
|
|
|
|
|
+ Assert.assertNotNull(fs);
|
|
fs.mkdirs(new Path("/tmp/foo"));
|
|
fs.mkdirs(new Path("/tmp/foo"));
|
|
hadoop.releaseFileSystem(fs);
|
|
hadoop.releaseFileSystem(fs);
|
|
try {
|
|
try {
|
|
fs.mkdirs(new Path("/tmp/foo"));
|
|
fs.mkdirs(new Path("/tmp/foo"));
|
|
- fail();
|
|
|
|
|
|
+ Assert.fail();
|
|
} catch (IOException ex) {
|
|
} catch (IOException ex) {
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
- fail();
|
|
|
|
|
|
+ Assert.fail();
|
|
}
|
|
}
|
|
server.destroy();
|
|
server.destroy();
|
|
}
|
|
}
|
|
@@ -266,8 +285,10 @@ public class TestFileSystemAccessService extends HFSTestCase {
|
|
@TestHdfs
|
|
@TestHdfs
|
|
public void fileSystemExecutor() throws Exception {
|
|
public void fileSystemExecutor() throws Exception {
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
- String services = StringUtils.join(",", Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
- FileSystemAccessService.class.getName()));
|
|
|
|
|
|
+ String services = StringUtils.join(",",
|
|
|
|
+ Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
+ SchedulerService.class.getName(),
|
|
|
|
+ FileSystemAccessService.class.getName()));
|
|
|
|
|
|
Configuration hadoopConf = new Configuration(false);
|
|
Configuration hadoopConf = new Configuration(false);
|
|
hadoopConf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, TestHdfsHelper.getHdfsConf().get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY));
|
|
hadoopConf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, TestHdfsHelper.getHdfsConf().get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY));
|
|
@@ -275,6 +296,7 @@ public class TestFileSystemAccessService extends HFSTestCase {
|
|
|
|
|
|
Configuration conf = new Configuration(false);
|
|
Configuration conf = new Configuration(false);
|
|
conf.set("server.services", services);
|
|
conf.set("server.services", services);
|
|
|
|
+ conf.set("server.hadoop.filesystem.cache.purge.timeout", "0");
|
|
Server server = new Server("server", dir, dir, dir, dir, conf);
|
|
Server server = new Server("server", dir, dir, dir, dir, conf);
|
|
server.init();
|
|
server.init();
|
|
FileSystemAccess hadoop = server.get(FileSystemAccess.class);
|
|
FileSystemAccess hadoop = server.get(FileSystemAccess.class);
|
|
@@ -291,10 +313,10 @@ public class TestFileSystemAccessService extends HFSTestCase {
|
|
});
|
|
});
|
|
try {
|
|
try {
|
|
fsa[0].mkdirs(new Path("/tmp/foo"));
|
|
fsa[0].mkdirs(new Path("/tmp/foo"));
|
|
- fail();
|
|
|
|
|
|
+ Assert.fail();
|
|
} catch (IOException ex) {
|
|
} catch (IOException ex) {
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
- fail();
|
|
|
|
|
|
+ Assert.fail();
|
|
}
|
|
}
|
|
server.destroy();
|
|
server.destroy();
|
|
}
|
|
}
|
|
@@ -305,8 +327,10 @@ public class TestFileSystemAccessService extends HFSTestCase {
|
|
@TestHdfs
|
|
@TestHdfs
|
|
public void fileSystemExecutorNoNameNode() throws Exception {
|
|
public void fileSystemExecutorNoNameNode() throws Exception {
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
- String services = StringUtils.join(",", Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
- FileSystemAccessService.class.getName()));
|
|
|
|
|
|
+ String services = StringUtils.join(",",
|
|
|
|
+ Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
+ SchedulerService.class.getName(),
|
|
|
|
+ FileSystemAccessService.class.getName()));
|
|
Configuration hadoopConf = new Configuration(false);
|
|
Configuration hadoopConf = new Configuration(false);
|
|
hadoopConf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, TestHdfsHelper.getHdfsConf().get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY));
|
|
hadoopConf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, TestHdfsHelper.getHdfsConf().get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY));
|
|
createHadoopConf(hadoopConf);
|
|
createHadoopConf(hadoopConf);
|
|
@@ -332,8 +356,10 @@ public class TestFileSystemAccessService extends HFSTestCase {
|
|
@TestHdfs
|
|
@TestHdfs
|
|
public void fileSystemExecutorException() throws Exception {
|
|
public void fileSystemExecutorException() throws Exception {
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
- String services = StringUtils.join(",", Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
- FileSystemAccessService.class.getName()));
|
|
|
|
|
|
+ String services = StringUtils.join(",",
|
|
|
|
+ Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
+ SchedulerService.class.getName(),
|
|
|
|
+ FileSystemAccessService.class.getName()));
|
|
|
|
|
|
Configuration hadoopConf = new Configuration(false);
|
|
Configuration hadoopConf = new Configuration(false);
|
|
hadoopConf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, TestHdfsHelper.getHdfsConf().get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY));
|
|
hadoopConf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, TestHdfsHelper.getHdfsConf().get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY));
|
|
@@ -341,6 +367,7 @@ public class TestFileSystemAccessService extends HFSTestCase {
|
|
|
|
|
|
Configuration conf = new Configuration(false);
|
|
Configuration conf = new Configuration(false);
|
|
conf.set("server.services", services);
|
|
conf.set("server.services", services);
|
|
|
|
+ conf.set("server.hadoop.filesystem.cache.purge.timeout", "0");
|
|
Server server = new Server("server", dir, dir, dir, dir, conf);
|
|
Server server = new Server("server", dir, dir, dir, dir, conf);
|
|
server.init();
|
|
server.init();
|
|
FileSystemAccess hadoop = server.get(FileSystemAccess.class);
|
|
FileSystemAccess hadoop = server.get(FileSystemAccess.class);
|
|
@@ -354,21 +381,86 @@ public class TestFileSystemAccessService extends HFSTestCase {
|
|
throw new IOException();
|
|
throw new IOException();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- fail();
|
|
|
|
|
|
+ Assert.fail();
|
|
} catch (FileSystemAccessException ex) {
|
|
} catch (FileSystemAccessException ex) {
|
|
- assertEquals(ex.getError(), FileSystemAccessException.ERROR.H03);
|
|
|
|
|
|
+ Assert.assertEquals(ex.getError(), FileSystemAccessException.ERROR.H03);
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
- fail();
|
|
|
|
|
|
+ Assert.fail();
|
|
}
|
|
}
|
|
|
|
|
|
try {
|
|
try {
|
|
fsa[0].mkdirs(new Path("/tmp/foo"));
|
|
fsa[0].mkdirs(new Path("/tmp/foo"));
|
|
- fail();
|
|
|
|
|
|
+ Assert.fail();
|
|
} catch (IOException ex) {
|
|
} catch (IOException ex) {
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
- fail();
|
|
|
|
|
|
+ Assert.fail();
|
|
}
|
|
}
|
|
server.destroy();
|
|
server.destroy();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @TestDir
|
|
|
|
+ @TestHdfs
|
|
|
|
+ public void fileSystemCache() throws Exception {
|
|
|
|
+ String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
|
|
+ String services = StringUtils.join(",",
|
|
|
|
+ Arrays.asList(InstrumentationService.class.getName(),
|
|
|
|
+ SchedulerService.class.getName(),
|
|
|
|
+ FileSystemAccessService.class.getName()));
|
|
|
|
+
|
|
|
|
+ Configuration hadoopConf = new Configuration(false);
|
|
|
|
+ hadoopConf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY,
|
|
|
|
+ TestHdfsHelper.getHdfsConf().get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY));
|
|
|
|
+ createHadoopConf(hadoopConf);
|
|
|
|
+
|
|
|
|
+ Configuration conf = new Configuration(false);
|
|
|
|
+ conf.set("server.services", services);
|
|
|
|
+ conf.set("server.hadoop.filesystem.cache.purge.frequency", "1");
|
|
|
|
+ conf.set("server.hadoop.filesystem.cache.purge.timeout", "1");
|
|
|
|
+ Server server = new Server("server", dir, dir, dir, dir, conf);
|
|
|
|
+ try {
|
|
|
|
+ server.init();
|
|
|
|
+ FileSystemAccess hadoop = server.get(FileSystemAccess.class);
|
|
|
|
+
|
|
|
|
+ FileSystem fs1 =
|
|
|
|
+ hadoop.createFileSystem("u", hadoop.getFileSystemConfiguration());
|
|
|
|
+ Assert.assertNotNull(fs1);
|
|
|
|
+ fs1.mkdirs(new Path("/tmp/foo1"));
|
|
|
|
+ hadoop.releaseFileSystem(fs1);
|
|
|
|
+
|
|
|
|
+ //still around because of caching
|
|
|
|
+ fs1.mkdirs(new Path("/tmp/foo2"));
|
|
|
|
+
|
|
|
|
+ FileSystem fs2 =
|
|
|
|
+ hadoop.createFileSystem("u", hadoop.getFileSystemConfiguration());
|
|
|
|
+
|
|
|
|
+ //should be same instance because of caching
|
|
|
|
+ Assert.assertEquals(fs1, fs2);
|
|
|
|
+
|
|
|
|
+ Thread.sleep(4 * 1000);
|
|
|
|
+
|
|
|
|
+ //still around because of lease count is 1 (fs2 is out)
|
|
|
|
+ fs1.mkdirs(new Path("/tmp/foo2"));
|
|
|
|
+
|
|
|
|
+ Thread.sleep(4 * 1000);
|
|
|
|
+
|
|
|
|
+ //still around because of lease count is 1 (fs2 is out)
|
|
|
|
+ fs2.mkdirs(new Path("/tmp/foo"));
|
|
|
|
+
|
|
|
|
+ hadoop.releaseFileSystem(fs2);
|
|
|
|
+ Thread.sleep(4 * 1000);
|
|
|
|
+
|
|
|
|
+ //should not be around as lease count is 0
|
|
|
|
+ try {
|
|
|
|
+ fs2.mkdirs(new Path("/tmp/foo"));
|
|
|
|
+ Assert.fail();
|
|
|
|
+ } catch (IOException ex) {
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ Assert.fail();
|
|
|
|
+ }
|
|
|
|
+ } finally {
|
|
|
|
+ server.destroy();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|