Esempio n. 1
0
 def __init__(self, server):
     FlowBase.__init__(self, server)
     self.apiroutine = RoutineContainer(self.scheduler)
     self.apiroutine.main = self._main
     self.routines.append(self.apiroutine)
     self._flowupdaters = {}
     self._extra_arps = {}
     self.createAPI(api(self.createproxyarp), api(self.removeproxyarp))
Esempio n. 2
0
 def __init__(self, server):
     FlowBase.__init__(self, server)
     self.apiroutine = RoutineContainer(self.scheduler)
     self.apiroutine.main = self._main
     self.routines.append(self.apiroutine)
     self._flowupdaters = {}
     self._extra_arps = {}
     self.createAPI(api(self.createproxyarp),
                    api(self.removeproxyarp))
Esempio n. 3
0
 def __init__(self, server):
     '''
     Constructor
     '''
     Module.__init__(self, server)
     self.apiroutine = RoutineContainer(self.scheduler)
     self.createAPI(api(self.start, self.apiroutine),
                    api(self.create, self.apiroutine),
                    api(self.get, self.apiroutine),
                    api(self.destroy, self.apiroutine))
Esempio n. 4
0
 def __init__(self, server, protocolclass):
     Module.__init__(self, server)
     self._protocolclass = protocolclass
     self.apiroutine = RoutineContainer(self.scheduler)
     self.managed_connections = set()
     self._createServers(self, '')
     self.createAPI(api(self.getservers),
                    api(self.stoplisten, self.apiroutine),
                    api(self.startlisten, self.apiroutine),
                    api(self.updateconfig, self.apiroutine),
                    api(self.getconnections))
Esempio n. 5
0
 def __init__(self, server, protocolclass):
     Module.__init__(self, server)
     self._protocolclass = protocolclass
     self.apiroutine = RoutineContainer(self.scheduler)
     self.managed_connections = set()
     self._createServers(self, '')
     self.createAPI(api(self.getservers),
                    api(self.stoplisten, self.apiroutine),
                    api(self.startlisten, self.apiroutine),
                    api(self.updateconfig, self.apiroutine),
                    api(self.getconnections))
Esempio n. 6
0
 def __init__(self, server):
     """
     Constructor
     """
     Module.__init__(self, server)
     self.apiroutine = RoutineContainer(self.scheduler)
     self.createAPI(
         api(self.start, self.apiroutine),
         api(self.create, self.apiroutine),
         api(self.get, self.apiroutine),
         api(self.destroy, self.apiroutine),
     )
Esempio n. 7
0
 def __init__(self, server):
     '''
     Constructor
     '''
     Module.__init__(self, server)
     self.timeoutroutine = RoutineContainer(self.scheduler)
     self.timeoutroutine.main = self._timeout
     self.db = {}
     self.routines.append(self.timeoutroutine)
     self.createAPI(api(self.get), api(self.set), api(self.delete),
                    api(self.mget), api(self.mgetwithcache), api(self.mset),
                    api(self.update), api(self.mupdate),
                    api(self.updateall), api(self.updateallwithtime))
Esempio n. 8
0
 def __init__(self, server):
     '''
     Constructor
     '''
     Module.__init__(self, server)
     self.apiroutine = RoutineContainer(self.scheduler)
     self.apiroutine.main = self._autoreload
     self._lastcheck = time()
     if self.autoreload:
         self.routines.append(self.apiroutine)
     self.createAPI(api(self.enableAutoReload), api(self.activeModules),
                    api(self.reloadmodules, self.apiroutine),
                    api(self.loadmodule, self.apiroutine),
                    api(self.unloadmodule, self.apiroutine))
Esempio n. 9
0
 def __init__(self, server):
     """
     Constructor
     """
     Module.__init__(self, server)
     self.apiroutine = RoutineContainer(self.scheduler)
     self.apiroutine.main = self._autoreload
     self._lastcheck = time()
     if self.autoreload:
         self.routines.append(self.apiroutine)
     self.createAPI(
         api(self.enableAutoReload),
         api(self.activeModules),
         api(self.reloadmodules, self.apiroutine),
         api(self.loadmodule, self.apiroutine),
         api(self.unloadmodule, self.apiroutine),
     )
Esempio n. 10
0
 def __init__(self, server):
     super(RemoteCall, self).__init__(server)
     self.app_routine = RoutineContainer(self.scheduler)
     # there is no need to run this container main, so don't append it
     # self.routines.append(self.app_routine)
     self.wc = WebClient()
     self.app_routine.main = self._main
     self.routines.append(self.app_routine)
     self.createAPI(api(self.call, self.app_routine))
Esempio n. 11
0
 def __init__(self, server):
     Module.__init__(self, server)
     taskpool = TaskPool(self.scheduler)
     self.taskpool = taskpool
     self.routines.append(self.taskpool)
     self.routines.append(NetworkPlugin(self))
     self.apiroutine = RoutineContainer(self.scheduler)
     self._reqid = 0
     self.createAPI(api(self.getdockerinfo, self.apiroutine))
Esempio n. 12
0
 def __init__(self, server):
     Module.__init__(self, server)
     self.apiroutine = RoutineContainer(self.scheduler)
     self.apiroutine.main = self._main
     self.routines.append(self.apiroutine)
     self._reqid = 0
     self._ownerid = uuid1().hex
     self.createAPI(api(self.createlogicalnetwork, self.apiroutine),
                    api(self.createlogicalnetworks, self.apiroutine),
                    api(self.createphysicalnetwork, self.apiroutine),
                    api(self.createphysicalnetworks, self.apiroutine),
                    api(self.createphysicalport, self.apiroutine),
                    api(self.createphysicalports, self.apiroutine),
                    api(self.createlogicalport, self.apiroutine),
                    api(self.createlogicalports, self.apiroutine),
                    api(self.getlogicalnetworks, self.apiroutine))
     self._logger.setLevel(logging.DEBUG)
Esempio n. 13
0
 def __init__(self, server):
     Module.__init__(self, server)
     self.apiroutine = RoutineContainer(self.scheduler)
     self.apiroutine.main = self._main
     self.routines.append(self.apiroutine)
     self._reqid = 0
     self._ownerid = uuid1().hex
     self.createAPI(api(self.createlogicalnetwork, self.apiroutine),
                    api(self.createlogicalnetworks, self.apiroutine),
                    api(self.createphysicalnetwork, self.apiroutine),
                    api(self.createphysicalnetworks, self.apiroutine),
                    api(self.createphysicalport, self.apiroutine),
                    api(self.createphysicalports, self.apiroutine),
                    api(self.createlogicalport, self.apiroutine),
                    api(self.createlogicalports, self.apiroutine),
                    api(self.getlogicalnetworks, self.apiroutine))
     self._logger.setLevel(logging.DEBUG)
Esempio n. 14
0
    def __init__(self,server):
        super(VXLANVtep,self).__init__(server)
        self.app_routine = RoutineContainer(self.scheduler)
        self.app_routine.main = self._main
        self.routines.append(self.app_routine)

        self.conns = {}
        self.vxlan_vlan_map_info = {}

        self.createAPI(publicapi(self.createioflowparts, self.app_routine,
                                 lambda connection,logicalnetwork,**kwargs:
                                        _is_vxlan(logicalnetwork)),
                       api(self.get_vxlan_bind_info,self.app_routine))
Esempio n. 15
0
 def __init__(self, server):
     Module.__init__(self, server)
     self.dispatcher = Dispatcher(self.scheduler)
     self.mimetypedatabase = mimetypes.MimeTypes(self.mimetypes)
     self._cache = {}
     self.apiroutine = RoutineContainer(self.scheduler)
     self.lastcleartime = 0
     def start(asyncStart = False):
         self._createHandlers(self)
     def close():
         self.dispatcher.close()
     self.apiroutine.start = start
     self.apiroutine.close = close
     self.routines.append(self.apiroutine)
     self.createAPI(api(self.updateconfig))
Esempio n. 16
0
 def __init__(self, server):
     Module.__init__(self, server)
     self.dispatcher = Dispatcher(self.scheduler)
     self.mimetypedatabase = mimetypes.MimeTypes(self.mimetypes)
     self._cache = {}
     self.apiroutine = RoutineContainer(self.scheduler)
     self.lastcleartime = 0
     def start(asyncStart = False):
         self._createHandlers(self)
     def close():
         self.dispatcher.close()
     self.apiroutine.start = start
     self.apiroutine.close = close
     self.routines.append(self.apiroutine)
     self.createAPI(api(self.updateconfig))
Esempio n. 17
0
 def __init__(self, server):
     Module.__init__(self, server)
     self.apiroutine = RoutineContainer(self.scheduler)
     self.apiroutine.main = self._manage_ports
     self.routines.append(self.apiroutine)
     self.managed_ports = {}
     self.createAPI(api(self.getports, self.apiroutine),
                    api(self.getallports, self.apiroutine),
                    api(self.getportbyno, self.apiroutine),
                    api(self.waitportbyno, self.apiroutine),
                    api(self.getportbyname, self.apiroutine),
                    api(self.waitportbyname, self.apiroutine),
                    api(self.resync, self.apiroutine))
     self._synchronized = False
Esempio n. 18
0
 def __init__(self, server):
     Module.__init__(self, server)
     self.apiroutine = RoutineContainer(self.scheduler)
     self.apiroutine.main = self._manage_ports
     self.routines.append(self.apiroutine)
     self.managed_ports = {}
     self.createAPI(api(self.getports, self.apiroutine),
                    api(self.getallports, self.apiroutine),
                    api(self.getportbyno, self.apiroutine),
                    api(self.waitportbyno, self.apiroutine),
                    api(self.getportbyname, self.apiroutine),
                    api(self.waitportbyname, self.apiroutine),
                    api(self.resync, self.apiroutine)
                    )
     self._synchronized = False
Esempio n. 19
0
 def __init__(self, server):
     Module.__init__(self, server)
     self.apiroutine = RoutineContainer(self.scheduler)
     self.apiroutine.main = self._manage_ports
     self.routines.append(self.apiroutine)
     self.managed_ports = {}
     self.managed_ids = {}
     self.monitor_routines = set()
     self.ports_uuids = {}
     self.wait_portnos = {}
     self.wait_names = {}
     self.wait_ids = {}
     self.bridge_datapathid = {}
     self.createAPI(api(self.getports, self.apiroutine),
                    api(self.getallports, self.apiroutine),
                    api(self.getportbyid, self.apiroutine),
                    api(self.waitportbyid, self.apiroutine),
                    api(self.getportbyname, self.apiroutine),
                    api(self.waitportbyname, self.apiroutine),
                    api(self.getportbyno, self.apiroutine),
                    api(self.waitportbyno, self.apiroutine),
                    api(self.resync, self.apiroutine))
     self._synchronized = False
Esempio n. 20
0
 def __init__(self, server):
     Module.__init__(self, server)
     self.apiroutine = RoutineContainer(self.scheduler)
     self.apiroutine.main = self._manage_ports
     self.routines.append(self.apiroutine)
     self.managed_ports = {}
     self.managed_ids = {}
     self.monitor_routines = set()
     self.ports_uuids = {}
     self.wait_portnos = {}
     self.wait_names = {}
     self.wait_ids = {}
     self.bridge_datapathid = {}
     self.createAPI(api(self.getports, self.apiroutine),
                    api(self.getallports, self.apiroutine),
                    api(self.getportbyid, self.apiroutine),
                    api(self.waitportbyid, self.apiroutine),
                    api(self.getportbyname, self.apiroutine),
                    api(self.waitportbyname, self.apiroutine),
                    api(self.getportbyno, self.apiroutine),
                    api(self.waitportbyno, self.apiroutine),
                    api(self.resync, self.apiroutine)
                    )
     self._synchronized = False
Esempio n. 21
0
 def __init__(self, server):
     Module.__init__(self, server)
     self.apiroutine = RoutineContainer(self.scheduler)
     self.apiroutine.main = self._manage_conns
     self.routines.append(self.apiroutine)
     self.managed_conns = {}
     self.endpoint_conns = {}
     self.table_modules = set()
     self._acquiring = False
     self._acquire_updated = False
     self._lastacquire = None
     self._synchronized = False
     self.createAPI(api(self.getconnections, self.apiroutine),
                    api(self.getconnection, self.apiroutine),
                    api(self.waitconnection, self.apiroutine),
                    api(self.getdatapathids, self.apiroutine),
                    api(self.getalldatapathids, self.apiroutine),
                    api(self.getallconnections, self.apiroutine),
                    api(self.getconnectionsbyendpoint, self.apiroutine),
                    api(self.getconnectionsbyendpointname, self.apiroutine),
                    api(self.getendpoints, self.apiroutine),
                    api(self.getallendpoints, self.apiroutine),
                    api(self.acquiretable, self.apiroutine),
                    api(self.unacquiretable, self.apiroutine),
                    api(self.lastacquiredtables)
                    )
Esempio n. 22
0
 def __init__(self, server):
     Module.__init__(self, server)
     self.apiroutine = RoutineContainer(self.scheduler)
     self.apiroutine.main = self._manage_conns
     self.routines.append(self.apiroutine)
     self.managed_conns = {}
     self.managed_systemids = {}
     self.managed_bridges = {}
     self.managed_routines = []
     self.endpoint_conns = {}
     self.createAPI(api(self.getconnection, self.apiroutine),
                    api(self.waitconnection, self.apiroutine),
                    api(self.getdatapathids, self.apiroutine),
                    api(self.getalldatapathids, self.apiroutine),
                    api(self.getallconnections, self.apiroutine),
                    api(self.getbridges, self.apiroutine),
                    api(self.getbridge, self.apiroutine),
                    api(self.getbridgebyuuid, self.apiroutine),
                    api(self.waitbridge, self.apiroutine),
                    api(self.waitbridgebyuuid, self.apiroutine),
                    api(self.getsystemids, self.apiroutine),
                    api(self.getallsystemids, self.apiroutine),
                    api(self.getconnectionbysystemid, self.apiroutine),
                    api(self.waitconnectionbysystemid, self.apiroutine),
                    api(self.getconnectionsbyendpoint, self.apiroutine),
                    api(self.getconnectionsbyendpointname, self.apiroutine),
                    api(self.getendpoints, self.apiroutine),
                    api(self.getallendpoints, self.apiroutine),
                    api(self.getallbridges, self.apiroutine),
                    api(self.getbridgeinfo, self.apiroutine),
                    api(self.waitbridgeinfo, self.apiroutine)
                    )
     self._synchronized = False
Esempio n. 23
0
 def __init__(self, server):
     Module.__init__(self, server)
     self.createAPI(api(self.createnotifier))
Esempio n. 24
0
 def __init__(self, server):
     self._redis_clients = {}
     TcpServerBase.__init__(self, server, Redis)
     self._sequencial = False
     self._sequencialsince = time()
     self._enterlock = False
     self._enterlocksince = time()
     if self.serialize == 'pickle' or self.serialize == 'cpickle' or self.serialize == 'cPickle':
         if self.serialize == 'pickle':
             if not self.cpickle:
                 p = pickle
             else:
                 p = cPickle
         else:
             p = cPickle
         if self.pickleversion is None or self.pickleversion == 'default':
             pickleversion = None
         elif self.pickleversion == 'highest':
             pickleversion = p.HIGHEST_PROTOCOL
         else:
             pickleversion = self.pickleversion
         if self.deflate:
             def _encode(obj):
                 return compress(p.dumps(obj, pickleversion), 1)
         else:
             def _encode(obj):
                 return p.dumps(obj, pickleversion)
         self._encode = _encode
         if self.deflate:
             def _decode(data):
                 if data is None:
                     return None
                 elif isinstance(data, Exception):
                     raise data
                 else:
                     try:
                         return p.loads(decompress(data))
                     except zlib_error:
                         return p.loads(data)
         else:
             def _decode(data):
                 if data is None:
                     return None
                 elif isinstance(data, Exception):
                     raise data
                 else:
                     return p.loads(data)
         self._decode = _decode
     else:
         if self.deflate:
             def _encode(obj):
                 return compress(json.dumps(obj, default=encode_default).encode('utf-8'), 1)
             self._encode = _encode
             def _decode(data):
                 if data is None:
                     return None
                 elif isinstance(data, Exception):
                     raise data
                 else:
                     try:
                         data = decompress(data)
                     except zlib_error:
                         pass
                     if not isinstance(data, str) and isinstance(data, bytes):
                         data = data.decode('utf-8')
                     return json.loads(data, object_hook=decode_object)
             self._decode = _decode
         else:
             def _encode(obj):
                 return json.dumps(obj, default=encode_default).encode('utf-8')
             self._encode = _encode
             def _decode(data):
                 if data is None:
                     return None
                 elif isinstance(data, Exception):
                     raise data
                 elif not isinstance(data, str) and isinstance(data, bytes):
                     data = data.decode('utf-8')
                 return json.loads(data, object_hook=decode_object)
             self._decode = _decode                
     self.appendAPI(api(self.getclient),
                    api(self.get, self.apiroutine),
                    api(self.set, self.apiroutine),
                    api(self.delete, self.apiroutine),
                    api(self.mget, self.apiroutine),
                    api(self.mset, self.apiroutine),
                    api(self.update, self.apiroutine),
                    api(self.mupdate, self.apiroutine),
                    api(self.updateall, self.apiroutine),
                    api(self.updateallwithtime, self.apiroutine),
                    api(self.listallkeys, self.apiroutine))
Esempio n. 25
0
 def __init__(self, server):
     Module.__init__(self, server)
     self._managed_objs = {}
     self._watches = {}
     self._watchedkeys = set()
     self._requests = []
     self._transactno = 0
     self._stale = False
     self._updatekeys = set()
     self._update_version = {}
     self.apiroutine = RoutineContainer(self.scheduler)
     self.apiroutine.main = self._update
     self.routines.append(self.apiroutine)
     self.createAPI(api(self.mget, self.apiroutine),
                    api(self.get, self.apiroutine),
                    api(self.mgetonce, self.apiroutine),
                    api(self.getonce, self.apiroutine),
                    api(self.mwatch, self.apiroutine),
                    api(self.watch, self.apiroutine),
                    api(self.munwatch, self.apiroutine),
                    api(self.unwatch, self.apiroutine),
                    api(self.unwatchall, self.apiroutine),
                    api(self.transact, self.apiroutine),
                    api(self.watchlist), api(self.walk, self.apiroutine))
Esempio n. 26
0
 def __init__(self, server):
     Module.__init__(self, server)
     self._tableacquire_routine = RoutineContainer(self.scheduler)
     self._tableacquire_routine.main = self._acquiretable
     self.routines.append(self._tableacquire_routine)
     self.createAPI(api(self.gettablerequest))
Esempio n. 27
0
 def __init__(self, server):
     Module.__init__(self, server)
     self._managed_objs = {}
     self._watches = {}
     self._watchedkeys = set()
     self._requests = []
     self._transactno = 0
     self._stale = False
     self._updatekeys = set()
     self._update_version = {}
     self.apiroutine = RoutineContainer(self.scheduler)
     self.apiroutine.main = self._update
     self.routines.append(self.apiroutine)
     self.createAPI(api(self.mget, self.apiroutine),
                    api(self.get, self.apiroutine),
                    api(self.mgetonce, self.apiroutine),
                    api(self.getonce, self.apiroutine),
                    api(self.mwatch, self.apiroutine),
                    api(self.watch, self.apiroutine),
                    api(self.munwatch, self.apiroutine),
                    api(self.unwatch, self.apiroutine),
                    api(self.unwatchall, self.apiroutine),
                    api(self.transact, self.apiroutine),
                    api(self.watchlist),
                    api(self.walk, self.apiroutine)
                    )
Esempio n. 28
0
    def __init__(self, server):
        super(VRouterApi, self).__init__(server)

        self.app_routine = RoutineContainer(self.scheduler)
        self.app_routine.main = self.main
        self.routines.append(self.app_routine)
        self._reqid = 0

        self.createAPI(api(self.createvirtualrouter, self.app_routine),
                       api(self.createvirtualrouters, self.app_routine),
                       api(self.updatevirtualrouter, self.app_routine),
                       api(self.updatevirtualrouters, self.app_routine),
                       api(self.deletevirtualrouter, self.app_routine),
                       api(self.deletevirtualrouters, self.app_routine),
                       api(self.listvirtualrouters, self.app_routine),
                       api(self.addrouterinterface, self.app_routine),
                       api(self.addrouterinterfaces, self.app_routine),
                       api(self.removerouterinterface, self.app_routine),
                       api(self.removerouterinterfaces, self.app_routine),
                       api(self.listrouterinterfaces, self.app_routine))
Esempio n. 29
0
 def __init__(self, server):
     Module.__init__(self, server)
     self._tableacquire_routine = RoutineContainer(self.scheduler)
     self._tableacquire_routine.main = self._acquiretable
     self.routines.append(self._tableacquire_routine)
     self.createAPI(api(self.gettablerequest))
Esempio n. 30
0
 def __init__(self, server):
     Module.__init__(self, server)
     self.apiroutine = RoutineContainer(self.scheduler)
     self.apiroutine.main = self._manage_conns
     self.routines.append(self.apiroutine)
     self.managed_conns = {}
     self.endpoint_conns = {}
     self.table_modules = set()
     self._acquiring = False
     self._acquire_updated = False
     self._lastacquire = None
     self._synchronized = False
     self.createAPI(api(self.getconnections, self.apiroutine),
                    api(self.getconnection, self.apiroutine),
                    api(self.waitconnection, self.apiroutine),
                    api(self.getdatapathids, self.apiroutine),
                    api(self.getalldatapathids, self.apiroutine),
                    api(self.getallconnections, self.apiroutine),
                    api(self.getconnectionsbyendpoint, self.apiroutine),
                    api(self.getconnectionsbyendpointname, self.apiroutine),
                    api(self.getendpoints, self.apiroutine),
                    api(self.getallendpoints, self.apiroutine),
                    api(self.acquiretable, self.apiroutine),
                    api(self.unacquiretable, self.apiroutine),
                    api(self.lastacquiredtables))
Esempio n. 31
0
 def __init__(self, server):
     Module.__init__(self, server)
     self.createAPI(api(self.createnotifier))
Esempio n. 32
0
 def __init__(self, server):
     Module.__init__(self, server)
     self.apiroutine = RoutineContainer(self.scheduler)
     self.apiroutine.main = self._manage_conns
     self.routines.append(self.apiroutine)
     self.managed_conns = {}
     self.managed_systemids = {}
     self.managed_bridges = {}
     self.managed_routines = []
     self.endpoint_conns = {}
     self.createAPI(api(self.getconnection, self.apiroutine),
                    api(self.waitconnection, self.apiroutine),
                    api(self.getdatapathids, self.apiroutine),
                    api(self.getalldatapathids, self.apiroutine),
                    api(self.getallconnections, self.apiroutine),
                    api(self.getbridges, self.apiroutine),
                    api(self.getbridge, self.apiroutine),
                    api(self.getbridgebyuuid, self.apiroutine),
                    api(self.waitbridge, self.apiroutine),
                    api(self.waitbridgebyuuid, self.apiroutine),
                    api(self.getsystemids, self.apiroutine),
                    api(self.getallsystemids, self.apiroutine),
                    api(self.getconnectionbysystemid, self.apiroutine),
                    api(self.waitconnectionbysystemid, self.apiroutine),
                    api(self.getconnectionsbyendpoint, self.apiroutine),
                    api(self.getconnectionsbyendpointname, self.apiroutine),
                    api(self.getendpoints, self.apiroutine),
                    api(self.getallendpoints, self.apiroutine),
                    api(self.getallbridges, self.apiroutine),
                    api(self.getbridgeinfo, self.apiroutine),
                    api(self.waitbridgeinfo, self.apiroutine))
     self._synchronized = False
Esempio n. 33
0
 def __init__(self, server):
     self._redis_clients = {}
     TcpServerBase.__init__(self, server, Redis)
     self._sequencial = False
     self._sequencialsince = time()
     self._enterlock = False
     self._enterlocksince = time()
     if self.serialize == 'pickle' or self.serialize == 'cpickle' or self.serialize == 'cPickle':
         if self.serialize == 'pickle':
             if not self.cpickle:
                 p = pickle
             else:
                 p = cPickle
         else:
             p = cPickle
         if self.pickleversion is None or self.pickleversion == 'default':
             pickleversion = None
         elif self.pickleversion == 'highest':
             pickleversion = p.HIGHEST_PROTOCOL
         else:
             pickleversion = self.pickleversion
         if self.deflate:
             def _encode(obj):
                 return compress(p.dumps(obj, pickleversion), 1)
         else:
             def _encode(obj):
                 return p.dumps(obj, pickleversion)
         self._encode = _encode
         if self.deflate:
             def _decode(data):
                 if data is None:
                     return None
                 elif isinstance(data, Exception):
                     raise data
                 else:
                     try:
                         return p.loads(decompress(data))
                     except zlib_error:
                         return p.loads(data)
         else:
             def _decode(data):
                 if data is None:
                     return None
                 elif isinstance(data, Exception):
                     raise data
                 else:
                     return p.loads(data)
         self._decode = _decode
     else:
         if self.deflate:
             def _encode(obj):
                 return compress(json.dumps(obj, default=encode_default).encode('utf-8'), 1)
             self._encode = _encode
             def _decode(data):
                 if data is None:
                     return None
                 elif isinstance(data, Exception):
                     raise data
                 else:
                     try:
                         data = decompress(data)
                     except zlib_error:
                         pass
                     if not isinstance(data, str) and isinstance(data, bytes):
                         data = data.decode('utf-8')
                     return json.loads(data, object_hook=decode_object)
             self._decode = _decode
         else:
             def _encode(obj):
                 return json.dumps(obj, default=encode_default).encode('utf-8')
             self._encode = _encode
             def _decode(data):
                 if data is None:
                     return None
                 elif isinstance(data, Exception):
                     raise data
                 elif not isinstance(data, str) and isinstance(data, bytes):
                     data = data.decode('utf-8')
                 return json.loads(data, object_hook=decode_object)
             self._decode = _decode                
     self.appendAPI(api(self.getclient),
                    api(self.get, self.apiroutine),
                    api(self.set, self.apiroutine),
                    api(self.delete, self.apiroutine),
                    api(self.mget, self.apiroutine),
                    api(self.mset, self.apiroutine),
                    api(self.update, self.apiroutine),
                    api(self.mupdate, self.apiroutine),
                    api(self.updateall, self.apiroutine),
                    api(self.updateallwithtime, self.apiroutine),
                    api(self.listallkeys, self.apiroutine))