n3nash commented on a change in pull request #600:  Timeline Service with 
Incremental View Syncing support
URL: https://github.com/apache/incubator-hudi/pull/600#discussion_r271905880
 
 

 ##########
 File path: hoodie-client/src/main/java/com/uber/hoodie/HoodieBaseClient.java
 ##########
 @@ -0,0 +1,96 @@
+/*
+ *  Copyright (c) 2018 Uber Technologies, Inc. (hoodie-dev-gr...@uber.com)
+ *
+ *  Licensed 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 com.uber.hoodie;
+
+import com.uber.hoodie.common.util.FSUtils;
+import com.uber.hoodie.config.HoodieWriteConfig;
+import com.uber.hoodie.func.EmbeddedTimelineServer;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.List;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.apache.spark.api.java.JavaSparkContext;
+
+public class HoodieBaseClient implements Serializable {
+
+  private static final Logger logger = 
LogManager.getLogger(HoodieBaseClient.class);
+
+  protected final transient FileSystem fs;
+  protected final transient JavaSparkContext jsc;
+  protected final HoodieWriteConfig config;
+  protected final String basePath;
+
+  /**
+   * Timeline Server has the same lifetime as that of Client.
+   * Any operations done on the same timeline service will be able to take 
advantage
+   * of the cached file-system view. New completed actions will be synced 
automatically
+   * in an incremental fashion.
+   */
+  private transient EmbeddedTimelineServer timelineServer;
+
+  protected HoodieBaseClient(JavaSparkContext jsc, HoodieWriteConfig 
clientConfig) {
+    this.fs = FSUtils.getFs(clientConfig.getBasePath(), 
jsc.hadoopConfiguration());
+    this.jsc = jsc;
+    this.basePath = clientConfig.getBasePath();
+    this.config = clientConfig;
+  }
+
+  /**
+   * Releases any resources used by the client.
+   */
+  public void close() {
+    stopEmbeddedServerView();
+  }
+
+  private void stopEmbeddedServerView() {
+    if (timelineServer != null) {
+      logger.info("Stopping Timeline service in driver !!");
+      timelineServer.stop();
+      timelineServer = null;
+      // Reset Storage Config to Client specified config
+      config.resetViewStorageConfig();
+    }
+  }
+
+  public void startEmbeddedServerView(List<String> partitions) {
+    if (config.isEmbeddedTimelineServerEnabled()) {
+      if (timelineServer == null) {
+        // Run Embedded Timeline Server
+        logger.info("Starting Timeline service in driver !!");
+        timelineServer = new EmbeddedTimelineServer(jsc.hadoopConfiguration(), 
config);
+        boolean success = timelineServer.preloadNeededPartitions(jsc, 
partitions);
+        if (!success) {
+          logger.warn("Unable to preload partitions. Proceeding as if embedded 
server is disabled");
 
 Review comment:
   Should we stop the `timelineServer` and set it to null here ?

----------------------------------------------------------------
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


With regards,
Apache Git Services

Reply via email to