Package org.apache.ambari.view.pig.templeton.client

Examples of org.apache.ambari.view.pig.templeton.client.TempletonApi


   * Checks connection to WebHCat
   * @param context View Context
   */
  public static void webhcatSmokeTest(ViewContext context) {
    try {
      TempletonApi api = connectToTempletonApi(context);
      api.status();
    } catch (WebApplicationException ex) {
      throw ex;
    } catch (Exception ex) {
      throw new ServiceFormattedException(ex.getMessage(), ex);
    }
View Full Code Here


    if (webhcatUrl == null) {
      String message = "dataworker.webhcat.url is not configured!";
      LOG.error(message);
      throw new MisconfigurationFormattedException("dataworker.webhcat.url");
    }
    return new TempletonApi(context.getProperties().get("dataworker.webhcat.url"),
        getTempletonUser(context), getTempletonUser(context), context);
  }
View Full Code Here

    FSDataOutputStream stream = new FSDataOutputStream(do_stream);
    expect(hdfsApi.create(anyString(), eq(true))).andReturn(stream);
    replay(hdfsApi);
    JobService.setHdfsApi(hdfsApi);

    TempletonApi api = createNiceMock(TempletonApi.class);
    jobService.getResourceManager().setTempletonApi(api);
    TempletonApi.JobData data = api.new JobData();
    expect(api.runPigQuery((File) anyObject(), anyString(), eq("-useHCatalog"))).andReturn(data);
    replay(api);

    Response response = doCreateJob("Test", "/tmp/script.pig", "-useHCatalog");

    Assert.assertEquals("-useHCatalog", do_stream.toString());
View Full Code Here

    FSDataOutputStream stream = new FSDataOutputStream(do_stream);
    expect(hdfsApi.create(anyString(), eq(true))).andReturn(stream);
    replay(hdfsApi);
    JobService.setHdfsApi(hdfsApi);

    TempletonApi api = createNiceMock(TempletonApi.class);
    jobService.getResourceManager().setTempletonApi(api);
    TempletonApi.JobData data = api.new JobData();
    expect(api.runPigQuery((File) anyObject(), anyString(), eq("-useHCatalog"))).andReturn(data);
    replay(api);

    properties.put("dataworker.username", "luke");
    Response response = doCreateJob("Test", "/tmp/script.pig", "-useHCatalog");
    JSONObject obj = (JSONObject)response.getEntity();
View Full Code Here

    FSDataOutputStream stream = new FSDataOutputStream(do_stream);
    expect(hdfsApi.create(anyString(), eq(true))).andReturn(stream);
    replay(hdfsApi);
    JobService.setHdfsApi(hdfsApi);

    TempletonApi api = createNiceMock(TempletonApi.class);
    jobService.getResourceManager().setTempletonApi(api);
    TempletonApi.JobData data = api.new JobData();
    expect(api.runPigQuery((File) anyObject(), anyString(), (String) isNull())).andReturn(data);
    replay(api);

    Response response = doCreateJob("Test", "/tmp/script.pig", null);

    Assert.assertEquals("", do_stream.toString());
View Full Code Here

    FSDataOutputStream stream = new FSDataOutputStream(do_stream);
    expect(hdfsApi.create(anyString(), eq(true))).andReturn(stream);
    replay(hdfsApi);
    JobService.setHdfsApi(hdfsApi);

    TempletonApi api = createNiceMock(TempletonApi.class);
    jobService.getResourceManager().setTempletonApi(api);
    TempletonApi.JobData data = api.new JobData();
    expect(api.runPigQuery((File) anyObject(), anyString(), eq("-useHCatalog"))).andReturn(data);
    replay(api);

    Response response = doCreateJob("Test", null, "-useHCatalog");
    Assert.assertEquals(400, response.getStatus());
    JSONObject obj = (JSONObject)response.getEntity();
View Full Code Here

    expect(hdfsApi.create(endsWith("script.pig"), eq(true))).andReturn(scriptStream);
    expect(hdfsApi.create(endsWith("params"), eq(true))).andReturn(templetonArgsStream);
    replay(hdfsApi);
    JobService.setHdfsApi(hdfsApi);

    TempletonApi api = createNiceMock(TempletonApi.class);
    jobService.getResourceManager().setTempletonApi(api);
    TempletonApi.JobData data = api.new JobData();
    expect(api.runPigQuery((File) anyObject(), anyString(), eq("-useHCatalog"))).andReturn(data);
    replay(api);

    Response response = doCreateJob("Test", null, "-useHCatalog", "pwd")// with forcedContent
    Assert.assertEquals(201, response.getStatus());
    Assert.assertEquals("-useHCatalog", baTempletonArgsStream.toString());
View Full Code Here

    FSDataOutputStream stream = new FSDataOutputStream(do_stream);
    expect(hdfsApi.create(anyString(), eq(true))).andReturn(stream);
    replay(hdfsApi);
    JobService.setHdfsApi(hdfsApi);

    TempletonApi api = createNiceMock(TempletonApi.class);
    jobService.getResourceManager().setTempletonApi(api);
    TempletonApi.JobData data = api.new JobData();
    expect(api.runPigQuery((File) anyObject(), anyString(), eq("-useHCatalog"))).andReturn(data);
    replay(api);

    Response response = doCreateJob(null, "/tmp/1.pig", "-useHCatalog");
    Assert.assertEquals(400, response.getStatus());
    JSONObject obj = (JSONObject)response.getEntity();
View Full Code Here

    FSDataOutputStream stream = new FSDataOutputStream(do_stream);
    expect(hdfsApi.create(anyString(), eq(true))).andReturn(stream);
    replay(hdfsApi);
    JobService.setHdfsApi(hdfsApi);

    TempletonApi api = createNiceMock(TempletonApi.class);
    jobService.getResourceManager().setTempletonApi(api);
    TempletonApi.JobData data = api.new JobData();
    expect(api.runPigQuery((File) anyObject(), anyString(), eq("-useHCatalog"))).andReturn(data);
    replay(api);

    Response response = doCreateJob("Test", "/tmp/script.pig", "-useHCatalog");
    Assert.assertEquals(500, response.getStatus());
    JSONObject obj = (JSONObject)response.getEntity();
View Full Code Here

    FSDataOutputStream stream = new FSDataOutputStream(do_stream);
    expect(hdfsApi.create(anyString(), eq(true))).andReturn(stream);
    replay(hdfsApi);
    JobService.setHdfsApi(hdfsApi);

    TempletonApi api = createNiceMock(TempletonApi.class);
    jobService.getResourceManager().setTempletonApi(api);
    TempletonApi.JobData data = api.new JobData();
    // Templeton returns 500 e.g.
    expect(api.runPigQuery((File) anyObject(), anyString(), eq("-useHCatalog"))).andThrow(new IOException());
    replay(api);

    Response response = doCreateJob("Test", "/tmp/script.pig", "-useHCatalog");
    Assert.assertEquals(500, response.getStatus());
    JSONObject obj = (JSONObject)response.getEntity();
View Full Code Here

TOP

Related Classes of org.apache.ambari.view.pig.templeton.client.TempletonApi

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.