<commit_before>"""
Event handling system.

Author: <NAME> <<EMAIL>>
Copyright: NORDUnet (2012)
"""


DISCOVER                = 'discover'

RESERVE                 = 'reserve'
RESERVE_RESPONSE        = 'reserve_response'
RESERVE_COMMIT          = 'reserve_commit'
RESERVE_COMMIT_RESPONSE = 'reserve_commit_response'
RESERVE_ABORT           = 'reserve_abort'
RESERVE_ABORT_RESPONSE  = 'reserve_abort_response'
RESERVE_TIMEOUT         = 'reserve_timeout'

PROVISION               = 'provision'
PROVISION_RESPONSE      = 'provision_response'
RELEASE                 = 'release'
RELEASE_RESPONSE        = 'release_response'

TERMINATE               = 'terminate'
TERMINATE_RESPONSE      = 'terminate_response'

QUERY                   = 'query'
QUERY_RESPONSE          = 'query_response'

DATA_PLANE_CHANGE       = 'data_plane_change'
ERROR_EVENT             = 'error_event'


SYSTEM_SERVICE          = 'service'
NSI2_REMOTE             = 'nsi2-remote'
NSI2_LOCAL              = 'nsi2-local'



class ServiceRegistry:

    def __init__(self):
        self.handlers = {}


    def getHandler(self, event, system):

        es = (event, system)
        return self.handlers[es]


    def registerEventHandler(self, event, handler, system):

        if event in self.handlers:
            raise ValueError('Handler for event %s already registered' % event)

        es = (event, system)
        self.handlers[es] = handler


    def deregisterEventHandler(self, event, system):

        es = (event, system)<commit_msg>add aggregator as registry subsystem, though not entirely sure how it is distinct from system service<commit_after>"""
Event handling system.

Author: <NAME> <<EMAIL>>
Copyright: NORDUnet (2012)
"""


DISCOVER                = 'discover'

RESERVE                 = 'reserve'
RESERVE_RESPONSE        = 'reserve_response'
RESERVE_COMMIT          = 'reserve_commit'
RESERVE_COMMIT_RESPONSE = 'reserve_commit_response'
RESERVE_ABORT           = 'reserve_abort'
RESERVE_ABORT_RESPONSE  = 'reserve_abort_response'
RESERVE_TIMEOUT         = 'reserve_timeout'

PROVISION               = 'provision'
PROVISION_RESPONSE      = 'provision_response'
RELEASE                 = 'release'
RELEASE_RESPONSE        = 'release_response'

TERMINATE               = 'terminate'
TERMINATE_RESPONSE      = 'terminate_response'

QUERY                   = 'query'
QUERY_RESPONSE          = 'query_response'

DATA_PLANE_CHANGE       = 'data_plane_change'
ERROR_EVENT             = 'error_event'

SYSTEM_SERVICE          = 'service'
NSI2_AGGREGATOR         = 'nsi2-aggregator'
NSI2_REMOTE             = 'nsi2-remote'
NSI2_LOCAL              = 'nsi2-local'



class ServiceRegistry:

    def __init__(self):
        self.handlers = {}


    def getHandler(self, event, system):

        es = (event, system)
        return self.handlers[es]


    def registerEventHandler(self, event, handler, system):

        if event in self.handlers:
            raise ValueError('Handler for event %s already registered' % event)

        es = (event, system)
        self.handlers[es] = handler


    def deregisterEventHandler(self, event, system):

        es = (event, system)
{'fraction_non_alphanumeric': 0.08785283856644466, 'fraction_numerical': 0.005708848715509039, 'mean_word_length': 2.4469945355191256, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3581792', 'n_tokens_mistral': 1026, 'n_tokens_neox': 987, 'n_words': 206}