Esempio n. 1
0
    def __init__(self,
                 name,
                 ha,
                 verKey,
                 publicKey,
                 queue_size=0,
                 bind_ip="0.0.0.0",
                 config=None):
        # TODO, remove *args, **kwargs after removing test

        assert name

        # Every remote has a unique name per stack, the name can be the
        # public key of the other end
        self.name = name
        self.ha = ha
        self.bind_ip = bind_ip
        # self.publicKey is the public key of the other end of the remote
        self.publicKey = publicKey
        # self.verKey is the verification key of the other end of the remote
        self.verKey = verKey
        self.queue_size = queue_size
        self.socket = None
        # TODO: A stack should have a monitor and it should identify remote
        # by endpoint

        self._numOfReconnects = 0
        self._isConnected = False
        self._lastConnectedAt = None
        self.config = config or getConfig()
        self.uid = name
Esempio n. 2
0
    def __init__(self,
                 name,
                 ha,
                 basedirpath,
                 msgHandler,
                 restricted=True,
                 seed=None,
                 onlyListener=False,
                 config=None,
                 msgRejectHandler=None):
        self._name = name
        self.ha = ha
        self.basedirpath = basedirpath
        self.msgHandler = msgHandler
        self.seed = seed
        self.config = config or getConfig()
        self.msgRejectHandler = msgRejectHandler or self.__defaultMsgRejectHandler

        self.listenerQuota = self.config.DEFAULT_LISTENER_QUOTA
        self.senderQuota = self.config.DEFAULT_SENDER_QUOTA
        self.msgLenVal = MessageLenValidator(self.config.MSG_LEN_LIMIT)

        self.homeDir = None
        # As of now there would be only one file in secretKeysDir and sigKeyDir
        self.publicKeysDir = None
        self.secretKeysDir = None
        self.verifKeyDir = None
        self.sigKeyDir = None

        self.signer = None
        self.verifiers = {}

        self.setupDirs()
        self.setupOwnKeysIfNeeded()
        self.setupSigning()

        # self.poller = test.asyncio.Poller()

        self.restricted = restricted

        self.ctx = None  # type: Context
        self.listener = None
        self.auth = None

        # Each remote is identified uniquely by the name
        self._remotes = {}  # type: Dict[str, Remote]

        self.remotesByKeys = {}

        # Indicates if this stack will maintain any remotes or will
        # communicate simply to listeners. Used in ClientZStack
        self.onlyListener = onlyListener
        self.peersWithoutRemotes = set()

        self._conns = set()  # type: Set[str]

        self.rxMsgs = deque()
        self._created = time.perf_counter()

        self.last_heartbeat_at = None
Esempio n. 3
0
    def __init__(self, config=None):

        # TODO: This should take directory
        self._config = config or getConfig()
        self._addTraceToLogging()
        self._addDisplayToLogging()

        self._handlers = {}
        self._format = logging.Formatter(fmt=self._config.logFormat,
                                         style=self._config.logFormatStyle)

        self._default_raet_verbosity = \
            getRAETLogLevelFromConfig("RAETLogLevel",
                                      Console.Wordage.terse,
                                      self._config)

        self._default_raet_log_file = \
            getRAETLogFilePath("RAETLogFilePath", self._config)

        if self._config.enableStdOutLogging:
            self.enableStdLogging()

        logLevel = logging.INFO
        if hasattr(self._config, "logLevel"):
            logLevel = self._config.logLevel
        self.setLogLevel(logLevel)
Esempio n. 4
0
    def __init__(self, config=None):

        # TODO: This should take directory
        self._config = config or getConfig()
        self._addTraceToLogging()
        self._addDisplayToLogging()
        self.apply_config(self._config)
Esempio n. 5
0
 def __init__(self, config=None):
     """
     :param self: 'NodeStacked'
     :param config: 'stp config'
     """
     self.outBoxes = {}  # type: Dict[int, deque]
     self.stp_config = config or getConfig()
     self.msg_len_val = MessageLenValidator(self.stp_config.MSG_LEN_LIMIT)
Esempio n. 6
0
 def __init__(self, config=None, metrics=NullMetricsCollector()):
     """
     :param self: 'NodeStacked'
     :param config: 'stp config'
     """
     self.outBoxes = {}  # type: Dict[int, deque]
     self.stp_config = config or getConfig()
     self.msg_len_val = MessageLenValidator(self.stp_config.MSG_LEN_LIMIT)
     self.metrics = metrics
Esempio n. 7
0
def tconf():
    tmp = getConfig()
    old_node_num = tmp.ZMQ_NODE_QUEUE_SIZE
    old_client_num = tmp.ZMQ_CLIENT_QUEUE_SIZE
    tmp.ZMQ_NODE_QUEUE_SIZE = BIG_NUM_OF_MSGS
    tmp.ZMQ_CLIENT_QUEUE_SIZE = BIG_NUM_OF_MSGS
    yield tmp
    tmp.ZMQ_NODE_QUEUE_SIZE = old_node_num
    tmp.ZMQ_CLIENT_QUEUE_SIZE = old_client_num
Esempio n. 8
0
def tconf():
    tmp = getConfig()
    old_node_num = tmp.ZMQ_NODE_QUEUE_SIZE
    old_client_num = tmp.ZMQ_CLIENT_QUEUE_SIZE
    tmp.ZMQ_NODE_QUEUE_SIZE = BIG_NUM_OF_MSGS
    tmp.ZMQ_CLIENT_QUEUE_SIZE = BIG_NUM_OF_MSGS
    yield tmp
    tmp.ZMQ_NODE_QUEUE_SIZE = old_node_num
    tmp.ZMQ_CLIENT_QUEUE_SIZE = old_client_num
Esempio n. 9
0
 def __init__(self, config=None, metrics=NullMetricsCollector()):
     """
     :param self: 'NodeStacked'
     :param config: 'stp config'
     """
     self.outBoxes = {}  # type: Dict[int, deque]
     self.stp_config = config or getConfig()
     self.msg_len_val = MessageLenValidator(self.stp_config.MSG_LEN_LIMIT)
     self.metrics = metrics
     self.enabled = self.stp_config.TRANSPORT_BATCH_ENABLED
Esempio n. 10
0
    def __init__(self, config=None):

        # TODO: This should take directory
        self._config = config or getConfig()
        self._addTraceToLogging()
        self._addDisplayToLogging()

        self._handlers = {}
        self._format = logging.Formatter(fmt=self._config.logFormat,
                                         style=self._config.logFormatStyle)

        if self._config.enableStdOutLogging:
            self.enableStdLogging()

        logLevel = logging.INFO
        if hasattr(self._config, "logLevel"):
            logLevel = self._config.logLevel
        self.setLogLevel(logLevel)
Esempio n. 11
0
    def __init__(self, name, ha, verKey, publicKey, config=None):
        # TODO, remove *args, **kwargs after removing test

        # Every remote has a unique name per stack, the name can be the
        # public key of the other end
        self.name = name
        self.ha = ha
        # self.publicKey is the public key of the other end of the remote
        self.publicKey = publicKey
        # self.verKey is the verification key of the other end of the remote
        self.verKey = verKey
        self.socket = None
        # TODO: A stack should have a monitor and it should identify remote
        # by endpoint

        self._numOfReconnects = 0
        self._isConnected = False
        self._lastConnectedAt = None
        self.config = config or getConfig()

        # Currently keeping uid field to resemble RAET RemoteEstate
        self.uid = name
Esempio n. 12
0
    def __init__(self, name, ha, verKey, publicKey, queue_size=0, bind_ip="0.0.0.0", config=None):
        # TODO, remove *args, **kwargs after removing test

        assert name

        # Every remote has a unique name per stack, the name can be the
        # public key of the other end
        self.name = name
        self.ha = ha
        self.bind_ip = bind_ip
        # self.publicKey is the public key of the other end of the remote
        self.publicKey = publicKey
        # self.verKey is the verification key of the other end of the remote
        self.verKey = verKey
        self.queue_size = queue_size
        self.socket = None
        # TODO: A stack should have a monitor and it should identify remote
        # by endpoint

        self._numOfReconnects = 0
        self._isConnected = False
        self._lastConnectedAt = None
        self.config = config or getConfig()
        self.uid = name
Esempio n. 13
0
    def __init__(self, name, ha, basedirpath, msgHandler, restricted=True,
                 seed=None, onlyListener=False, config=None, msgRejectHandler=None, queue_size=0,
                 create_listener_monitor=False, metrics=NullMetricsCollector(),
                 mt_incoming_size=None, mt_outgoing_size=None, timer=None):
        self._name = name
        self.ha = ha
        self.basedirpath = basedirpath
        self.msgHandler = msgHandler
        self.seed = seed
        self.queue_size = queue_size
        self.config = config or getConfig()
        self.msgRejectHandler = msgRejectHandler or self.__defaultMsgRejectHandler

        self.metrics = metrics
        self.mt_incoming_size = mt_incoming_size
        self.mt_outgoing_size = mt_outgoing_size

        self.listenerQuota = self.config.DEFAULT_LISTENER_QUOTA
        self.listenerSize = self.config.DEFAULT_LISTENER_SIZE
        self.senderQuota = self.config.DEFAULT_SENDER_QUOTA
        self.msgLenVal = MessageLenValidator(self.config.MSG_LEN_LIMIT)

        self.homeDir = None
        # As of now there would be only one file in secretKeysDir and sigKeyDir
        self.publicKeysDir = None
        self.secretKeysDir = None
        self.verifKeyDir = None
        self.sigKeyDir = None

        self.signer = None
        self.verifiers = {}

        self.setupDirs()
        self.setupOwnKeysIfNeeded()
        self.setupSigning()

        # self.poller = test.asyncio.Poller()

        self.restricted = restricted

        self.ctx = None  # type: Context
        self.listener = None
        self.create_listener_monitor = create_listener_monitor
        self.listener_monitor = None
        self.auth = None

        # Each remote is identified uniquely by the name
        self._remotes = {}  # type: Dict[str, Remote]

        self.remotesByKeys = {}

        # Indicates if this stack will maintain any remotes or will
        # communicate simply to listeners. Used in ClientZStack
        self.onlyListener = onlyListener

        self._conns = set()  # type: Set[str]

        self.rxMsgs = deque()
        self._created = time.perf_counter()

        self.last_heartbeat_at = None

        self._stashed_to_disconnected = {}
        self._stashed_pongs = set()
        self._received_pings = set()
        self._client_message_provider = ClientMessageProvider(self.name,
                                                              self.config,
                                                              self.prepare_to_send,
                                                              self.metrics,
                                                              self.mt_outgoing_size,
                                                              timer)
Esempio n. 14
0
def tconf():
    return getConfig()
Esempio n. 15
0
def tconf():
    tmp = getConfig()
    old_num = tmp.ZMQ_INTERNAL_QUEUE_SIZE
    tmp.ZMQ_INTERNAL_QUEUE_SIZE = BIG_NUM_OF_MSGS
    yield tmp
    tmp.ZMQ_INTERNAL_QUEUE_SIZE = old_num
Esempio n. 16
0
    def __init__(self, name, ha, basedirpath, msgHandler, restricted=True,
                 seed=None, onlyListener=False, config=None, msgRejectHandler=None, queue_size=0,
                 create_listener_monitor=False, metrics=NullMetricsCollector(),
                 mt_incoming_size=None, mt_outgoing_size=None):
        self._name = name
        self.ha = ha
        self.basedirpath = basedirpath
        self.msgHandler = msgHandler
        self.seed = seed
        self.queue_size = queue_size
        self.config = config or getConfig()
        self.msgRejectHandler = msgRejectHandler or self.__defaultMsgRejectHandler

        self.metrics = metrics
        self.mt_incoming_size = mt_incoming_size
        self.mt_outgoing_size = mt_outgoing_size

        self.listenerQuota = self.config.DEFAULT_LISTENER_QUOTA
        self.listenerSize = self.config.DEFAULT_LISTENER_SIZE
        self.senderQuota = self.config.DEFAULT_SENDER_QUOTA
        self.msgLenVal = MessageLenValidator(self.config.MSG_LEN_LIMIT)

        self.homeDir = None
        # As of now there would be only one file in secretKeysDir and sigKeyDir
        self.publicKeysDir = None
        self.secretKeysDir = None
        self.verifKeyDir = None
        self.sigKeyDir = None

        self.signer = None
        self.verifiers = {}

        self.setupDirs()
        self.setupOwnKeysIfNeeded()
        self.setupSigning()

        # self.poller = test.asyncio.Poller()

        self.restricted = restricted

        self.ctx = None  # type: Context
        self.listener = None
        self.create_listener_monitor = create_listener_monitor
        self.listener_monitor = None
        self.auth = None

        # Each remote is identified uniquely by the name
        self._remotes = {}  # type: Dict[str, Remote]

        self.remotesByKeys = {}

        # Indicates if this stack will maintain any remotes or will
        # communicate simply to listeners. Used in ClientZStack
        self.onlyListener = onlyListener

        self._conns = set()  # type: Set[str]

        self.rxMsgs = deque()
        self._created = time.perf_counter()

        self.last_heartbeat_at = None

        self._stashed_to_disconnected = {}
        self._stashed_pongs = set()
        self._received_pings = set()