Skip to content

Commit

Permalink
More dse commands
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-tr-adamson committed Oct 10, 2014
1 parent 4c871c3 commit ce8430d
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 24 deletions.
44 changes: 37 additions & 7 deletions ccmlib/cmds/node_cmds.py
Expand Up @@ -38,7 +38,9 @@ def node_cmds():
"nodetool",
"dsetool",
"setworkload",
"hadoop",
"hive",
"pig",
"sqoop"
]

Expand Down Expand Up @@ -601,38 +603,66 @@ def run(self):
print_(str(e), file=sys.stderr)
exit(1)

class NodeHadoopCmd(Cmd):
def description(self):
return "Launch a hadoop session connected to this node"

def get_parser(self):
usage = "usage: ccm node_name hadoop [options] [hadoop_options]"
parser = self._get_default_parser(usage, self.description(), ignore_unknown_options=True)
return parser

def validate(self, parser, options, args):
Cmd.validate(self, parser, options, args, node_name=True, load_cluster=True)
self.hadoop_options = args[1:]

def run(self):
self.node.hadoop(self.hadoop_options)

class NodeHiveCmd(Cmd):
def description(self):
return "Launch a hive session connected to this node"

def get_parser(self):
usage = "usage: ccm node_name hive [options] [hive_options]"
parser = self._get_default_parser(usage, self.description(), ignore_unknown_options=True)
parser.add_option('-v', '--verbose', action="store_true", dest="verbose",
help="With --exec, show cli output after completion", default=False)
return parser

def validate(self, parser, options, args):
Cmd.validate(self, parser, options, args, node_name=True, load_cluster=True)
self.hive_options = parser.get_ignored() + args[1:]

def run(self):
self.node.hive(self.options.verbose, self.hive_options)
self.node.hive(self.hive_options)

class NodePigCmd(Cmd):
def description(self):
return "Launch a pig session connected to this node"

def get_parser(self):
usage = "usage: ccm node_name pig [options] [pig_options]"
parser = self._get_default_parser(usage, self.description(), ignore_unknown_options=True)
return parser

def validate(self, parser, options, args):
Cmd.validate(self, parser, options, args, node_name=True, load_cluster=True)
self.pig_options = parser.get_ignored() + args[1:]

def run(self):
self.node.pig(self.pig_options)

class NodeSqoopCmd(Cmd):
def description(self):
return "Launch a sqoop session connected to this node"

def get_parser(self):
usage = "usage: ccm node_name sqoop [options] [hive_options]"
usage = "usage: ccm node_name sqoop [options] [sqoop_options]"
parser = self._get_default_parser(usage, self.description(), ignore_unknown_options=True)
parser.add_option('-v', '--verbose', action="store_true", dest="verbose",
help="With --exec, show cli output after completion", default=False)
return parser

def validate(self, parser, options, args):
Cmd.validate(self, parser, options, args, node_name=True, load_cluster=True)
self.sqoop_options = args[1:] + parser.get_ignored()

def run(self):
self.node.sqoop(self.options.verbose, self.sqoop_options)
self.node.sqoop(self.sqoop_options)
10 changes: 8 additions & 2 deletions ccmlib/common.py
Expand Up @@ -174,8 +174,14 @@ def make_dse_env(install_dir, node_path):
env['DSE_CONF'] = os.path.join(node_path, 'resources', 'dse', 'conf')
env['CASSANDRA_HOME'] = os.path.join(install_dir, 'resources', 'cassandra')
env['CASSANDRA_CONF'] = os.path.join(node_path, 'resources', 'cassandra', 'conf')
env['HADOOP_CONF'] = os.path.join(node_path, 'resources', 'hadoop', 'conf')
env['HIVE_CONF'] = os.path.join(node_path, 'resources', 'hive', 'conf')
env['HADOOP_CONF_DIR'] = os.path.join(node_path, 'resources', 'hadoop', 'conf')
env['HIVE_CONF_DIR'] = os.path.join(node_path, 'resources', 'hive', 'conf')
env['SQOOP_CONF_DIR'] = os.path.join(node_path, 'resources', 'sqoop', 'conf')
env['TOMCAT_CONF_DIR'] = os.path.join(node_path, 'resources', 'tomcat', 'conf')
env['PIG_CONF_DIR'] = os.path.join(node_path, 'resources', 'pig', 'conf')
env['MAHOUT_CONF_DIR'] = os.path.join(node_path, 'resources', 'mahout', 'conf')
env['SPARK_CONF_DIR'] = os.path.join(node_path, 'resources', 'spark', 'conf')
env['SHARK_CONF_DIR'] = os.path.join(node_path, 'resources', 'shark', 'conf')
return env

def check_win_requirements():
Expand Down
35 changes: 22 additions & 13 deletions ccmlib/dse_node.py
Expand Up @@ -182,15 +182,31 @@ def dsetool(self, cmd):
p = subprocess.Popen(args, env=env)
p.wait()

def hive(self, show_output=False, hive_options=[]):
def hadoop(self, hadoop_options=[]):
env = common.make_dse_env(self.get_install_dir(), self.get_path())
dse = common.join_bin(self.get_install_dir(), 'bin', 'dse')
args = [dse, 'hadoop']
args += hadoop_options
p = subprocess.Popen(args, env=env)
p.wait()

def hive(self, hive_options=[]):
env = common.make_dse_env(self.get_install_dir(), self.get_path())
dse = common.join_bin(self.get_install_dir(), 'bin', 'dse')
args = [dse, 'hive']
args += hive_options
p = subprocess.Popen(args, env=env)
p.wait()

def sqoop(self, show_output=False, sqoop_options=[]):
def pig(self, pig_options=[]):
env = common.make_dse_env(self.get_install_dir(), self.get_path())
dse = common.join_bin(self.get_install_dir(), 'bin', 'dse')
args = [dse, 'pig']
args += pig_options
p = subprocess.Popen(args, env=env)
p.wait()

def sqoop(self, sqoop_options=[]):
env = common.make_dse_env(self.get_install_dir(), self.get_path())
dse = common.join_bin(self.get_install_dir(), 'bin', 'dse')
args = [dse, 'sqoop']
Expand All @@ -206,17 +222,10 @@ def import_dse_config_files(self):
self.__update_yaml()

def copy_config_files(self):
if not os.path.isdir(os.path.join(self.get_path(), 'resources', 'dse', 'conf')):
os.makedirs(os.path.join(self.get_path(), 'resources', 'dse', 'conf'))
if not os.path.isdir(os.path.join(self.get_path(), 'resources', 'cassandra', 'conf')):
os.makedirs(os.path.join(self.get_path(), 'resources', 'cassandra', 'conf'))
if not os.path.isdir(os.path.join(self.get_path(), 'resources', 'hadoop', 'conf')):
os.makedirs(os.path.join(self.get_path(), 'resources', 'hadoop', 'conf'))
if not os.path.isdir(os.path.join(self.get_path(), 'resources', 'hive', 'conf')):
os.makedirs(os.path.join(self.get_path(), 'resources', 'hive', 'conf'))
common.copy_directory(os.path.join(self.get_install_dir(), 'resources', 'dse', 'conf'), os.path.join(self.get_path(), 'resources', 'dse', 'conf'))
common.copy_directory(os.path.join(self.get_install_dir(), 'resources', 'cassandra', 'conf'), os.path.join(self.get_path(), 'resources', 'cassandra', 'conf'))
common.copy_directory(os.path.join(self.get_install_dir(), 'resources', 'hive', 'conf'), os.path.join(self.get_path(), 'resources', 'hive', 'conf'))
for product in ['dse', 'cassandra', 'hadoop', 'hive', 'tomcat', 'spark', 'shark', 'mahout', 'pig']:
if not os.path.isdir(os.path.join(self.get_path(), 'resources', product, 'conf')):
os.makedirs(os.path.join(self.get_path(), 'resources', product, 'conf'))
common.copy_directory(os.path.join(self.get_install_dir(), 'resources', product, 'conf'), os.path.join(self.get_path(), 'resources', product, 'conf'))

def import_bin_files(self):
os.makedirs(os.path.join(self.get_path(), 'resources', 'cassandra', 'bin'))
Expand Down
10 changes: 8 additions & 2 deletions ccmlib/node.py
Expand Up @@ -628,10 +628,16 @@ def nodetool(self, cmd, capture_output=False):
def dsetool(self, cmd):
raise common.ArgumentError('Cassandra nodes do not support dsetool')

def hive(self, show_output=False, hive_options=[]):
def hadoop(self, hadoop_options=[]):
raise common.ArgumentError('Cassandra nodes do not support hadoop')

def hive(self, hive_options=[]):
raise common.ArgumentError('Cassandra nodes do not support hive')

def sqoop(self, show_output=False, sqoop_options=[]):
def pig(self, pig_options=[]):
raise common.ArgumentError('Cassandra nodes do not support pig')

def sqoop(self, sqoop_options=[]):
raise common.ArgumentError('Cassandra nodes do not support sqoop')

def scrub(self, options):
Expand Down

0 comments on commit ce8430d

Please sign in to comment.