Search in sources :

Example 11 with ClientService

use of org.apache.hadoop.mapreduce.v2.app.client.ClientService in project hadoop by apache.

the class TestAMWebApp method testMRWebAppSSLDisabled.

@Test
public void testMRWebAppSSLDisabled() throws Exception {
    MRApp app = new MRApp(2, 2, true, this.getClass().getName(), true) {

        @Override
        protected ClientService createClientService(AppContext context) {
            return new MRClientService(context);
        }
    };
    Configuration conf = new Configuration();
    // MR is explicitly disabling SSL, even though setting as HTTPS_ONLY
    conf.set(YarnConfiguration.YARN_HTTP_POLICY_KEY, Policy.HTTPS_ONLY.name());
    Job job = app.submit(conf);
    String hostPort = NetUtils.getHostPortString(((MRClientService) app.getClientService()).getWebApp().getListenerAddress());
    // http:// should be accessible
    URL httpUrl = new URL("http://" + hostPort);
    HttpURLConnection conn = (HttpURLConnection) httpUrl.openConnection();
    InputStream in = conn.getInputStream();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    IOUtils.copyBytes(in, out, 1024);
    Assert.assertTrue(out.toString().contains("MapReduce Application"));
    // https:// is not accessible.
    URL httpsUrl = new URL("https://" + hostPort);
    try {
        HttpURLConnection httpsConn = (HttpURLConnection) httpsUrl.openConnection();
        httpsConn.getInputStream();
        Assert.fail("https:// is not accessible, expected to fail");
    } catch (Exception e) {
        Assert.assertTrue(e instanceof SSLException);
    }
    app.waitForState(job, JobState.SUCCEEDED);
    app.verifyCompleted();
}
Also used : HttpURLConnection(java.net.HttpURLConnection) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) InputStream(java.io.InputStream) AppContext(org.apache.hadoop.mapreduce.v2.app.AppContext) MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MRClientService(org.apache.hadoop.mapreduce.v2.app.client.MRClientService) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) SSLException(javax.net.ssl.SSLException) URL(java.net.URL) SSLException(javax.net.ssl.SSLException) MRApp(org.apache.hadoop.mapreduce.v2.app.MRApp) Test(org.junit.Test)

Example 12 with ClientService

use of org.apache.hadoop.mapreduce.v2.app.client.ClientService in project hadoop by apache.

the class JobHistoryServer method serviceInit.

@Override
protected void serviceInit(Configuration conf) throws Exception {
    Configuration config = new YarnConfiguration(conf);
    config.setBoolean(Dispatcher.DISPATCHER_EXIT_ON_ERROR_KEY, true);
    // This is required for WebApps to use https if enabled.
    MRWebAppUtil.initialize(getConfig());
    try {
        doSecureLogin(conf);
    } catch (IOException ie) {
        throw new YarnRuntimeException("History Server Failed to login", ie);
    }
    jobHistoryService = new JobHistory();
    historyContext = (HistoryContext) jobHistoryService;
    stateStore = createStateStore(conf);
    this.jhsDTSecretManager = createJHSSecretManager(conf, stateStore);
    clientService = createHistoryClientService();
    aggLogDelService = new AggregatedLogDeletionService();
    hsAdminServer = new HSAdminServer(aggLogDelService, jobHistoryService);
    addService(stateStore);
    addService(new HistoryServerSecretManagerService());
    addService(jobHistoryService);
    addService(clientService);
    addService(aggLogDelService);
    addService(hsAdminServer);
    DefaultMetricsSystem.initialize("JobHistoryServer");
    JvmMetrics jm = JvmMetrics.initSingleton("JobHistoryServer", null);
    pauseMonitor = new JvmPauseMonitor();
    addService(pauseMonitor);
    jm.setPauseMonitor(pauseMonitor);
    super.serviceInit(config);
}
Also used : YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) HSAdminServer(org.apache.hadoop.mapreduce.v2.hs.server.HSAdminServer) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) JvmMetrics(org.apache.hadoop.metrics2.source.JvmMetrics) AggregatedLogDeletionService(org.apache.hadoop.yarn.logaggregation.AggregatedLogDeletionService) IOException(java.io.IOException) JvmPauseMonitor(org.apache.hadoop.util.JvmPauseMonitor)

Aggregations

Test (org.junit.Test)8 Configuration (org.apache.hadoop.conf.Configuration)7 AppContext (org.apache.hadoop.mapreduce.v2.app.AppContext)7 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)7 ClientService (org.apache.hadoop.mapreduce.v2.app.client.ClientService)6 MRApp (org.apache.hadoop.mapreduce.v2.app.MRApp)5 RunningAppContext (org.apache.hadoop.mapreduce.v2.app.MRAppMaster.RunningAppContext)4 Job (org.apache.hadoop.mapreduce.v2.app.job.Job)4 IOException (java.io.IOException)3 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)3 DrainDispatcher (org.apache.hadoop.yarn.event.DrainDispatcher)3 HttpURLConnection (java.net.HttpURLConnection)2 URL (java.net.URL)2 JobHistoryEvent (org.apache.hadoop.mapreduce.jobhistory.JobHistoryEvent)2 MockAppContext (org.apache.hadoop.mapreduce.v2.app.MockAppContext)2 MRClientService (org.apache.hadoop.mapreduce.v2.app.client.MRClientService)2 Task (org.apache.hadoop.mapreduce.v2.app.job.Task)2 ContainerAllocator (org.apache.hadoop.mapreduce.v2.app.rm.ContainerAllocator)2 AllocatorRunnable (org.apache.hadoop.mapreduce.v2.app.rm.RMCommunicator.AllocatorRunnable)2 RMContainerAllocator (org.apache.hadoop.mapreduce.v2.app.rm.RMContainerAllocator)2