zxcware commented on a change in pull request #2854: [GOBBLIN-1009] Create load
balancer for Gobblin Service
URL: https://github.com/apache/incubator-gobblin/pull/2854#discussion_r360615747
##########
File path:
gobblin-service-loadbalancer/src/main/java/org/apache/gobblin/service/loadbalancer/ForwardRequestServlet.java
##########
@@ -0,0 +1,174 @@
+package org.apache.gobblin.service.loadbalancer;
+
+import com.google.common.base.Optional;
+import com.typesafe.config.Config;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Enumeration;
+import java.util.concurrent.Future;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletException;
+import org.apache.commons.io.IOUtils;
+import org.apache.gobblin.util.HashingUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
+import org.apache.http.impl.nio.client.HttpAsyncClients;
+import org.apache.http.protocol.HTTP;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class ForwardRequestServlet extends HttpServlet {
+
+ public CloseableHttpAsyncClient client;
+
+ private final String STATEFULSET_URL_PREFIX = "http://gaas-";
+ // TODO: split this up into configuration or something
+ private final String STATEFULSET_URL_SUFFIX =
".gaas.default.svc.cluster.local:6956";
+ private final String LOADBALANCER_PREFIX = "gobblinServiceLoadbalancer.";
+ private final String NUM_SCHEDULERS_KEY = "numSchedulers";
+ private final String FLOW_NAME_KEY = "flowName";
+ private final String FLOW_GROUP_KEY = "flowGroup";
+ private int numSchedulers;
+ protected final Logger _log;
+
+ ForwardRequestServlet(Config config, Optional<Logger> log) {
+ _log = log.isPresent() ? log.get() : LoggerFactory.getLogger(getClass());
+ this.numSchedulers = config.getInt(LOADBALANCER_PREFIX +
NUM_SCHEDULERS_KEY);
+ _log.info("Load balancer started with {} servers", this.numSchedulers);
+ this.client = HttpAsyncClients.createDefault();
Review comment:
We might be able to leverage `request.getRequestDispatcher` to forward
request instead of using a client.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services