[HUDI-1203] add port configuration for EmbeddedTimelineService (#2142)
This commit is contained in:
@@ -103,7 +103,7 @@ public abstract class AbstractHoodieClient implements Serializable, AutoCloseabl
|
||||
LOG.info("Starting Timeline service !!");
|
||||
Option<String> hostAddr = context.getProperty(EngineProperty.EMBEDDED_SERVER_HOST);
|
||||
timelineServer = Option.of(new EmbeddedTimelineService(context, hostAddr.orElse(null),
|
||||
config.getClientSpecifiedViewStorageConfig()));
|
||||
config.getEmbeddedTimelineServerPort(), config.getClientSpecifiedViewStorageConfig()));
|
||||
try {
|
||||
timelineServer.get().startServer();
|
||||
// Allow executor to find this newly instantiated timeline service
|
||||
|
||||
@@ -39,17 +39,19 @@ public class EmbeddedTimelineService {
|
||||
private static final Logger LOG = LogManager.getLogger(EmbeddedTimelineService.class);
|
||||
|
||||
private int serverPort;
|
||||
private int preferredPort;
|
||||
private String hostAddr;
|
||||
private final SerializableConfiguration hadoopConf;
|
||||
private final FileSystemViewStorageConfig config;
|
||||
private transient FileSystemViewManager viewManager;
|
||||
private transient TimelineService server;
|
||||
|
||||
public EmbeddedTimelineService(HoodieEngineContext context, String embeddedTimelineServiceHostAddr, FileSystemViewStorageConfig config) {
|
||||
public EmbeddedTimelineService(HoodieEngineContext context, String embeddedTimelineServiceHostAddr, int embeddedTimelineServerPort, FileSystemViewStorageConfig config) {
|
||||
setHostAddr(embeddedTimelineServiceHostAddr);
|
||||
this.config = config;
|
||||
this.hadoopConf = context.getHadoopConf();
|
||||
this.viewManager = createViewManager();
|
||||
this.preferredPort = embeddedTimelineServerPort;
|
||||
}
|
||||
|
||||
private FileSystemViewManager createViewManager() {
|
||||
@@ -66,7 +68,7 @@ public class EmbeddedTimelineService {
|
||||
}
|
||||
|
||||
public void startServer() throws IOException {
|
||||
server = new TimelineService(0, viewManager, hadoopConf.newCopy());
|
||||
server = new TimelineService(preferredPort, viewManager, hadoopConf.newCopy());
|
||||
serverPort = server.startService();
|
||||
LOG.info("Started embedded timeline server at " + hostAddr + ":" + serverPort);
|
||||
}
|
||||
|
||||
@@ -99,6 +99,8 @@ public class HoodieWriteConfig extends DefaultHoodieConfig {
|
||||
|
||||
public static final String EMBEDDED_TIMELINE_SERVER_ENABLED = "hoodie.embed.timeline.server";
|
||||
public static final String DEFAULT_EMBEDDED_TIMELINE_SERVER_ENABLED = "true";
|
||||
public static final String EMBEDDED_TIMELINE_SERVER_PORT = "hoodie.embed.timeline.server.port";
|
||||
public static final String DEFAULT_EMBEDDED_TIMELINE_SERVER_PORT = "0";
|
||||
|
||||
public static final String FAIL_ON_TIMELINE_ARCHIVING_ENABLED_PROP = "hoodie.fail.on.timeline.archiving";
|
||||
public static final String DEFAULT_FAIL_ON_TIMELINE_ARCHIVING_ENABLED = "true";
|
||||
@@ -255,6 +257,10 @@ public class HoodieWriteConfig extends DefaultHoodieConfig {
|
||||
return Boolean.parseBoolean(props.getProperty(EMBEDDED_TIMELINE_SERVER_ENABLED));
|
||||
}
|
||||
|
||||
public int getEmbeddedTimelineServerPort() {
|
||||
return Integer.parseInt(props.getProperty(EMBEDDED_TIMELINE_SERVER_PORT, DEFAULT_EMBEDDED_TIMELINE_SERVER_PORT));
|
||||
}
|
||||
|
||||
public boolean isFailOnTimelineArchivingEnabled() {
|
||||
return Boolean.parseBoolean(props.getProperty(FAIL_ON_TIMELINE_ARCHIVING_ENABLED_PROP));
|
||||
}
|
||||
@@ -953,6 +959,11 @@ public class HoodieWriteConfig extends DefaultHoodieConfig {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withEmbeddedTimelineServerPort(int port) {
|
||||
props.setProperty(EMBEDDED_TIMELINE_SERVER_PORT, String.valueOf(port));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withBulkInsertSortMode(String mode) {
|
||||
props.setProperty(BULKINSERT_SORT_MODE, mode);
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user