kfaraz commented on code in PR #18142:
URL: https://github.com/apache/druid/pull/18142#discussion_r2151410146
##########
server/src/main/java/org/apache/druid/query/lookup/LookupReferencesManager.java:
##########
@@ -475,12 +477,18 @@ private Map<String, LookupExtractorFactoryContainer>
tryGetLookupListFromCoordin
coordinatorClient.fetchLookupsForTier(tier), true);
}
catch (Exception e) {
- HttpResponseException httpEx = (HttpResponseException) e.getCause();
- LOG.warn(
- "No lookups found for tier [%s], status [%s]",
- tier,
- httpEx.getResponse().getStatus()
- );
+ Throwable rootCause = Throwables.getRootCause(e);
+ if (rootCause instanceof HttpResponseException) {
+ HttpResponseException httpEx = (HttpResponseException) rootCause;
Review Comment:
Nit:
```suggestion
final HttpResponseException httpException = (HttpResponseException)
rootCause;
```
##########
server/src/main/java/org/apache/druid/query/lookup/LookupReferencesManager.java:
##########
@@ -476,38 +471,26 @@ private List<LookupBean>
getLookupListFromCoordinator(String tier)
@Nullable
private Map<String, LookupExtractorFactoryContainer>
tryGetLookupListFromCoordinator(String tier)
- throws IOException, InterruptedException
{
- final StringFullResponseHolder response = fetchLookupsForTier(tier);
- if (response.getStatus().equals(HttpResponseStatus.NOT_FOUND)) {
- LOG.warn("No lookups found for tier [%s], response [%s]", tier,
response);
- return null;
- } else if (!response.getStatus().equals(HttpResponseStatus.OK)) {
- throw new IOE(
- "Error while fetching lookup code from Coordinator with status[%s]
and content[%s]",
- response.getStatus(),
- response.getContent()
- );
+ try {
+ return FutureUtils.getUnchecked(
+ coordinatorClient.fetchLookupsForTier(tier), true);
Review Comment:
formatting:
```suggestion
return
FutureUtils.getUnchecked(coordinatorClient.fetchLookupsForTier(tier), true);
```
##########
server/src/main/java/org/apache/druid/query/lookup/LookupReferencesManager.java:
##########
@@ -476,38 +471,26 @@ private List<LookupBean>
getLookupListFromCoordinator(String tier)
@Nullable
private Map<String, LookupExtractorFactoryContainer>
tryGetLookupListFromCoordinator(String tier)
- throws IOException, InterruptedException
{
- final StringFullResponseHolder response = fetchLookupsForTier(tier);
- if (response.getStatus().equals(HttpResponseStatus.NOT_FOUND)) {
- LOG.warn("No lookups found for tier [%s], response [%s]", tier,
response);
- return null;
- } else if (!response.getStatus().equals(HttpResponseStatus.OK)) {
- throw new IOE(
- "Error while fetching lookup code from Coordinator with status[%s]
and content[%s]",
- response.getStatus(),
- response.getContent()
- );
+ try {
+ return FutureUtils.getUnchecked(
+ coordinatorClient.fetchLookupsForTier(tier), true);
}
-
- // Older version of getSpecificTier returns a list of lookup names.
- // Lookup loading is performed via snapshot if older version is present.
- // This check is only for backward compatibility and should be removed in
a future release
- if (response.getContent().startsWith("[")) {
- LOG.info(
- "Failed to retrieve lookup information from coordinator, " +
- "because coordinator appears to be running on older Druid version. "
+
- "Attempting to load lookups using snapshot instead"
- );
- return null;
- } else {
- Map<String, Object> lookupNameToGenericConfig =
- jsonMapper.readValue(response.getContent(),
LOOKUPS_ALL_GENERIC_REFERENCE);
- return LookupUtils.tryConvertObjectMapToLookupConfigMap(
- lookupNameToGenericConfig,
- jsonMapper
- );
+ catch (Exception e) {
+ Throwable rootCause = Throwables.getRootCause(e);
+ if (rootCause instanceof HttpResponseException) {
+ HttpResponseException httpEx = (HttpResponseException) rootCause;
+ if
(httpEx.getResponse().getStatus().equals(HttpResponseStatus.NOT_FOUND)) {
+ LOG.info(
+ "No lookups found for tier [%s], status [%s]",
+ tier,
+ httpEx.getResponse().getStatus()
+ );
+ return null;
+ }
Review Comment:
The catch clause should re-throw the exception if the cause was not a 404.
##########
server/src/main/java/org/apache/druid/query/lookup/LookupReferencesManager.java:
##########
@@ -476,38 +471,26 @@ private List<LookupBean>
getLookupListFromCoordinator(String tier)
@Nullable
private Map<String, LookupExtractorFactoryContainer>
tryGetLookupListFromCoordinator(String tier)
- throws IOException, InterruptedException
{
- final StringFullResponseHolder response = fetchLookupsForTier(tier);
- if (response.getStatus().equals(HttpResponseStatus.NOT_FOUND)) {
- LOG.warn("No lookups found for tier [%s], response [%s]", tier,
response);
- return null;
- } else if (!response.getStatus().equals(HttpResponseStatus.OK)) {
- throw new IOE(
- "Error while fetching lookup code from Coordinator with status[%s]
and content[%s]",
- response.getStatus(),
- response.getContent()
- );
+ try {
+ return FutureUtils.getUnchecked(
+ coordinatorClient.fetchLookupsForTier(tier), true);
}
-
- // Older version of getSpecificTier returns a list of lookup names.
- // Lookup loading is performed via snapshot if older version is present.
- // This check is only for backward compatibility and should be removed in
a future release
- if (response.getContent().startsWith("[")) {
- LOG.info(
- "Failed to retrieve lookup information from coordinator, " +
- "because coordinator appears to be running on older Druid version. "
+
- "Attempting to load lookups using snapshot instead"
- );
- return null;
- } else {
- Map<String, Object> lookupNameToGenericConfig =
- jsonMapper.readValue(response.getContent(),
LOOKUPS_ALL_GENERIC_REFERENCE);
- return LookupUtils.tryConvertObjectMapToLookupConfigMap(
- lookupNameToGenericConfig,
- jsonMapper
- );
+ catch (Exception e) {
+ Throwable rootCause = Throwables.getRootCause(e);
+ if (rootCause instanceof HttpResponseException) {
+ HttpResponseException httpEx = (HttpResponseException) rootCause;
+ if
(httpEx.getResponse().getStatus().equals(HttpResponseStatus.NOT_FOUND)) {
+ LOG.info(
+ "No lookups found for tier [%s], status [%s]",
+ tier,
+ httpEx.getResponse().getStatus()
+ );
+ return null;
+ }
+ }
}
+ return Map.of();
Review Comment:
We should not return empty in any case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]