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);
}
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());
}
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;
}
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;
}
Aggregations