use of org.komamitsu.fluency.fluentd.ingester.sender.failuredetect.FailureDetector in project fluency by komamitsu.
the class FluencyBuilderForFluentd method createBaseSender.
private FluentdSender createBaseSender(String host, Integer port, boolean withHeartBeater) {
if (withHeartBeater && port == null) {
throw new IllegalArgumentException("`port` should be specified when using heartbeat");
}
if (isSslEnabled()) {
SSLSender.Config senderConfig = new SSLSender.Config();
FailureDetector failureDetector = null;
if (host != null) {
senderConfig.setHost(host);
}
if (port != null) {
senderConfig.setPort(port);
}
if (withHeartBeater) {
SSLHeartbeater.Config hbConfig = new SSLHeartbeater.Config();
hbConfig.setHost(host);
hbConfig.setPort(port);
SSLHeartbeater heartbeater = new SSLHeartbeater(hbConfig);
failureDetector = new FailureDetector(new PhiAccrualFailureDetectStrategy(), heartbeater);
}
if (connectionTimeoutMilli != null) {
senderConfig.setConnectionTimeoutMilli(connectionTimeoutMilli);
}
if (readTimeoutMilli != null) {
senderConfig.setReadTimeoutMilli(readTimeoutMilli);
}
return new SSLSender(senderConfig, failureDetector);
} else {
TCPSender.Config senderConfig = new TCPSender.Config();
FailureDetector failureDetector = null;
if (host != null) {
senderConfig.setHost(host);
}
if (port != null) {
senderConfig.setPort(port);
}
if (withHeartBeater) {
TCPHeartbeater.Config hbConfig = new TCPHeartbeater.Config();
hbConfig.setHost(host);
hbConfig.setPort(port);
TCPHeartbeater heartbeater = new TCPHeartbeater(hbConfig);
failureDetector = new FailureDetector(new PhiAccrualFailureDetectStrategy(), heartbeater);
}
if (connectionTimeoutMilli != null) {
senderConfig.setConnectionTimeoutMilli(connectionTimeoutMilli);
}
if (readTimeoutMilli != null) {
senderConfig.setReadTimeoutMilli(readTimeoutMilli);
}
return new TCPSender(senderConfig, failureDetector);
}
}
Aggregations