Skip to content

Commit

Permalink
Hop server enhancement apache#4569
Browse files Browse the repository at this point in the history
- add command line options for (host, port, shutdownport, proxyhost,
proxyport,ssl)
- support for override properties on the command line
- add shutdown listener to web server
- add shutdown servlet
- add RemoteHopServer class to interact with a Hop server and clean
HopServerMeta
- remove setup hop server syntax by hostname and port
- add HopServerTerminate extension point after shutdown
- all HopServerXXX extension points now provide a HopServer object,
rather than a HopServer/WebServer mix
  • Loading branch information
nadment committed Nov 15, 2024
1 parent a0c412d commit b8e504a
Show file tree
Hide file tree
Showing 23 changed files with 1,425 additions and 1,489 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ public enum HopExtensionPoint {
BeforeCheckTransform("Right before a transform is about to be verified."),
AfterCheckTransform("After a transform has been checked for warnings/errors."),

HopServerInit("Right before the Hop webserver starts"),
HopServerStartup("Right after the Hop webserver has started and is fully functional"),
HopServerShutdown("Right before the Hop webserver will shut down"),
HopServerInit("Right before the Hop server starts"),
HopServerStartup("Right after the Hop server has started and is fully functional"),
HopServerShutdown("Right before the Hop server will shut down"),
HopServerTerminate("Right after the Hop server will shut down"),
HopServerCalculateFilename(
"Right after the server configuration filename is determined, before it is used"),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.apache.hop.core.annotations.HopServerServlet;
import org.apache.hop.www.IHopServerPlugin;

/** This class represents the carte plugin type. */
/** This class represents the Hop server plugin type. */
@PluginMainClassType(IHopServerPlugin.class)
@PluginAnnotationType(HopServerServlet.class)
public class HopServerPluginType extends BasePluginType<HopServerServlet> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.apache.hop.server.HopServerMeta;
import org.apache.hop.www.GetExecutionInfoServlet;
import org.apache.hop.www.RegisterExecutionInfoServlet;
import org.apache.hop.www.RemoteHopServer;
import org.apache.http.client.utils.URIBuilder;

@GuiPlugin(description = "File execution information location GUI elements")
Expand Down Expand Up @@ -81,7 +82,7 @@ public class RemoteExecutionInfoLocation implements IExecutionInfoLocation {
@HopMetadataProperty(key = "location")
protected String locationName;

private HopServerMeta server;
private RemoteHopServer server;
private ExecutionInfoLocation location;
private IVariables variables;

Expand All @@ -105,9 +106,11 @@ public void initialize(IVariables variables, IHopMetadataProvider metadataProvid
this.variables = variables;
try {
if (StringUtils.isNotEmpty(serverName)) {
server =
HopServerMeta serverMeta =
metadataProvider.getSerializer(HopServerMeta.class).load(variables.resolve(serverName));
server = new RemoteHopServer(serverMeta);
}

if (StringUtils.isNotEmpty(locationName)) {
location =
metadataProvider
Expand Down Expand Up @@ -488,15 +491,6 @@ public void setPluginName(String pluginName) {
this.pluginName = pluginName;
}

/**
* Gets server
*
* @return value of server
*/
public HopServerMeta getServer() {
return server;
}

/**
* Gets serverName
*
Expand Down Expand Up @@ -551,15 +545,6 @@ public void setVariables(IVariables variables) {
this.variables = variables;
}

/**
* Sets server
*
* @param server value of server
*/
public void setServer(HopServerMeta server) {
this.server = server;
}

/**
* Gets location
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import org.apache.hop.www.PrepareExecutionPipelineServlet;
import org.apache.hop.www.RegisterPackageServlet;
import org.apache.hop.www.RegisterPipelineServlet;
import org.apache.hop.www.RemoteHopServer;
import org.apache.hop.www.SniffTransformServlet;
import org.apache.hop.www.StartExecutionPipelineServlet;
import org.apache.hop.www.WebResult;
Expand Down Expand Up @@ -126,7 +127,7 @@ public class RemotePipelineEngine extends Variables implements IPipelineEngine<P
protected EngineMetrics engineMetrics;
protected Result previousResult;

protected HopServerMeta hopServer;
protected RemoteHopServer hopServer;

protected ILoggingObject parent;
protected IPipelineEngine<PipelineMeta> parentPipeline;
Expand Down Expand Up @@ -242,10 +243,12 @@ public void prepareExecution() throws HopException {
serverPollInterval =
Const.toLong(resolve(remotePipelineRunConfiguration.getServerPollInterval()), 2000L);

hopServer = metadataProvider.getSerializer(HopServerMeta.class).load(hopServerName);
if (hopServer == null) {
HopServerMeta hopServerMeta =
metadataProvider.getSerializer(HopServerMeta.class).load(hopServerName);
if (hopServerMeta == null) {
throw new HopException("Hop server '" + hopServerName + "' could not be found");
}
hopServer = new RemoteHopServer(hopServerMeta);

PipelineExecutionConfiguration pipelineExecutionConfiguration =
new PipelineExecutionConfiguration();
Expand Down Expand Up @@ -308,7 +311,7 @@ private void sendToHopServer(

executionConfiguration.getParametersMap().putAll(params);

hopServer.getLogChannel().setLogLevel(executionConfiguration.getLogLevel());
hopServer.getLog().setLogLevel(executionConfiguration.getLogLevel());

try {
if (remotePipelineRunConfiguration.isExportingResources()) {
Expand Down Expand Up @@ -502,7 +505,7 @@ public void run() {
private synchronized void getPipelineStatus() throws RuntimeException {
try {
HopServerPipelineStatus pipelineStatus =
hopServer.getPipelineStatus(this, subject.getName(), containerId, lastLogLineNr);
hopServer.requestPipelineStatus(this, subject.getName(), containerId, lastLogLineNr);
synchronized (engineMetrics) {
hasHaltedComponents = false;
engineMetrics.setStartDate(pipelineStatus.getExecutionStartDate());
Expand Down Expand Up @@ -648,7 +651,7 @@ public void waitUntilFinished() {
@Override
public void stopAll() {
try {
hopServer.stopPipeline(this, subject.getName(), containerId);
hopServer.requestStopPipeline(this, subject.getName(), containerId);
getPipelineStatus();
} catch (Exception e) {
throw new RuntimeException(
Expand All @@ -664,7 +667,7 @@ public boolean hasHaltedComponents() {
@Override
public void pauseExecution() {
try {
hopServer.pauseResumePipeline(this, subject.getName(), containerId);
hopServer.requestPauseResumePipeline(this, subject.getName(), containerId);
getPipelineStatus();
} catch (Exception e) {
throw new RuntimeException(
Expand Down Expand Up @@ -1328,22 +1331,6 @@ public void setLogChannel(ILogChannel log) {
this.logChannel = log;
}

/**
* Gets Hop server metadata
*
* @return value of Hop server
*/
public HopServerMeta getHopServer() {
return hopServer;
}

/**
* @param hopServer The hopServer to set
*/
public void setHopServer(HopServerMeta hopServer) {
this.hopServer = hopServer;
}

/**
* Gets engineMetrics
*
Expand Down
Loading

0 comments on commit b8e504a

Please sign in to comment.