Exemple #1
0
    def slave(self, shareQueue, count, sharedLst, services, lock):
        logger.info(current_process())
        # obtain all request infomation
        while True:
            item = shareQueue.get()
            count.value = count.value + 1
            if item == 'Done':
                break
            else:
                # handle item
                tree = Tree(item['serviceId'], item['total_time'],
                            item['datetime'], item['thread_name'])
                method_lst = item['method_lst']
                for method in method_lst:
                    tree.insert(Node(method))
                # the invalid means there exists some node its children execution time larger than the total time
                # discard the invalid tree
                if tree.check_validation() is False:
                    continue
                tree.calcu_statistic()
                # tree hash
                tree.root.getHash()
                if item['serviceId'] in self.services.keys():
                    treeLst = self.services[item['serviceId']]
                    treeLst.append(tree)
                    self.services[item['serviceId']] = treeLst
                else:
                    treeLst = [tree]
                    self.services[item['serviceId']] = treeLst
            # create sub process to merge call tree
        self.startUpMerge()
        self.clearUp()
        # return to main process
        while self.finalTreeCollection.empty() is False:
            sharedLst.append(self.finalTreeCollection.get())

        logger.info("%s-%s" % (current_process(), "Done"))
Exemple #2
0
import random
from util import Tree

root = Tree("root")
allNodes = {"root": root}

set2Word = {}
word2Set = {}

with open("set2WordV.txt", "r") as s2w:
    cont = s2w.read()
    sets = cont.split("$")
    for set in sets:
        pairs = set.split(":")
        num = pairs[0]
        word = pairs[1]
        set2Word[num] = word
        word2Set[word] = num

# final cleansing of the paths
paths = []
clean_paths = []
with open("tree_struct.txt", 'r') as tree_struct:
    struct_cont = tree_struct.read()
    paths = struct_cont.split("$")
    # count = 0
    for path in paths:
        tokens = path.split("<-")
        num_of_tokens = len(tokens)
        new_path = tokens[0]
        for i in range(1, num_of_tokens):