예제 #1
0
    def __init__(self, pdb, rootcc):
        """
        @param pdb: PlayerDatabase
        @param rootcc: Root CounterCollection
        """
        BaseThread.__init__(self)
        self.pdb = pdb

        cc = CounterCollection(
            'alpha_counter',
            description=u'Module that creates games from hero picking rooms')
        self.matches_dt = PulseCounter('matches_made',
                                       resolution=60,
                                       units=u'matches per minute',
                                       description=u'successful allocations')
        self.matches_dt_so = PulseCounter(
            'matches_failed_so',
            resolution=60,
            units=u'matches per minute',
            description=u'fails to allocate due to shard overload')
        self.matches_dt_fl = PulseCounter(
            'matches_failed_fl',
            resolution=60,
            units=u'matches per minute',
            description=u'fails to allocate due to other reasons')
        cc.add(self.matches_dt)
        cc.add(self.matches_dt_so)
        cc.add(self.matches_dt_fl)
        rootcc.add(cc)
예제 #2
0
파일: root.py 프로젝트: Iwan91/Ninja-Tower
    def __init__(self,
                 host,
                 username,
                 password,
                 dbname,
                 rootcc,
                 dbtype='mysql'):
        """@type rootcc: L{satella.instrumentation.CounterCollection}"""
        assert dbtype == 'mysql', 'I cannot support other databases!'

        dd = DatabaseDefinition(
            MySQLdb.connect,
            (MySQLdb.OperationalError, MySQLdb.InterfaceError),
            (host, username, password, dbname))

        self.cp = ConnectionPool(dd)

        # Set up instrumentation
        insmgr = CounterCollection('database')
        self.cursors_counter = PulseCounter('cursors',
                                            resolution=60,
                                            units=u'cursors per minute',
                                            description='SQL cursors created')
        insmgr.add(self.cursors_counter)
        rootcc.add(insmgr)
예제 #3
0
    def __init__(self, server_socket, to_eventprocessor, from_eventprocessor, pdbhelper, rootcc):
        """@type server_socket: ServerSocket
        @type to_eventprocessor: L{Queue.Queue}
        @type from_eventprocessor: L{Queue.Queue}
        @param rootcc: root counter collection
        @type rootcc: L{satella.instrumentation.CounterCollection}"""

        SelectHandlingLayer.__init__(self)

        # Set up the server socket and attach it to SL
        self.server_socket = server_socket
        self.register_channel(server_socket)

        # dictionary (user pids => respective PlayerSocket)
        self.authenticated_channels = {}


        # Queue section
        self.to_ep = to_eventprocessor
        self.from_ep = from_eventprocessor

        # PDB section
        self.pdbhelper = pdbhelper

        # Instrumentation section
        cc = CounterCollection('selectlayer')
        self.connections_counter = DeltaCounter('connections', units='connections',
                                                description='SSL connections to server')

        self.outbound_events = PulseCounter('events_to_ep', resolution=60,
                                            units='events per minute',
                                            description='events sent to EventProcessor')
        cc.add(self.connections_counter)
        cc.add(self.outbound_events)
        rootcc.add(cc)
예제 #4
0
    def __init__(self, server_sockets, rootcc):
        SelectHandlingLayer.__init__(self)

        # process server sockets
        self.server_sockets = server_sockets    # there may be many
        for server_socket in server_sockets:
            self.register_channel(server_socket)


        self.reqtasks = []


        # ---------- instrumentation stuff
        self.c_lshardmgrs_connected = DeltaCounter('lshardmgrs_connected', 
                                                   description='Amount of lshardmgrs connected')
        self.c_requests_dispatched = PulseCounter('requests_dispatched', 
                                                  resolution=60, units=u'requests per minute',
                                                  description='Requests to allocate a server sent')
        self.c_alloc_orders = PulseCounter('allocation_orders', resolution=60,
                                           units=u'allocation requests per minute',
                                           description=u'Allocation requests received')
        self.c_requests_success = PulseCounter('requests_successful', resolution=60,
                                               units=u'successful requests per minute',
                                               description=u'Requests successfully executed')
        self.c_requests_failed = PulseCounter('requests_failed', resolution=60,
                                              units=u'failed requests per minute',
                                              description=u'Failed requests')

        def calculate_shards_available():
            a = [x for x in self.channels if x not in self.server_sockets]
            a = [x for x in a if x.who == 'l']
            return sum([x.shards for x in a])

        self.c_shards_available = CallbackCounter('shards_available', calculate_shards_available,
                                                  units=u'shards', description=u'Available shards')
        rootcc.add(self.c_lshardmgrs_connected)
        rootcc.add(self.c_requests_dispatched)
        rootcc.add(self.c_alloc_orders)
        rootcc.add(self.c_requests_success)
        rootcc.add(self.c_requests_failed)
        rootcc.add(self.c_shards_available)
예제 #5
0
    def __init__(self, pdb, rootcc):
        """
        @param pdb: PlayerDatabase
        @param rootcc: Root CounterCollection
        """
        BaseThread.__init__(self)
        self.pdb = pdb

        cc = CounterCollection('match_maker', 
                               description=u'Module that organizes matches from enqueued players')
        self.total_matches_made = DeltaCounter('matches_made', units=u'matches', description=u'total matches made')
        self.matches_dt = PulseCounter('matches_made_p', resolution=60, units=u'matches per minute',
                                       description=u'organized matches per minute')
        cc.add(self.total_matches_made)
        cc.add(self.matches_dt)
        rootcc.add(cc)
예제 #6
0
파일: root.py 프로젝트: Iwan91/Ninja-Tower
    def __init__(self, pdbhelper, rootcc, qmangr, to_eventprocessor,
                 cshardmgr_interface):
        """@type pdbhelper: L{lobbyapp.playerdb.api.PDBHelperInterface} implementation.
        @type qmangr: L{lobbyapp.queuemangr.QueueManager}
        @param to_eventprocessor: Queue that can be used to send orders to EventProcessor
        @type to_eventprocessor: L{Queue.Queue}
        @param cshardmgr_interface: interface to CShardMgr
        @type cshardmgr_interface: tuple(str, int)"""
        Monitor.__init__(self)

        self.pirs = {}  #: pid => PlayerInformationRecord

        self.cshardmgr_interface = cshardmgr_interface

        self.pdbhelper = pdbhelper
        self.qmangr = qmangr
        self.alphas = []  # all existing AlphaMatches
        self.betagammas = []  # all existing BetaGammas

        self.to_eventprocessor = to_eventprocessor

        cc = CounterCollection('player_database')
        self.transactions_counter = PulseCounter(
            'transactions',
            resolution=60,
            units=u'transactions per minute',
            description=u'player database transactions performed')
        alphas_waiting = CallbackCounter('alphas_waiting',
                                         self.alphas.__len__,
                                         description=u'matches being prepared')
        betagammas = CallbackCounter('betagammas',
                                     self.betagammas.__len__,
                                     description=u'matches being played')
        cc.add(self.transactions_counter)
        cc.add(alphas_waiting)
        cc.add(betagammas)
        rootcc.add(cc)