mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
AP-7517 Add additional logging of error scenarios to dictionary update.
When `dictionaries.json` cannot be loaded from the CDN for any reason during dictionary updates, we are now logging a `dictionary.update.failed` event. GitOrigin-RevId: 16047217e88718e05085d2699431ae9420b9a92a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
885291fe87
commit
c37fbee0d7
+1
-1
@@ -14,7 +14,7 @@ public interface EventLogMetadataLoader {
|
||||
String loadMetadataFromServer() throws EventLogMetadataLoadException;
|
||||
|
||||
@NotNull
|
||||
Map<String, Long> getDictionariesLastModifiedOnServer(String recorderId);
|
||||
Map<String, Long> getDictionariesLastModifiedOnServer(String recorderId) throws EventLogMetadataLoadException;
|
||||
|
||||
@NotNull
|
||||
String loadDictionaryFromServer(String recorderId, String dictionaryName) throws EventLogMetadataLoadException;
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ public class EventLogServerMetadataLoader implements EventLogMetadataLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Map<String, Long> getDictionariesLastModifiedOnServer(String recorderId) {
|
||||
public @NotNull Map<String, Long> getDictionariesLastModifiedOnServer(String recorderId) throws EventLogMetadataLoadException {
|
||||
StatsConnectionSettings settings = mySettingsClient.getApplicationInfo().getConnectionSettings();
|
||||
return EventLogMetadataUtils.dictionariesLastModified(mySettingsClient.provideDictionaryServiceUrl(), recorderId, settings);
|
||||
}
|
||||
|
||||
+19
-1
@@ -142,9 +142,27 @@ public class ValidationRulesPersistedStorage implements IntellijValidationRulesS
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Long> getDictionariesModifiedOnServer() {
|
||||
try {
|
||||
return myMetadataLoader.getDictionariesLastModifiedOnServer(myRecorderId);
|
||||
}
|
||||
catch (EventLogMetadataLoadException e) {
|
||||
eventLogSystemCollector.logDictionaryUpdateFailed(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void updateDictionaries() {
|
||||
var dictionariesLastModifiedLocally = myMetadataPersistence.getDictionariesLastModified();
|
||||
var dictionariesLastModifiedOnServer = myMetadataLoader.getDictionariesLastModifiedOnServer(myRecorderId);
|
||||
Map<String, Long> dictionariesLastModifiedOnServer = getDictionariesModifiedOnServer();
|
||||
|
||||
if (dictionariesLastModifiedOnServer == null) {
|
||||
if (LOG.isTraceEnabled()) {
|
||||
LOG.trace("Error occurred loading dictionaries list from server");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (LOG.isTraceEnabled()) {
|
||||
LOG.trace(
|
||||
"Loading dictionaries, last modified cached=" + dictionariesLastModifiedLocally +
|
||||
|
||||
+9
-3
@@ -117,17 +117,23 @@ public final class EventLogMetadataUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, Long> dictionariesLastModified(@Nullable String serviceUrl, @NotNull String recorderId, @NotNull StatsConnectionSettings settings) {
|
||||
if (isEmptyOrSpaces(serviceUrl)) return Map.of();
|
||||
public static Map<String, Long> dictionariesLastModified(@Nullable String serviceUrl, @NotNull String recorderId, @NotNull StatsConnectionSettings settings)
|
||||
throws EventLogMetadataLoadException {
|
||||
if (isEmptyOrSpaces(serviceUrl)) {
|
||||
throw new EventLogMetadataLoadException(EventLogMetadataLoadErrorType.EMPTY_SERVICE_URL);
|
||||
}
|
||||
|
||||
String baseUrl = serviceUrl + recorderId + "/";
|
||||
RemoteDictionaryList dictionaryList;
|
||||
try {
|
||||
StatsRequestResult<String> result = StatsHttpRequests.request( baseUrl + "dictionaries.json", settings).send(r -> r.readAsString());
|
||||
if (!result.isSucceed()) {
|
||||
throw new EventLogMetadataLoadException(EventLogMetadataLoadErrorType.UNREACHABLE_SERVICE, result.getError());
|
||||
}
|
||||
dictionaryList = parseRemoteDictionaryList(result.getResult());
|
||||
}
|
||||
catch (StatsResponseException | IOException | EventLogMetadataParseException e) {
|
||||
return Map.of();
|
||||
throw new EventLogMetadataLoadException(EventLogMetadataLoadErrorType.ERROR_ON_LOAD, e);
|
||||
}
|
||||
|
||||
Map<String, Long> lastModifiedMap = new HashMap<>();
|
||||
|
||||
Reference in New Issue
Block a user