@Override public boolean equals(Object o) { if (o != null && o instanceof DataSourceName) { return name.equals(((DataSourceName) o).asName()); } return false; }
@Override public String toString() { return String.format("BaseMetadataAvailability for data source = %s", getDataSourceName().asName()); }
/** * Get a set of intervals available for each column in the data source. * * @param dataSourceName The data source for which to get the availability by column * * @return a map of column name to a set of available intervals */ public Map<String, SimplifiedIntervalList> getAvailableIntervalsByDataSource(DataSourceName dataSourceName) { if (!allSegmentsByColumn.containsKey(dataSourceName)) { String message = String.format( "Datasource '%s' is not available in the metadata service", dataSourceName.asName() ); LOG.error(message); throw new IllegalStateException(message); } return allSegmentsByColumn.get(dataSourceName).get(); }
@Override public boolean equals(Object obj) { if (obj instanceof BaseMetadataAvailability && this.getClass().equals(obj.getClass())) { BaseMetadataAvailability that = (BaseMetadataAvailability) obj; return Objects.equals(getDataSourceName().asName(), that.getDataSourceName().asName()) // Since metadata service is mutable, use instance equality to ensure table equality is stable && getDataSourceMetadataService() == that.getDataSourceMetadataService(); } return false; }
@Override public void invoke(int statusCode, String reason, String responseBody) { // No Content is an expected but A-typical response. // Usually, it means Druid knows about the data source, but no segments have been loaded if (statusCode == NO_CONTENT.getStatusCode()) { String msg = String.format( "Druid returned 204 NO CONTENT when loading metadata for the '%s' datasource. While not an " + "error, it is unusual for a Druid data source to report having no data in it. Please " + "verify that your cluster is healthy.", dataSourceName.asName() ); LOG.warn(msg); metadataService.update( dataSourceName, new DataSourceMetadata(dataSourceName.asName(), Collections.emptyMap(), Collections.emptyList()) ); } else { String msg = String.format( "%s: HTTP error while trying to load metadata for data source: %s - %d %s, Response body: %s", getName(), dataSourceName.asName(), statusCode, reason, responseBody ); LOG.error(msg); } } }
/** * Queries Druid for updated datasource metadata and then updates the datasource metadata service. * * @param dataSourceName The data source to be updated. */ protected void queryDataSourceMetadata(DataSourceName dataSourceName) { String resourcePath = String.format(DATASOURCE_METADATA_QUERY_FORMAT, dataSourceName.asName()); // Success callback will update datasource metadata on success SuccessCallback success = buildDataSourceMetadataSuccessCallback(dataSourceName); HttpErrorCallback errorCallback = getErrorCallback(dataSourceName); druidWebService.getJsonObject(success, errorCallback, failureCallback, resourcePath); }
public String getName() { return getPhysicalTable().getDataSourceNames().stream().findFirst() .orElseThrow(() -> { LOG.error(TOO_FEW_BACKING_DATA_SOURCES.logFormat(getPhysicalTable())); return new IllegalArgumentException(TOO_FEW_BACKING_DATA_SOURCES.format(getPhysicalTable())); }).asName(); }