Skip to content
This repository was archived by the owner on Apr 15, 2022. It is now read-only.

Commit cb5657a

Browse files
authored
Merge pull request #8 from splicemachine/DBAAS-2396
DBAAS-2396: Made fix to jdbc url and try/catch for creating url
2 parents 590ade6 + 43136ac commit cb5657a

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

splicemachine/spark/context.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -217,27 +217,20 @@ class SpliceMLContext(PySpliceContext):
217217
on the Cloud Service (Zeppelin Notebook), this class
218218
does many things for ease of use.
219219
"""
220-
@staticmethod
221-
def get_jdbc_url():
222-
"""
223-
Get the JDBC Url for the current cluster (internal w/ no timeout)
224-
:return: (string) jdbc url
225-
"""
226-
import os
227-
framework = os.environ['FRAMEWORK_NAME']
228-
return 'jdbc:splice://{framework}-proxy.marathon.mesos:1527/splicedb'.format(
229-
framework=framework)
230-
231220
def __init__(self, sparkSession, useH2O=False, _unit_testing=False):
232221
"""
233-
"Automagically" find the JDBC URL and establish a connection
222+
Automatically find the JDBC URL and establish a connection
234223
to the current Splice Machine database
235224
:param sparkSession: the sparksession object
236225
:param useH2O: whether or not to
237226
:param _unit_testing: whether or not we are unit testing
238227
"""
239-
PySpliceContext.__init__(self, self.get_jdbc_url(), sparkSession, _unit_testing)
240-
228+
try:
229+
url = os.environ['JDBC_URL']
230+
PySpliceContext.__init__(self, url, sparkSession, _unit_testing)
231+
except:
232+
print('The SpliceMLContext is only for use on the cloud service. Please import and use the PySpliceContext instead.\nUsage:\n\tfrom splicemachine.spark.context import PySpliceContext\n\tsplice = PySpliceContext(jdbc_url, sparkSession)')
233+
return -1
241234
if useH2O:
242235
from pysparkling import H2OConf, H2OContext
243236
h2oConf = H2OConf(sparkSession)

0 commit comments

Comments
 (0)