[HUDI-603]: DeltaStreamer can now fetch schema before every run in continuous mode (#1566)
Co-authored-by: Balaji Varadarajan <balaji.varadarajan@robinhood.com>
This commit is contained in:
@@ -161,4 +161,8 @@ public abstract class AsyncCompactService extends HoodieAsyncService {
|
||||
protected boolean shouldStopCompactor() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public synchronized void updateWriteClient(AbstractHoodieWriteClient writeClient) {
|
||||
this.compactor.updateWriteClient(writeClient);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,4 +38,9 @@ public abstract class AbstractCompactor<T extends HoodieRecordPayload, I, K, O>
|
||||
}
|
||||
|
||||
public abstract void compact(HoodieInstant instant) throws IOException;
|
||||
|
||||
public void updateWriteClient(AbstractHoodieWriteClient<T, I, K, O> writeClient) {
|
||||
this.compactionClient = writeClient;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
|
||||
package org.apache.hudi.client;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
|
||||
import org.apache.hudi.client.common.EngineProperty;
|
||||
import org.apache.hudi.client.embedded.EmbeddedTimelineServerHelper;
|
||||
import org.apache.hudi.client.embedded.EmbeddedTimelineService;
|
||||
import org.apache.hudi.client.common.HoodieEngineContext;
|
||||
import org.apache.hudi.common.fs.FSUtils;
|
||||
@@ -29,6 +27,7 @@ import org.apache.hudi.common.table.timeline.versioning.TimelineLayoutVersion;
|
||||
import org.apache.hudi.common.util.Option;
|
||||
import org.apache.hudi.config.HoodieWriteConfig;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.FileSystem;
|
||||
import org.apache.log4j.LogManager;
|
||||
import org.apache.log4j.Logger;
|
||||
@@ -100,14 +99,8 @@ public abstract class AbstractHoodieClient implements Serializable, AutoCloseabl
|
||||
if (config.isEmbeddedTimelineServerEnabled()) {
|
||||
if (!timelineServer.isPresent()) {
|
||||
// Run Embedded Timeline Server
|
||||
LOG.info("Starting Timeline service !!");
|
||||
Option<String> hostAddr = context.getProperty(EngineProperty.EMBEDDED_SERVER_HOST);
|
||||
timelineServer = Option.of(new EmbeddedTimelineService(context, hostAddr.orElse(null),
|
||||
config.getEmbeddedTimelineServerPort(), config.getClientSpecifiedViewStorageConfig()));
|
||||
try {
|
||||
timelineServer.get().startServer();
|
||||
// Allow executor to find this newly instantiated timeline service
|
||||
config.setViewStorageConfig(timelineServer.get().getRemoteFileSystemViewConfig());
|
||||
timelineServer = EmbeddedTimelineServerHelper.createEmbeddedTimelineService(context, config);
|
||||
} catch (IOException e) {
|
||||
LOG.warn("Unable to start timeline service. Proceeding as if embedded server is disabled", e);
|
||||
stopEmbeddedServerView(false);
|
||||
@@ -129,4 +122,8 @@ public abstract class AbstractHoodieClient implements Serializable, AutoCloseabl
|
||||
config.getConsistencyGuardConfig(),
|
||||
Option.of(new TimelineLayoutVersion(config.getTimelineLayoutVersion())));
|
||||
}
|
||||
|
||||
public Option<EmbeddedTimelineService> getTimelineServer() {
|
||||
return timelineServer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.hudi.client.embedded;
|
||||
|
||||
import org.apache.hudi.client.common.EngineProperty;
|
||||
import org.apache.hudi.client.common.HoodieEngineContext;
|
||||
import org.apache.hudi.common.util.Option;
|
||||
import org.apache.hudi.config.HoodieWriteConfig;
|
||||
|
||||
import org.apache.log4j.LogManager;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Helper class to instantiate embedded timeline service.
|
||||
*/
|
||||
public class EmbeddedTimelineServerHelper {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(EmbeddedTimelineService.class);
|
||||
|
||||
/**
|
||||
* Instantiate Embedded Timeline Server.
|
||||
* @param context Hoodie Engine Context
|
||||
* @param config Hoodie Write Config
|
||||
* @return TimelineServer if configured to run
|
||||
* @throws IOException
|
||||
*/
|
||||
public static Option<EmbeddedTimelineService> createEmbeddedTimelineService(
|
||||
HoodieEngineContext context, HoodieWriteConfig config) throws IOException {
|
||||
Option<EmbeddedTimelineService> timelineServer = Option.empty();
|
||||
if (config.isEmbeddedTimelineServerEnabled()) {
|
||||
// Run Embedded Timeline Server
|
||||
LOG.info("Starting Timeline service !!");
|
||||
Option<String> hostAddr = context.getProperty(EngineProperty.EMBEDDED_SERVER_HOST);
|
||||
timelineServer = Option.of(new EmbeddedTimelineService(context, hostAddr.orElse(null),
|
||||
config.getEmbeddedTimelineServerPort(), config.getClientSpecifiedViewStorageConfig()));
|
||||
timelineServer.get().startServer();
|
||||
updateWriteConfigWithTimelineServer(timelineServer.get(), config);
|
||||
}
|
||||
return timelineServer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts hoodie write config with timeline server settings.
|
||||
* @param timelineServer Embedded Timeline Server
|
||||
* @param config Hoodie Write Config
|
||||
*/
|
||||
public static void updateWriteConfigWithTimelineServer(EmbeddedTimelineService timelineServer,
|
||||
HoodieWriteConfig config) {
|
||||
// Allow executor to find this newly instantiated timeline service
|
||||
if (config.isEmbeddedTimelineServerEnabled()) {
|
||||
config.setViewStorageConfig(timelineServer.getRemoteFileSystemViewConfig());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user