Skip to content

Commit

Permalink
Fixed typo and formatting after merge of #56
Browse files Browse the repository at this point in the history
  • Loading branch information
jhannes committed Nov 18, 2021
1 parent 7e836f7 commit 5661475
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
* </ul>
*
* <h4>Authorization</h4>
*
* The configurable <code>elasitcsearchAuthorizationHeader</code> is the value the client will include as
* <p>
* The configurable <code>elasticsearchAuthorizationHeader</code> is the value the client will include as
* Authorization header
* when communicating with <code>elasticsearchUrl</code>. It is not to be confused by Basic authentication. If you
* need basic authentication you need to remember to provide its configuration value as '<code>Basic
Expand Down Expand Up @@ -96,7 +96,7 @@ public void configureProxy(Configuration configuration) {
configuration.optionalString("proxy").ifPresent(proxyHost -> {
int colonPos = proxyHost.lastIndexOf(':');
String hostname = colonPos != -1 ? proxyHost.substring(0, colonPos) : proxyHost;
int proxyPort = colonPos != -1 ? Integer.parseInt(proxyHost.substring(colonPos+1)) : 80;
int proxyPort = colonPos != -1 ? Integer.parseInt(proxyHost.substring(colonPos + 1)) : 80;
this.proxy = new Proxy(Proxy.Type.HTTP, InetSocketAddress.createUnresolved(hostname, proxyPort));
});
}
Expand Down Expand Up @@ -138,11 +138,12 @@ List<String> indexDocuments(Iterable<LogEvent> logEvents) throws IOException {

URL url = new URL(elasticsearchUrl, elasticsearchUrlPath);
HttpURLConnection connection = NetUtils.post(
url,
String.join("\n", jsons),
APPLICATION_X_NDJSON,
proxy,
elasticsearchAuthorizationHeaderValue);
url,
String.join("\n", jsons),
APPLICATION_X_NDJSON,
proxy,
elasticsearchAuthorizationHeaderValue
);

return parseBulkApiResponse(JsonParser.parseObject(connection));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;

import org.logevents.util.JsonUtil;

/**
Expand Down Expand Up @@ -32,8 +33,8 @@
* </ul>
*
* <h4>Authorization</h4>
*
* The configurable <code>elasitcsearchAuthorizationHeader</code> is the value the client will include as
* <p>
* The configurable <code>elasticsearchAuthorizationHeader</code> is the value the client will include as
* Authorization header
* when communicating with <code>elasticsearchUrl</code>. It is not to be confused by Basic authentication. If you
* need basic authentication you need to remember to provide its configuration value as '<code>Basic
Expand All @@ -44,8 +45,6 @@
public class HumioLogEventObserver extends ElasticsearchLogEventObserver {

private static final String DEFAULT_HUMIO_BULK_API_PATH = "api/v1/ingest/elastic-bulk";
private static final List<String> EMPTY_LIST_SINCE_HUMIO_API_HAS_NO_SANE_BULK_API_RESPONSE_CONTAINING_DOCUMENT_IDS_FROM_INSERT =
Collections.emptyList();

public HumioLogEventObserver(Map<String, String> properties, String prefix) {
super(properties, prefix);
Expand All @@ -62,11 +61,11 @@ protected List<String> parseBulkApiResponse(Map<String, Object> response) throws
if (isAnyApiErrors) {
List<Map<String, Object>> items = JsonUtil.getObjectList(response, "items");
long numberOfFailedMessages = items.stream()
.filter(o -> !String.valueOf(JsonUtil.getField(JsonUtil.getObject(o, "create"), "status")).equals("200"))
.count();
.filter(o -> !String.valueOf(JsonUtil.getField(JsonUtil.getObject(o, "create"), "status")).equals("200"))
.count();

throw new IOException("Failed sending "+ numberOfFailedMessages + " out of " + items.size() + " entries");
throw new IOException("Failed sending " + numberOfFailedMessages + " out of " + items.size() + " entries");
}
return EMPTY_LIST_SINCE_HUMIO_API_HAS_NO_SANE_BULK_API_RESPONSE_CONTAINING_DOCUMENT_IDS_FROM_INSERT;
return Collections.emptyList();
}
}

0 comments on commit 5661475

Please sign in to comment.