Package io.teknek.hiveunit.common

Examples of io.teknek.hiveunit.common.Response


  public void testScriptFileInput() {
    Map<String, File> inputFiles = Maps.newHashMap();
    File file = new File("src/test/resources/files/squidlog-SMALL.txt");
    inputFiles.put("$INPUT1", file);

    Response output =
      HiveBuilder.create()
        .withClientProperties(TestingUtil.getDefaultProperties())
        .hiveTestWithEmbeddedHive("src/test/resources/scripts/squid-logs.hql")
        .outputForInputFiles(inputFiles);

    List<String> expected = Lists.newArrayList();
    expected.add("http://www.maps.google.com/8314c8d5-7df9-4abe-8acb-9366b7c887c2\tGET\t1.374100685556E9");

    assertEquals(expected, output.getResult());
  }
View Full Code Here


    lines.add("1374100685.556 4 192.168.5.178 TCP_CLIENT_REFRESH_MISS/200 1069 POST http://www.google.com/analytics/6b8f7d8a-5832-439b-8dcf-34f60108b3d5 mestevez DIRECT/192.168.5.117 text/html");
    lines.add("1374100685.556 4 192.168.5.178 TCP_CLIENT_REFRESH_MISS/200 1315 GET http://www.twitter.com/30af5bdb-fa3e-4a8f-bcb1-bce6479dc413 mrodriguez DIRECT/192.168.5.117 text/html");
    lines.add("1374100685.556 4 192.168.5.178 TCP_CLIENT_REFRESH_MISS/200 1318 POST http://www.google.com/analytics/f03c65be-459e-4358-8653-0fa0e971cfb6 mestevez DIRECT/192.168.5.117 text/html");
    input.put("$INPUT1", lines);

    Response output =
      HiveBuilder.create()
        .withClientProperties(TestingUtil.getDefaultProperties())
        .hiveTestWithEmbeddedHive("src/test/resources/scripts/squid-logs.hql")
        .outputForInput(input);

    List<String> expected = Lists.newArrayList();
    expected.add("http://www.maps.google.com/8314c8d5-7df9-4abe-8acb-9366b7c887c2\tGET\t1.374100685556E9");

    assertEquals(expected, output.getResult());
  }
View Full Code Here

    } catch (IOException e) {
      logger.log(Level.SEVERE, null, e);
    } catch (CommandNeedRetryException e) {
      logger.log(Level.SEVERE, null, e);
    }
    return new Response((processorResponse != null) ? processorResponse.getResponseCode() : -40, results);
  }
View Full Code Here

  @Override
  public Response execute(String command) {
    try {
      hive.client.execute(command);
      return new Response(hive.client.getStatus().getValue(), hive.client.fetchAll());
    } catch (TException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }

    Response response = outputForInputFiles(inputFiles);
    //cleanup aux files to avoid filling too much space
    for (File file : inputs) {
      file.delete();
    }
    return response;
View Full Code Here

    this.scriptFile = scriptFile;
    this.params = params;
  }

  public Response execute() {
    Response response = null;
    List<String> out = Lists.newArrayList();
    for (String command : buildCommandsFromScript()) {
      response = hive.execute(replaceVariables(command));
      out.addAll(response.getResult());
    }
    return new Response((response == null) ? ResponseStatus.FAILURE : response.getResponseStatus(), out);
  }
View Full Code Here

TOP

Related Classes of io.teknek.hiveunit.common.Response

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.