示例#1
0
    def test_enable_tcp_keep_alive(self):
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        class _Transport():
            def getHandle(self):
                return s

            def setTcpKeepAlive(self, value):
                s.setsockopt(socket.SOL_TCP, socket.SO_KEEPALIVE, value)

        enableTcpKeepAlive(_Transport(), True, None)
        self.assertEquals(s.getsockopt(socket.SOL_TCP, socket.SO_KEEPALIVE), 1)
示例#2
0
  def connectionMade(self):
    self.setTimeout(settings.METRIC_CLIENT_IDLE_TIMEOUT)
    enableTcpKeepAlive(self.transport, settings.TCP_KEEPALIVE, settings)
    self.peerName = self.getPeerName()

    if settings.LOG_LISTENER_CONN_SUCCESS:
      log.listener("%s connection with %s established" % (
        self.__class__.__name__, self.peerName))

    if state.metricReceiversPaused:
      self.pauseReceiving()

    state.connectedMetricReceiverProtocols.add(self)
    if settings.USE_FLOW_CONTROL:
      events.pauseReceivingMetrics.addHandler(self.pauseReceiving)
      events.resumeReceivingMetrics.addHandler(self.resumeReceiving)
示例#3
0
文件: client.py 项目: drawks/carbon
  def connectionMade(self):
    log.clients("%s::connectionMade" % self)
    self.paused = False
    self.connected = True
    self.transport.registerProducer(self, streaming=True)
    # Define internal metric names
    self.lastResetTime = time()
    self.destinationName = self.factory.destinationName
    self.queuedUntilReady = 'destinations.%s.queuedUntilReady' % self.destinationName
    self.sent = 'destinations.%s.sent' % self.destinationName
    self.batchesSent = 'destinations.%s.batchesSent' % self.destinationName

    self.slowConnectionReset = 'destinations.%s.slowConnectionReset' % self.destinationName
    enableTcpKeepAlive(self.transport, settings.TCP_KEEPALIVE, settings)

    d = self.factory.connectionMade
    # Setup a new deferred before calling the callback to allow callbacks
    # to re-register themselves.
    self.factory.connectionMade = Deferred()
    d.callback(self)

    self.sendQueued()
示例#4
0
文件: client.py 项目: wridgers/carbon
    def connectionMade(self):
        log.clients("%s::connectionMade" % self)
        self.paused = False
        self.connected = True
        self.transport.registerProducer(self, streaming=True)
        # Define internal metric names
        self.lastResetTime = time()
        self.destinationName = self.factory.destinationName
        self.queuedUntilReady = 'destinations.%s.queuedUntilReady' % self.destinationName
        self.sent = 'destinations.%s.sent' % self.destinationName
        self.batchesSent = 'destinations.%s.batchesSent' % self.destinationName

        self.slowConnectionReset = 'destinations.%s.slowConnectionReset' % self.destinationName
        enableTcpKeepAlive(self.transport, settings.TCP_KEEPALIVE, settings)

        d = self.factory.connectionMade
        # Setup a new deferred before calling the callback to allow callbacks
        # to re-register themselves.
        self.factory.connectionMade = Deferred()
        d.callback(self)

        self.sendQueued()