Beispiel #1
0
    def __init__(self, clientId):
        self.uiState = componentui.WorkerComponentUIState()
        self.uiState.addKey('client-id', clientId)
        self.fd = None
        self.uiState.addKey('fd', None)

        # these values can be set to None, which would mean
        # Unknown, not supported
        # these are supported
        for key in (
                'bytes-read-current',  # bytes read over current connection
                'bytes-read-total',  # bytes read over all connections
                'reconnects',  # number of connections made by this client
                'last-connect',  # last client connection, in epoch seconds
                'last-disconnect',  # last client disconnect, in epoch seconds
                'last-activity',  # last time client read or connected
        ):
            self.uiState.addKey(key, 0)
        # these are possibly unsupported
        for key in (
                'buffers-dropped-current',  # buffers dropped over current conn
                'buffers-dropped-total',  # buffers dropped over all connections
        ):
            self.uiState.addKey(key, None)

        # internal state allowing us to track global numbers
        self._buffersDroppedBefore = 0
        self._bytesReadBefore = 0
Beispiel #2
0
 def __init__(self, feederName):
     self.feederName = feederName
     self.elementName = 'feeder:' + feederName
     self.payName = self.elementName + '-pay'
     self.uiState = componentui.WorkerComponentUIState()
     self.uiState.addKey('feederName')
     self.uiState.set('feederName', feederName)
     self.uiState.addListKey('clients')
     self._fdToClient = {}  # fd -> (FeederClient, cleanupfunc)
     self._clients = {}  # id -> FeederClient
Beispiel #3
0
    def __init__(self, eaterAlias, eaterName):
        self.eaterAlias = eaterAlias
        self.eaterName = eaterName
        self.feedId = None
        self.fd = None
        self.elementName = 'eater:' + eaterAlias
        self.depayName = self.elementName + '-depay'
        # for use to detect duplicate streamheader buffers
        self.streamheaderBufferProbeHandler = None
        self.streamheader = []
        self.setPadMonitor(None)
        self.uiState = componentui.WorkerComponentUIState()
        self.uiState.addKey('eater-alias')
        self.uiState.set('eater-alias', eaterAlias)
        self.uiState.addKey('eater-name')
        self.uiState.set('eater-name', eaterName)
        # dict for the current connection
        connectionDict = {
            "feed-id": None,
            "time-timestamp-discont": None,
            "timestamp-timestamp-discont": 0.0,  # ts of buffer after discont,
            # in float seconds
            "last-timestamp-discont": 0.0,
            "total-timestamp-discont": 0.0,
            "count-timestamp-discont": 0,
            "time-offset-discont": None,
            "offset-offset-discont": 0,  # offset of buffer
            # after discont
            "last-offset-discont": 0,
            "total-offset-discont": 0,
            "count-offset-discont": 0
        }
        self.uiState.addDictKey('connection', connectionDict)

        for key in (
                'last-connect',  # last client connection, in epoch sec
                'last-disconnect',  # last client disconnect, in epoch sec
                'total-connections',  # number of connections by this client
                'count-timestamp-discont',  # number of timestamp disconts seen
                'count-offset-discont',  # number of timestamp disconts seen
        ):
            self.uiState.addKey(key, 0)
        for key in (
                'total-timestamp-discont',  # total timestamp discontinuity
                'total-offset-discont',  # total offset discontinuity
        ):
            self.uiState.addKey(key, 0.0)
        self.uiState.addKey('fd', None)
Beispiel #4
0
    def init(self):
        """
        A subclass should do as little as possible in its init method.
        In particular, it should not try to access resources.

        Failures during init are marshalled back to the manager through
        the worker's remote_create method, since there is no component state
        proxied to the manager yet at the time of init.
        """
        self.state = planet.WorkerJobState()

        self.name = self.config['name']

        self.state.set('pid', os.getpid())
        self.setMood(moods.waking)

        self.medium = None  # the medium connecting us to the manager's avatar

        self.uiState = componentui.WorkerComponentUIState()
        self.uiState.addKey('cpu-percent')
        self.uiState.addKey('start-time')
        self.uiState.addKey('current-time')
        self.uiState.addKey('virtual-size')
        self.uiState.addKey('total-memory')
        self.uiState.addKey('num-cpus')
        self.uiState.addKey('flu-debug')
        self.uiState.addKey('properties')

        self.uiState.addHook(self)

        self.plugs = {}

        self._happyWaits = []

        # Start the cpu-usage updating.
        self._lastTime = time.time()
        self._lastClock = time.clock()
        self._cpuPoller = Poller(self._pollCPU, 5, start=False)
        self._memoryPoller = Poller(self._pollMemory, 60, start=False)
        self._cpuPollerDC = None
        self._memoryPollerDC = None
        self._shutdownHook = None
 def remote_getState(self):
     if not hasattr(self, 'state'):
         self.state = componentui.WorkerComponentUIState()
         self.state.addKey('name', 'lois')
         self.state.addListKey('children')
     return self.state