|
|
@ -62,8 +62,10 @@ import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; |
|
|
|
import org.apache.dolphinscheduler.spi.enums.ResourceType; |
|
|
|
import org.apache.dolphinscheduler.spi.enums.ResourceType; |
|
|
|
|
|
|
|
|
|
|
|
import py4j.GatewayServer; |
|
|
|
import py4j.GatewayServer; |
|
|
|
|
|
|
|
import py4j.GatewayServer.GatewayServerBuilder; |
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils; |
|
|
|
import org.apache.commons.collections.CollectionUtils; |
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.net.InetAddress; |
|
|
|
import java.net.InetAddress; |
|
|
@ -657,28 +659,27 @@ public class PythonGateway { |
|
|
|
|
|
|
|
|
|
|
|
@PostConstruct |
|
|
|
@PostConstruct |
|
|
|
public void init() { |
|
|
|
public void init() { |
|
|
|
if (pythonGatewayConfiguration.getEnabled()) { |
|
|
|
if (pythonGatewayConfiguration.isEnabled()) { |
|
|
|
this.start(); |
|
|
|
this.start(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void start() { |
|
|
|
private void start() { |
|
|
|
GatewayServer server; |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
InetAddress gatewayHost = InetAddress.getByName(pythonGatewayConfiguration.getGatewayServerAddress()); |
|
|
|
InetAddress gatewayHost = InetAddress.getByName(pythonGatewayConfiguration.getGatewayServerAddress()); |
|
|
|
InetAddress pythonHost = InetAddress.getByName(pythonGatewayConfiguration.getPythonAddress()); |
|
|
|
GatewayServerBuilder serverBuilder = new GatewayServer.GatewayServerBuilder() |
|
|
|
server = new GatewayServer( |
|
|
|
.entryPoint(this) |
|
|
|
this, |
|
|
|
.javaAddress(gatewayHost) |
|
|
|
pythonGatewayConfiguration.getGatewayServerPort(), |
|
|
|
.javaPort(pythonGatewayConfiguration.getGatewayServerPort()) |
|
|
|
pythonGatewayConfiguration.getPythonPort(), |
|
|
|
.connectTimeout(pythonGatewayConfiguration.getConnectTimeout()) |
|
|
|
gatewayHost, |
|
|
|
.readTimeout(pythonGatewayConfiguration.getReadTimeout()); |
|
|
|
pythonHost, |
|
|
|
if (!StringUtils.isEmpty(pythonGatewayConfiguration.getAuthToken())) { |
|
|
|
pythonGatewayConfiguration.getConnectTimeout(), |
|
|
|
serverBuilder.authToken(pythonGatewayConfiguration.getAuthToken()); |
|
|
|
pythonGatewayConfiguration.getReadTimeout(), |
|
|
|
} |
|
|
|
null); |
|
|
|
|
|
|
|
GatewayServer.turnLoggingOn(); |
|
|
|
GatewayServer.turnLoggingOn(); |
|
|
|
logger.info("PythonGatewayService started on: " + gatewayHost.toString()); |
|
|
|
logger.info("PythonGatewayService started on: " + gatewayHost.toString()); |
|
|
|
server.start(); |
|
|
|
serverBuilder.build().start(); |
|
|
|
} catch (UnknownHostException e) { |
|
|
|
} catch (UnknownHostException e) { |
|
|
|
logger.error("exception occurred while constructing PythonGatewayService().", e); |
|
|
|
logger.error("exception occurred while constructing PythonGatewayService().", e); |
|
|
|
} |
|
|
|
} |
|
|
|