Search in sources :

Example 21 with HostAddress

use of io.trino.spi.HostAddress in project trino by trinodb.

the class Failures method toFailure.

private static ExecutionFailureInfo toFailure(Throwable throwable, Set<Throwable> seenFailures) {
    if (throwable == null) {
        return null;
    }
    String type;
    HostAddress remoteHost = null;
    if (throwable instanceof Failure) {
        type = ((Failure) throwable).getType();
    } else {
        Class<?> clazz = throwable.getClass();
        type = firstNonNull(clazz.getCanonicalName(), clazz.getName());
    }
    if (throwable instanceof TrinoTransportException) {
        remoteHost = ((TrinoTransportException) throwable).getRemoteHost();
    }
    if (seenFailures.contains(throwable)) {
        return new ExecutionFailureInfo(type, "[cyclic] " + throwable.getMessage(), null, ImmutableList.of(), ImmutableList.of(), null, GENERIC_INTERNAL_ERROR.toErrorCode(), remoteHost);
    }
    seenFailures.add(throwable);
    ExecutionFailureInfo cause = toFailure(throwable.getCause(), seenFailures);
    ErrorCode errorCode = toErrorCode(throwable);
    if (errorCode == null) {
        if (cause == null) {
            errorCode = GENERIC_INTERNAL_ERROR.toErrorCode();
        } else {
            errorCode = cause.getErrorCode();
        }
    }
    return new ExecutionFailureInfo(type, throwable.getMessage(), cause, Arrays.stream(throwable.getSuppressed()).map(failure -> toFailure(failure, seenFailures)).collect(toImmutableList()), Arrays.stream(throwable.getStackTrace()).map(Objects::toString).collect(toImmutableList()), getErrorLocation(throwable), errorCode, remoteHost);
}
Also used : TrinoTransportException(io.trino.spi.TrinoTransportException) Objects(java.util.Objects) ErrorCode(io.trino.spi.ErrorCode) StandardErrorCode(io.trino.spi.StandardErrorCode) HostAddress(io.trino.spi.HostAddress) Failure(io.trino.execution.Failure) ExecutionFailureInfo(io.trino.execution.ExecutionFailureInfo)

Example 22 with HostAddress

use of io.trino.spi.HostAddress in project trino by trinodb.

the class TestPhoenixSplit method testPhoenixSplitJsonRoundtrip.

@Test
public void testPhoenixSplitJsonRoundtrip() throws Exception {
    List<HostAddress> addresses = ImmutableList.of(HostAddress.fromString("host:9000"));
    List<Scan> scans = ImmutableList.of(new Scan().withStartRow(Bytes.toBytes("A")).withStopRow(Bytes.toBytes("Z")));
    PhoenixInputSplit phoenixInputSplit = new PhoenixInputSplit(scans);
    PhoenixSplit expected = new PhoenixSplit(addresses, SerializedPhoenixInputSplit.serialize(phoenixInputSplit));
    assertTrue(objectMapper.canSerialize(PhoenixSplit.class));
    String json = objectMapper.writeValueAsString(expected);
    PhoenixSplit actual = objectMapper.readValue(json, PhoenixSplit.class);
    assertEquals(actual.getPhoenixInputSplit(), expected.getPhoenixInputSplit());
    assertEquals(actual.getAddresses(), expected.getAddresses());
}
Also used : PhoenixInputSplit(org.apache.phoenix.mapreduce.PhoenixInputSplit) Scan(org.apache.hadoop.hbase.client.Scan) HostAddress(io.trino.spi.HostAddress) Test(org.testng.annotations.Test)

Example 23 with HostAddress

use of io.trino.spi.HostAddress in project trino by trinodb.

the class PlainTextKafkaConsumerFactory method configure.

@Override
public Properties configure(ConnectorSession session) {
    Properties properties = new Properties();
    properties.setProperty(BOOTSTRAP_SERVERS_CONFIG, nodes.stream().map(HostAddress::toString).collect(joining(",")));
    properties.setProperty(KEY_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class.getName());
    properties.setProperty(VALUE_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class.getName());
    properties.setProperty(RECEIVE_BUFFER_CONFIG, Long.toString(kafkaBufferSize.toBytes()));
    properties.setProperty(ENABLE_AUTO_COMMIT_CONFIG, Boolean.toString(false));
    properties.setProperty(SECURITY_PROTOCOL_CONFIG, securityProtocol.name());
    return properties;
}
Also used : Properties(java.util.Properties) HostAddress(io.trino.spi.HostAddress) ByteArrayDeserializer(org.apache.kafka.common.serialization.ByteArrayDeserializer)

Example 24 with HostAddress

use of io.trino.spi.HostAddress in project trino by trinodb.

the class PlainTextKafkaProducerFactory method configure.

@Override
public Properties configure(ConnectorSession session) {
    Properties properties = new Properties();
    properties.setProperty(BOOTSTRAP_SERVERS_CONFIG, nodes.stream().map(HostAddress::toString).collect(joining(",")));
    properties.setProperty(KEY_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class.getName());
    properties.setProperty(VALUE_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class.getName());
    properties.setProperty(ACKS_CONFIG, "all");
    properties.setProperty(LINGER_MS_CONFIG, Long.toString(5));
    properties.setProperty(SECURITY_PROTOCOL_CONFIG, securityProtocol.name());
    return properties;
}
Also used : Properties(java.util.Properties) HostAddress(io.trino.spi.HostAddress) ByteArraySerializer(org.apache.kafka.common.serialization.ByteArraySerializer)

Aggregations

HostAddress (io.trino.spi.HostAddress)24 ImmutableList (com.google.common.collect.ImmutableList)9 ConnectorSplit (io.trino.spi.connector.ConnectorSplit)8 Test (org.testng.annotations.Test)7 InternalNode (io.trino.metadata.InternalNode)6 HashSet (java.util.HashSet)5 List (java.util.List)5 Map (java.util.Map)5 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)4 ImmutableSet (com.google.common.collect.ImmutableSet)4 HashMap (java.util.HashMap)4 Objects.requireNonNull (java.util.Objects.requireNonNull)4 Split (io.trino.metadata.Split)3 TrinoException (io.trino.spi.TrinoException)3 FixedSplitSource (io.trino.spi.connector.FixedSplitSource)3 Objects (java.util.Objects)3 Properties (java.util.Properties)3 Host (com.datastax.driver.core.Host)2 HashMultimap (com.google.common.collect.HashMultimap)2 ImmutableMultimap (com.google.common.collect.ImmutableMultimap)2