版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
Ch.5DesigningtheArchitectureInstructor:TanLiwei軟件設(shè)計與體系結(jié)構(gòu)軟件體系結(jié)構(gòu)之質(zhì)量屬性referenceSoftwarearchitectureinpractice–ch1,ch5,ch7contentsDesigningArchitecture:AchievingQualities軟件體系結(jié)構(gòu)之質(zhì)量屬性ArchitectureBusinessCycle(ABC)CreatingthearchitectureHowdoesthearchitectcreateanarchitecture?(Multiplechoice):Byre-usingapproachesfromotherarchitectures通過重用來自于其他體系結(jié)構(gòu)的方法
Byinventingnewapproachesoutofthinair無中生有地發(fā)明新方法
Bymagic耍魔術(shù),變一個CreatingthearchitectureArchitectsprimarilyworkbyusingpreviously-triedsolutionsLargescale:PatternsandstylesSmallscale:TacticsStyles,patterns,andtacticsrepresentconceptualtoolsinthearchitect’s“toolbag.”Professionalarchitectsalwayskeeptheirtoolbaguptodate.風(fēng)格,模式和策略是體系架構(gòu)師的工具箱中的概念工具。專業(yè)的體系架構(gòu)師會不斷更新自己的工具箱。PatternsandstylesThemoderntermis“patterns”butearlypapersonsoftwarearchitecturewroteabout“softwarearchitecturestyles.”Stylesinarchitecturewereanalogoustostylesinhouses:Victorian(multi-story,lotsoffrilly(鑲褶邊的)wooddecorations,tallwindows,basicallysquarefootprint…)Colonial(brickfront,pillarsorcolumns,usuallysymmetricalfront…)Ranch(single-story,sprawling,notverydecorated…)大農(nóng)場PatternsandstylesIndependentcomponentpatternsCommunication-processesEventsystemsImplicitinvocationExplicitinvocationDataflowpatternsBatchsequentialPipe-and-filterLayersData-centeredpatternsBlackboardrepositoryVirtualmachinepatternsInterpretersRule-basedsystemsCall-returnpatternsMainprogramandsubroutineObjectorientedStyles->PatternsThen,thedesignpatternscommunityarrived.Architecturalstyleswereclearlyjustpatterns,whosescopeofdesignwasthewholesystem–thatis,whosescopewasthearchitecture.Now,architecturalpatternsistheterminuse.Therearebooksofarchitecturalpatterns,e.g.,Buschmann,F.,R.Meunier,H.Rohnert,P.Sommerlad,andM.Stal.1996.Pattern-OrientedSoftwareArchitecture,Volume1:ASystemofPatterns.Wiley.現(xiàn)在到了設(shè)計模式時代,體系結(jié)構(gòu)風(fēng)格顯然就是模式,其設(shè)計范圍是整個系統(tǒng)。現(xiàn)在使用的術(shù)語是體系結(jié)構(gòu)模式。關(guān)于體系結(jié)構(gòu)模式的經(jīng)典圖書ArchitecturalpatternsThesearebroadly-scopedsolutionstopreviouslyencounteredproblems.Anarchitecturalpatternisfoundrepeatedlyinpracticeisapackageofdesigndecisionshasknownpropertiesthatpermitreusedescribesaclassofarchitectures模式會在實(shí)際應(yīng)用中被不斷地重復(fù);它是一個設(shè)計決策包;具有眾所周知的可重用的屬性;模式描述了一類體系結(jié)構(gòu)。ArchitecturalpatternsApatternisdeterminedanddescribedbyasetofelementtypesforexample,datarepositories,processes,andobjectsasetofinteractionmechanismsorconnectorsforexample,subroutinecalls,events,andpipesatopologicallayoutofthecomponentsasetofsemanticconstraintscoveringtopology,elementbehavior,andinteractionmechanismsInaddition,apatternisdescribedbywhenandwhytouseit模式的描述:組成元素的類型、交互機(jī)制或連接器、組件的拓?fù)湟?guī)劃、語義約束以及何時為什么使用該模式。ArchitecturalpatternsThesearewidelyknownandincludemanyfamiliardesignapproaches:LayeredPipe-andfilterClient-serverThinclientThickclientAsynchronousSynchronousN-tierclient-serverEtc.Peer-topeerAgent-basedsystemsService-orientedarchitecturesEtc.Observe:No“universal”listPatternscanbecombined:e.g.,layeredclient-serverPatternscanbespecializedChoiceofpatternstouseisnotrandom!注意:不可能列出所有的模式;多個模式可以組合;模式可能是專門化的;模式的選擇不是隨機(jī)的。TacticsAnarchitecturaltacticisafine-graineddesignapproachusedtoachieveaqualityattributeresponse.Tacticsarethe“buildingblocks”ofdesignfromwhicharchitecturalpatternsarecreated.體系結(jié)構(gòu)策略是一種可獲得質(zhì)量屬性響應(yīng)的細(xì)膩的設(shè)計方法。策略可看作用來搭建體系結(jié)構(gòu)模式的積木塊。TacticsWhatisitthatimpartsportabilitytoonedesign,highperformancetoanother,andintegrabilitytoathird?Theachievementofthesequalitiesreliesonfundamentaldesigndecisions.Atacticisadesigndecisionthatinfluencesthecontrolofaqualityattributeresponse.Wecallacollectionoftacticsanarchitecturalstrategy.是什么向外界傳達(dá)一個設(shè)計的靈便性、高性能和可集成性?依賴于基本的設(shè)計決策。策略是指影響質(zhì)量屬性響應(yīng)控制的設(shè)計決策。策略的集合叫做體系結(jié)構(gòu)戰(zhàn)略。AvailabilityTactics可用性策略keepfaultsfrombecomingfailuresoratleastboundtheeffectsofthefaultandmakerepairpossible.使缺陷不要成為失敗,或者至少限制缺陷的影響并使修復(fù)成為可能。AvailabilityTacticsfaultdetection.故障檢測Ping/echo,Heartbeat,Exceptionsfaultrecovery故障恢復(fù)Faultrecoveryconsistsofpreparingforrecoveryandmakingthesystemrepair.Voting,Activeredundancy,Passiveredundancy,Spare,Shadowoperation,Stateresynchronization,Checkpoint/rollbackfaultprevention故障預(yù)防Removalfromservice,Transactions,ProcessmonitorFaultdetectionPing/echoOnecomponentissuesapingandexpectstoreceivebackanecho,withinapredefinedtime,fromthecomponentunderscrutiny.usedwithinagroupofcomponentsmutuallyresponsibleforonetask.usedbyclientstoensurethataserverobjectandthecommunicationpathtotheserverareoperatingwithintheexpectedperformancebounds."Ping/echo"faultdetectorscanbeorganizedinahierarchy,inwhichalowest-leveldetectorpingsthesoftwareprocesseswithwhichitsharesaprocessor,andthehigher-levelfaultdetectorspinglower-levelones.Thisuseslesscommunicationsbandwidththanaremotefaultdetectorthatpingsallprocesses.一個組件發(fā)出ping信號,期待在預(yù)計的時間內(nèi)從要監(jiān)視的組件收到響應(yīng)它用于一組共同負(fù)責(zé)一個任務(wù)的組件。可以被客戶端用來測試服務(wù)器及通信信道能在預(yù)計的性能約束內(nèi)操作FaultdetectionHeartbeat(deadmantimer).Inthiscaseonecomponentemitsaheartbeatmessageperiodicallyandanothercomponentlistensforit.Iftheheartbeatfails,theoriginatingcomponentisassumedtohavefailedandafaultcorrectioncomponentisnotified.Theheartbeatcanalsocarrydata.Forexample,anautomatedtellermachinecanperiodicallysendthelogofthelasttransactiontoaserver.Thismessagenotonlyactsasaheartbeatbutalsocarriesdatatobeprocessed.一個組件周期性地發(fā)出心跳(heartbeat)消息,其它組件監(jiān)聽之。如果沒聽到心跳,說明前者已經(jīng)失效,通知糾錯組件。心跳也可攜帶數(shù)據(jù)。例如自動出納機(jī)周期性地向服務(wù)器發(fā)送最新交易日志。FaultdetectionExceptions.例外Onemethodforrecognizingfaultsistoencounteranexception,whichisraisedwhenoneofthefaultclassesisrecognized.Theexceptionhandlertypicallyexecutesinthesameprocessthatintroducedtheexception.發(fā)現(xiàn)錯誤的另一種方法是使用例外,它在錯誤發(fā)生時拋出。例外處理器通常位于拋出例外的進(jìn)程中。FaultrecoveryVotingProcessesrunningonredundantprocessorseachtakeequivalentinputandcomputeasimpleoutputvaluethatissenttoavoter.Ifthevoterdetectsdeviantbehaviorfromasingleprocessor,itfailsit.Thismethodisusedtocorrectfaultyoperationofalgorithmsorfailureofaprocessorandisoftenusedincontrolsystems.Ifalloftheprocessorsutilizethesamealgorithms,theredundancydetectsonlyaprocessorfaultandnotanalgorithmfault.在冗余的處理器上運(yùn)行的進(jìn)程獲得相同的輸入并計算出一個輸出值,將之送到投票器,若投票器從一個處理器檢測到異常行為,放棄之。此方法被用于糾正有缺陷的算法運(yùn)算或處理器的失效,常用于控制系統(tǒng)中。若所有的處理器使用同樣的算法,則該冗余只能檢測處理器失效,不能檢測算法失效。FaultrecoveryActiveredundancy(hotrestart).主動冗余Allredundantcomponentsrespondtoeventsinparallel.Consequently,theyareallinthesamestate.Whenafaultoccurs,thedowntimeofsystemsusingthistacticisusuallymillisecondssincethebackupiscurrentandtheonlytimetorecoveristheswitchingtime.Synchronizationisperformedbyensuringthatallmessagestoanyredundantcomponentaresenttoallredundantcomponents.所有的冗余組件同時響應(yīng)事件。結(jié)果,他們處于同樣的狀態(tài)。錯誤發(fā)生的停機(jī)時間通常是微秒級。需要進(jìn)行同步,做法是把送往任一個組件的消息同時送其他冗余組件。FaultrecoveryPassiveredundancy(warmrestart/dualredundancy/tripleredundancy).被動冗余Onecomponent(theprimary)respondstoeventsandinformstheothercomponents(thestandbys)ofstateupdatestheymustmake.Whenafaultoccurs,thesystemmustfirstensurethatthebackupstateissufficientlyfreshbeforeresumingservices.Synchronizationistheresponsibilityoftheprimarycomponent,whichmayuseatomicbroadcaststothesecondarytoguaranteesynchronizationThedowntimecanusuallybelimitedtoseconds.一個組件(主組件)對事件響應(yīng),同時通知其他組件(備份)更新狀態(tài)。當(dāng)錯誤發(fā)生,恢復(fù)服務(wù)前系統(tǒng)必須保證備份狀態(tài)足夠新。同步是主組件的職責(zé),它使用自動廣播來保證同步。停機(jī)時間通常是秒級。FaultrecoverySpare.備用的Astandbysparecomputingplatformisconfiguredtoreplacemanydifferentfailedcomponents.Itmustberebootedtotheappropriatesoftwareconfigurationandhaveitsstateinitializedwhenafailureoccurs.Makingacheckpointofthesystemstatetoapersistentdeviceperiodicallyandloggingallstatechangestoapersistentdeviceallowsforthesparetobesettotheappropriatestate.Thedowntimeforthistacticisusuallyminutes.使用一備用的計算平臺來替換許多不同的失敗組件。當(dāng)失敗發(fā)生時,必須重啟到適當(dāng)?shù)能浖渲孟?,并初始化狀態(tài)。做法是周期性地向持久化設(shè)備保存系統(tǒng)狀態(tài)的檢查點(diǎn),并把所有的狀態(tài)變化記錄到持久化設(shè)備下,以便備用設(shè)備恢復(fù)。停工期通常以分鐘計。FaultrecoveryShadowoperation.鏡像操作Apreviouslyfailedcomponentmayberunin"shadowmode"forashorttimetomakesurethatitmimicsthebehavioroftheworkingcomponentsbeforerestoringittoservice.失敗的組件可以運(yùn)行于鏡像模式一段時間以保證它在恢復(fù)服務(wù)前仿真正常組件的行為。FaultrecoveryStateresynchronization.狀態(tài)再同步Thepassiveandactiveredundancytacticsrequirethecomponentbeingrestoredtohaveitsstateupgradedbeforeitsreturntoservice.Theupdatingapproachwilldependonthedowntimethatcanbesustained,thesizeoftheupdate,andthenumberofmessagesrequiredfortheupdate.Asinglemessagecontainingthestateispreferable,ifpossible.Incrementalstateupgrades,withperiodsofservicebetweenincrements,leadtocomplicatedsoftware.被動與主動冗余策略要求被恢復(fù)的組件在回到服務(wù)前使其狀態(tài)升級。升級步驟依賴于可忍受的停工期、更新的大小和更新要求的消息數(shù)量。如果可能的話,包含狀態(tài)的簡單消息是首選的。FaultrecoveryCheckpoint/rollback.檢查點(diǎn)/回滾Acheckpointisarecordingofaconsistentstatecreatedeitherperiodicallyorinresponsetospecificevents.Sometimesasystemfailsinanunusualmanner,withadetectablyinconsistentstate.Inthiscase,thesystemshouldberestoredusingapreviouscheckpointofaconsistentstateandalogofthetransactionsthatoccurredsincethesnapshotwastaken.檢查點(diǎn)是周期性或在發(fā)生特定事件時創(chuàng)建的一致性狀態(tài)的記錄。有時系統(tǒng)以不尋常的方式失敗于可檢測的不一致狀態(tài)。此時,系統(tǒng)應(yīng)該用以前的一個一致狀態(tài)的檢查點(diǎn)和檢查點(diǎn)之后發(fā)生的事務(wù)記錄來恢復(fù)。FaultpreventionRemovalfromservice.移除服務(wù)Thistacticremovesacomponentofthesystemfromoperationtoundergosomeactivitiestopreventanticipatedfailures.Transactions.事務(wù)Atransactionisthebundlingofseveralsequentialstepssuchthattheentirebundlecanbeundoneatonce.Processmonitor.進(jìn)程監(jiān)視器Onceafaultinaprocesshasbeendetected,amonitoringprocesscandeletethenonperformingprocessandcreateanewinstanceofit,initializedtosomeappropriatestateasinthesparetactic.SummaryofavailabilitytacticsModifiabilityTacticsTacticstocontrolmodifiabilityhaveastheirgoalcontrollingthetimeandcosttoimplement,test,anddeploychanges.控制可修改性的策略致力于控制軟件實(shí)現(xiàn)、測試、和配置改變的時間和成本可根據(jù)目標(biāo)把修改策略分組:(1)localizemodifications:減少直接被修改影響的模塊數(shù)量(2)Preventtherippleeffect:把修改限制到局部模塊(3)Deferbindingtime:控制部署時間和成本LocalizeModifications局部修改受影響的模塊數(shù)與修改的成本沒有精確的關(guān)系,但把修改限制到少量的模塊通??梢詼p少成本。這里給出5種限制范圍的策略:Maintainsemanticcoherence.保持語義一致性Semanticcoherencereferstotherelationshipsamongresponsibilitiesinamodule.Thegoalistoensurethatalloftheseresponsibilitiesworktogetherwithoutexcessiverelianceonothermodules.語義一致性指一個模塊中各職責(zé)間的關(guān)系。目的是保證模塊內(nèi)各職責(zé)一起工作而沒有對其它模塊的額外依賴。LocalizeModifications局部修改Anticipateexpectedchanges預(yù)見期望的修改Consideringthesetofenvisionedchangesprovidesawaytoevaluateaparticularassignmentofresponsibilities.Thetacticofanticipatingexpectedchangesdoesnotconcernitselfwiththecoherenceofamodule’sresponsibilitiesbutratherwithminimizingtheeffectsofthechanges.Inrealitythistacticisdifficulttousebyitselfsinceitisnotpossibletoanticipateallchanges.Forthatreason,itisusuallyusedinconjunctionwithsemanticcoherence.預(yù)先考慮將來的修改提供了一種評估職責(zé)分派的方法。這種方法并不關(guān)心模塊職責(zé)的一致性本身,而是要把修改帶來的影響降到最低?,F(xiàn)實(shí)中這種策略很難單獨(dú)使用,因?yàn)轭A(yù)期所有的修改是不可能的,因此,常常與語義一致性聯(lián)合使用LocalizeModifications局部修改Generalizethemodule.使模塊一般化Makingamodulemoregeneralallowsittocomputeabroaderrangeoffunctionsbasedoninput.Theinputcanbethoughtofasdefiningalanguageforthemodule.Themoregeneralamodule,themorelikelythatrequestedchangescanbemadebyadjustingtheinputlanguageratherthanbymodifyingthemodule使模塊更一般化允許計算更多的基于輸入的功能。該輸入可看著為模塊定義了一種語言。模塊越一般化,要求的修改就越能通過調(diào)整輸入語言來實(shí)現(xiàn),而不用修改模塊。LocalizeModifications局部修改Limitpossibleoptions.限制可能的選項(xiàng)Modifications,especiallywithinaproductline,maybefarrangingandhenceaffectmanymodules.Restrictingthepossibleoptionswillreducetheeffectofthesemodifications.修改,特別是生產(chǎn)線上的修改,范圍非常廣泛,因此會影響許多模塊。限制可能的選項(xiàng)可以減少修改帶來的影響。PreventRippleEffects防止?jié)i漪效應(yīng)Arippleeffectfromamodificationisthenecessityofmakingchangestomodulesnotdirectlyaffectedbyit.修改的漣漪效應(yīng)指當(dāng)修改一個模塊時,必須修改另一個受到間接影響的模塊的必要性。IfmoduleAischangedtoaccomplishaparticularmodification,thenmoduleBischangedonlybecauseofthechangetomoduleA.Bhastobemodifiedbecauseitdepends,insomesense,onA.比如,由于模塊B因?yàn)槟撤N原因依賴于模塊A,當(dāng)模塊A被修改時,那么都有哪些依賴呢?PreventRippleEffects-typesofdependenciesSyntaxof語法data.ForBtocompile(orexecute)correctly,thetype(orformat)ofthedatathatisproducedbyAandconsumedbyBmustbeconsistentwiththetype(orformat)ofdataassumedbyB.B要使用A產(chǎn)生的數(shù)據(jù),要求A提供的數(shù)據(jù)與B所要求的在類型(或格式)上一致Service.ForBtocompileandexecutecorrectly,thesignatureofservicesprovidedbyAandinvokedbyBmustbeconsistentwiththeassumptionsofB.B使用A提供的服務(wù),服務(wù)的簽名必須一致。PreventRippleEffects-typesofdependenciesSemanticsof語義data.ForBtoexecutecorrectly,thesemanticsofthedataproducedbyAandconsumedbyBmustbeconsistentwiththeassumptionsofB.生產(chǎn)者提供的數(shù)據(jù)的語義必須與消費(fèi)者所需要的一致。service.ForBtoexecutecorrectly,thesemanticsoftheservicesproducedbyAandusedbyBmustbeconsistentwiththeassumptionsofB.服務(wù)的語義也要一致。PreventRippleEffects-typesofdependenciesSequenceof順序data.ForBtoexecutecorrectly,itmustreceivethedataproducedbyAinafixedsequence.Forexample,adatapacket‘sheadermustprecedeitsbodyinorderofreception(asopposedtoprotocolsthathavethesequencenumberbuiltintothedata).B的正確執(zhí)行依賴于從A收到的數(shù)據(jù)的順序control.ForBtoexecutecorrectly,Amusthaveexecutedpreviouslywithincertaintimingconstraints.Forexample,Amusthaveexecutednolongerthan5msbeforeBexecutes.B的正確執(zhí)行依賴于A在之前的某個時間約束下執(zhí)行完P(guān)reventRippleEffects-typesofdependenciesIdentityofaninterfaceofA.接口的標(biāo)識Amayhavemultipleinterfaces.ForBtocompileandexecutecorrectly,theidentity(nameorhandle)oftheinterfacemustbeconsistentwiththeassumptionsofB.A可能有多個接口,B的正確執(zhí)行要求接口的標(biāo)識(名稱或操作)與B所假定的一致LocationofA(runtime).運(yùn)行時的位置ForBtoexecutecorrectly,theruntimelocationofAmustbeconsistentwiththeassumptionsofB.Forexample,BmayassumethatAislocatedinadifferentprocessonthesameprocessor.B的正確執(zhí)行要求A運(yùn)行的位置與B的假定一致。如B可能要求B處于同一處理器的不同進(jìn)程中。PreventRippleEffects-typesofdependenciesQualityofservice/dataprovidedbyA.質(zhì)量ForBtoexecutecorrectly,somepropertyinvolvingthequalityofthedataorserviceprovidedbyAmustbeconsistentwithB‘sassumptions.B的正確執(zhí)行依賴于A提供的數(shù)據(jù)或服務(wù)的質(zhì)量Forexample,dataprovidedbyaparticularsensormusthaveacertainaccuracyinorderforthealgorithmsofBtoworkcorrectly.比如要求傳感器提供的數(shù)據(jù)達(dá)到一定的精度PreventRippleEffects-typesofdependenciesExistenceofA.B的正確執(zhí)行要求A必須存在ForBtoexecutecorrectly,Amustexist.Forexample,ifBisrequestingaservicefromanobjectA,andAdoesnotexistandcannotbedynamicallycreated,thenBwillnotexecutecorrectly.ResourcebehaviorofA.ForBtoexecutecorrectly,theresourcebehaviorofAmustbeconsistentwithB‘sassumptions.ThiscanbeeitherresourceusageofA(AusesthesamememoryasB)orresourceownership(BreservesaresourcethatAbelievesitowns).B對A的資源行為有要求,比如要求A使用某資源或擁有某資源PreventRippleEffects-tacticsNoticethatnoneofourtacticsnecessarilypreventtherippleofsemanticchanges.Hideinformation.隱藏信息Informationhidingisthedecompositionoftheresponsibilitiesforanentity(asystemorsomedecompositionofasystem)intosmallerpiecesandchoosingwhichinformationtomakeprivateandwhichtomakepublic.把實(shí)體的職責(zé)分解為若干較小的部分,并選擇哪些應(yīng)該是private,哪些public。即把易變的部分分拆出去。PreventRippleEffects-tacticsMaintainexistinginterfaces.保持現(xiàn)有接口IfBdependsonthenameandsignatureofaninterfaceofA,maintainingthisinterfaceanditssyntaxallowsBtoremainunchanged.若B依賴于A的接口名稱和基調(diào),保持接口及其語義允許B保持不變。PatternsthatimplementthistacticincludeAddinginterfaceAddingadapterProvidingastubA.PreventRippleEffects-tacticsRestrictcommunicationpaths.限制通信路徑Restrictthemoduleswithwhichagivenmodulesharesdata.Thatis,reducethenumberofmodulesthatconsumedataproducedbythegivenmoduleandthenumberofmodulesthatproducedataconsumedbyit.限制共享數(shù)據(jù)的模塊。即限制為同一模塊提供數(shù)據(jù)的生產(chǎn)者的數(shù)量,或限制消費(fèi)者的數(shù)量。Thiswillreducetherippleeffectsincedataproduction/consumptionintroducesdependenciesthatcauseripples.PreventRippleEffects–tacticsUseanintermediary.使用中間物IfBhasanytypeofdependencyonAotherthansemantic,itispossibletoinsertanintermediarybetweenBandAthatmanagesactivitiesassociatedwiththedependency.Theintermediaryare:data(syntax).Repositories(bothblackboardandpassive)actasintermediariesbetweentheproducerandconsumerofdata.service(syntax).Thefacade,bridge,mediator,strategy,proxy,andfactorypatternsallprovideintermediariesthatconvertthesyntaxofaservicefromoneformintoanother.若B對A有任何非語義的依賴,在B和A之間插入一個中間物來管理與依賴相關(guān)的活動是可能的。中間物可以是:數(shù)據(jù)(語法)。倉儲是數(shù)據(jù)的生產(chǎn)者和消費(fèi)者之間的中間物。服務(wù)。把服務(wù)從一種形式轉(zhuǎn)換為另一種形式的語法。PreventRippleEffects-tacticsidentityofaninterfaceofA.Abrokerpatterncanbeusedtomaskchangesintheidentityofaninterface.IfBdependsontheidentityofaninterfaceofAandthatidentitychanges,byaddingthatidentitytothebrokerandhavingthebrokermaketheconnectiontothenewidentityofA,Bcanremainunchanged.locationofA(runtime).AnameserverenablesthelocationofAtobechangedwithoutaffectingB.Aisresponsibleforregisteringitscurrentlocationwiththenameserver,andBretrievesthatlocationfromthenameserver.中間物可以是:
A的接口身份。使用broker(中間人)來屏蔽接口的改變
A的位置(運(yùn)行時)。使用一個名字服務(wù)器使得A的位置的改變不會影響到B。PreventRippleEffects-tacticsresourcebehaviorofAorresourcecontrolledbyA.Aresourcemanagerisanintermediarythatisresponsibleforresourceallocation.Certainresourcemanagers(e.g.,thosebasedonRateMonotonicAnalysisinreal-timesystems)canguaranteethesatisfactionofallrequestswithincertainconstraints.A,ofcourse,mustgiveupcontroloftheresourcetotheresourcemanager.existenceofA.Thefactorypatternhastheabilitytocreateinstancesasneeded,andthusthedependenceofBontheexistenceofAissatisfiedbyactionsofthefactory.中間物可以是:
A的資源行為。使用資源管理器來負(fù)責(zé)資源分配。
A的存在。工廠模式有在需要時創(chuàng)建實(shí)例的能力,故B在A的存在上的依賴可通過工廠的動作來解決。DeferBindingTime延遲綁定時間Thetwotacticcategorieswehavediscussedaredesignedtominimizethenumberofmodulesthatrequirechangingtoimplementmodification.Ourmodificationscenariosincludetwoelementsthatarenotsatisfiedbyreducingthenumberofmodulestobechanged–timetodeployandallowingnondeveloperstomakechanges.Deferringbindingtimesupportsbothofthosescenariosatthecostofrequiringadditionalinfrastructuretosupportthelatebinding.前邊討論的兩類策略用來最小化在實(shí)現(xiàn)修改時要求改變的模塊數(shù)量。我們的修改場景中包括不通過減少改變的模塊數(shù)量來滿足的兩個元素-配置時間和允許非開發(fā)人員進(jìn)行改變。延遲綁定時間支持這兩個元素,但需要額外的基礎(chǔ)構(gòu)造來支持延遲綁定DeferBindingTime延遲綁定時間Manytacticsareintendedtohaveimpactatloadtimeorruntime,suchasthefollowingRuntimeregistrationsupportsplug-and-playoperationatthecostofadditionaloverheadtomanagetheregistration.Publish/subscriberegistration,forexample,canbeimplementedateitherruntimeorloadtime.Configurationfilesareintendedtosetparametersatstartup.Polymorphismallowslatebindingofmethodcalls.Componentreplacementallowsloadtimebinding.Adherencetodefinedprotocolsallowsruntimebindingofindependentprocesses.許多策略試圖影響裝載時間或運(yùn)行時間,例如:運(yùn)行時注冊配置文件試圖在啟動時設(shè)置參數(shù)。多態(tài)性允許推遲方法調(diào)用的綁定。組件替換允許裝載時綁定。SummaryofmodifiabilitytacticsPerformanceTacticsperformancetacticsistogeneratearesponsetoaneventarrivingatthesystemwithinsometimeconstraint.性能上的策略就是在某個時間約束內(nèi)對到達(dá)系統(tǒng)的事件產(chǎn)生響應(yīng)PerformanceTacticsTwobasiccontributorstotheresponsetimeResourceconsumption.ResourcesincludeCPU,datastores,networkcommunicationbandwidth,andmemory,butitcanalsoincludeentitiesdefinedbytheparticularsystemunderdesign.Blockedtime.AcomputationcanbeblockedfromusingaresourcebecauseofContentionforresourcesAvailabilityofresourcesDependencyonothercomputation對響應(yīng)時間有兩個基本的貢獻(xiàn)者:資源消費(fèi)。資源包括CPU、數(shù)據(jù)存儲、網(wǎng)絡(luò)通信帶寬和內(nèi)存,也可包括由特定的系統(tǒng)定義的實(shí)體。阻塞時間。一個計算可能被阻塞到要使用的資源上,因?yàn)闋帄Z資源、資源的可用性或者對其他計算的依賴。PerformanceTacticsthreetacticcategories:resourcedemand資源需求resourcemanagement資源管理resourcearbitration資源仲裁ResourceDemandOnetacticforreducinglatencyistoreducetheresourcesrequiredforprocessinganeventstream.Waystodothisincludethefollowing.Increasecomputationalefficiency.Onestepintheprocessingofaneventoramessageisapplyingsomealgorithm.Improvingthealgorithmsusedincriticalareaswilldecreaselatency.Reducecomputationaloverhead.Ifthereisnorequestforaresource,processingneedsarereduced.資源請求的來源是事件流。資源需求的兩個特征是資源流中的事件間的時間間隔(請求資源的頻率)和每次請求消耗多少資源。減少延遲的一個策略是減少處理事件流所需要的資源。具體做法包括:提高計算效率。即改善臨界區(qū)中使用的算法。減少計算的管理開銷。如果一個資源可以不要,那么處理就被簡化了。ResourceDemandAnothertacticforreducinglatencyistoreducethenumberofeventsprocessed.Thiscanbedoneinoneoftwofashions.Manageeventrate.Ifitispossibletoreducethesamplingfrequencyatwhichenvironmentalvariablesaremonitored,demandcanbereduced.Controlfrequencyofsampling.Ifthereisnocontroloverthearrivalofexternallygeneratedevents,queuedrequestscanbesampledatalowerfrequency,possiblyresultinginthelossofrequests.另一個策略是減少處理的事件數(shù)量。這也可以分兩個方面:管理事件速率。如果可能減少監(jiān)控的環(huán)境變量的抽樣頻率,則資源需求可減少??刂瞥闃宇l率。如果對外部產(chǎn)生事件的到達(dá)沒有控制,隊列中的請求可能以較低的頻率采樣,可能導(dǎo)致請求丟失。ResourceDemandOthertacticsforreducingormanagingdemandinvolvecontrollingtheuseofresources.Boundexecutiontimes.Placealimitonhowmuchexecutiontimeisusedtorespondtoanevent.Sometimesthismakessenseandsometimesitdoesnot.Foriterative,data-dependentalgorithms,limitingthenumberofiterationsisamethodforboundingexecutiontimes.Boundqueuesizes.Thiscontrolsthemaximumnumberofqueuedarrivalsandconsequentlytheresourcesusedtoprocessthearrivals.減少或管理資源要求的另一策略是控制資源的使用:控制執(zhí)行時間。對用于響應(yīng)事件的執(zhí)行時間進(jìn)行限制。有時這樣做有意義有時沒有。對迭代的數(shù)據(jù)相關(guān)算法,限制迭代的次數(shù)是一種控制執(zhí)行時間的方法??刂脐犃谐叽纭<纯刂脐犃兄械竭_(dá)的請求的最大數(shù)量。因而控制了使用的資源。ResourceManagementIntroduceconcurrency.Ifrequestscanbeprocessedinparallel,theblockedtimecanbereduced.Maintainmultiplecopiesofeitherdataorcomputations.Clientsinaclient-serverpatternarereplicasofthecomputation.Increaseavailableresources.Fasterprocessors,additionalprocessors,additionalmemory,andfasternetworksallhavethepotentialforreducinglatency.即使資源請求沒法控制,對資源的管理也會影響響應(yīng)時間,一些控制策略包括:引入并發(fā)。如果請求可以并行處理,阻塞時間可以減少。維持?jǐn)?shù)據(jù)或計算的多個拷貝。如CS模式中的客戶是計算的多個復(fù)制品。復(fù)制的目的是減少競爭。增加可用的資源。如更快的處理器,更多的處理器,增加內(nèi)存,更快的網(wǎng)絡(luò),都是減少延遲的潛在方法。ResourceArbitrationFirst-in/First-out.FIFOqueuestreatallrequestsforresourcesasequalsandsatisfytheminturn.Fixed-priorityscheduling.Fixed-priorityschedulingassignseachsourceofresourcerequestsaparticularpriorityandassignstheresourcesinthatpriorityorder.semanticimportancedeadlinemonotonicratemonotonic有資源競爭,就有資源計劃,如處理器、緩存、網(wǎng)絡(luò)等。架構(gòu)師的目標(biāo)就是要理解各資源的使用特性,選擇諧調(diào)的調(diào)度策略。一種安排策略概念上有兩部分:優(yōu)先權(quán)分配和調(diào)度。優(yōu)先權(quán)安排可以象先進(jìn)先出那么簡單,也可以與請求的最終期限或語義重要性綁在一起。安排的標(biāo)準(zhǔn)包括最優(yōu)資源使用率、請求的重要程度、最小化使用的資源共享數(shù)量、最低延遲、最大化吞吐量、防止餓死以保證公平等等。架構(gòu)死需要意識到可能沖突的標(biāo)準(zhǔn),以及所選策略對滿足標(biāo)準(zhǔn)的影響。只有當(dāng)指派的資源可用,高優(yōu)先權(quán)的事件流才被調(diào)度。有時這依賴于資源搶占策略。如:隨時搶占、僅在特定的搶占點(diǎn)搶占、不能搶占正執(zhí)行的進(jìn)程資源等。幾種常用的調(diào)度策略如下:先進(jìn)先出。使用FIFO隊列,平等對待所有的資源請求,輪流處理。固定優(yōu)先權(quán)。為每個資源請求源賦予特定的優(yōu)先權(quán),并安該順序分派資源。分派依據(jù)包括:語義重要性、最終期限單調(diào)、速率單調(diào)(即對周期性事件流,周期短優(yōu)先)ResourceArbitrationDynamicpriorityschedulingroundrobin.Roundrobinisaschedulingstrategythatorderstherequestsandthen,ateveryassignmentpossibility,assignstheresourcetothenextrequestinthatorder.earliestdeadlinefirst.Earliestdeadlinefirstassignsprioritiesbasedonthependingrequestswiththeearliestdeadline.Fixed-priorityscheduling.動態(tài)優(yōu)先權(quán)調(diào)度循環(huán)調(diào)度(輪式調(diào)度)。把資源排成環(huán),每次調(diào)度后,環(huán)中的下一個優(yōu)先權(quán)最高。最早最終期限優(yōu)先。ResourceArbitrationStaticscheduling.Acyclicexecutivescheduleisaschedulingstrategywherethepreemptionpointsandthesequenceofassignmenttotheresourcearedeterminedoffline.靜態(tài)調(diào)度循環(huán)執(zhí)行調(diào)度是這樣一種調(diào)度策略,搶占點(diǎn)和資源分派順序離線決定。SummaryofperformancetacticsSecurityTacticsTacticsforachievingsecuritycanbedividedintothoseconcernedwithresistingattacksthoseconcernedwithdetectingattacksthoseconcernedwithrecoveringfromattacks.獲取安全性的策略可以分幾類:那些與抵抗攻擊相關(guān)的;檢測攻擊相關(guān)的;從攻擊中恢復(fù);ResistingattacksAuthenticateusers.Authentication(鑒定)isensuringthatauserorremotecomputerisactuallywhoitpurportstobe.Passwords,one-timepasswords,digitalcertificates,andbiometricidentificationsprovideauthentication.Authorizeusers.Authorization(授權(quán))isensuringthatanauthenticateduserhastherightstoaccessandmodifyeitherdataorservices.抵抗攻擊的方法:鑒別用戶。確保用戶或遠(yuǎn)程計算機(jī)確實(shí)是它所聲稱的那一個。相關(guān)技術(shù)包括口令、一次性口令、數(shù)字證書、生物測定等。授權(quán)用戶。給予授權(quán)用戶訪問或修改數(shù)據(jù)的權(quán)力。ResistingattacksMaintaindataconfidentiality(機(jī)密).Datashouldbeprotectedfromunauthorizedaccess.Confidentialityisusuallyachievedbyapplyingsomeformofencryptiontodataandtocommunicationlinks.Encryptionprovidesextraprotectiontopersistentlymaintaineddatabeyondthatavailablefromauthorization.Communicationlinkstypicallydonothaveauthorizationcontrols.Encryptionistheonlyprotectionforpassingdataoverpubliclyaccessiblecommunicationlinks.維持?jǐn)?shù)據(jù)機(jī)密性。機(jī)密性通常通過某種形式的機(jī)密技術(shù)來達(dá)到。對于通信鏈路來說,一般沒有授權(quán)控制方法,加密是唯一的保護(hù)手段。ResistingattacksMaintainintegrity.Datashouldbedeliveredasintended.Itcanhaveredundantinformationencodedinit,suchaschecksumsorhashresults,whichcanbeencryptedeitheralongwithorindependentlyfromtheoriginaldata.Limitexposure.Attackstypicallydependonexploitingasingleweaknesstoattackalldataandservicesonahost.Thearchitectcandesigntheallocationofservicestohostssothatlimitedservicesareavailableoneachhost.維護(hù)完整性 數(shù)據(jù)應(yīng)按意圖交付。它可能包含冗余信息如檢測位或哈希碼,必須全部交付給接收方。限制曝露 典型攻擊是從主機(jī)的一個弱點(diǎn)入手進(jìn)而攻擊所有數(shù)據(jù)和服務(wù)。架構(gòu)師可設(shè)計服務(wù)對主機(jī)的分配以便限制每個主機(jī)可用的服務(wù)。ResistingattacksLimitaccess.Firewallsrestrictaccessbasedonmessagesourceordestinationport.限制訪問 使用防火墻基于消息來源或目標(biāo)端口限制訪問
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024-2030年中國黃酸乙酯鈉行業(yè)發(fā)展前景預(yù)測及投資可行性分析報告
- 2024-2030年中國魚皮明膠行業(yè)發(fā)展趨勢預(yù)測及投資價值研究報告
- 2024-2030年中國餐飲市場領(lǐng)航調(diào)研及投資經(jīng)營模式分析報告
- 2024-2030年中國風(fēng)光互補(bǔ)系統(tǒng)行業(yè)發(fā)展趨勢規(guī)劃分析報告
- 2024-2030年中國集群通信系統(tǒng)行業(yè)運(yùn)作模式及投資規(guī)劃分析報告
- 2024-2030年中國防水膨脹珍珠巖板產(chǎn)業(yè)未來發(fā)展趨勢及投資策略分析報告
- 2024-2030年中國鍋爐行業(yè)供需趨勢及投資策略分析報告
- 2024-2030年中國鉛酸蓄電池行業(yè)產(chǎn)銷運(yùn)行狀況分析及未來趨勢發(fā)展預(yù)測報告
- 2024年技術(shù)聯(lián)合股權(quán)協(xié)議
- 2024年新品銷售合作協(xié)議
- 日間手術(shù)應(yīng)急預(yù)案方案
- 退費(fèi)賬戶確認(rèn)書
- 幼兒園小班《汽車滴滴響》
- 杭州娃哈哈精密機(jī)械有限公司新增年產(chǎn)40000臺展示冰柜產(chǎn)品生產(chǎn)線的技術(shù)改造項(xiàng)目環(huán)境影響報告
- 安徽省示范高中培優(yōu)聯(lián)盟2023-2024學(xué)年高一上學(xué)期冬季聯(lián)賽數(shù)學(xué)試題(含答案)
- 聲母h教學(xué)課件-副本
- 印度尼西亞概況
- 變應(yīng)性支氣管肺曲霉病診治專家-共識(2022年修訂版)解讀
- 隊形隊列及廣播體操比賽評分表
- 自考《商法》00808復(fù)習(xí)筆記
- 2021年主題公園研究-環(huán)球影城
評論
0/150
提交評論