Ejemplo n.º 1
0
 def __init__(self, start=1, multiplier=1, offset=0, tag=""):
     Primitive.__init__(self)
     self.Range = 1000000
     self.Next = start
     self.Tag = tag
     self.Offset = offset
     self.Multiplier = multiplier
Ejemplo n.º 2
0
Archivo: cdsrv.py Proyecto: imandr/ring
 def __init__(self, ether):
     Primitive.__init__(self)
     self.Data = {}
     self.Ether = ether
     self.Synchronized = False
     self.PendingUpdates = {}  # key -> value
     self.ID = self.MyRank = self.Ether.ID  # use the Ether ID (hex string) as rank
Ejemplo n.º 3
0
 def __init__(self, adjust=False):
     Primitive.__init__(self)
     self.Contexts = {}
     self.Delay = 0.0
     self.Adjust = adjust
     if adjust:
         self.Delay = Tracer.benchmark()
Ejemplo n.º 4
0
Archivo: link.py Proyecto: imandr/ring
 def __init__(self, capacity, lowwater=None):
         Primitive.__init__(self)
         if lowwater is None:    lowwater = int(capacity*0.9)
         assert lowwater < capacity
         self.Capacity = capacity
         self.LowWater = lowwater
         self.Memory = {}            # tid -> (time, data)
Ejemplo n.º 5
0
 def __init__(self, node, inx, nodes):
     Primitive.__init__(self)
     self.Node = node
     self.Index = inx
     self.UpNodes = nodes  #[(inx, ip, port), ...]
     self.UpStream = None
     self.UpIndex = None
Ejemplo n.º 6
0
 def __init__(self, session, files, max_matchers, stagger):
     Primitive.__init__(self)
     self.Matches = []
     self.Unmatches = []
     self.Queue = TaskQueue(
         max_matchers,
         stagger=stagger,
         tasks=[Matcher(self, session, path) for path in files])
Ejemplo n.º 7
0
 def __init__(self, config, logger=None):
     name = config["name"]
     #print("Service(): config:", config)
     self.ServiceName = name
     Primitive.__init__(self, name=f"[service {name}]")
     Logged.__init__(self, f"[app {name}]", logger, debug=True)
     self.Config = None
     self.Initialized = self.initialize(config)
Ejemplo n.º 8
0
Archivo: link.py Proyecto: imandr/ring
 def __init__(self, inx, nodes):
     Primitive.__init__(self)
     self.Index = inx
     self.Nodes = nodes          # [(ip, ip_bind, port),...]
     _, ip_bind, port = nodes[inx]
     up_nodes = [(i,) + (ip, port) for i, (ip, _, port) in enumerate(nodes)]
     up_nodes = (up_nodes[inx:] + up_nodes[:inx])[::-1]  # sorted in upwards order
     self.UpNodes = up_nodes
     self.Seen = SeenMemory(10000)               # data: (seen, sent_edge, sent_diagonal)
     self.DiagonalLink = DiagonalLink(self, ip_bind, port)
     self.DownLink = DownLink(self, inx, ip_bind, port)
     self.UpLink = UpLink(self, inx, self.UpNodes)
Ejemplo n.º 9
0
 def __init__(self, root):
     Primitive.__init__(self)
     self.Root = root
     self.Cache = VFSCache(self)  # lpath -> (entry_time, type, info)
     self.CellInxDB = CellIndexDB(self.Root + '/.cellinx')
     self.LastFlush = 0
     self.Debug = 0
     if self.getDirInfo('/') == None:
         info = VFSDirInfo('/')
         info.Prot = 'rwrw'
         info.Username = '******'
         self.storeDirInfo(info)
         self.debug("created / entry")
Ejemplo n.º 10
0
 def __init__(self, sock=None, send_masked=False, max_fragment=None):
     Primitive.__init__(self)
     self.Sock = sock
     self.Closed = False
     self.CloseReceived = False
     self.CloseSent = False
     self.SendMasked = send_masked
     self.ClosedCode = None
     self.ClosedStatus = ""
     self.MaxFragment = max_fragment
     self.SendLock = RLock()
     self.RecvLock = RLock()
     self.BufferedFragments = []  # [(fin, opcode, data),... ]
Ejemplo n.º 11
0
 def __init__(self, handler_map=None):
     #
     # handler_map:
     #   - WSHandler subclass - all in one handler
     #   - [(pattern, class), ...]
     #.  - {pattern:class, ...}
     #
     Primitive.__init__(self)
     self.Map = []
     if isinstance(handler_map, list):
         self.Map = handler_map
     elif isinstance(handler_map, dict):
         self.Map = list(handler_map.items())
     else:
         self.Map = [('*', handler_map)]
Ejemplo n.º 12
0
    def __init__(self, root):
        Primitive.__init__(self)
        self.Root = root
        self.Cache = VFSCache(self)  # lpath -> (entry_time, type, info)
        self.CellInxDB = CellIndexDB(self.Root + '/.cellinx')
        self.LastFlush = 0
        self.Debug = 0

        info = VFSDirInfo('/')
        info.Prot = 'rwrw'
        info.Username = '******'
        self.DB = VFSDBStorage(self.Root + "/vfs.db", info.serialize())
        self.FlushInterval = 30.0

        self.debug("root info: %s" % (self.getDirInfo('/'), ))
Ejemplo n.º 13
0
    def __init__(self, dbfile, root_info):
        Primitive.__init__(self)
        self.DB = SQLiteDB(dbfile)
        with self.DB.transaction() as t:
            t.execute("""
                create table if not exists vfs (
                    dpath text,
                    key text,
                    type text,
                    info text,
                    primary key (dpath, key)
                );
                """)

        if self.type("/") != 'd':
            self.mkdir("/", root_info)
Ejemplo n.º 14
0
 def __init__(self, config, logger=None):
     self.Instance = config["instance"]
     Primitive.__init__(self, name=f"[app {self.Instance}]")        
     Logged.__init__(self, f"[app {self.Instance}]", logger, debug=True)
     self.configure(config)
Ejemplo n.º 15
0
 def __init__(self, ether):
     Primitive.__init__(self)
     self.Data = {}
     self.Ether = ether
     self.Synchronized = False
     self.PendingUpdates = {}        # key -> value
Ejemplo n.º 16
0
 def __init__(self, path):
     Primitive.__init__(self)
     self.Path = path
     self.N = 0
     self.T = 0.0
Ejemplo n.º 17
0
 def __init__(self, cfg):
     Primitive.__init__(self)
     self.Replicators = TaskQueue(cfg.get('max_rep', 2), stagger=0.5)
     self.DClient = DataClient((cfg["broadcast"], cfg["listen_port"]),
                               cfg["farm_name"])