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 @@ -107,4 +107,15 @@ private static void checkIfHeatMapFeatureIsEnabled() {
throw new WebApplicationException(Response.Status.NOT_FOUND);
}
}

/**
* This API do a health check for HeatMapProvider source if it is initialized
* and returning response.
* @return HealthCheckResponse wrapped in Response object.
*/
@GET
@Path("/healthCheck")
public Response getReadAccessMetaData() {
return Response.ok(heatMapService.doHeatMapHealthCheck()).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.hadoop.ozone.recon.api.types;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* This is Solr Health Check response for healthCheck API.
*/
public final class HealthCheckResponse {

/** Health check response message. */
@JsonProperty("message")
private String message;

/** Health check status code. */
@JsonProperty("status")
private int status;

// Private constructor to prevent direct instantiation
private HealthCheckResponse(Builder builder) {
this.message = builder.message;
this.status = builder.status;
}

public String getMessage() {
return message;
}

public int getStatus() {
return status;
}

/**
* Builder class.
*/
public static class Builder {

// Required parameters
private String message;

private int status;

// Constructor with required parameters
public Builder(String message, int status) {
this.message = message;
this.status = status;
}

// Build method to create a new Person instance
public HealthCheckResponse build() {
return new HealthCheckResponse(this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.scm.server.OzoneStorageContainerManager;
import org.apache.hadoop.ozone.recon.api.types.EntityReadAccessHeatMapResponse;
import org.apache.hadoop.ozone.recon.api.types.HealthCheckResponse;
import org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager;
import org.apache.hadoop.ozone.recon.spi.ReconNamespaceSummaryManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.core.Response;

import static org.apache.hadoop.hdds.recon.ReconConfigKeys.OZONE_RECON_HEATMAP_PROVIDER_KEY;
import static org.apache.hadoop.ozone.OzoneConsts.OM_KEY_PREFIX;

Expand Down Expand Up @@ -104,4 +107,11 @@ private String validatePath(String path) {
return path;
}

public HealthCheckResponse doHeatMapHealthCheck() {
if (null != heatMapProvider) {
return heatMapProvider.doHeatMapHealthCheck();
}
return new HealthCheckResponse.Builder("HeatMapProviderImpl class not loaded or initialized.",
Response.Status.OK.getStatusCode()).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.scm.server.OzoneStorageContainerManager;
import org.apache.hadoop.ozone.recon.api.types.EntityMetaData;
import org.apache.hadoop.ozone.recon.api.types.HealthCheckResponse;
import org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager;
import org.apache.hadoop.ozone.recon.spi.ReconNamespaceSummaryManager;

import javax.ws.rs.core.Response;
import java.net.InetSocketAddress;
import java.util.List;

/**
Expand Down Expand Up @@ -65,4 +68,12 @@ void init(OzoneConfiguration ozoneConfiguration,
ReconOMMetadataManager omMetadataManager,
ReconNamespaceSummaryManager namespaceSummaryManager,
OzoneStorageContainerManager reconSCM) throws Exception;

default InetSocketAddress getSolrAddress() {
return null;
}

default HealthCheckResponse doHeatMapHealthCheck() {
return new HealthCheckResponse.Builder("Healthy", Response.Status.OK.getStatusCode()).build();
};
}