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

Commit

Permalink
Merge pull request #8 from splicemachine/DBAAS-2396
Browse files Browse the repository at this point in the history
DBAAS-2396: Made fix to jdbc url and try/catch for creating url
  • Loading branch information
Ben-Epstein authored Apr 16, 2019
2 parents 590ade6 + 43136ac commit cb5657a
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions splicemachine/spark/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,27 +217,20 @@ class SpliceMLContext(PySpliceContext):
on the Cloud Service (Zeppelin Notebook), this class
does many things for ease of use.
"""
@staticmethod
def get_jdbc_url():
"""
Get the JDBC Url for the current cluster (internal w/ no timeout)
:return: (string) jdbc url
"""
import os
framework = os.environ['FRAMEWORK_NAME']
return 'jdbc:splice://{framework}-proxy.marathon.mesos:1527/splicedb'.format(
framework=framework)

def __init__(self, sparkSession, useH2O=False, _unit_testing=False):
"""
"Automagically" find the JDBC URL and establish a connection
Automatically find the JDBC URL and establish a connection
to the current Splice Machine database
:param sparkSession: the sparksession object
:param useH2O: whether or not to
:param _unit_testing: whether or not we are unit testing
"""
PySpliceContext.__init__(self, self.get_jdbc_url(), sparkSession, _unit_testing)

try:
url = os.environ['JDBC_URL']
PySpliceContext.__init__(self, url, sparkSession, _unit_testing)
except:
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)')
return -1
if useH2O:
from pysparkling import H2OConf, H2OContext
h2oConf = H2OConf(sparkSession)
Expand Down

0 comments on commit cb5657a

Please sign in to comment.