- ?cs:dZdklZdkZdkZdkZdkZdkZdkZ dk l Z !dk l Z "dk lZlZ#dklZ$dklZlZlZ%dklZ&d klZ(dkZ)d klZ*d klZlZ+d kl Z l!Z!l"Z",d k#l$Z$-dk%l&Z&.dk'l(Z(l)Z)0da*2dZ+7ei,e-e-dZ.;defdYZ/>dfdYZ0gdfdYZ1dfdYZ2dei3fdYZ4dZ5dei3fdYZ6dS( sThe StorageServer class and the exception that it may raise. This server acts as a front-end for one or more real storages, like file storage or Berkeley storage. XXX Need some basic access control-- a declaration of the methods exported for invocation by the server. (s nested_scopesN(s ClientStub(s CommitLog(s StorageStatss StatsServer(s Dispatcher(sManagedServerConnectionsDelaysMTDelay(strigger(s AuthError(sResolvedSerial(s StorageErrorsStorageTransactionError(sTransactionErrors ReadOnlyErrors ConflictError(s referencesf(s Transaction(su64soid_reprsZSScs 2345dtiadS(s?Internal helper to reset the logging label (e.g. after fork()).sZSS:%sN(sossgetpids_label(((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys set_label2scs-789ti|pt||d|dS(s,Internal helper to log a message using zLOG.serrorN(szLOGsLOGslabels_labelslevelsmessageserror(smessageslevelslabelserror((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pyslog7ssStorageServerErrorcs;tZdZ<RS(s8Error reported when an unpickleable exception is raised.(s__name__s __module__s__doc__(((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pysStorageServerError;ss ZEOStoragecsT>tZdZ?BeiZFgZHdedZ^dZ ddZ gdZ rdZ }dZ eiedZd Zed Zd Zd Zd ZdZdZdZdZ dZ*dZ0ddZ;dZCddZKdZWdZ ZdZ!]dZ"vdZ#dZ$dZ%d Z&d!Z'd"Z(d#Z)d$Z*d%Z+d&Z,d'Z-d(Z. d)Z/d*Z0d+Z1,d,Z29ed-Z3Md.Z4Zd/Z5RS(0s7Proxy to underlying storage for a single remote client.icsHI||_Kt|_Lt|_Mt|_Nt|_Ot|_Pd|_Qt|_ R||_ Sd|_ Td|_ Ud|_ Vt|_Wd|_X||_Zh|_[x'|iD[]}\t|i|i( sselfs transactionsreprsidstidsstorages _transactionsstidsNones __class__s__name__sname(sselfsnamestidsstid((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys__repr__}s  ) cs&ti|i||d|dS(Nserror(szLOGsLOGsselfs log_labelslevelsmsgserror(sselfsmsgslevelserror((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pyslogscsI|ii|_|ii|_|ii|_|ii|_|ii|_|ii|_|ii|_y|ii }Wnt j o nX|}|i i|xX|iD]G}tot|| ptt||t|i|qW|ii|_dS(s'Delegate several methods to the storageN(sselfsstorages versionEmptysversionss getSerialshistorysloads loadSerialsmodifiedInVersionsgetExtensionMethodssfnsAttributeErrorsds _extensionssupdateskeyssnames __debug__shasattrsAssertionErrorssetattrsgetattrslastTransaction(sselfsdsfnsname((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pyssetup_delegations&  "#cs>|iotn|itjoctiiii }|i d|t i |tj o|t|ndSn|ii|jotiiii }|i d|t|t|iift i |tj o||ii|ndSndSdS(Nsno current transaction: %s()is(%s(%s) invalid; current transaction = %si(sselfs read_onlys ReadOnlyErrors transactionsNonessyss _getframesf_backsf_codesco_namescallerslogszLOGsPROBLEMsexcstidsidsrepr(sselfstidsexcscaller((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys _check_tids   +  csC|ii}| p |djo tSn|SdS(sReturn string specifying name of authentication module to use. The module name should be auth_%s where %s is auth_protocol.snoneN(sselfsservers auth_protocolsprotocolsNone(sselfsprotocol((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pysgetAuthProtocols  csI|io|i otdn|itj o |idtdn|ii i |}|tjo(|id|td|n| o|i p |i otn|i p||_ ||_ ||_|i|ii||\|_|_dS(sSelect the storage that this client will use This method must be the first one called by the client. For authenticated storages this method will be called by the client immediately after authentication is finished. s+Client was never authenticated with server!sduplicate register() callsunknown storage_id: %ssunknown storage: %sN(sselfs auth_realms authenticateds AuthErrorsstoragesNoneslogs ValueErrorsserversstoragessgets storage_ids read_onlys isReadOnlys ReadOnlyErrorssetup_delegationsregister_connectionstimeoutsstats(sselfs storage_ids read_onlysstorage((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pysregisters$"   csht|id<|iid<|iid<|iid<|iid<|iid<|id|idt|@|iid|i t Af|i dS(Nspack(time=%s) started...spack(time=%s) completei( sselfslogsreprstimesstoragespacks referencesfsservers invalidates storage_idsNones get_size_info(sselfstime((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys _pack_impl;s idcs~CDE|ioFtnG|djo Hd}nIgi}t|DI]}||ii qW~SdS(s8Return a sequence of n new oids, where n defaults to 100iiN( sselfs read_onlys ReadOnlyErrorsnsappends_[1]srangesisstoragesnew_oid(sselfsns_[1]si((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pysnew_oidsCs  csKL|ioMtnN|ii|}O|o9P|ii||i t Qt d|R|SnSfSdS(Ncs Q|dfS(Ns(soid(soid((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pysQs( sselfs read_onlys ReadOnlyErrorsstoragesundostransaction_idsoidssservers invalidates storage_idsNonesmap(sselfstransaction_idsoids((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pysundoKs   cs#WXt|ii|||SdS(N(s run_in_threadsselfsstoragesundoInfosfirstslastsspec(sselfsfirstslastsspec((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pysundoInfoWscs Z[t|ii||SdS(N(s run_in_threadsselfsstoragesundoLogsfirstslast(sselfsfirstslast((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pysundoLogZscs(]^|io_tn`|itj oNa|ii|jo%b|idt|cdSnetdnht |_}i||_j||_ k||_ l||_ng|_og|_pt|_q||_r||_sd|_t|iid7_dS(Nsduplicate tpc_begin(%s)s9Multiple simultaneous tpc_begin requests from one client.ii(sselfs read_onlys ReadOnlyErrors transactionsNonesidslogsreprsStorageTransactionErrors Transactionstsusers descriptionsexts _extensionsserialss invalidateds CommitLogstxnlogstidsstatuss store_failedsstatss active_txns(sselfsidsusers descriptionsextstidsstatusst((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys tpc_begin]s&           csvw|i| o xdSnyto|iptz|iid8_{|iid7_||i i |i }|i i }~|io2|ii||i||i|in|i|SdS(Ni(sselfs _check_tidsids __debug__slockedsAssertionErrorsstatss active_txnsscommitssstorages tpc_finishs transactionslastTransactionstids invalidatedsservers invalidates storage_ids get_size_infos_clear_transaction(sselfsidstid((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys tpc_finishvs   cs|i| o dSn|iid8_|iid7_|io|ii|i n|i dS(Ni( sselfs _check_tidsidsstatss active_txnssabortsslockedsstorages tpc_aborts transactions_clear_transaction(sselfsid((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys tpc_aborts  cst|_|ii|ioOd|_|ii|t|i_ |i d|i ndS(Nis!Transaction released storage lock( sNonesselfs transactionstxnlogscloseslockedstimeoutsendsstatss lock_timeslogs_handle_waiting(sself((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys_clear_transactions   cs|i o|ii}xltt|D]U}||\}}||jo,||=|i dt|Pnq6Wn|i oD|i i d8_ |i id7_|i|i indS(NsAClosed connection removed from waiting list. Clients waiting: %d.i(sselfslockedsstorages_waitingswaitingsrangeslensisdszslogs transactionsstatss active_txnssabortss tpc_abortsid(sselfsdsiszswaiting((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys_aborts   csN|i|dt|iid7_|ii||||dS(Nsexci( sselfs _check_tidsidsStorageTransactionErrorsstatssstoresstxnlogsstoresoidsserialsdatasversion(sselfsoidsserialsdatasversionsid((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pysstoreascsQi|dtioiSnidSdS(Nsexccs iS(N(sselfs_vote((sself(s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pyss(sselfs _check_tidsidsStorageTransactionErrorslockeds_votes_wait(sselfsid((sselfs9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pysvotes csWi|dtioiSnidSdS(NsexccsiS(N(sselfs _abortVersionssrc((ssrcsself(s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pyss(sselfs _check_tidsidsStorageTransactionErrorslockeds _abortVersionssrcs_wait(sselfssrcsid((sselfssrcs9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys abortVersions cs]i|dtioiSnidSdS(NsexccsiS(N(sselfs_commitVersionssrcsdest((sdestssrcsself(s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pyss( sselfs _check_tidsidsStorageTransactionErrorslockeds_commitVersionssrcsdests_wait(sselfssrcsdestsid((sselfssrcsdests9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys commitVersions csWi|dtioiSnidSdS(NsexccsiS(N(sselfs_transactionalUndostrans_id((sselfstrans_id(s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pyss(sselfs _check_tidsidsStorageTransactionErrorslockeds_transactionalUndostrans_ids_wait(sselfstrans_idsid((sselfstrans_ids9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pystransactionalUndos csTd|_|ii|ti|i_|ii|||dS(Ni( sselfslockedstimeoutsbeginstimesstatss lock_timesstorages tpc_beginstxnstidsstatus(sselfstxnstidsstatus((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys _tpc_begins c sTt}y+|ii|||||i }Wnwt t fj o nt j oG}d|_t|toH|iid7_|idt|t|ftint|t o@ti} |id| d tid| ~ nti}d|_y|i |dWnBdt!|}|i|tit#|}nX|}n/X|djo|i$i%||fn|t&jo9|ii'd7_'|idt|tin|i(i%||f|tjSdS( Nisconflict error oid=%s msg=%ssstore error: %s, %siserrors%Couldn't pickle storage exception: %sssconflict resolved oid=%s()sNoneserrsselfsstoragesstoresoidsserialsdatasversions transactions newserials SystemExitsKeyboardInterrupts Exceptions store_faileds isinstances ConflictErrorsstatss conflictsslogsoid_reprsstrszLOGsBLATHERsTransactionErrorssyssexc_infosERRORscPicklesPicklerspicklersfastsdumpsreprsmsgsStorageServerErrors invalidatedsappendsResolvedSerialsconflicts_resolvedsserials( sselfsoidsserialsdatasversionspicklersmsgserrs newserialsexc_info((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys_storesB   "  $csK|ii|i |io  dSn |ii|iSdS(N(sselfsclients serialnossserialss store_failedsstoragestpc_votes transaction(sself((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys_votes  cso |ii||i}gi}|D]}|||fq/~}|i i ||SdS(N( sselfsstorages abortVersionssrcs transactionsoidssappends_[1]soidsinvs invalidatedsextend(sselfssrcs_[1]soidsinvsoids((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys _abortVersion s "cs|ii|||i}gi}|D]}|||fq2~}|i i ||oJgi}|D]}|||fq~}|i i |n|SdS(N( sselfsstorages commitVersionssrcsdests transactionsoidssappends_[1]soidsinvs invalidatedsextend(sselfssrcsdests_[1]soidsinvsoids((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys_commitVersions" "cso|ii||i}gi}|D]}||t fq/~}|i i | |SdS(N( sselfsstoragestransactionalUndostrans_ids transactionsoidssappends_[1]soidsNonesinvs invalidatedsextend(sselfstrans_ids_[1]soidsinvsoids((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys_transactionalUndos "cs,.||_/|iioS0t}1|iii||f2|i dt |ii4|Sn$6|i dt i 7|i SdS(Ns=Transaction blocked waiting for storage. Clients waiting: %d.s"Transaction acquired storage lock.(sthunksselfs_thunksstorages _transactionsDelaysds_waitingsappendslogslenszLOGsBLATHERs_restart(sselfsthunksd((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys_wait,s    cs9;|iidjo <d}n >d}?|i||ii|iif@dtiA|i|i |i |i B|ii \}}Cx9t|DC](}E|i|i oFPnqWG|i}H|tj oI|i|nK|SdS(Nis4Preparing to commit transaction: %d object, %d bytess5Preparing to commit transaction: %d objects, %d bytesslevel(sselfstxnlogsstoresstemplateslogssizeszLOGsBLATHERs _tpc_begins transactionstidsstatuss get_loadersloadssloadersrangesis_storesloads_thunksrespsdelaysNonesreply(sselfsdelaysistemplatesloadssrespsloader((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys_restart9s  %  csMOxO|iioP|iiid\}}Q|i||oXR|iio-St|ii}T|i d|nW|i dXdSnq WdS(Nis3Blocked transaction restarted. Clients waiting: %dsBlocked transaction restarted.( sselfsstorages_waitingspopsdelays zeo_storages_restart_otherslensnslog(sselfsdelaysns zeo_storage((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys_handle_waitingMscsqZ]y^|i|WnI_`|idadtidtib|i i cdSnXedSdS(Ns-Unexpected error handling waiting transactionslevelserrorii( s zeo_storages_restartsdelaysselfslogszLOGsWARNINGssyssexc_infos connectionsclose(sselfs zeo_storagesdelay((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys_restart_otherZs  (6s__name__s __module__s__doc__s ClientStubs ClientStoragesClientStorageStubClasss extensionssNones__init__s finish_auths set_databasesnotifyConnectedsnotifyDisconnecteds__repr__szLOGsINFOslogssetup_delegations _check_tidsgetAuthProtocolsregistersget_infos get_size_infosgetExtensionMethodsszeoLoadsgetInvalidationss zeoVerifys endZeoVerifyspacks _pack_implsnew_oidssundosundoInfosundoLogs tpc_begins tpc_finishs tpc_aborts_clear_transactions_abortsstoreasvotes abortVersions commitVersionstransactionalUndos _tpc_begins_stores_votes _abortVersions_commitVersions_transactionalUndos_waits_restarts_handle_waitings_restart_other(((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys ZEOStorage>s^            !              (    s StorageServercsgtZdZoseZteZueZwdde e e e e dZ dZ dZ dZ +fe dZKdZgd Zzd ZRS( s3The server side implementation of ZEO. The StorageServer is the 'manager' for incoming connections. Each connection is associated with its own ZEOStorage instance (defined below). The StorageServer may handle multiple storages; each ZEOStorage instance only handles a single storage. iidc sTw||_||_tdigi} |iD]=\} } | d| | i odpd| i fqE~ }t d|ii|odpd|fx#|iD]} g| _qW||_||_||_| |_t|_|o|i|ng|_||_h|_|i|d|i|_ h|_!h|_"xy|ii#D]e} t$|i!| <|tjot&}nt(|}|i)||i"| ti iDt]*}uyv|iWn wxnXq}WdS(s}Close the dispatcher so that there are no new connections. This is only called from the test suite, AFAICT. N( sselfs dispatchersclosesmonitorsNonesstoragessvaluessstoragesasyncores socket_mapss(sselfsssstorage((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys close_servergs  csTz~xD|iiD]0}|i|jo|i|inqWdS(s|Internal: remove the given connection from self.connections. This is the inverse of register_connection(). N(sselfs connectionssvaluessclsconnsobjsremove(sselfsconnscl((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys close_connzs  (s__name__s __module__s__doc__s DispatchersDispatcherClasss ZEOStoragesZEOStorageClasssManagedServerConnectionsManagedServerConnectionClasssNones__init__s _setup_authsnew_connectionsregister_connections invalidatesget_invalidationss close_servers close_conn(((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys StorageServergs   !l "    sStubTimeoutThreadcs#tZdZdZRS(Ncs dS(N((sselfsclient((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pysbeginscs dS(N((sselfsclient((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pysends(s__name__s __module__sbeginsend(((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pysStubTimeoutThreads  s TimeoutThreadcsDtZdZdZdZdZdZRS(s5Monitors transaction progress and generates timeouts.csotii||id||_t|_t|_ ti |_ t |_ dS(Ni(s threadingsThreads__init__sselfs setDaemonstimeouts_timeoutsNones_clients _deadlines Conditions_condstriggers_trigger(sselfstimeout((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys__init__s   cs|iizZto|itjpt||_ti|i |_ |ii Wd|ii XdS(N( sselfs_condsacquires __debug__s_clientsNonesAssertionErrorsclientstimes_timeouts _deadlinesnotifysrelease(sselfsclient((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pysbegins! cs|iiz^to|itj ptto|i|jptt|_t|_Wd|ii XdS(N( sselfs_condsacquires __debug__s_clientsNonesAssertionErrorsclients _deadlinesrelease(sselfsclient((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pysends!! csxdo|iiztx(|itjo|iiq/W|iti}|djot|_n|iWd|ii X|djo4i d|i |i idnti|q WdS(Niis$Transaction timeout after %s secondscsiiS(N(sclients connectionsclose((sclient(s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pyss(sselfs_condsacquires _deadlinesNoneswaitstimeshowlongs_clientsclientsreleaseslogs_timeouts_triggers pull_triggerssleep(sselfsclientshowlong((sclients9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pysruns" (s__name__s __module__s__doc__s__init__sbeginsendsrun(((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys TimeoutThreads  cs0t||}|i|iSdS(N(sSlowMethodThreadsmethodsargsstsstartsdelay(smethodsargsst((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys run_in_threads sSlowMethodThreadcs,tZdZdZdZRS(sThread to run potentially slow storage methods. Clients can use the delay attribute to access the MTDelay object used to send a zrpc response at the right time. csAtii|||_||_t|_ dS(N( s threadingsThreads__init__sselfsmethods_methodsargss_argssMTDelaysdelay(sselfsmethodsargs((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys__init__s  csy|i|i}WnPttfj o nCtj o |iit i nX|ii |dS(N( sselfs_methods_argssresults SystemExitsKeyboardInterrupts Exceptionsdelayserrorssyssexc_infosreply(sselfsresult((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pysruns (s__name__s __module__s__doc__s__init__srun(((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pysSlowMethodThreads (7s__doc__s __future__s nested_scopessasyncorescPicklesosssyss threadingstimesZEOs ClientStubs ZEO.CommitLogs CommitLogs ZEO.monitors StorageStatss StatsServersZEO.zrpc.servers DispatchersZEO.zrpc.connectionsManagedServerConnectionsDelaysMTDelaysZEO.zrpc.triggerstriggersZEO.Exceptionss AuthErrorszLOGsZODB.ConflictResolutionsResolvedSerialsZODB.POSExceptions StorageErrorsStorageTransactionErrorsTransactionErrors ReadOnlyErrors ConflictErrorsZODB.referencesfs referencesfsZODB.Transactions Transactions ZODB.utilssu64soid_reprs_labels set_labelsINFOsNoneslogsStorageServerErrors ZEOStorages StorageServersStubTimeoutThreadsThreads TimeoutThreads run_in_threadsSlowMethodThread(%sSlowMethodThreadscPickles Transactionsasyncores nested_scopess ClientStubsResolvedSerials referencesfsu64s set_labels ZEOStoragesDelays ConflictErrorsMTDelayssyss run_in_threadsManagedServerConnections StorageStatssoid_reprsStorageServerErrors AuthErrorsStorageTransactionErrors StatsServerslogsStubTimeoutThreads Dispatchers threadingstriggers ReadOnlyErrorstimeszLOGs TimeoutThreads CommitLogs StorageErrorsossTransactionErrors StorageServer((s9/usr/pkg/lib/python2.2/site-packages/ZEO/StorageServer.pys?sD          +<