You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gobblin.apache.org by GitBox <gi...@apache.org> on 2019/12/20 22:59:17 UTC

[GitHub] [incubator-gobblin] Will-Lo opened a new pull request #2854: Create load balancer

Will-Lo opened a new pull request #2854: Create load balancer
URL: https://github.com/apache/incubator-gobblin/pull/2854
 
 
   Dear Gobblin maintainers,
   
   Please accept this PR. I understand that it will not be reviewed until I have checked off all the steps below!
   
   
   ### JIRA
   - [ ] My PR addresses the following [Gobblin JIRA](https://issues.apache.org/jira/browse/GOBBLIN/) issues and references them in the PR title. For example, "[GOBBLIN-XXX] My Gobblin PR"
       - https://issues.apache.org/jira/browse/GOBBLIN-XXX
   
   
   ### Description
   - [ ] Here are some details about my PR, including screenshots (if applicable):
   
   
   ### Tests
   - [ ] My PR adds the following unit tests __OR__ does not need testing for this extremely good reason:
   
   
   ### Commits
   - [ ] My commits all reference JIRA issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
       1. Subject is separated from body by a blank line
       2. Subject is limited to 50 characters
       3. Subject does not end with a period
       4. Subject uses the imperative mood ("add", not "adding")
       5. Body wraps at 72 characters
       6. Body explains "what" and "why", not "how"
   
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-gobblin] zxcware commented on a change in pull request #2854: [GOBBLIN-1009] Create load balancer for Gobblin Service

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-gobblin] zxcware commented on a change in pull request #2854: [GOBBLIN-1009] Create load balancer for Gobblin Service

Posted by GitBox <gi...@apache.org>.
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_r360614255
 
 

 ##########
 File path: gobblin-service-loadbalancer/src/main/java/org/apache/gobblin/service/loadbalancer/GobblinServiceLoadBalancer.java
 ##########
 @@ -0,0 +1,57 @@
+package org.apache.gobblin.service.loadbalancer;
+
+import com.google.common.base.Optional;
+import com.typesafe.config.Config;
+import com.typesafe.config.ConfigFactory;
+import org.apache.gobblin.runtime.app.ApplicationException;
+import org.apache.gobblin.runtime.app.ApplicationLauncher;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class GobblinServiceLoadBalancer implements ApplicationLauncher {
+  private Server server;
 
 Review comment:
   Try if we can merge Load Balancing into the `nginx` server container. We might need create a load balancing image on top of an nginx image.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-gobblin] zxcware commented on a change in pull request #2854: [GOBBLIN-1009] Create load balancer for Gobblin Service

Posted by GitBox <gi...@apache.org>.
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_r360614396
 
 

 ##########
 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();
+    this.client.start();
+  }
+
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) {
 
 Review comment:
   Is this an `override`? If so, let's add `@override` annotation for better code readability, avoiding future readers asking this question. This one applies to the other methods

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-gobblin] Will-Lo closed pull request #2854: [GOBBLIN-1009] Create load balancer for Gobblin Service

Posted by GitBox <gi...@apache.org>.
Will-Lo closed pull request #2854:
URL: https://github.com/apache/incubator-gobblin/pull/2854


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [incubator-gobblin] Will-Lo closed pull request #2854: [GOBBLIN-1009] Create load balancer for Gobblin Service

Posted by GitBox <gi...@apache.org>.
Will-Lo closed pull request #2854:
URL: https://github.com/apache/incubator-gobblin/pull/2854


   


----------------------------------------------------------------
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:
users@infra.apache.org