Example usage for org.apache.hadoop.mapred JobConf getCredentials

List of usage examples for org.apache.hadoop.mapred JobConf getCredentials

Introduction

In this page you can find the example usage for org.apache.hadoop.mapred JobConf getCredentials.

Prototype

public Credentials getCredentials() 

Source Link

Document

Get credentials for the job.

Usage

From source file:org.pentaho.big.data.impl.shim.mapreduce.PentahoMapReduceJobBuilderImplTest.java

License:Apache License

@Test
public void testSubmitAlreadyInstalled() throws Exception {
    Configuration conf = mock(Configuration.class);
    JobConf jobConf = mock(JobConf.class);
    when(jobConf.getCredentials()).thenReturn(new Credentials());

    when(conf.getAsDelegateConf(any())).thenReturn(jobConf);
    FileSystem fileSystem = mock(FileSystem.class);
    DistributedCacheUtil distributedCacheUtil = mock(DistributedCacheUtil.class);
    Path kettleEnvInstallDir = mock(Path.class);
    URI kettleEnvInstallDirUri = new URI("http://testUri/path");
    when(kettleEnvInstallDir.toUri()).thenReturn(kettleEnvInstallDirUri);

    when(hadoopShim.getFileSystem(conf)).thenReturn(fileSystem);
    when(hadoopShim.getDistributedCacheUtil()).thenReturn(distributedCacheUtil);
    when(conf.get(PentahoMapReduceJobBuilderImpl.PENTAHO_MAPREDUCE_PROPERTY_USE_DISTRIBUTED_CACHE))
            .thenReturn("true");
    String installPath = "/path" + Const.FILE_SEPARATOR;
    when(conf.get(PentahoMapReduceJobBuilderImpl.PENTAHO_MAPREDUCE_PROPERTY_KETTLE_HDFS_INSTALL_DIR))
            .thenReturn(installPath);/*  www  .  jav a  2  s  .  com*/
    String installId = "install_id";
    when(conf.get(PentahoMapReduceJobBuilderImpl.PENTAHO_MAPREDUCE_PROPERTY_KETTLE_INSTALLATION_ID))
            .thenReturn(installId);
    when(fileSystem.asPath(installPath, installId)).thenReturn(kettleEnvInstallDir);
    when(distributedCacheUtil.isKettleEnvironmentInstalledAt(fileSystem, kettleEnvInstallDir)).thenReturn(true);
    String mapreduceClasspath = "mapreduceClasspath";
    when(conf.get(PentahoMapReduceJobBuilderImpl.MAPREDUCE_APPLICATION_CLASSPATH,
            PentahoMapReduceJobBuilderImpl.DEFAULT_MAPREDUCE_APPLICATION_CLASSPATH))
                    .thenReturn(mapreduceClasspath);

    pentahoMapReduceJobBuilder.submit(conf);
    verify(logChannelInterface).logBasic(BaseMessages.getString(PentahoMapReduceJobBuilderImpl.PKG,
            PentahoMapReduceJobBuilderImpl.JOB_ENTRY_HADOOP_TRANS_JOB_EXECUTOR_CONFIGURING_JOB_WITH_KETTLE_AT,
            kettleEnvInstallDirUri.getPath()));
    verify(conf).set(PentahoMapReduceJobBuilderImpl.MAPREDUCE_APPLICATION_CLASSPATH,
            PentahoMapReduceJobBuilderImpl.CLASSES + mapreduceClasspath);
    verify(distributedCacheUtil).configureWithKettleEnvironment(conf, fileSystem, kettleEnvInstallDir);
}

From source file:org.pentaho.big.data.impl.shim.mapreduce.PentahoMapReduceJobBuilderImplTest.java

License:Apache License

@Test
public void testSubmitInstallSucceed() throws Exception {
    Configuration conf = mock(Configuration.class);
    JobConf jobConf = mock(JobConf.class);
    when(jobConf.getCredentials()).thenReturn(new Credentials());
    when(conf.getAsDelegateConf(any())).thenReturn(jobConf);

    FileSystem fileSystem = mock(FileSystem.class);
    DistributedCacheUtil distributedCacheUtil = mock(DistributedCacheUtil.class);
    Path kettleEnvInstallDir = mock(Path.class);
    URI kettleEnvInstallDirUri = new URI("http://testUri/path");
    when(kettleEnvInstallDir.toUri()).thenReturn(kettleEnvInstallDirUri);

    when(hadoopShim.getFileSystem(conf)).thenReturn(fileSystem);
    when(hadoopShim.getDistributedCacheUtil()).thenReturn(distributedCacheUtil);
    when(conf.get(PentahoMapReduceJobBuilderImpl.PENTAHO_MAPREDUCE_PROPERTY_USE_DISTRIBUTED_CACHE))
            .thenReturn("true");
    String installPath = "/path" + Const.FILE_SEPARATOR;
    when(conf.get(PentahoMapReduceJobBuilderImpl.PENTAHO_MAPREDUCE_PROPERTY_KETTLE_HDFS_INSTALL_DIR))
            .thenReturn(installPath);//from  ww  w. ja  va 2 s.  c om
    String installId = "install_id";
    when(conf.get(PentahoMapReduceJobBuilderImpl.PENTAHO_MAPREDUCE_PROPERTY_KETTLE_INSTALLATION_ID))
            .thenReturn(installId);
    when(fileSystem.asPath(installPath, installId)).thenReturn(kettleEnvInstallDir);
    when(distributedCacheUtil.isKettleEnvironmentInstalledAt(fileSystem, kettleEnvInstallDir)).thenReturn(false)
            .thenReturn(true);
    String mapreduceClasspath = "mapreduceClasspath";
    when(conf.get(PentahoMapReduceJobBuilderImpl.MAPREDUCE_APPLICATION_CLASSPATH,
            PentahoMapReduceJobBuilderImpl.DEFAULT_MAPREDUCE_APPLICATION_CLASSPATH))
                    .thenReturn(mapreduceClasspath);
    when(pmrArchiveGetter.getPmrArchive(conf)).thenReturn(mock(FileObject.class));

    pentahoMapReduceJobBuilder.submit(conf);

    verify(logChannelInterface).logBasic(BaseMessages.getString(PentahoMapReduceJobBuilderImpl.PKG,
            PentahoMapReduceJobBuilderImpl.JOB_ENTRY_HADOOP_TRANS_JOB_EXECUTOR_CONFIGURING_JOB_WITH_KETTLE_AT,
            kettleEnvInstallDirUri.getPath()));
    verify(conf).set(PentahoMapReduceJobBuilderImpl.MAPREDUCE_APPLICATION_CLASSPATH,
            PentahoMapReduceJobBuilderImpl.CLASSES + mapreduceClasspath);
    verify(distributedCacheUtil).configureWithKettleEnvironment(conf, fileSystem, kettleEnvInstallDir);
}