Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void initialize(ResourceWatcherService resourceWatcher) throws IOException {
watcher.addListener(new GeoipDirectoryListener());
resourceWatcher.add(watcher, ResourceWatcherService.Frequency.HIGH);

LOGGER.info("initialized config databases [{}] and watching [{}] for changes", configDatabases.keySet(), geoipConfigDir);
LOGGER.debug("initialized config databases [{}] and watching [{}] for changes", configDatabases.keySet(), geoipConfigDir);
}

DatabaseReaderLazyLoader getDatabase(String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
if (Files.exists(geoipTmpDirectory) == false) {
Files.createDirectories(geoipTmpDirectory);
}
LOGGER.info("initialized database registry, using geoip-databases directory [{}]", geoipTmpDirectory);
LOGGER.debug("initialized database node service, using geoip-databases directory [{}]", geoipTmpDirectory);
ingestServiceArg.addIngestClusterStateListener(this::checkDatabases);
this.ingestService = ingestServiceArg;
}
Expand Down Expand Up @@ -261,7 +261,7 @@ void retrieveAndUpdateDatabase(String databaseName, GeoIpTaskState.Metadata meta
}

final Path databaseTmpFile = Files.createFile(geoipTmpDirectory.resolve(databaseName + ".tmp"));
LOGGER.info("downloading geoip database [{}] to [{}]", databaseName, databaseTmpGzFile);
LOGGER.debug("downloading geoip database [{}] to [{}]", databaseName, databaseTmpGzFile);
retrieveDatabase(
databaseName,
recordedMd5,
Expand Down Expand Up @@ -348,7 +348,7 @@ void updateDatabase(String databaseFileName, String recordedMd5, Path file) {
LOGGER.debug("no pipelines found to reload");
}
}
LOGGER.info("successfully reloaded changed geoip database file [{}]", file);
LOGGER.info("successfully loaded geoip database file [{}]", file.getFileName());
} catch (Exception e) {
LOGGER.error((Supplier<?>) () -> new ParameterizedMessage("failed to update database [{}]", databaseFileName), e);
}
Expand All @@ -357,7 +357,7 @@ void updateDatabase(String databaseFileName, String recordedMd5, Path file) {
void removeStaleEntries(Collection<String> staleEntries) {
for (String staleEntry : staleEntries) {
try {
LOGGER.info("database [{}] no longer exists, cleaning up...", staleEntry);
LOGGER.debug("database [{}] no longer exists, cleaning up...", staleEntry);
DatabaseReaderLazyLoader existing = databases.remove(staleEntry);
assert existing != null;
existing.close(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.logging.log4j.util.Supplier;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.admin.indices.flush.FlushRequest;
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
Expand Down Expand Up @@ -119,7 +121,7 @@ public void setPollInterval(TimeValue pollInterval) {

// visible for testing
void updateDatabases() throws IOException {
logger.info("updating geoip databases");
logger.debug("updating geoip databases");
List<Map<String, Object>> response = fetchDatabasesOverview();
for (Map<String, Object> res : response) {
if (res.get("name").toString().endsWith(".tgz")) {
Expand All @@ -131,7 +133,7 @@ void updateDatabases() throws IOException {
@SuppressWarnings("unchecked")
private <T> List<T> fetchDatabasesOverview() throws IOException {
String url = endpoint + "?elastic_geoip_service_tos=agree";
logger.info("fetching geoip databases overview from [" + url + "]");
logger.debug("fetching geoip databases overview from [{}]", url);
byte[] data = httpClient.getBytes(url);
try (
XContentParser parser = XContentType.JSON.xContent()
Expand All @@ -149,7 +151,7 @@ void processDatabase(Map<String, Object> databaseInfo) {
updateTimestamp(name, state.get(name));
return;
}
logger.info("updating geoip database [" + name + "]");
logger.debug("downloading geoip database [{}]", name);
String url = databaseInfo.get("url").toString();
if (url.startsWith("http") == false) {
// relative url, add it after last slash (i.e resolve sibling) or at the end if there's no slash after http[s]://
Expand All @@ -164,12 +166,12 @@ void processDatabase(Map<String, Object> databaseInfo) {
state = state.put(name, new Metadata(start, firstChunk, lastChunk - 1, md5, start));
updateTaskState();
stats = stats.successfulDownload(System.currentTimeMillis() - start).databasesCount(state.getDatabases().size());
logger.info("updated geoip database [" + name + "]");
logger.info("successfully downloaded geoip database [{}]", name);
deleteOldChunks(name, firstChunk);
}
} catch (Exception e) {
stats = stats.failedDownload();
logger.error("error updating geoip database [" + name + "]", e);
logger.error((Supplier<?>) () -> new ParameterizedMessage("error downloading geoip database [{}]", name), e);
}
}

Expand All @@ -189,7 +191,7 @@ void deleteOldChunks(String name, int firstChunk) {

// visible for testing
protected void updateTimestamp(String name, Metadata old) {
logger.info("geoip database [" + name + "] is up to date, updated timestamp");
logger.debug("geoip database [{}] is up to date, updated timestamp", name);
state = state.put(
name,
new Metadata(old.getLastUpdate(), old.getFirstChunk(), old.getLastChunk(), old.getMd5(), System.currentTimeMillis())
Expand Down