Created
December 5, 2014 17:22
-
-
Save krha/31cfd488efb29cdf8021 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def control_migration(self): | |
self.qmp.connect() | |
counter_check_comp_size = 0 | |
ret = self.qmp.qmp_negotiate() | |
if not ret: | |
raise CloudletGenerationError("failed to connect to qmp channel") | |
sleep(5) | |
if VMOverlayCreationMode.LIVE_MIGRATION_STOP == VMOverlayCreationMode.LIVE_MIGRATION_FINISH_ASAP: | |
self.migration_stop_time = self._stop_migration() | |
elif VMOverlayCreationMode.LIVE_MIGRATION_STOP == VMOverlayCreationMode.LIVE_MIGRATION_FINISH_USE_SMAPSHOT_SIZE: | |
iteration_issue_time_list = list() | |
sleep_between_iteration = 2 | |
while(not self.stop.wait(0.1)): | |
unprocessed_memory_snapshot_size = self.memory_snapshot_queue.qsize() *\ | |
VMOverlayCreationMode.PIPE_ONE_ELEMENT_SIZE | |
#LOG.debug("[live] %d" % unprocessed_memory_snapshot_size) | |
if unprocessed_memory_snapshot_size < 1024*1024*10: # 10 MB | |
LOG.debug("[live][qmp] iterate_raw_live") | |
ret = self.qmp.iterate_raw_live() | |
iteration_issue_time_list.append(time()) | |
sleep(sleep_between_iteration) | |
if len(iteration_issue_time_list) < 2: | |
continue | |
latest_time_diff = iteration_issue_time_list[-1] - iteration_issue_time_list[-2] | |
if latest_time_diff < sleep_between_iteration*1.4: | |
counter_check_comp_size += 1 | |
if self.compdata_queue.qsize() == 0: | |
# stop after transmitting everything | |
self.migration_stop_time = self._stop_migration() | |
break | |
if len(iteration_issue_time_list) > 5: | |
self.migration_stop_time = self._stop_migration() | |
break | |
self.qmp.disconnect() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment