fx19880617 commented on a change in pull request #5266: URL: https://github.com/apache/incubator-pinot/pull/5266#discussion_r429119690
########## File path: pinot-tools/src/main/java/org/apache/pinot/tools/service/api/resources/PinotServiceManagerInstanceResource.java ########## @@ -0,0 +1,241 @@ +/** + * 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.pinot.tools.service.api.resources; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.inject.Inject; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.apache.commons.configuration.Configuration; +import org.apache.commons.configuration.PropertiesConfiguration; +import org.apache.pinot.common.utils.CommonConstants; +import org.apache.pinot.common.utils.NetUtil; +import org.apache.pinot.controller.ControllerConf; +import org.apache.pinot.spi.services.ServiceRole; +import org.apache.pinot.spi.utils.JsonUtils; +import org.apache.pinot.tools.service.PinotServiceManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.apache.pinot.common.utils.CommonConstants.Controller.CONFIG_OF_CONTROLLER_METRICS_PREFIX; +import static org.apache.pinot.common.utils.CommonConstants.Controller.DEFAULT_METRICS_PREFIX; +import static org.apache.pinot.tools.utils.PinotConfigUtils.TMP_DIR; +import static org.apache.pinot.tools.utils.PinotConfigUtils.getAvailablePort; + + +@Api(tags = "Startable") +@Path("/") +public class PinotServiceManagerInstanceResource { + + private static final Logger LOGGER = LoggerFactory.getLogger(PinotServiceManagerInstanceResource.class); + + @Inject + private PinotServiceManager _pinotServiceManager; + + @GET + @Produces(MediaType.APPLICATION_JSON) + @Path("/instances") + @ApiOperation(value = "Get Pinot Instances Status") + @ApiResponses(value = {@ApiResponse(code = 200, message = "Instance Status"), @ApiResponse(code = 500, message = "Internal server error")}) + public Map<String, PinotInstanceStatus> getPinotAllInstancesStatus() { + Map<String, PinotInstanceStatus> results = new HashMap<>(); + for (String instanceId : _pinotServiceManager.getRunningInstanceIds()) { + results.put(instanceId, _pinotServiceManager.getInstanceStatus(instanceId)); + } + return results; + } + + @GET + @Produces(MediaType.APPLICATION_JSON) + @Path("/instances/{instanceName}") + @ApiOperation(value = "Get Pinot Instance Status") + @ApiResponses(value = {@ApiResponse(code = 200, message = "Instance Status"), @ApiResponse(code = 404, message = "Instance Not Found"), @ApiResponse(code = 500, message = "Internal server error")}) + public PinotInstanceStatus getPinotInstanceStatus( + @ApiParam(value = "Name of the instance") @PathParam("instanceName") String instanceName) { + List<String> instanceIds = _pinotServiceManager.getRunningInstanceIds(); + if (instanceIds.contains(instanceName)) { + return _pinotServiceManager.getInstanceStatus(instanceName); + } + throw new WebApplicationException(String.format("Instance [%s] not found.", instanceName), + Response.Status.NOT_FOUND); + } + + @DELETE Review comment: added `stopAllPinotInstances` and `stopPinotInstancesByRole` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org