gianm commented on a change in pull request #6567: Overlord console - add enable/disable button for remote workers URL: https://github.com/apache/incubator-druid/pull/6567#discussion_r237030662
########## File path: indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/RemoteWorkerProxyResource.java ########## @@ -0,0 +1,107 @@ +/* + * 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.druid.indexing.overlord.http; + +import com.sun.jersey.spi.container.ResourceFilters; +import org.apache.druid.guice.annotations.EscalatedGlobal; +import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.java.util.http.client.HttpClient; +import org.apache.druid.java.util.http.client.Request; +import org.apache.druid.java.util.http.client.response.StatusResponseHandler; +import org.apache.druid.java.util.http.client.response.StatusResponseHolder; +import org.apache.druid.server.http.security.ConfigResourceFilter; +import org.jboss.netty.handler.codec.http.HttpMethod; + +import javax.inject.Inject; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.net.URI; +import java.net.URL; +import java.nio.charset.StandardCharsets; + +@Path("/druid/indexer/v1/remote-worker") +public class RemoteWorkerProxyResource +{ + private static final Logger log = new Logger(RemoteWorkerProxyResource.class); + + private final HttpClient httpClient; + private static final StatusResponseHandler RESPONSE_HANDLER = new StatusResponseHandler(StandardCharsets.UTF_8); + + @Inject + public RemoteWorkerProxyResource(@EscalatedGlobal final HttpClient httpClient) + { + this.httpClient = httpClient; + } + + @POST + @Path("/{scheme}/{host}/disable") + @Produces(MediaType.APPLICATION_JSON) + @ResourceFilters(ConfigResourceFilter.class) + public Response doDisable( + @PathParam("scheme") final String scheme, + @PathParam("host") final String host + ) + { + return sendRequestToWorker(scheme, host, "/druid/worker/v1/disable", "Failed to disable worker!"); + } + + @POST + @Path("/{scheme}/{host}/enable") + @Produces(MediaType.APPLICATION_JSON) + @ResourceFilters(ConfigResourceFilter.class) + public Response doEnable( + @PathParam("scheme") final String scheme, + @PathParam("host") final String host Review comment: We should verify that the `host` is actually one of our workers. Otherwise this endpoint allows you to get the overlord to proxy to _anything_, which would not be desired. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
