Search in sources :

Example 11 with Server

use of org.apache.hadoop.lib.server.Server in project hadoop by apache.

the class TestFileSystemAccessService method fileSystemExecutorNoNameNode.

@Test
@TestException(exception = FileSystemAccessException.class, msgRegExp = "H06.*")
@TestDir
@TestHdfs
public void fileSystemExecutorNoNameNode() 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);
    Server server = new Server("server", dir, dir, dir, dir, conf);
    server.init();
    FileSystemAccess fsAccess = server.get(FileSystemAccess.class);
    Configuration hdfsConf = fsAccess.getFileSystemConfiguration();
    hdfsConf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, "");
    fsAccess.execute("u", hdfsConf, new FileSystemAccess.FileSystemExecutor<Void>() {

        @Override
        public Void execute(FileSystem fs) throws IOException {
            return null;
        }
    });
}
Also used : FileSystemAccess(org.apache.hadoop.lib.service.FileSystemAccess) Configuration(org.apache.hadoop.conf.Configuration) Server(org.apache.hadoop.lib.server.Server) FileSystem(org.apache.hadoop.fs.FileSystem) IOException(java.io.IOException) TestHdfs(org.apache.hadoop.test.TestHdfs) TestException(org.apache.hadoop.test.TestException) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 12 with Server

use of org.apache.hadoop.lib.server.Server in project hadoop by apache.

the class TestFileSystemAccessService method noKerberosKeytabProperty.

@Test
@TestException(exception = ServiceException.class, msgRegExp = "H01.*")
@TestDir
public void noKerberosKeytabProperty() throws Exception {
    String dir = TestDirHelper.getTestDir().getAbsolutePath();
    String services = StringUtils.join(",", Arrays.asList(InstrumentationService.class.getName(), SchedulerService.class.getName(), FileSystemAccessService.class.getName()));
    Configuration conf = new Configuration(false);
    conf.set("server.services", services);
    conf.set("server.hadoop.authentication.type", "kerberos");
    conf.set("server.hadoop.authentication.kerberos.keytab", " ");
    Server server = new Server("server", dir, dir, dir, dir, conf);
    server.init();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) Server(org.apache.hadoop.lib.server.Server) TestException(org.apache.hadoop.test.TestException) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 13 with Server

use of org.apache.hadoop.lib.server.Server in project hadoop by apache.

the class TestFileSystemAccessService method fileSystemExecutorException.

@Test
@TestDir
@TestHdfs
public void fileSystemExecutorException() 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.timeout", "0");
    Server server = new Server("server", dir, dir, dir, dir, conf);
    server.init();
    FileSystemAccess hadoop = server.get(FileSystemAccess.class);
    final FileSystem[] fsa = new FileSystem[1];
    try {
        hadoop.execute("u", hadoop.getFileSystemConfiguration(), new FileSystemAccess.FileSystemExecutor<Void>() {

            @Override
            public Void execute(FileSystem fs) throws IOException {
                fsa[0] = fs;
                throw new IOException();
            }
        });
        Assert.fail();
    } catch (FileSystemAccessException ex) {
        Assert.assertEquals(ex.getError(), FileSystemAccessException.ERROR.H03);
    } catch (Exception ex) {
        Assert.fail();
    }
    try {
        fsa[0].mkdirs(new Path("/tmp/foo"));
        Assert.fail();
    } catch (IOException ex) {
    } catch (Exception ex) {
        Assert.fail();
    }
    server.destroy();
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) Server(org.apache.hadoop.lib.server.Server) IOException(java.io.IOException) TestException(org.apache.hadoop.test.TestException) IOException(java.io.IOException) FileSystemAccessException(org.apache.hadoop.lib.service.FileSystemAccessException) ServiceException(org.apache.hadoop.lib.server.ServiceException) FileSystemAccess(org.apache.hadoop.lib.service.FileSystemAccess) FileSystem(org.apache.hadoop.fs.FileSystem) FileSystemAccessException(org.apache.hadoop.lib.service.FileSystemAccessException) TestHdfs(org.apache.hadoop.test.TestHdfs) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 14 with Server

use of org.apache.hadoop.lib.server.Server in project hadoop by apache.

the class TestFileSystemAccessService method inWhitelists.

@Test
@TestDir
public void inWhitelists() throws Exception {
    String dir = TestDirHelper.getTestDir().getAbsolutePath();
    String services = StringUtils.join(",", Arrays.asList(InstrumentationService.class.getName(), SchedulerService.class.getName(), FileSystemAccessService.class.getName()));
    Configuration conf = new Configuration(false);
    conf.set("server.services", services);
    Server server = new Server("server", dir, dir, dir, dir, conf);
    server.init();
    FileSystemAccessService fsAccess = (FileSystemAccessService) server.get(FileSystemAccess.class);
    fsAccess.validateNamenode("NN");
    server.destroy();
    conf = new Configuration(false);
    conf.set("server.services", services);
    conf.set("server.hadoop.name.node.whitelist", "*");
    server = new Server("server", dir, dir, dir, dir, conf);
    server.init();
    fsAccess = (FileSystemAccessService) server.get(FileSystemAccess.class);
    fsAccess.validateNamenode("NN");
    server.destroy();
    conf = new Configuration(false);
    conf.set("server.services", services);
    conf.set("server.hadoop.name.node.whitelist", "NN");
    server = new Server("server", dir, dir, dir, dir, conf);
    server.init();
    fsAccess = (FileSystemAccessService) server.get(FileSystemAccess.class);
    fsAccess.validateNamenode("NN");
    server.destroy();
}
Also used : FileSystemAccess(org.apache.hadoop.lib.service.FileSystemAccess) Configuration(org.apache.hadoop.conf.Configuration) Server(org.apache.hadoop.lib.server.Server) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Example 15 with Server

use of org.apache.hadoop.lib.server.Server in project hadoop by apache.

the class TestFileSystemAccessService method createFileSystem.

@Test
@TestDir
@TestHdfs
public void createFileSystem() 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.timeout", "0");
    Server server = new Server("server", dir, dir, dir, dir, conf);
    server.init();
    FileSystemAccess hadoop = server.get(FileSystemAccess.class);
    FileSystem fs = hadoop.createFileSystem("u", hadoop.getFileSystemConfiguration());
    Assert.assertNotNull(fs);
    fs.mkdirs(new Path("/tmp/foo"));
    hadoop.releaseFileSystem(fs);
    try {
        fs.mkdirs(new Path("/tmp/foo"));
        Assert.fail();
    } catch (IOException ex) {
    } catch (Exception ex) {
        Assert.fail();
    }
    server.destroy();
}
Also used : FileSystemAccess(org.apache.hadoop.lib.service.FileSystemAccess) Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) Server(org.apache.hadoop.lib.server.Server) FileSystem(org.apache.hadoop.fs.FileSystem) IOException(java.io.IOException) TestException(org.apache.hadoop.test.TestException) IOException(java.io.IOException) FileSystemAccessException(org.apache.hadoop.lib.service.FileSystemAccessException) ServiceException(org.apache.hadoop.lib.server.ServiceException) TestHdfs(org.apache.hadoop.test.TestHdfs) TestDir(org.apache.hadoop.test.TestDir) Test(org.junit.Test)

Aggregations

Configuration (org.apache.hadoop.conf.Configuration)19 Server (org.apache.hadoop.lib.server.Server)19 TestDir (org.apache.hadoop.test.TestDir)19 Test (org.junit.Test)19 FileSystemAccess (org.apache.hadoop.lib.service.FileSystemAccess)10 TestException (org.apache.hadoop.test.TestException)10 IOException (java.io.IOException)5 FileSystem (org.apache.hadoop.fs.FileSystem)5 TestHdfs (org.apache.hadoop.test.TestHdfs)5 Path (org.apache.hadoop.fs.Path)4 ServiceException (org.apache.hadoop.lib.server.ServiceException)4 FileSystemAccessException (org.apache.hadoop.lib.service.FileSystemAccessException)4 Map (java.util.Map)2 Instrumentation (org.apache.hadoop.lib.service.Instrumentation)2 JSONObject (org.json.simple.JSONObject)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 StringWriter (java.io.StringWriter)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1