本文整理汇总了Python中charms.layer.apache_bigtop_base.Bigtop.check_hdfs_setup方法的典型用法代码示例。如果您正苦于以下问题:Python Bigtop.check_hdfs_setup方法的具体用法?Python Bigtop.check_hdfs_setup怎么用?Python Bigtop.check_hdfs_setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类charms.layer.apache_bigtop_base.Bigtop
的用法示例。
在下文中一共展示了Bigtop.check_hdfs_setup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_datanode
# 需要导入模块: from charms.layer.apache_bigtop_base import Bigtop [as 别名]
# 或者: from charms.layer.apache_bigtop_base.Bigtop import check_hdfs_setup [as 别名]
def start_datanode(namenode):
hookenv.status_set('maintenance', 'starting datanode')
# NB: service should be started by install, but we want to verify it is
# running before we set the .started state and open ports. We always
# restart here, which may seem heavy-handed. However, restart works
# whether the service is currently started or stopped. It also ensures the
# service is using the most current config.
started = host.service_restart('hadoop-hdfs-datanode')
if started:
# Create a /user/ubuntu dir in HDFS (this is safe to run multiple times).
bigtop = Bigtop()
if not bigtop.check_hdfs_setup():
try:
utils.wait_for_hdfs(30)
bigtop.setup_hdfs()
except utils.TimeoutError:
# HDFS is not yet available or is still in safe mode, so we can't
# do the initial setup (create dirs); skip setting the .started
# state below so that we try again on the next hook.
hookenv.status_set('waiting', 'waiting on hdfs')
return
# HDFS is ready. Open ports and set .started, status, and app version
for port in get_layer_opts().exposed_ports('datanode'):
hookenv.open_port(port)
set_state('apache-bigtop-datanode.started')
hookenv.status_set('maintenance', 'datanode started')
hookenv.application_version_set(get_hadoop_version())
else:
hookenv.log('DataNode failed to start')
hookenv.status_set('blocked', 'datanode failed to start')
remove_state('apache-bigtop-datanode.started')
for port in get_layer_opts().exposed_ports('datanode'):
hookenv.close_port(port)
示例2: TestBigtopUnit
# 需要导入模块: from charms.layer.apache_bigtop_base import Bigtop [as 别名]
# 或者: from charms.layer.apache_bigtop_base.Bigtop import check_hdfs_setup [as 别名]
#.........这里部分代码省略.........
'''
set_state('apache-bigtop-base.puppet_queued')
mock_ver.return_value = '1.2.0'
Bigtop._handle_queued_puppet()
self.assertTrue(mock_trigger.called)
self.assertFalse(is_state('apache-bigtop-base.puppet_queued'))
@mock.patch('charms.layer.apache_bigtop_base.utils')
@mock.patch('charms.layer.apache_bigtop_base.chdir')
@mock.patch('charms.layer.apache_bigtop_base.unitdata')
def test_trigger_puppet(self, mock_unit, mock_chdir, mock_utils):
'''
Test to verify that we attempt to trigger puppet correctly.
'''
def verify_utils_call(user, puppet, *args):
self.assertEqual(user, 'root')
self.assertEqual(puppet, 'puppet')
mock_kv = mock.Mock()
mock_unit.kv.return_value = mock_kv
mock_kv.get.return_value = 'foo'
mock_utils.run_as.side_effect = verify_utils_call
self.bigtop.trigger_puppet()
self.assertTrue(mock_utils.run_as.called)
# TODO: verify the Java 1.7 logic.
@mock.patch('charms.layer.apache_bigtop_base.subprocess')
@mock.patch('charms.layer.apache_bigtop_base.utils.run_as')
def test_check_hdfs_setup(self, mock_run, mock_sub):
'''
Verify that our hdfs setup check works as expected, and handles
errors as expected.
'''
class MockException(Exception):
pass
mock_sub.CalledProcessError = MockException
def mock_raise(*args, **kwargs):
raise MockException('foo!')
for s in ['ubuntu', ' ubuntu ', 'ubuntu ', ' ubuntu']:
mock_run.return_value = s
self.assertTrue(self.bigtop.check_hdfs_setup())
for s in ['foo', ' ', '', ' bar', 'notubuntu', 'ubuntu not ']:
mock_run.return_value = s
self.assertFalse(self.bigtop.check_hdfs_setup())
mock_run.side_effect = mock_raise
self.assertFalse(self.bigtop.check_hdfs_setup())
@unittest.skip('noop')
def test_spec(self):
'''Nothing to test that the linter won't handle.'''
@mock.patch('charms.layer.apache_bigtop_base.subprocess')
@mock.patch('charms.layer.apache_bigtop_base.utils.run_as')
@mock.patch('charms.layer.apache_bigtop_base.chdir')
@mock.patch('charms.layer.apache_bigtop_base.chownr')
@mock.patch('charms.layer.apache_bigtop_base.layer.options')