Package org.apache.ambari.view.pig.utils

Examples of org.apache.ambari.view.pig.utils.HdfsApi


    }
    return hdfsApi;
  }

  protected static HdfsApi connectToHDFSApi(ViewContext context) {
    HdfsApi api = null;
    Thread.currentThread().setContextClassLoader(null);

    String defaultFS = context.getProperties().get("dataworker.defaultFs");
    if (defaultFS == null) {
      String message = "dataworker.defaultFs is not configured!";
      LOG.error(message);
      throw new MisconfigurationFormattedException("dataworker.defaultFs");
    }

    try {
      api = new HdfsApi(defaultFS, getHdfsUsername(context));
      LOG.info("HdfsApi connected OK");
    } catch (IOException e) {
      String message = "HdfsApi IO error: " + e.getMessage();
      LOG.error(message);
      throw new ServiceFormattedException(message, e);
View Full Code Here


    return jobService.runJob(request, resp_obj, uriInfo);
  }

  @Test
  public void testSubmitJob() throws Exception {
    HdfsApi hdfsApi = createNiceMock(HdfsApi.class);
    expect(hdfsApi.copy(eq("/tmp/script.pig"), startsWith("/tmp/.pigjobs/"))).andReturn(true);

    ByteArrayOutputStream do_stream = new ByteArrayOutputStream();

    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);
View Full Code Here

    Assert.assertTrue(job.isInProgress());
  }

  @Test
  public void testSubmitJobUsernameProvided() throws Exception {
    HdfsApi hdfsApi = createNiceMock(HdfsApi.class);
    expect(hdfsApi.copy(eq("/tmp/script.pig"), startsWith("/tmp/.pigjobs/"))).andReturn(true);

    ByteArrayOutputStream do_stream = new ByteArrayOutputStream();

    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);
View Full Code Here

    Assert.assertTrue(((PigJob) obj.get("job")).getStatusDir().startsWith("/tmp/.pigjobs/luke/test"));
  }

  @Test
  public void testSubmitJobNoArguments() throws Exception {
    HdfsApi hdfsApi = createNiceMock(HdfsApi.class);
    expect(hdfsApi.copy(eq("/tmp/script.pig"), startsWith("/tmp/.pigjobs/"))).andReturn(true);

    ByteArrayOutputStream do_stream = new ByteArrayOutputStream();

    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);
View Full Code Here

    Assert.assertTrue(job.isInProgress());
  }

  @Test
  public void testSubmitJobNoFile() throws Exception {
    HdfsApi hdfsApi = createNiceMock(HdfsApi.class);
    expect(hdfsApi.copy(eq("/tmp/script.pig"), startsWith("/tmp/.pigjobs/"))).andReturn(true);

    ByteArrayOutputStream do_stream = new ByteArrayOutputStream();

    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);
View Full Code Here

    Assert.assertTrue(((String)obj.get("message")).contains("No pigScript file or forcedContent specifed;"));
  }

  @Test
  public void testSubmitJobForcedContent() throws Exception {
    HdfsApi hdfsApi = createNiceMock(HdfsApi.class);

    ByteArrayOutputStream baScriptStream = new ByteArrayOutputStream();
    ByteArrayOutputStream baTempletonArgsStream = new ByteArrayOutputStream();

    FSDataOutputStream scriptStream = new FSDataOutputStream(baScriptStream);
    FSDataOutputStream templetonArgsStream = new FSDataOutputStream(baTempletonArgsStream);
    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);
View Full Code Here

    Assert.assertEquals("pwd", baScriptStream.toString());
  }

  @Test
  public void testSubmitJobNoTitle() throws Exception {
    HdfsApi hdfsApi = createNiceMock(HdfsApi.class);
    expect(hdfsApi.copy(eq("/tmp/script.pig"), startsWith("/tmp/.pigjobs/"))).andReturn(true);

    ByteArrayOutputStream do_stream = new ByteArrayOutputStream();

    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);
View Full Code Here

    Assert.assertTrue(((String)obj.get("message")).contains("No title specifed"));
  }

  @Test
  public void testSubmitJobFailed() throws Exception {
    HdfsApi hdfsApi = createNiceMock(HdfsApi.class);
    expect(hdfsApi.copy(eq("/tmp/script.pig"), startsWith("/tmp/.pigjobs/"))).andReturn(false);

    ByteArrayOutputStream do_stream = new ByteArrayOutputStream();

    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);
View Full Code Here

    Assert.assertTrue(((String)obj.get("message")).contains("Can't copy"));
  }

  @Test
  public void testSubmitJobTempletonError() throws Exception {
    HdfsApi hdfsApi = createNiceMock(HdfsApi.class);
    expect(hdfsApi.copy(eq("/tmp/script.pig"), startsWith("/tmp/.pigjobs/"))).andReturn(true);

    ByteArrayOutputStream do_stream = new ByteArrayOutputStream();

    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);
View Full Code Here

    Assert.assertTrue(((String) obj.get("message")).contains("Templeton"));
  }

  @Test
  public void testKillJob() throws Exception {
    HdfsApi hdfsApi = createNiceMock(HdfsApi.class);
    expect(hdfsApi.copy(eq("/tmp/script.pig"), startsWith("/tmp/.pigjobs/"))).andReturn(true);

    ByteArrayOutputStream do_stream = new ByteArrayOutputStream();

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

    TempletonApi api = createStrictMock(TempletonApi.class);
    jobService.getResourceManager().setTempletonApi(api);
View Full Code Here

TOP

Related Classes of org.apache.ambari.view.pig.utils.HdfsApi

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.