Skip to content

Commit

Permalink
#1431 removed callback
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjapapa committed Oct 26, 2018
1 parent 794a816 commit 7ed7408
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 53 deletions.
29 changes: 0 additions & 29 deletions src/main/python/smv/smvapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
from smv.utils import smv_copy_array, check_socket, scala_seq_to_list
from smv.error import SmvRuntimeError, SmvDqmValidationError
import smv.helpers
from smv.utils import FileObjInputStream
from smv.runinfo import SmvRunInfoCollector
from smv.modulesvisitor import ModulesVisitor
from smv.smvmodulerunner import SmvModuleRunner
Expand Down Expand Up @@ -129,34 +128,6 @@ def __init__(self, arglist, _sparkSession = None):
# issue #429 set application name from smv config
sc._conf.setAppName(self.appName())

# user may choose a port for the callback server
gw = sc._gateway
cbsp = self.cmd_line.cbsPort
cbs_port = cbsp if cbsp is not None else gw._python_proxy_port

# check wither the port is in-use or not for several times - if all fail, error out
check_counter = 0
while(not check_socket(cbs_port) and check_counter < int(self.maxCbsPortRetries())):
cbs_port += 1
check_counter += 1

if (not check_socket(cbs_port)):
raise SmvRuntimeError("Start Python callback server failed. Port {0}-{1} are all in use. Please consider increasing the maximum retries or overriding the default port.".format(cbs_port - check_counter, cbs_port))

if "_callback_server" not in gw.__dict__ or gw._callback_server is None:
print("Starting Py4j callback server on port {0}".format(cbs_port))
gw.callback_server_parameters.eager_load = True
gw.callback_server_parameters.daemonize = True
gw.callback_server_parameters.daemonize_connections = True
gw.callback_server_parameters.port = cbs_port
gw.start_callback_server(gw.callback_server_parameters)
gw._callback_server.port = cbs_port
gw._python_proxy_port = gw._callback_server.port
# get the GatewayServer object in JVM by ID
jgws = JavaObject("GATEWAY_SERVER", gw._gateway_client)
# update the port of CallbackClient with real port
gw.jvm.SmvPythonHelper.updatePythonGatewayPort(jgws, gw._python_proxy_port)

self.repoFactory = DataSetRepoFactory(self)
self.dsm.register(self.repoFactory)

Expand Down
24 changes: 0 additions & 24 deletions src/main/python/smv/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,30 +111,6 @@ def infer_full_name_from_part(full_names, part_name):
else:
raise SmvRuntimeError("Partial name {} is ambiguous".format(part_name))

class FileObjInputStream(object):
"""Wraps a Python binary file object to be used like a java.io.InputStream."""

def __init__(self, fileobj):
self.fileobj = fileobj

def read(self, maxsize):
buf = self.fileobj.read(maxsize)
# The following should work in both Python 2.7 and 3.5.
#
# In 2.7, read() returns a str even in 'rb' mode, but calling
# bytearray converts it to the right type.
#
# In 3.5, read() returns a bytes in 'rb' mode, and calling
# bytearray does not require a specified encoding
buf = bytearray(buf)
return buf

def close(self):
self.fileobj.close()

class Java:
implements = ['org.tresamigos.smv.IAnyInputStream']

# If using Python 2, prefer cPickle because it is faster
# If using Python 3, there is no cPickle (cPickle is now the implementation of pickle)
# see https://docs.python.org/3.1/whatsnew/3.0.html#library-changes
Expand Down

0 comments on commit 7ed7408

Please sign in to comment.