예제 #1
0
 @BeforeMethod
 public void setUp() throws Exception {
   address = HostAddress.fromParts("localhost", 1234);
   split =
       new LocalFileSplit(
           address, LocalFileTables.HttpRequestLogTable.getSchemaTableName(), TupleDomain.all());
 }
예제 #2
0
  @Test
  public void testJsonRoundTrip() {
    Properties schema = new Properties();
    schema.setProperty("foo", "bar");
    schema.setProperty("bar", "baz");

    ImmutableList<HivePartitionKey> partitionKeys =
        ImmutableList.of(
            new HivePartitionKey("a", HIVE_STRING, "apple"),
            new HivePartitionKey("b", HiveType.HIVE_LONG, "42"));
    ImmutableList<HostAddress> addresses =
        ImmutableList.of(
            HostAddress.fromParts("127.0.0.1", 44), HostAddress.fromParts("127.0.0.1", 45));
    HiveSplit expected =
        new HiveSplit(
            "clientId",
            "db",
            "table",
            "partitionId",
            "path",
            42,
            88,
            schema,
            partitionKeys,
            addresses,
            OptionalInt.empty(),
            true,
            TupleDomain.<HiveColumnHandle>all(),
            ImmutableMap.of(1, HIVE_STRING));

    String json = codec.toJson(expected);
    HiveSplit actual = codec.fromJson(json);

    assertEquals(actual.getClientId(), expected.getClientId());
    assertEquals(actual.getDatabase(), expected.getDatabase());
    assertEquals(actual.getTable(), expected.getTable());
    assertEquals(actual.getPartitionName(), expected.getPartitionName());
    assertEquals(actual.getPath(), expected.getPath());
    assertEquals(actual.getStart(), expected.getStart());
    assertEquals(actual.getLength(), expected.getLength());
    assertEquals(actual.getSchema(), expected.getSchema());
    assertEquals(actual.getPartitionKeys(), expected.getPartitionKeys());
    assertEquals(actual.getAddresses(), expected.getAddresses());
    assertEquals(actual.getColumnCoercions(), expected.getColumnCoercions());
    assertEquals(actual.isForceLocalScheduling(), expected.isForceLocalScheduling());
  }
 @JsonCreator
 public KafkaSplit(
     @JsonProperty("clientId") String clientId,
     @JsonProperty("topicName") String topicName,
     @JsonProperty("partitionId") int partitionId,
     @JsonProperty("brokerHost") String brokerHost,
     @JsonProperty("brokerPort") int brokerPort,
     @JsonProperty("sampleRate") int sampleRate,
     @JsonProperty("startTs") long startTs,
     @JsonProperty("endTs") long endTs,
     @JsonProperty("zookeeper") String zookeeper,
     @JsonProperty("zkSessionTimeout") int zkSessionTimeout,
     @JsonProperty("zkConnectTimeout") int zkConnectTimeout) {
   checkNotNull(clientId, "clientId is null");
   checkNotNull(topicName, "topicName is null");
   checkNotNull(partitionId, "partitionId is null");
   checkNotNull(startTs, "startTs is null");
   checkNotNull(endTs, "endTs is null");
   this.clientId = clientId;
   this.topicName = topicName;
   this.partitionId = partitionId;
   this.brokerHost = brokerHost;
   this.brokerPort = brokerPort;
   this.sampleRate = sampleRate;
   this.startTs = startTs;
   this.endTs = endTs;
   this.zookeeper = zookeeper;
   this.zkSessionTimeout = zkSessionTimeout;
   this.zkConnectTimeout = zkConnectTimeout;
   try {
     InetAddress address = InetAddress.getByName(brokerHost);
     this.address = HostAddress.fromParts(address.getHostAddress(), 8080);
   } catch (UnknownHostException ex) {
     throw new RuntimeException(ex.toString());
   }
 }
예제 #4
0
 @Override
 public HostAddress getHostAndPort() {
   return HostAddress.fromParts(hostname, 8080);
 }