本文整理汇总了Python中ambari_agent.ActionQueue.ActionQueue.stop方法的典型用法代码示例。如果您正苦于以下问题:Python ActionQueue.stop方法的具体用法?Python ActionQueue.stop怎么用?Python ActionQueue.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ambari_agent.ActionQueue.ActionQueue
的用法示例。
在下文中一共展示了ActionQueue.stop方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ActionQueueStartStop
# 需要导入模块: from ambari_agent.ActionQueue import ActionQueue [as 别名]
# 或者: from ambari_agent.ActionQueue.ActionQueue import stop [as 别名]
def test_ActionQueueStartStop(self):
actionQueue = ActionQueue(AmbariConfig().getConfig())
actionQueue.IDLE_SLEEP_TIME = 0.01
actionQueue.start()
actionQueue.stop()
actionQueue.join()
self.assertEqual(actionQueue.stopped(), True, 'Action queue is not stopped.')
示例2: test_heartbeat_with_status_multiple
# 需要导入模块: from ambari_agent.ActionQueue import ActionQueue [as 别名]
# 或者: from ambari_agent.ActionQueue.ActionQueue import stop [as 别名]
def test_heartbeat_with_status_multiple(self, read_stack_version_method):
actionQueue = ActionQueue(AmbariConfig.AmbariConfig().getConfig())
actionQueue.IDLE_SLEEP_TIME = 0.01
read_stack_version_method.return_value="1.3.0"
heartbeat = Heartbeat(actionQueue)
actionQueue.start()
max_number_of_status_entries = 0
for i in range(1,5):
statusCommand = {
"serviceName" : 'HDFS',
"commandType" : "STATUS_COMMAND",
"clusterName" : "",
"componentName" : "DATANODE",
'configurations':{'global' : {}}
}
actionQueue.put(statusCommand)
time.sleep(0.1)
result = heartbeat.build(101)
number_of_status_entries = len(result['componentStatus'])
# print "Heartbeat with status: " + str(result) + " XXX " + str(number_of_status_entries)
if max_number_of_status_entries < number_of_status_entries:
max_number_of_status_entries = number_of_status_entries
actionQueue.stop()
actionQueue.join()
NUMBER_OF_COMPONENTS = 1
self.assertEquals(max_number_of_status_entries == NUMBER_OF_COMPONENTS, True)
示例3: test_RetryAction
# 需要导入模块: from ambari_agent.ActionQueue import ActionQueue [as 别名]
# 或者: from ambari_agent.ActionQueue.ActionQueue import stop [as 别名]
def test_RetryAction(self):
action={'id' : 'tttt'}
config = AmbariConfig().getConfig()
actionQueue = ActionQueue(config)
path = actionQueue.getInstallFilename(action['id'])
configFile = {
"data" : "test",
"owner" : os.getuid(),
"group" : os.getgid() ,
"permission" : 0700,
"path" : path,
"umask" : 022
}
#note that the command in the action is just a listing of the path created
#we just want to ensure that 'ls' can run on the data file (in the actual world
#this 'ls' would be a puppet or a chef command that would work on a data
#file
badAction = {
'id' : 'tttt',
'kind' : 'INSTALL_AND_CONFIG_ACTION',
'workDirComponent' : 'abc-hdfs',
'file' : configFile,
'clusterDefinitionRevision' : 12,
'command' : ['/bin/ls',"/foo/bar/badPath1234"]
}
path=getFilePath(action,path)
goodAction = {
'id' : 'tttt',
'kind' : 'INSTALL_AND_CONFIG_ACTION',
'workDirComponent' : 'abc-hdfs',
'file' : configFile,
'clusterDefinitionRevision' : 12,
'command' : ['/bin/ls',path]
}
actionQueue.start()
response = {'actions' : [badAction,goodAction]}
actionQueue.maxRetries = 2
actionQueue.sleepInterval = 1
result = actionQueue.put(response)
results = actionQueue.result()
sleptCount = 1
while (len(results) < 2 and sleptCount < 15):
time.sleep(1)
sleptCount += 1
results = actionQueue.result()
actionQueue.stop()
actionQueue.join()
self.assertEqual(len(results), 2, 'Number of results is not 2.')
result = results[0]
maxretries = config.get('command', 'maxretries')
self.assertEqual(int(result['retryActionCount']),
int(maxretries),
"Number of retries is %d and not %d" %
(int(result['retryActionCount']), int(str(maxretries))))
result = results[1]
self.assertEqual(int(result['retryActionCount']),
1,
"Number of retries is %d and not %d" %
(int(result['retryActionCount']), 1))
示例4: test_ActionQueueStartStop
# 需要导入模块: from ambari_agent.ActionQueue import ActionQueue [as 别名]
# 或者: from ambari_agent.ActionQueue.ActionQueue import stop [as 别名]
def test_ActionQueueStartStop(self, CustomServiceOrchestrator_mock,
get_mock, process_command_mock):
CustomServiceOrchestrator_mock.return_value = None
dummy_controller = MagicMock()
config = MagicMock()
actionQueue = ActionQueue(config, dummy_controller)
actionQueue.start()
time.sleep(0.1)
actionQueue.stop()
actionQueue.join()
self.assertEqual(actionQueue.stopped(), True, 'Action queue is not stopped.')
self.assertTrue(process_command_mock.call_count > 1)
示例5: test_command_in_progress
# 需要导入模块: from ambari_agent.ActionQueue import ActionQueue [as 别名]
# 或者: from ambari_agent.ActionQueue.ActionQueue import stop [as 别名]
def test_command_in_progress(self):
config = AmbariConfig().getConfig()
tmpfile = tempfile.gettempdir()
config.set('agent', 'prefix', tmpfile)
actionQueue = ActionQueue(config)
actionQueue.IDLE_SLEEP_TIME = 0.01
executor_started_event = threading.Event()
end_executor_event = threading.Event()
actionQueue.puppetExecutor = FakeExecutor(executor_started_event, end_executor_event)
before_start_result = actionQueue.result()
command = {
'commandId': 17,
'role' : "role",
'taskId' : "taskId",
'clusterName' : "clusterName",
'serviceName' : "serviceName",
'status' : 'IN_PROGRESS',
'hostname' : "localhost.localdomain",
'hostLevelParams': "hostLevelParams",
'clusterHostInfo': "clusterHostInfo",
'roleCommand': "roleCommand",
'configurations': "configurations",
'commandType': "EXECUTION_COMMAND",
'configurations':{'global' : {}}
}
actionQueue.put(command)
actionQueue.start()
executor_started_event.wait()
#print ("ii: " + pprint.pformat(actionQueue.commandInProgress))
in_progress_result = actionQueue.result()
end_executor_event.set()
actionQueue.stop()
actionQueue.join()
after_start_result = actionQueue.result()
self.assertEquals(len(before_start_result['componentStatus']), 0)
self.assertEquals(len(before_start_result['reports']), 0)
self.assertEquals(len(in_progress_result['componentStatus']), 0)
self.assertEquals(len(in_progress_result['reports']), 1)
self.assertEquals(in_progress_result['reports'][0]['status'], "IN_PROGRESS")
self.assertEquals(in_progress_result['reports'][0]['stdout'], "Dummy output")
self.assertEquals(in_progress_result['reports'][0]['exitCode'], 777)
self.assertEquals(in_progress_result['reports'][0]['stderr'], 'Dummy err')
self.assertEquals(len(after_start_result['componentStatus']), 0)
self.assertEquals(len(after_start_result['reports']), 1)
self.assertEquals(after_start_result['reports'][0]['status'], "COMPLETED")
self.assertEquals(after_start_result['reports'][0]['stdout'], "returned stdout")
self.assertEquals(after_start_result['reports'][0]['exitCode'], 0)
self.assertEquals(after_start_result['reports'][0]['stderr'], 'returned stderr')
示例6: test_cancel
# 需要导入模块: from ambari_agent.ActionQueue import ActionQueue [as 别名]
# 或者: from ambari_agent.ActionQueue.ActionQueue import stop [as 别名]
def test_cancel(self, CustomServiceOrchestrator_mock,
get_mock, process_command_mock):
CustomServiceOrchestrator_mock.return_value = None
dummy_controller = MagicMock()
config = MagicMock()
actionQueue = ActionQueue(config, dummy_controller)
actionQueue.start()
actionQueue.put([self.datanode_install_command, self.hbase_install_command])
self.assertEqual(2, actionQueue.commandQueue.qsize())
actionQueue.reset()
self.assertTrue(actionQueue.commandQueue.empty())
time.sleep(0.1)
actionQueue.stop()
actionQueue.join()
self.assertEqual(actionQueue.stopped(), True, 'Action queue is not stopped.')
示例7: test_configtags
# 需要导入模块: from ambari_agent.ActionQueue import ActionQueue [as 别名]
# 或者: from ambari_agent.ActionQueue.ActionQueue import stop [as 别名]
def test_configtags(self):
config = AmbariConfig().getConfig()
tmpfile = tempfile.gettempdir()
config.set('agent', 'prefix', tmpfile)
actionQueue = ActionQueue(config)
actionQueue.IDLE_SLEEP_TIME = 0.01
executor_started_event = threading.Event()
end_executor_event = threading.Event()
actionQueue.puppetExecutor = FakeExecutor(executor_started_event, end_executor_event)
command = {
'commandId': 17,
'role' : "role",
'taskId' : "taskId",
'clusterName' : "clusterName",
'serviceName' : "serviceName",
'status' : 'IN_PROGRESS',
'hostname' : "localhost.localdomain",
'hostLevelParams': "hostLevelParams",
'clusterHostInfo': "clusterHostInfo",
'roleCommand': "roleCommand",
'configurations': "configurations",
'commandType': "EXECUTION_COMMAND",
'configurations':{'global' : {}},
'configurationTags':{'global' : { 'tag': 'v1' }}
}
actionQueue.put(command)
actionQueue.start()
executor_started_event.wait()
end_executor_event.set()
actionQueue.stop()
actionQueue.join()
after_start_result = actionQueue.result()
configname = os.path.join(tmpfile, 'config.json')
self.assertEquals(len(after_start_result['componentStatus']), 0)
self.assertEquals(len(after_start_result['reports']), 1)
self.assertEquals(after_start_result['reports'][0]['status'], "COMPLETED")
self.assertEquals(after_start_result['reports'][0]['stdout'], "returned stdout")
self.assertEquals(after_start_result['reports'][0]['exitCode'], 0)
self.assertEquals(after_start_result['reports'][0]['stderr'], 'returned stderr')
self.assertEquals(len(after_start_result['reports'][0]['configurationTags']), 1)
self.assertEquals(True, os.path.isfile(configname))
os.remove(configname)
示例8: test_parallel_exec
# 需要导入模块: from ambari_agent.ActionQueue import ActionQueue [as 别名]
# 或者: from ambari_agent.ActionQueue.ActionQueue import stop [as 别名]
def test_parallel_exec(self, CustomServiceOrchestrator_mock,
process_command_mock, gpeo_mock):
CustomServiceOrchestrator_mock.return_value = None
dummy_controller = MagicMock()
config = MagicMock()
gpeo_mock.return_value = 1
config.get_parallel_exec_option = gpeo_mock
actionQueue = ActionQueue(config, dummy_controller)
actionQueue.put([self.datanode_install_command, self.hbase_install_command])
self.assertEqual(2, actionQueue.commandQueue.qsize())
actionQueue.start()
time.sleep(1)
actionQueue.stop()
actionQueue.join()
self.assertEqual(actionQueue.stopped(), True, 'Action queue is not stopped.')
self.assertEqual(2, process_command_mock.call_count)
process_command_mock.assert_any_calls([call(self.datanode_install_command), call(self.hbase_install_command)])
示例9: test_heartbeat_with_status
# 需要导入模块: from ambari_agent.ActionQueue import ActionQueue [as 别名]
# 或者: from ambari_agent.ActionQueue.ActionQueue import stop [as 别名]
def test_heartbeat_with_status(self, read_stack_version_method):
actionQueue = ActionQueue(AmbariConfig.AmbariConfig().getConfig())
read_stack_version_method.return_value="1.3.0"
heartbeat = Heartbeat(actionQueue)
statusCommand = {
"serviceName" : 'HDFS',
"commandType" : "STATUS_COMMAND",
"clusterName" : "",
"componentName" : "DATANODE",
'configurations':{'global' : {}}
}
actionQueue.put(statusCommand)
actionQueue.start()
time.sleep(0.1)
actionQueue.stop()
actionQueue.join()
result = heartbeat.build(101)
self.assertEquals(len(result['componentStatus']) > 0, True, 'Heartbeat should contain status of HDFS components')
示例10: test_reset_queue
# 需要导入模块: from ambari_agent.ActionQueue import ActionQueue [as 别名]
# 或者: from ambari_agent.ActionQueue.ActionQueue import stop [as 别名]
def test_reset_queue(self, CustomServiceOrchestrator_mock,
get_mock, process_command_mock, gpeo_mock):
CustomServiceOrchestrator_mock.return_value = None
dummy_controller = MagicMock()
dummy_controller.recovery_manager = RecoveryManager(tempfile.mktemp())
config = MagicMock()
gpeo_mock.return_value = 0
config.get_parallel_exec_option = gpeo_mock
actionQueue = ActionQueue(config, dummy_controller)
actionQueue.start()
actionQueue.put([self.datanode_install_command, self.hbase_install_command])
self.assertEqual(2, actionQueue.commandQueue.qsize())
self.assertTrue(actionQueue.tasks_in_progress_or_pending())
actionQueue.reset()
self.assertTrue(actionQueue.commandQueue.empty())
self.assertFalse(actionQueue.tasks_in_progress_or_pending())
time.sleep(0.1)
actionQueue.stop()
actionQueue.join()
self.assertEqual(actionQueue.stopped(), True, 'Action queue is not stopped.')