/** * <p> * Builds a GatewayServer instance using the provided parameters. If gateway is provided, * some parameters will be ignored (callbackClient and entryPoint). * </p> * * @return */ public GatewayServer build() { if (gateway == null) { if (callbackClient == null) { callbackClient = new CallbackClient(GatewayServer.DEFAULT_PYTHON_PORT); } return new GatewayServer(entryPoint, javaPort, javaAddress, connectTimeout, readTimeout, customCommands, callbackClient, serverSocketFactory, authToken); } else { return new GatewayServer(gateway, javaPort, javaAddress, connectTimeout, readTimeout, customCommands, serverSocketFactory, authToken); } }
/** * @param args */ public static void main(String[] args) { GatewayServer server = new GatewayServer(new Object()); server.start(); }
@Override public void run(CommandLine line, ToolRunningContext context) throws Exception { GatewayServer server = new GatewayServer(); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { System.out.println(); System.out.println("Shutting down py-powsybl server"); server.shutdown(); } }); // execute the py4j Gateway service //TODO customize service parameters: address, port, ..... server.start(); System.out.println("py-powsybl server started; CTRL+C to stop it"); } }
/** * Starts a Py4j gateway server. * * @param portFile the file to have the gateway server listening port (in string format) written to * @return the gateway server * @throws IOException if failed to start the server or failed to write out the port. */ public static GatewayServer startPy4jGateway(Path portFile) throws IOException { GatewayServer server = new GatewayServer(null, 0); try { server.start(); } catch (Py4JNetworkException e) { throw new IOException(e); } // Write the port number in string form to the port file Files.write(portFile, Integer.toString(server.getListeningPort()).getBytes(StandardCharsets.UTF_8)); return server; } }
/** * Starts a Py4j gateway server. * * @param portFile the file to have the gateway server listening port (in string format) written to * @return the gateway server * @throws IOException if failed to start the server or failed to write out the port. */ public static GatewayServer startPy4jGateway(Path portFile) throws IOException { GatewayServer server = new GatewayServer(null, 0); try { server.start(); } catch (Py4JNetworkException e) { throw new IOException(e); } // Write the port number in string form to the port file Files.write(portFile, Integer.toString(server.getListeningPort()).getBytes(StandardCharsets.UTF_8)); return server; } }
/** * Starts a Py4j gateway server. * * @param portFile the file to have the gateway server listening port (in string format) written to * @return the gateway server * @throws IOException if failed to start the server or failed to write out the port. */ public static GatewayServer startPy4jGateway(Path portFile) throws IOException { GatewayServer server = new GatewayServer(null, 0); try { server.start(); } catch (Py4JNetworkException e) { throw new IOException(e); } // Write the port number in string form to the port file Files.write(portFile, Integer.toString(server.getListeningPort()).getBytes(StandardCharsets.UTF_8)); return server; } }
//AdditionApplication.java import py4j.GatewayServer; public class AdditionApplication { public static void main(String[] args) { AdditionApplication app = new AdditionApplication(); // app is now the gateway.entry_point GatewayServer server = new GatewayServer(app); server.start(); } }
import py4j.GatewayServer; public class myTest { public static void main(String[] args) { myTest app = new myTest(); // app is now the gateway.entry_point GatewayServer server = new GatewayServer(app); server.start(); } }
public static void main(String[] args) { GatewayServer gatewayServer = new GatewayServer(new DeepLearning4jEntryPoint()); gatewayServer.start(); log.info("DeepLearning4j Gateway server running"); } }
public static void main(String[] args) { server = new GatewayServer(new PythonImporter()); server.start(); log.info("Py4jServer has started!!!!"); } }
GatewayServer server = new GatewayServer(tp); server.start();
int gatewayServerPort = gatewayServerSocket.getLocalPort(); GatewayServer pyServer = new GatewayServer(this, gatewayServerPort); gatewayServerSocket.close(); pyServer.start();
LOG.info("Setting up TensorFlow job..."); GatewayServer pyServer = new GatewayServer(executor, executor.gatewayServerPort); pyServer.start(); executor.shellEnv.put(Constants.PY4JGATEWAY, String.valueOf(executor.gatewayServerPort));