分布式系统原理与范型课后习题答案

合集下载

分布式系统原理与范型考试-2009-12

分布式系统原理与范型考试-2009-12

Department Computer Science Distributed Systems VU University15.12.2009 MAKE SURE THAT YOUR HANDWRITING IS READABLE1a Explain what is meant by request-level and message-level interceptors in middleware.5pt Request-level interceptors are special local components to which an invocation request is passed before passing it to the underlying middleware.Such an interceptor is invocation aware in the sense that it knows with which invocation it is dealing,and for which server it is intended.Typically,such interceptors can be used to implement replicated calls.A message-level interceptor is a component that is logically placed between the middleware and the underlying operating system.It can thus handle only basic network messages,for example,by fragmenting them into smaller parts(and assembling these parts at the receiver side).1b Where does the need for adaptive middleware come from?5pt Middleware is intended to incorporate general-purpose,i.e.,application-independent,mechanisms for distributed computing.The problem is that for practical purposes,it is very difficult to separate policy from mechanism,with the effect that many middleware solutions are not right for specific applications.The result is the need to be able to tweak the middleware for the specific needs of an application.1c In the underlying feedback control loop,give an example of the analysis component in combination with the reference input.5ptAn example that is also discussed in the book,is analyzing whether measured performance is as good as it could have been when another replication scenario would have been used.In this case, the reference input is a cost function that needs to be minimized.2a What is the difference between transport-layer switching and content-aware request distribution?5pt With transport-layer switching,a front end to a server cluster accepts incoming TCP connections and hands these off to one of the back-end servers using only information that is available at the TCP-level:client address and destination port.In the case of content-aware request distribution,the switch can also inspect the content of requests(such as an HTTP URL)and use that information to decide to which back-end server the request should be forwarded.2b Explain how TCP handoff works and why it is difficult to apply to wide-area networks.5pt With TCP handoff,an incoming connection request is forwarded by a switch to a specific server, which then sends the response back directly to the client,using the network address of the switch.This last issue is problematic is a wide-area system,as it essentially involves spoofing the switch, which is often difficult to do across administrative domains.2c Explain how the content-aware request distribution can be combined with TCP handoff.5pt Your answer should explain what is happening in Figure12-9.Essential is that you mention the initial handoff to a distributor or dispatcher to decide what the best server could be based on content, after which the TCP connection is handed off to that server.The switch is subsequently informed.3a Traditional RPC mechanisms cannot handle pointers.What is the problem and how can it be ad-dressed?5pt The problem is that pointers passed as parameters refer to a memory location that is local to the caller.That location is not only often meaningless to the receipient,but more important is that the recipient will most likely not have the data structure in its memory that the caller has.There are not many things you can do about this,except copying the entire(dynamic data structure)from the caller to the callee when doing the RPC.An alternative is to replace pointers by global systemwide references,as is done with Java object references.3b Where does the need for at-least-once and at-most-once semantics come from?Why can’t we have exactly-once semantics?5pt The problem originates from having a(suspected)server crash,detected by the lack of a response in the case of an RPC.What the client-side software can do is either resend the request until itfinally gets a response(at-least-once semantics)or immediately reports the failure to the client application, thus providing at-most-once semantics.Guaranteeing exactly-once semantics is,in principle,impos-sible,because you cannot know in general whether the server crashed before or after executing the requested operation.3c Consider a client/server system based on RPC,and assume the server is replicated for performance.Sketch an RPC-based solution for hiding replication of the server from the client.5pt Simply take a client-side stub that replicates the call to the respective servers.It is essential that you mention that these calls should be done in parallel and that(for example)thefirst response is immediately passed to the client.Serializing the RPCs or waiting for all responses is OK for fault tolerance,but certainly not for performance.4a Resolve the following key lookups for the shown Chord-based P2P system:5ptsource key41542221302127201815@4:14–18;22@4:20–21–28;30@21:28–1;27@21:28;18@20:4–14–184b Adjust thefinger tables of nodes18and14when a node with ID24enters the ring.Also give the finger table of node24.5pt Node18:[20,20,24,28,4];Node14:[18,18,18,24,1];Node24:[28,28,28,1,9].4c Chord allows keys to be looked up recursively or iteratively.Explain the differences,as well as the main advantage of iterative over recursive lookup.5pt With recursive lookups,a message is forwarded from peer to peer until it reaches its destination.In contrast,with an iterative lookup,the requester is returned the next peer it should ask for the key.One can argue that in the case of Chord,iterative lookups are much better:recursive lookups do not have the advantage of proximity-awareness.Also,note that iterative lookups have the advantage of letting the client handle failures more easily.5a Explain how two-phase commit works.5pt Make sure that you explain(1)coordinator sends vote-request;(2)participants respond;(3)coordi-nator sends decision;(4)participants ack.5b Explain what happens when a participant,who is in the READY state,times out because it hasn’t received a response from the coordinator yet.5pt In that case,P can check whether any of the other particpants has made a transition to either ABORT or INIT(in which case P can abort)or COMMIT(and commit as well).The difficulty is when all others are in READY:they all need to wait until the coordinator recovers.5c If we use two-phase commit for a distributed transaction,can we allow a coordinator to issue two distributed transactions(involving the same participants)at the same time?5pt Yes:the local transaction managers at the participants will handle any concurrency issues.What is seen here is that the use of2PC is completely independent of the semantics of specific transactions.6a How can a Web hosting service help in handlingflash crowds?5pt Crucial for a correct answer is that you not only state that content is replicated,but that the origin server is assumed to be capable of redirecting requests,but perhaps no longer in also returning content-rich responses.Note that distributed request distribution is really tricky business.6b Akamai uses DNS-based redirection.Explain how resolution of the name would work.5pt The trick is that the regular DNS will resolve the name ,pointing to a DNS server that is controlled by Akamai.If we use iterative DNS name resolution,that server will know the IP address ot the requesting client,and be able to decide to which server(with logical name )it can forward the request.6c Explain the difference between content-aware and content-blind caching for Web applications by means of an example.5pt With content-aware caching,the cache has knowledge on the data model that is used by the Web application,and with that,can conduct query-containment procedures to see whether a query could possibly be addressed by the data that is already cached.For example,if an edge server had once received the query“select ALL FROM books WITH author=Irving”,it can cache that ter, when receiving a query“select ALL FROM books WITH author=Irving AND date<2008”,the edge server should be able to recognize that this is a subquery,and that it can thus look into its local cache.With content-blind caching,the cache simply attaches a unique id to an entire,specific query in order to check whether that exact query had been issued before.If so,it can possibly return the previously stored response from its cache.In our example,the two queries would each get a unqiue ID,which is then used to do a cache lookup.Grading:Thefinal grade is calculated by accumulating the scores per question(maximum:90points),and adding10bonus points.The maximum total is therefore100points.。

《分布式系统原理与范型第版》原书课件资料

《分布式系统原理与范型第版》原书课件资料

Types of Communication
Figure 4-4. Viewing middleware as an intermediate (distributed) service in application-level communication.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5
Middleware Protocols
Figure 4-3. An adapted reference model for networked communication.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5
Writing a Client and a Server (2)
Three files output by the IDL compiler: • • • A header file (e.g., interface.h, in C terms). The client stub. The server stub.
Passing Value Parameters (3)
Figure 4-8. (a) The original message on the Pentium.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5

分布式系统概念与设计(第三版)课后习题与答案Chapter5

分布式系统概念与设计(第三版)课后习题与答案Chapter5

Chapter 5Exercise Solutions5.1The Election interface provides two remote methods:vote: with two parameters through which the client supplies the name of a candidate (a string) and the‘voter’s number’ (an integer used to ensure each user votes once only). The voter’s numbers areallocated sparsely from the range of integers to make them hard to guess.result: with two parameters through which the server supplies the client with the name of a candidateand the number of votes for that candidate.Which of the parameters of these two procedures are input and which are output parameters?5.1 Ans.vote: input parameters: name of candidate, voter’s number;result: output parameters: name of candidate, number of votes5.2Discuss the invocation semantics that can be achieved when the request-reply protocol isimplemented over a TCP/IP connection, which guarantees that data is delivered in the order sent,without loss or duplication. Take into account all of the conditions causing a connection to bebroken.5.2 Ans.A process is informed that a connection is broken:•when one of the processes exits or closes the connection.•when the network is congested or fails altogetherTherefore a client process cannot distinguish between network failure and failure of the server.Provided that the connection continues to exist, no messages are lost, therefore, every request will receive a corresponding reply, in which case the client knows that the method was executed exactly once.However, if the server process crashes, the client will be informed that the connection is broken and the client will know that the method was executed either once (if the server crashed after executing it) or not at all (if the server crashed before executing it).But, if the network fails the client will also be informed that the connection is broken. This may have happened either during the transmission of the request message or during the transmission of the reply message. As before the method was executed either once or not at all.Therefore we have at-most-once call semantics.5.3Define the interface to the Election service in CORBA IDL and Java RMI. Note that CORBA IDLprovides the type long for 32 bit integers. Compare the methods in the two languages forspecifying input and output arguments.5.3 Ans.CORBA IDL:interface Election {void vote(in string name, in long number);void result(out string name, out long votes);};Java RMIWe need to define a class for the result e.g.class Result {String name;int votes;}The interface is:import java.rmi.*;public interface Election extends Remote{void vote(String name, int number) throws RemoteException;Result result () throws RemoteException;};This example shows that the specification of input arguments is similar in CORBA IDL and Java RMI.This example shows that if a method returns more than one result, Java RMI is less convenient than CORBA IDL because all output arguments must be packed together into an instance of a class.5.4The Election service must ensure that a vote is recorded whenever any user thinks they have casta vote.Discuss the effect of maybe call semantics on the Election service.Would at-least-once call semantics be acceptable for the Election service or would yourecommend at-most-once call semantics?5.4 Ans.Maybe call semantics is obviously inadequate for vote! Ex 5.1 specifies that the voter’s number is used to ensure that the user only votes once. This means that the server keeps a record of who has voted. Therefore at-least-once semantics is alright, because any repeated attempts to vote are foiled by the server.5.5 A request-reply protocol is implemented over a communication service with omission failures toprovide at-least-once RMI invocation semantics. In the first case the implementor assumes anasynchronous distributed system. In the second case the implementor assumes that the maximumtime for the communication and the execution of a remote method is T. In what way does the latterassumption simplify the implementation?5.5 Ans.In the first case, the implementor assumes that if the client observes an omission failure it cannot tell whether it is due to loss of the request or reply message, to the server having crashed or having taken longer than usual.Therefore when the request is re-transmitted the client may receive late replies to the original request. The implementation must deal with this.In the second case, an omission failure observed by the client cannot be due to the server taking too long.Therefore when the request is re-transmitted after time T, it is certain that a late reply will not come from the server. There is no need to deal with late replies5.6Outline an implementation for the Election service that ensures that its records remain consistentwhen it is accessed concurrently by multiple clients.5.6 Ans.Suppose that each vote in the form {String vote, int number} is appended to a data structure such as a Java Vector. Before this is done, the voter number in the request message must be checked against every voterecorded in the Vector. Note that an array indexed by voter’s number is not a practical implementation as the numbers are allocated sparsely.The operations to access and update a Vector are synchronized, making concurrent access safe.Alternatively use any form of synchronization to ensure that multiple clients’ access and update operations do not conflict with one another.5.7The Election service must ensure that all votes are safely stored even when the server processcrashes. Explain how this can be achieved with reference to the implementation outline in youranswer to Exercise 5.6.5.7 Ans.The state of the server must be recorded in persistent storage so that it can be recovered when the server is restarted. It is essential that every successful vote is recorded in persistent storage before the client request is acknowledged.A simple method is to serialize the Vector of votes to a file after each vote is cast.A more efficient method would append the serialized votes incrementally to a file.Recovery will consist of de-serializing the file and recreating a new vector.5.8Show how to use Java reflection to construct the client proxy class for the Election interface. Givethe details of the implementation of one of the methods in this class, which should call the methoddoOperation with the following signature:byte [] doOperation (RemoteObjectRef o, Method m, byte[] arguments);Hint: an instance variable of the proxy class should hold a remote object reference (see Exercise 4.12).5.8 Ans.Use classes Class and Method. Use type RemoteObjectRef as type of instance variable. The class Class has method getMethod whose arguments give class name and an array of parameter types. The proxy’s vote method, should have the same parameters as the vote in the remote interface - that is: two parameters of type String and int. Get the object representing the vote method from the class Election and pass it as the second argument of doOperation. The two arguments of vote are converted to an array of byte and passed as the third argument of doOperation.import ng.reflect;class VoteProxy {RemoteObjectRef ref;private static Method voteMethod;private static Method resultMethod;static {try {voteMethod = Election.class.getMethod ("vote", new Class[]{ng.String.class,int.class}));resultMethod = Election.class.getMethod ("result", new Class[] {}));}catch(NoSuchMethodException){}}public void vote (String arg1, int arg2) throws RemoteException {try {byte args [] = // convert arguments arg1 and arg2 to an array of bytesbyte result = DoOperation(ref, voteMethod, args);return ;} catch (...) {}}5.9Show how to generate a client proxy class using a language such as C++ that does not supportreflection, for example from the CORBA interface definition given in your answer to Exercise 5.3.Give the details of the implementation of one of the methods in this class, which should call themethod doOperation defined in Figure 4.12.5.9 Ans.Each proxy method is generated from the signature of the method in the IDL interface,e.g.void vote(in string name, in long number);An equivalent stub method in the client language e.g. C++ is produced e.g.void vote(const char *vote, int number)Each method in the interface is given a number e.g. vote = 1, result = 2.use char args[length of string + size of int] and marshall two arguments into this array and call doOperation as follows:char * result = DoOperation(ref, 1, args);we still assume that ref is an instance variable of the proxy class. A marshalling method is generated for each argument type used.5.10Explain how to use Java reflection to construct a generic dispatcher. Give Java code for adispatcher whose signature is:public void dispatch(Object target, Method aMethod, byte[] args)The arguments supply the target object, the method to be invoked and the arguments for thatmethod in an array of bytes.5.10 Ans.Use the class Method. To invoke a method supply the object to be invoked and an array of Object containing the arguments. The arguments supplied in an array of bytes must be converted to an array of Object.public void dispatch(Object target, Method aMethod, byte[] args)throws RemoteException {Object[] arguments = // extract arguments from array of bytestry{aMethod.invoke(target, arguments);catch(...){}}5.11Exercise 5.8 required the client to convert Object arguments into an array of bytes before invokingdoOperation and Exercise 5.10 required the dispatcher to convert an array of bytes into an arrayof Object s before invoking the method. Discuss the implementation of a new version ofdoOperation with the following signature:Object [] doOperation (RemoteObjectRef o, Method m, Object[] arguments);which uses the ObjectOutputStream and ObjectInputStream classes to stream the request and replymessages between client and server over a TCP connection. How would these changes affect thedesign of the dispatcher?5.11 Ans.The method DoOperation sends the invocation to the target’s remote object reference by setting up a TCP connection (as shown in Figures 4.5 and 4.6) to the host and port specified in ref. It opens an ObjectOutputStream and uses writeObject to marshal ref, the method, m and the arguments by serializing them to an ObjectOutputStream. For the results, it opens an ObjectIntputStream and uses readObject to get the results from the stream.At the server end, the dispatcher is given a connection to the client and opens an ObjectIntputStream and uses readObject to get the arguments sent by the client. Its signature will be:public void dispatch(Object target, Method aMethod)5.12 A client makes remote procedure calls to a server. The client takes 5 milliseconds to compute thearguments for each request, and the server takes 10 milliseconds to process each request. The localoperating system processing time for each send or receive operation is 0.5 milliseconds, and thenetwork time to transmit each request or reply message is 3 milliseconds. Marshalling orunmarshalling takes 0.5 milliseconds per message.Calculate the time taken by the client to generate and return from two requests:(i)if it is single-threaded, and(ii)if it has two threads that can make requests concurrently on a single processor.You can ignore context-switching times. Is there a need for asynchronous RPC if client and serverprocesses are threaded?5.12 Ans.i) time per call = calc. args + marshal args + OS send time + message transmission +OS receive time + unmarshall args + execute server procedure+ marshall results + OS send time + message transmission +OS receive time + unmarshal args= 5 + 4*marshal/unmarshal + 4*OS send/receive + 2*message transmission + execute server procedure = 5+ 4*0.5 + 4*0.5 + +2*3 + 10 ms = 5+2+2+6+10 =25ms.Time for two calls = 50 ms.ii) threaded calls:client does calc. args + marshal args + OS send time (call 1) = 5+.5=.5 = 6then calc args + marshal args + OS send time (call 2) = 6= 12 ms then waits for reply from first callserver gets first call aftermessage transmission + OS receive time + unmarshal args = 6+ 3+.5+.5= 10 ms, takes 10+1 to execute, marshal, send at 21 msserver receives 2nd call before this, but works on it after 21 ms taking10+1, sends it at 32 ms from startclient receives it 3+1 = 4 ms later i.e. at 36 ms(message transmission + OS receive time + unmarshal args) laterTime for 2 calls = 36 ms.5.13Design a remote object table that can support distributed garbage collection as well as translatingbetween local and remote object references. Give an example involving several remote objects andproxies at various sites to illustrate the use of the table. Show what happens when an invocationcauses a new proxy to be created. Then show what happens when one of the proxies becomesunreachable.5.13 Ans..local reference remote reference holdersThe table will have three columns containing the local reference and the remote reference of a remote object and the virtual machines that currently have proxies for that remote object. There will be one row in the table for each remote object exported at the site and one row for each proxy held at the site.To illustrate its use, suppose that there are 3 sites with the following exported remote objects:S1: A1, A2, A3S2: B1, B2;S3: C1;and that proxies for A1 are held at S2 and S3; a proxy for B1 is held at S3.Then the tables hold the following information:.at S1at S2at S3local remote holders local remote holders local remote holdersa1A1S2, S3b1B1S3c1C1a2A2b2B2a1A1proxya3A3a1A1proxy b1B1proxy Now suppose that C1(at S3) invokes a method in B1 causing it to return a reference to B2. The table at S2 adds the holder S3 to the entry for B2 and the table at S3 adds a new entry for the proxy of B2.Suppose that the proxy for A1 at S3 becomes unreachable. S3 sends a message to S1 and the holder S3 is removed from A1. The proxy for A1 is removed from the table at S3.5.14 A simpler version of the distributed garbage collection algorithm described in Section 5.2.6 justinvokes addRef at the site where a remote object lives whenever a proxy is created and removeRefwhenever a proxy is deleted. Outline all the possible effects of communication and process failureson the algorithm. Suggest how to overcome each of these effects, but without using leases.5.14 Ans.AddRef message lost - the owning site doesn’t know about the client’s proxy and may delete the remote object when it is still needed. (The client does not allow for this failure).RemoveRef message lost - the owning site doesn’t know the remote object has one less user. It may continue to keep the remote object when it is no longer needed.Process holding a proxy crashes - owning site may continue to keep the remote object when it is no longer needed.Site owning a remote object crashes. Will not affects garbage collection algorithmLoss of addRef is discussed in the Section 5.2.6.When a removeRef fails, the client can repeat the call until either it succeeds or the owner’s failure has been detected.One solution to a proxy holder crashing is for the owning sites to set failure detectors on holding sites and then remove holders after they are known to have failed.5.15Discuss how to use events and notifications as described in the Jini distributed event specificationin the context of the shared whiteboard application. The RemoteEvent class is defined as followsin Arnold et al. [1999].public class RemoteEvent extends java.util.EventObject {public RemoteEvent(Object source, long eventID,long seqNum, MarshalledObject handback)public Object getSource () {…}public long getID() {…}public long getSequenceNumber() {…}public MarshalledObject getRegistrationObject() {…}}The first argument of the constructor is a remote object. Notifications inform listeners that an eventhas occurred but the listeners are responsible for obtaining further details.5.15 Ans.Event identifier,. evID s. Decided by the EventGenerator. Simplest solution is just to have one type of event -the addition of a new GraphicalObject. Other event types could for example refer to deletion of a GraphicalObject.Clients need to be notified of the remote object reference of each new GraphicalObject that is added to the server. Suppose that an object in the server is the EventGenerator. It could implement the EventGenerator interface and provide the register operation, or it could be done more simplye.g. addListener(RemoteEventListener listener, long evID)// add this listener to a vector of listenersThis would be better if Leases were used to avoid dealing with lost clients.The newShape method of shapeListServant (Figure 5.14) could be the event generator. It will notify all of the EventListeners that have registered with it, each time a new GraphicalObject is added. e.g.RemoteEvent event = new RemoteEvent(this, ADD_EVENT, version, null)for all listeners in the vectorlistener.notify(event)Each client creates an RemoteEventListener for receiving notifications of events and then registers interest in events with the server, passing the EventListener as argument.class MyListener implements RemoteEventListener {public MyListener() throws RemoteException[}public void notify(RemoteEvent event) throws UnknownEventException,RemoteException {Object source = getSource();long id = event.getID();long version = event.getSequenceNumber();// get the newly created GraphicalObject from the server}}Then to become a listener (add the following to the client program shown in Figure 5.15):sList.addListener(new MyListener(), ADD_EVENT);The client getting the newGraphicalObject needs to be able to get it directly from the version number, rather than by getting the list of Shapes and then getting the GraphicalObject. The interface to ShapeList could be amended to allow this.5.16Suggest a design for a notification mailbox service which is intended to store notifications onbehalf of multiple subscribers, allowing subscribers to specify when they require notifications tobe delivered. Explain how subscribers that are not always active can make use of the service youdescribe. How will the service deal with subscribers that crash while they have delivery turned on?5.16 Ans.The Mailbox service will provide an interface allowing a client to register interest in another object. The client will need to know the RemoteEventListener provided by the Mailbox service so that notifications may be passed from event generators to the RemoteEventListener and then on to the client. The client will also need a means of interacting with the Mailbox service so as to turn delivery on and off. Therefore define register as follows:Registration register() ...The result is a reference to a remote object whose methods enable the client to get a reference to a RemoteEventListener and to turn delivery on and off.To use the Mailbox service, the client registers with it and receives a Registration object, which it saves in a file. It registers the RemoteEventListener provided by the Mailbox service with all of the EventGenerators whose events it wants to have notification of. If the client crashes, it can restore the Registration object when it restarts. Whenever it wants to receive events it turns delivery on and when it does not want them it turns delivery off.The design should make it possible to specify a lease for each subscriber.5.17Explain how a forwarding observer may be used to enhance the reliability and performance ofobjects of interest in an event service.5.17 Ans.Reliability:The forwarding observer can retry notifications that fail at intervals of time.If the forwarding observer is on the same computer as the object of interest, then the two could not fail independently.Performance:The forwarding observer can optimize multicast protocols to subscribers.In Jini it could deal with renewing leases.5.18Suggest ways in which observers can be used to improve the reliability or performance of yoursolution to Exercise 5.13.5.18 Ans.The server can be relieved of saving information about all of the clients’ interests by creating a forwarding agent on the same computer. the forwarding agent could use a multicast protocol to send notifications to the clients. IP multicast would do since it is not crucial that every notification be received. A missed version number can be rectified as soon as another one is received.。

分布式系统:原理与范式第二版答案

分布式系统:原理与范式第二版答案

PRENTICE HALL
UPPER SADDLE RIVER, NJ 07458
SOLUTIONS TO CHAPTER 1 PROBLEMS 1. Q: An alternative definition for a distributed system is that of a collection of independent computers providing the view of being a single system, that is, it is completely hidden from users that there even multiple computers. Give an example where this view would come in very handy. A: What immediately comes to mind is parallel computing. If one could design programs that run without any serious modifications on distributed systems that appear to be the same as nondistributed systems, life would be so much easier. Achieving a single-system view is by now considered virtually impossible when performance is in play. 2. Q: What is the role of middleware in a distributed system? A: To enhance the distribution transparency that is missing in network operating systems. In other words, middleware aims at improving the single-system view that a distributed system should have. 3. Q: Many networked systems are organized in terms of a back office and a front office. How does organizations match with the coherent view we demand for a distributed system? A: A mistake easily made is to assume that a distributed system as operating in an organization, should be spread across the entire organization. In practice, we see distributed systems being installed along the way that an organization is split up. In this sense, we could have a distributed system supporting backoffice procedures and processes, as well as a separate front-office system. Of course, the two may be coupled, but there is no reason for letting this coupling be fully transparent. 4. Q: Explain what is meant by (distribution) transparency, and give examples of different types of transparency. A: Distribution transparency is the phenomenon by which distribution aspects in a system are hidden from users and applications. Examples include access transparency, location transparency, migration transparency, relocation transparency, replication transparency, concurrency transparency, failure transparency, and persistence transparency. 5. Q: Why is it sometimes so hard to hide the occurrence and recovery from failures in a distributed system? A: It is generally impossible to detect whether a server is actually down, or that it is simply slow in responding. Consequently, a system may have to report that a service is not available, although, in fact, the server is just slow.

分布式课后习题答案

分布式课后习题答案

分布式课后习题答案第⼀章分布式数据库系统概述1.1请⽤⾃⼰的语⾔定义下列分布式数据库系统中的术语:(1)局部数据:只提供本站点的局部应⽤所需要的数据。

全局数据:虽然物理上存储在个站点上,但是参与全局应⽤(2)全局/局部⽤户:局部⽤户:⼀个⽤户或⼀个应⽤如果只访问他注册的那个站点上的数据称为本地或局部⽤户或本地应⽤;全局⽤户:如果访问涉及两个或两个以上的站点中的数据,称为全局⽤户或全局应⽤。

全局/局部DBMS:1)LDBMS(Local DBMS):局部场地上的数据库管理系统,其功能是建⽴和管理局部数据库,提供场地⾃治能⼒,执⾏局部应⽤及全局查询的⼦查询。

(2)GDBMS(Global DBMS):全局数据库管理系统,主要功能是提供分布透明性,协调全局事物的执⾏,协调各局部DBMS 以完成全局应⽤,保证数据库的全局⼀致性,执⾏并发控制,实现更新同步,提供全局恢复功能等。

(3)全局外模式:全局应⽤的⽤户视图,也称全局视图。

从⼀个由各局部数据库组成的逻辑集合中抽取,即全局外模式是全局概念式的⼦集。

对全局⽤户⽽⾔,都可以认为在整个分布式数据库系统的各个站点上的所有数据库都如同在本站点上⼀样,只关⼼他们⾃⼰所使⽤的那部分数据(4)全局概念模式:描述分布式数据库中全局数据的逻辑结构和数据特性,是分布式数据库的全局概念视图。

采⽤关系模型的全局概念模式由⼀组全局关系的定义(如关系名、关系中的属性、每⼀属性的数据类型和长度等)和完整性定义(关系的主键、外键及完整性其他约束条件等)组成。

(5)分⽚模式:描述全局数据的逻辑划分。

每个全局关系可以通过选择和投影的关系操作被逻辑划分为若⼲⽚段。

分⽚模式描述数据分⽚或定义⽚段,以及全局关系与⽚段之间的映像。

这种映像是⼀对多的。

(6)分配模式:根据选定的数据分布策略,定义各⽚段的物理存放站点,即定义⽚段映像的类型,确定分布式数据库是冗余的还是⾮冗余的,以及冗余的程度。

如果⼀个⽚段分配在多个站点上,则⽚段的映像是⼀对多的,分布式数据库是冗余的,否则是不冗余的。

分布式课后习题答案

分布式课后习题答案

第一章分布式数据库系统概述请用自己的语言定义下列分布式数据库系统中的术语:(1)全局/局部数据:(详见课本第9页所谓的局部数据是指……;所谓的全局数据是指……)(2)全局/局部用户(应用):(3)全局/局部DBMS:(4)全局/局部DB:(5)全局外模式:(详见课本第13页)由全局用户视图组成,是全局概念模式的子集。

(6)全局概念模式:(详见课本第13页)定义分布式数据库系统中所有数据的整体逻辑结构,是全局应用的公共数据视图。

(7)分片模式:(详见课本第13页)是全局数据整体逻辑结构分割后的局部逻辑结构,是DDBS 的全局数据的逻辑划分视图.(8)分配模式:(详见课本第13页)用于根据选定的数据总体分配方案,定义各片段的物理存放地点.(9)局部概念模式:(详见课本第13-14页)是全局概念模式被分片和分配到局部场地上的映像的逻辑结构及特征的描述,是全局概念模式的子集。

其逻辑结构与局部DBMS所支持的数据模型有关,当全局数据模型与局部数据模型不同时,局部概念模式还应包括数据模型转换的描述。

(10)局部内模式:描述局部概念模式涉及的数据在局部DBMS中的物理结构及物理存储细节,完全与非分布式系统相同。

1.2采用分布式数据库系统的主要原因是什么?(P1)1.3分布式数据库系统可分为哪些类?(课件第1章。

课本P6,7,8)1.4什么是分布式数据库系统?它具有哪些主要特点?怎么样区别分布式数据库系统与只提供远程数据访问功能的网络数据库系统?(分布式数据库系统的定义、特点详见课件第1.课本P6)1.5分布式DBMS具有哪些集中式DBMS不具备的功能?(课件第1章。

课本P15)用自己的语言解析“什么时候需要进行数据分片和数据复制”?(课本第10,11页)式数据库系统中,为什么要对数据进行分片?什么是关系的片段?关系的片段有哪些主要类型?(课本第9-10页。

数据分片是指数据存放单位不是全部关系,而是关系的一个片段。

分布式系统原理与范型 考试 2009 答案

分布式系统原理与范型 考试 2009 答案
1
it is sent, or even at the same time it is sent, since it takes a finite, nonzero amount of time to arrive. 7. finger table (chap 5) Instead of linear approach toward key lookup, each Chord node maintains a finger table of at most m entries. If FTp denotes the finger table of node p, then FTp[i] = succ (p + 2i-1) Put in other words, the i-th entry points to the first node succeeding p by at least 2i-1. 8. out of band data (chap 3) Data is to be processed by the server before any other data from that client. 9. MapReduce (5pt)
2
二、简答题(共70分) 1. Q: What is the difference between a vertical distribution and a horizontal distribution? (chap 2, 5pt) A: Vertical distribution refers to the distribution of the different layers in a multitiered architectures across multiple machines. In principle, each layer is implemented on a different machine. Horizontal distribution deals with the distribution of a single layer across multiple machines, such as distributing a single database. 2. Q: Is a server that maintains a TCP/IP connection to a client stateful or stateless? (chap 3) A: Assuming the server maintains no other information on that client, one could justifiably argue that the server is stateless. The issue is that not the server, but the transport layer at the server maintains state on the client. What the local operating systems keep track of is, in principle, of no concern to the server. 3. Q: One way to handle parameter conversion in RPC systems is to have each machine send parameters in its native representation, with the other one doing the translation, if need be. The native system could be indicated by a code in the first byte. However, since locating the first byte in the first word is precisely the problem, can this actually work? (chap 4) A: First of all, when one computer sends byte 0, it always arrives in byte 0. Thus the destination computer can simply access byte 0 (using a byte instruction) and the code will be in it. It does not matter whether this is the low-order byte or the high-order byte. An alternative scheme is to put the code in all the bytes of the first word. Then no matter which byte is examined, the code will be there. 4. Q: Routing tables in IBM WebSphere, and in many other message-queuing systems, are configured manually. Describe a simple way to do this automatically. (chap 4) A: The simplest implementation is to have a centralized component in which the topology of the queuing network is maintained. That component simply calculates all best routes between pairs of queue managers using a known routing algorithm, and subsequently generates routing tables for each queue manager. These tables can be downloaded by each manager separately. This approach works in queuing networks where there are only relatively few, but possibly widely dispersed, queue managers. 5. Q: Is an identifier allowed to contain information on the entity it refers to? (chap 5) A: Yes, but that information is not allowed to change, because that would imply changing the identifier. The old identifier should remain valid, so that changing it would imply that an entity has two identifiers, violating the second property of identifiers. 6. Q: When a node synchronizes its clock to that of another node, it is generally a good idea to take previous measurements into account as well. Why? Also, give an example of how such past readings could be taken into account. (chap 6) A: The obvious reason is that there may be an error in the current reading. Assuming that clocks need only be gradually adjusted, one possibility is to consider the last N values and compute a median or average. If the measured value falls outside a current interval, it is not taken into account (but is added to the list). Likewise, a new value can be computed by taking a weighted average, or an aging algorithm.

分布式数据库系统部分课后题答案

分布式数据库系统部分课后题答案

∑ ∑ aff ( A1, A1) =
3 l =1
accl
(qk
)
=
acc1
(q2
TITLE
根据如下关系代数表达式进行分片后的 EMP TITLE PAY 连接图:
EMP1 = σ TITLE =”Elect. Eng.”(EMP);
EMP2 =σ TITLE =”Syst. Anal.”(EMP);
EMP3 = σ TITLE =”Mech. Eng..”(EMP);
EMP4 =σ TITLE =”Programmer”(EMP);
TITLE Mech. Eng. Programmer Mech. Eng
图 5.5.2
EMP2 ENO ENAME E1 J. Doe E2 M. Smith E5 B. Casey E6 L. Chu E8 J. Jones
TITLE Elect. Eng Syst. Anal. Syst. Anal. Elect. Eng. Syst. Anal.
PAY TITLE
Elect. Eng. Syst. Anal. Mech. Eng. Programmer
SAL 40000 34000 27000 24000
Figure 5.3. Modified Example Database
5.1 p1: TITLE < “Programmer” and p2: TITLE > “Programmer”. (a) 根据{ p1, p2 }对关系 EMP 进行水平分片:EMP1 = σ TITLE < ”Programmer” (EMP);
q5 1 1 1 0 0
(a)
S1 S2 S3
q1 10 20 0

分布式计算原理及应用第五章部分答案

分布式计算原理及应用第五章部分答案

1.In the context of distributed computing,describe the client-server paradigm.Why is this paradigm especially appropriate for network services?Answer:In distributed computing,the client-server paradigm refers to a model for network applications where processes play one of two different roles:a server process,also called a server for short,if dedicated to managing access to some network service,while client processes,called clients for short,access the server to obtain a network service.The client-server model is designed for providing network services,which were,and still are,the most popular application of distributed computing.By network service we mean a service provided to allow network users to share resources.It is very easy for us to create a mechanism that a server can provide service concurrently for multiple clients,that is,one-to-many.ing the three-tier software architecture presented in this chapter,design and implement a client-server suite for the following protocol (it is not a well-known service):Each client sends a name to the server.The sever accumulates the names received from successive clients (by appending each,with a newline character,'/n',to a static string).Upon receiving a name,the server sends the names it has collected to the client.The client then displays all the names it receives from the server.Figure 5.38 below illustrates the sequence diagram of the protocol with 3 concurrent client sessions.a.Is this server a stateful server?If so,what kind of state information(global or session) does it maintain?b.Create one or more of the following suites for the protocol:i.Connectionless server and clientii.Connection-oriented,iterative server and clientiii.Connection-oriented,concurrent server and clientFor each suite,hand in:(A)program listings,and (B) a description of how the three-tier architecture is realized using separate software modules(Java classes).Name server Client1 Client2 Client3MattMattCathyMatt\nCathyJohnMatt\nCathy\nJohnFigure 5.35 A sequence diagram of the protocol showing three concurrent client sessions.A.This server is a stateful server.It maintains a global information which records all the messages by order the clients send to it,separated by the character '\n'.B.i.Connectionless server and clientClient:(1)Presentationpackage distributedComputing;//This is the presentation layer//connectionlessimport java.io.BufferedReader;import java.io.InputStreamReader;public class Client1 {static final String endMessage = ".";public static void main(String[] args){InputStreamReader is = new InputStreamReader(System.in);BufferedReader br = new BufferedReader(is);try{System.out.println("Welcome to the client.\n"+"What is the name of the server host?");String hostName = br.readLine();if(hostName.length()==0)hostName = "localhost";System.out.println("What is the port number of the server host?");String portNum = br.readLine();if(portNum.length()==0)portNum = "13";ClientHelper1 helper =new ClientHelper1(hostName,portNum);boolean done = false;String message,echo;while(!done){System.out.println("Enter a line to receive an echo back" +"from the server,"+"or a single peroid to quit.");message = br.readLine();if((message.trim()).equals(endMessage)){done = true;helper.done();}else{echo = helper.getEcho(message); //send messages and receive responseSystem.out.println(echo);}}}catch(Exception ex){ex.printStackTrace();}}}(2)Applicationpackage distributedComputing;//this is the application layer//connectionlessimport java.io.IOException;import .InetAddress;import .SocketException;import .UnknownHostException;public class ClientHelper1 {private MyClientDatagramSocket mySocket;private InetAddress serverHost;private int serverPort;ClientHelper1(String hostName,String portNum)throws SocketException,UnknownHostException{this.serverHost = InetAddress.getByName(hostName);this.serverPort = Integer.parseInt(portNum);this.mySocket = new MyClientDatagramSocket();}public String getEcho(String message)throws SocketException,IOException{String echo = "";mySocket.sendMessage(serverHost, serverPort, message);echo = mySocket.receiveMessage();echo.replaceAll(" ", "");return echo;}public void done() throws SocketException{mySocket.close();}}(3)Servicepackage distributedComputing;//this is the service layer//connectionlessimport java.io.IOException;import .DatagramPacket;import .DatagramSocket;import .InetAddress;import .SocketException;public class MyClientDatagramSocket extends DatagramSocket{static final int MAX_LEN = 64;MyClientDatagramSocket() throws SocketException{super();}MyClientDatagramSocket(int portNo) throws SocketException{super(portNo);}public void sendMessage(InetAddress receiverHost,int receiverPort,String message) throws IOException{byte[] sendBuffer = message.getBytes();DatagramPacket datagram =new DatagramPacket(sendBuffer,sendBuffer.length,receiverHost,receiverPort);this.send(datagram);}public String receiveMessage () throws IOException{byte[] receiveBuffer = new byte[MAX_LEN];DatagramPacket datagram =new DatagramPacket(receiveBuffer,receiveBuffer.length);this.receive(datagram);String message = new String(datagram.getData(),0,datagram.getLength());return message;}}Server:(1)presentation and applicationpackage distributedComputing;//connectionless//These are the application layer and the presentation layerimport java.util.Date;public class Server1 {private static StringBuffer sbf = new StringBuffer();public static void main(String[] args){int serverPort = 13;if(args.length==1)serverPort = Integer.parseInt(args[0]);try{MyServerDatagramSocket mySocket =new MyServerDatagramSocket(serverPort);System.out.println("server ready.");while(true){DatagramMessage request =mySocket.receiveMessageAndSender();System.out.println("Request received");String message = request.getMessage();//这里有问题if(sbf.length()==0)sbf.append(message);elsesbf.append("\\n"+message);System.out.println("message received:"+message);mySocket.sendMessage(request.getAddress(), request.getPort(), sbf.toString());}}catch(Exception ex){ex.printStackTrace();}}}(2)Servicepackage distributedComputing;//connecitonless//this is the service layerimport java.io.IOException;import .DatagramPacket;import .DatagramSocket;import .InetAddress;import .SocketException;public class MyServerDatagramSocket extends DatagramSocket{static final int MAX_LEN = 64;MyServerDatagramSocket(int portNo) throws SocketException{super(portNo);}public void sendMessage(InetAddress receiverHost,int receiverPort,String message)throws IOException{byte[] sendBuffer = message.getBytes();DatagramPacket datagram =new DatagramPacket(sendBuffer,sendBuffer.length,receiverHost,receiverPort);this.send(datagram);}public String receiveMessage() throws IOException{byte[] receiveBuffer = new byte[MAX_LEN];DatagramPacket datagram =new DatagramPacket(receiveBuffer,receiveBuffer.length);this.receive(datagram);String message = new String(datagram.getData(),0,datagram.getLength());return message;}public DatagramMessage receiveMessageAndSender() throws IOException{byte[] receiveBuffer = new byte[MAX_LEN];DatagramPacket datagram =new DatagramPacket(receiveBuffer,receiveBuffer.length);this.receive(datagram);DatagramMessage returnV al = new DatagramMessage();returnV al.putV al(new String(datagram.getData(),0,datagram.getLength()), datagram.getAddress(), datagram.getPort());return returnV al;}}(3)package of the datagrampackage distributedComputing;//This class helps the program to package the datagramimport .InetAddress;public class DatagramMessage { private String message;private InetAddress senderAddress; private int senderPort;public void putV al(String message,InetAddress addr,int port){ this.message = message; this.senderAddress = addr; this.senderPort = port;}public String getMessage(){ return this.message; }public InetAddress getAddress(){ return this.senderAddress; }public int getPort(){ return this.senderPort;}}UML class diagram for Client1Client1DatagramPacketClientHelper1DatagramSocketMyClient DatagramSocketsendMessage() receiveMessage()Presentation logic Application logicService logicUML class diagram for Server1Running Result:Client ServerDatagramPacketDatagramMessageMyServerDatagramSocketsendMessage() receiveMessage() receiveMessageAnd Sender()Server1 DatagramSocketService logicPresentation+applicationlogicii.Connection-oriented,iterative server and clientClient:(1)Presentationpackage distributedComputing;//connection-oriented//this is the presentation layerimport java.io.BufferedReader;import java.io.InputStreamReader;public class Client2 {static final String endMessage = ".";public static void main(String[] args){InputStreamReader is = new InputStreamReader(System.in);BufferedReader br = new BufferedReader(is);try{System.out.println("Welcome to the client.\n"+"What is the name of the server host?");String hostName = br.readLine();if(hostName.length()==0)hostName = "localhost";System.out.println("What is the port number of the server host?");String portNum = br.readLine();if(portNum.length()==0)portNum = "13";ClientHelper2 helper =new ClientHelper2(hostName,portNum);boolean done = false;String message,echo;while(!done){System.out.println("Enter a line to receive an echo back" +"from the server,"+"or a single peroid to quit.");message = br.readLine();if((message.trim()).equals(endMessage)){done = true;helper.done();}else{echo = helper.getEcho(message);System.out.println(echo);}}}catch(Exception ex){ex.printStackTrace();}}}(2)Applicationpackage distributedComputing;//connection-oriented//this is the application layerimport java.io.IOException;import .InetAddress;import .SocketException;import .UnknownHostException;public class ClientHelper2 {static final String endMessage = ".";private MyStreamSocket mySocket;private InetAddress serverHost;private int serverPort;ClientHelper2(String hostName,String portNum) throws SocketException,UnknownHostException,IOException{ this.serverHost = InetAddress.getByName(hostName);this.serverPort = Integer.parseInt(portNum);this.mySocket = new MyStreamSocket(hostName,this.serverPort);System.out.println("Connection request made");}public String getEcho(String message) throws SocketException,IOException{ String echo = "";mySocket.sendMessage(message);echo = mySocket.receiveMessage();return echo;}public void done() throws SocketException,IOException{mySocket.sendMessage(endMessage);mySocket.close();}}(3)Servicepackage distributedComputing;//connection-oriented//this is the service layerimport java.io.BufferedReader;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.io.OutputStream;import java.io.OutputStreamWriter;import java.io.PrintWriter;import .Socket;import .SocketException;public class MyStreamSocket extends Socket{private Socket socket;private BufferedReader input;private PrintWriter output;MyStreamSocket(String acceptorHost,int acceptorPort) throws SocketException, IOException{ socket = new Socket(acceptorHost,acceptorPort);setStreams();}MyStreamSocket(Socket socket) throws IOException{this.socket = socket;setStreams();}private void setStreams() throws IOException{InputStream inStream = socket.getInputStream();input =new BufferedReader(new InputStreamReader(inStream));OutputStream outStream = socket.getOutputStream();output =new PrintWriter(new OutputStreamWriter(outStream));}public void sendMessage(String message) throws IOException{ output.println(message);output.flush();}public String receiveMessage() throws IOException{String message = input.readLine();return message;}}Server:(1)presentation and applicationpackage distributedComputing;//connection-oriented//these are the presentation layer and the application layerimport .ServerSocket;public class Server2 {static final String endMessage = ".";private static StringBuffer sbf = new StringBuffer();public static void main(String[] args){int serverPort = 13;String message;if(args.length==1)serverPort = Integer.parseInt(args[0]);try{ServerSocket myConnectionSocket =new ServerSocket(serverPort);System.out.println("Waiting for a connection.");MyStreamSocket myDataSocket = new MyStreamSocket(myConnectionSocket.accept());System.out.println("connection accepted");boolean done = false;while(!done){message = myDataSocket.receiveMessage();System.out.println("message received:"+message);if(sbf.length()==0)sbf.append(message);elsesbf.append("\\n"+message);if((message.trim()).equals(endMessage)){System.out.println("Session over.");myDataSocket.close();done = true;}else{myDataSocket.sendMessage(sbf.toString());}}}catch(Exception ex){ex.printStackTrace();}}}(2)ServiceIt's the same as the Client's.UML class diagram for Client2Client2ClientHelper2 MyStreamSocketsendMessage()receiveMessage() SocketPresentation logicApplication logicService logicUML class diagram for Server2Server3Running Result:Client ServerServerSocketThreadMyStreamSocketreceiveMessage AndSender()SocketService logicPresentation and Application logiciii.Connection-oriented,concurrent server and clientIt's almost the same as the answer of the below question except that there is some differences with the server.(1)ServerThreadpackage distributedComputing;public class ServerThread implements Runnable{static final String endMessage = ".";static StringBuffer sbf = new StringBuffer();MyStreamSocket myDataSocket;ServerThread(MyStreamSocket myDataSocket){this.myDataSocket = myDataSocket;}public void run(){boolean done = false;String message;try{while(!done){message = myDataSocket.receiveMessage();System.out.println("message received:"+message);if(sbf.length()==0)sbf.append(message);elsesbf.append("\\n"+message);if((message.trim()).equals(endMessage)){System.out.println("Session over.");myDataSocket.close();done = true;}else{myDataSocket.sendMessage(sbf.toString());}}}catch(Exception ex){System.out.println("Exception caught in thread:"+ex);}}}(2)Serverpackage distributedComputing;import .ServerSocket;public class Server3 {private static StringBuffer sbf = new StringBuffer();public static void main(String[] args){int serverPort = 13;String message;if(args.length==1)serverPort = Integer.parseInt(args[0]);try{ServerSocket myConnectionSocket =new ServerSocket(serverPort);System.out.println("Server ready");while(true){System.out.println("Waiting for a connection");MyStreamSocket myDataSocket = new MyStreamSocket(myConnectionSocket.accept());System.out.println("connection accepted");Thread theThread =new Thread(new ServerThread(myDataSocket));theThread.start();}}catch(Exception ex){ex.printStackTrace();}}}Running Result:Client1 Client2These are two differentconnectionServerChapter 210.Draw a sequence diagram for the Daytime protocol.Answer :Server Client11.Is it possible for a Daytime client to be blocked indefinitely?Explain.Answer :It's possible for a Daytime client to be blocked indefinitely when the server starts its receiving service after the client's giving request.Ask for a timestampResponse with a timestampTime。

分布式系统原理与范型课后习题答案

分布式系统原理与范型课后习题答案

分布式系统原理与范型课后习题答案专业专心专注第一章绪论1、中间件在分布式系统中扮演什么角色,答:中间件主要是为了增强分布式系统的透明性(这正是网络操作系统所缺乏的),换言之,中间件的目标是分布式系统的单系统视图。

2、解释(分布)透明性的含义,并且给出各种类型透明性的例子。

答:分布透明性是一种现象,即一个系统的分布情况对于用户和应用来说是隐藏的。

包括:访问透明、位置透明、移植透明、重定位透明、复制透明、并发透明、故障透明和持久性透明。

3、在分布式系统中,为什么有时难以隐藏故障的发生以及故障恢复过程,答:通常,要探测一个服务器是停止服务还是该服务器的反应变慢这些情况是不可能的。

因此,一个系统可能在服务响应变慢的时候报告该服务已经停止了。

4、为什么有时候要求最大程度地实现透明性并不好,答:最大程度地实现透明性可能导致相当大的性能损失,从而导致用户无法接受。

5、什么是开放的分布式系统,开放性带来哪些好处,答:开放的分布式系统根据明确定义的规则来提供服务。

开放系统能够很容易地与其它系统协作,同时也允许应用移植到同一个系统的不同实现中。

6、请对可扩展系统的含义做出准确描述答:一个系统的可扩展包含下面几个方面:组件的数量、几何尺寸、管理域的数量与尺寸,前提是这个系统可以在上面几个方面进行增加而不会导致不可接受的性能损失。

7、可以通过应用多种技术来取得可扩展性。

请说出这些技术。

答:可扩展性可以通过分布式、复制和缓存来获得。

8、多处理器系统与多计算机系统有什么不同,答:在多处理器系统中,多个CPU访问共享的主存储器。

在多计算机系统中没有共享存储器,CPU之间只能通过消息传递来进行通信。

9、在多计算机系统中的256个CPU组成了一个16 X 16的网格方阵。

在最坏的情况下,消息的延迟时间有多长(以跳(hop)的形式给出,跳是结点之间的逻辑距离),答:假设路由是最优的,最长的路由是从网格方阵的一个角落到对角的角落。

那么这个路由的长度是30跳。

《分布式系统原理与范型--(第二版)》复习资料

《分布式系统原理与范型--(第二版)》复习资料

分布式复习资料第1章分布式系统是若干独立计算机的结合,这些计算机对于用户来说就像是单个相关系统。

硬件方面:机器本身是独立的。

软件方面:对用户来说就像与单个系统打交道。

重要特性:1、各种计算机之间的差别以及计算机之间的通信方式的差别对用户是隐藏的。

2、用户和应用程序无论在何时何地都能够以一种一致和统一的方式与分布式系统进行交互。

中间件:为了使种类各异的计算机和网络都呈现为单个的系统,分布式系统常常通过一个“软件层”组织起来。

该“软件层”在逻辑上位于由用户和应用程序组成的高层与由操作系统组成的低层之间。

如图,这样的分布式系统有时又称为中间件。

注意层次分布与组件分布式系统的最主要目标是使用户能够方便地访问远程资源,并且以一种受控的方式与其他用户共享这些资源。

透明性:如果一个分布式系统能够在用户和应用程序面前呈现为单个计算机系统,这样的分布式系统就是透明的。

透明的类型:1、访问透明性:指对不同数据表示形式以及资源访问方式的隐藏。

2、位置透明性:指用户无法判别资源在系统中的物理位置。

3、并发透明性:在资源共享时,用户不会感觉到他人也在使用自己正使用的资源。

4、故障透明性:用户不会注意到某个资源(也许他从未听说过这个资源)无法正常工作,以及系统随后从故障中恢复的过程。

开放性:一个开放式的分布式系统,是根据一系列准则来提供服务,这些准则描述了所提供服务的语法和含义。

互操作性:刻画了来自不同厂商的系统或组件的两种实现能够在何种程度上共存并且协同工作,这种共存和协同工作只能依赖于通过双方在公共标准中规定的各自所提供的服务来完成。

可移植性:刻画了这样的性能,如果为分布式系统A开发了某个应用程序,并且另一个分布式系统B与A具有相同的接口,该应用程序在不做任何修改的情况下在B上执行的可行程度。

可扩展性:当一个系统需要进行扩展时,必须解决多方面的问题。

首先考虑规模上的扩展。

在需要支持更多的用户或资源时,我们常常收到集中的服务、数据以及算法所造成的限制,如图所示。

分布式系统复习题与参考答案(答案完全版)

分布式系统复习题与参考答案(答案完全版)
分布式系统复习题与参考答案答案完全版分布式系统分布式文件系统分布式操作系统分布式能源系统分布式系统架构分布式存储系统分布式系统设计分布式系统工程实践分布式文件系统对比无线分布式系统
关于分布式系统复习题与参考答案
一、 填空题(每题 n 分,答错 个扣 分,全Байду номын сангаас全扣,共计 m 分)
1.下面特征分别属于计算机网络和分布式计算机系统,请加以区别: 分布式计算机是指系统内部对用户是完全透明的; 系统中的计算机即合作又自治; 系统可以 利用多种物理和逻辑资源,可以动态地给它们分配任务。 计算机网络是指互连的计算机是分布在不同地理位置的多台独立的“自治计算机” 。 2.点到点通信子网的拓扑结构主要有以下几种:星型、环型、树型、网状型,请根据其特 征填写相应结构。 网状型 :结点之间的连接是任意的,没有规律。环型:节点通过点到点通信线路连接成闭 合环路。星型:节点通过点到点通信线路与中心结点相连;树型:结点按层次进行连接。 3.分布式计算系统可以分为两个子组,它们是集群计算系统和网格计算系统。 4.分布式事务处理具有 4 个特性,原子性:对外部来说,事务处理是不可见的;一致性: 事务处理不会违反系统的不变性;独立性:并发的事务处理不会相互干扰;持久性:事务处 理一旦提交,所发生的改变是永久性的。 5.网络协议有三要素组成,时序是对事件实现顺序的详细说明;语义是指需要发出何种控 制信息,以及要完成的动作与作出的响应;语法是指用户数据与控制信息的结构与格式 6.根据组件和连接器的不同,分布式系统体系结构最重要的有 4 种,它们是:分层体系结 构、基于对象的体系结构、以数据为中心的体系结构、基于事件的体系结构 7.在客户-服务器的体系结构中,应用分层通常分为 3 层,用户接口层、处理层和数据层。 8.有两种类型的分布式操作系统,多处理器操作系统和多计算机操作系统。 9.软件自适应的基本技术有 3 种,一是要点分离、二是计算映像、三是基于组件的设计。 10.DCE 本身是由多个服务构成的,常用的有分布式文件系统、目录服务、安全服务以及 分布式时间服务等。 11.TCP/IP 体系结构的传输层上定义的两个传输协议为传输控制协议(TCP)和用户数据报协 议(UDP)。 12.Windows NT 的结构借用了层次模型和客户/服务器两种模型。 13.常用的进程调度算法有先来先服务、优先数法和轮转法 14.进程的三个基本状态是就绪、执行、等待(阻塞)。 15.进程是 程序 在一个数据集合上的 运行过程 ,是系统进行资源分配和调度的一个 独 立单位 16.进程四个特征是 动态性, 并发性, 独立性 ,异步性。 17.操作系统通常可以分为以下几种类型:批处理系统、分时系统、 实时系统 、 网络操 作系统 和分布式操作系统。 18.解决死锁的基本方法包括预防死锁, 避免死锁,死锁检测,死锁恢复。 19.在引进线程的操作系统中,调度和分派的基本单位是线程,拥有资源的单位是进程。 20.在面向流的通信中,为连续提供支持数据流的模式有异步传输模式、同步传输模式和等 时传输模式三种。 21. 在流同步机制, 通常有在数据单元层次上进行显式同步和通过高级接口支持的同步两种。 22.在分布式系统中,挂载外部名称空间至少需要的信息是:访问协议的名称、服务器的名 称和外部名称空间中挂载点的名称。 23.在名称空间的实现中,为了有效实现名称空间,通常把它划分为逻辑上的三层,其三层 指的是全局层、行政层和管理层。

分布式系统复习题与参考答案(答案完全版)

分布式系统复习题与参考答案(答案完全版)
关于分布式系统复习题与参考答案
一、 填空题(每题 n 分,答错 个扣 分,全错全扣,共计 m 分)
1.下面特征分别属于计算机网络和分布式计算机系统,请加以区别: 分布式计算机是指系统内部对用户是完全透明的; 系统中的计算机即合作又自治; 系统可以 利用多种物理和逻辑资源,可以动态地给它们分配任务。 计算机网络是指互连的计算机是分布在不同地理位置的多台独立的“自治计算机” 。 2.点到点通信子网的拓扑结构主要有以下几种:星型、环型、树型、网状型,请根据其特 征填写相应结构。 网状型 :结点之间的连接是任意的,没有规律。环型:节点通过点到点通信线路连接成闭 合环路。星型:节点通过点到点通信线路与中心结点相连;树型:结点按层次进行连接。 3.分布式计算系统可以分为两个子组,它们是集群计算系统和网格计算系统。 4.分布式事务处理具有 4 个特性,原子性:对外部来说,事务处理是不可见的;一致性: 事务处理不会违反系统的不变性;独立性:并发的事务处理不会相互干扰;持久性:事务处 理一旦提交,所发生的改变是永久性的。 5.网络协议有三要素组成,时序是对事件实现顺序的详细说明;语义是指需要发出何种控 制信息,以及要完成的动作与作出的响应;语法是指用户数据与控制信息的结构与格式 6.根据组件和连接器的不同,分布式系统体系结构最重要的有 4 种,它们是:分层体系结 构、基于对象的体系结构、以数据为中心的体系结构、基于事件的体系结构 7.在客户-服务器的体系结构中,应用分层通常分为 3 层,用户接口层、处理层和数据层。 8.有两种类型的分布式操作系统,多处理器操作系统和多计算机操作系统。 9.软件自适应的基本技术有 3 种,一是要点分离、二是计算映像、三是基于组件的设计。 10.DCE 本身是由多个服务构成的,常用的有分布式文件系统、目录服务、安全服务以及 分布式时间服务等。 11.TCP/IP 体系结构的传输层上定义的两个传输协议为传输控制协议(TCP)和用户数据报协 议(UDP)。 12.Windows NT 的结构借用了层次模型和客户/服务器两种模型。 13.常用的进程调度算法有先来先服务、优先数法和轮转法 14.进程的三个基本状态是就绪、执行、等待(阻塞)。 15.进程是 程序 在一个数据集合上的 运行过程 ,是系统进行资源分配和调度的一个 独 立单位 16.进程四个特征是 动态性, 并发性, 独立性 ,异步性。 17.操作系统通常可以分为以下几种类型:批处理系统、分时系统、 实时系统 、 网络操 作系统 和分布式操作系统。 18.解决死锁的基本方法包括预防死锁, 避免死锁,死锁检测,死锁恢复。 19.在引进线程的操作系统中,调度和分派的基本单位是线程,拥有资源的单位是进程。 20.在面向流的通信中,为连续提供支持数据流的模式有异步传输模式、同步传输模式和等 时传输模式三种。 21. 在流同步机制, 通常有在数据单元层次上进行显式同步和通过高级接口支持的同步两种。 22.在分布式系统中,挂载外部名称空间至少需要的信息是:访问协议的名称、服务器的名 称和外部名称空间中挂载点的名称。 23.在名称空间的实现中,为了有效实现名称空间,通常把它划分为逻辑上的三层,其三层 指的是全局层、行政层和管理层。

分布式系统概念与设计(第三版)课后习题与答案Chapter15

分布式系统概念与设计(第三版)课后习题与答案Chapter15

Chapter 15Solutions15.1Outline a system to support a distributed music rehearsal facility. Suggest suitable QoSrequirements and a hardware and software configuration that might be used.15.1 Ans..This is a particularly demanding interactive distributed multimedia application. Konstantas et al. [1997] report that a round-trip delay of less than 50 ms is required for it. Clearly, video and sound should be tightly synchronized so that the musicians can use visual cues as well as audio ones. Bandwidths should be suitable for the cameras and audio inputs used, e.g. 1.5 Mbps for video streams and 44 kbps for audio streams. Loss rates should be low, but not necessarily zero.The QoS requirements are much stricter than for conventional videoconferencing – music performance is impossible without strict synchronization. A software environment that includes QoS management with resource contracts is required. The operating systems and networks used should provide QoS guarantees. Few general-purpose OS’s provide them at present. Dedicated real-time OS’s are available but they are difficult to use for high-level application development.Current technologies that should be suitable:•ATM network.•PC’s with hardware for MPEG or MJPEG compression.•Real-time OS with support for high-level software development, e.g. in CORBA or Java.15.2The Internet does not currently offer any resource reservation or quality of service managementfacilities. How do the existing Internet-based audio and video streaming applications achieveacceptable quality? What limitations do the solutions they adopt place on multimediaapplications?15.2 Ans..There are two types of Internet-based applications:a)Media delivery systems such as music streaming, Internet radio and TV applications.b)Interactive applications such as Internet phone and video conferencing (NetMeeting, CuSeemMe).For type (a), the main technique used is traffic shaping, and more specifically, buffering at the destination.Typically, the data is played out some 5–10 seconds after its delivery at the destination. This masks the uneven latency and delivery rate (jitter) of Internet protocols and masks the delays incurred in the network and transport layers of the Internet due to store-and-forward transmission and TCP’s reliability mechanisms.For type (b), the round trip delay must be kept below 100 ms so the above technique is ruled out. Instead, stream adaptation is used. Specifically, video is transmitted with high levels of compression and reduced frame rates. Audio requires less adaptation. UDP is generally used.Overall, type (a) systems work reasonably well for audio and low-resolution video only. For type (b) the results are usually unsatisfactory unless the network routes and operating system priorities are explicitly managed.15.3Explain the distinctions between the three forms of synchronization (synchronous distributedstate, media synchronization and external synchronization) that may be required in distributedmultimedia applications. Suggest mechanisms by which each of them could be achieved, forexample in a videoconferencing application.15.3 Ans..synchronous distributed state: All users should see the same application state. For example, the results of operation on controls for a video, such as start and pause should be synchronized, so that all users see the same frame. This can be done by associating the current state (sample number) of the active multimedia streams with each state-change message. This constitutes a form of logical vector timestamp.media synchronization: Certain streams are closely coupled. E.g. the audio that accompanies a video stream.They should be synchronised using timestamps embedded in the media data.external synchronization: This is really an instance of synchronous distributed state. The messages that update shared whiteboards and other shared objects should carry vector timestamps giving the states of media streams.15.4Outline the design of a QoS manager to enable desktop computers connected by an ATM networkto support several concurrent multimedia applications. Define an API for your QoS manager,giving the main operations with their parameters and results.15.4 Ans..Each multimedia application requires a resource contract for each of its multimedia streams. Whenever a new stream is to be started, a request is made to the QoS manager specifying CPU resources, memory and network connections with their Flow Specs. The QoS manager performs an analysis similar to Figure 15.6 for each end-to-end stream. If several streams are required for a single application, there is a danger of deadlock – resources are allocated for some of the streams, but the needs of the remaining streams cannot be satisfied. When this happens, the QoS negotiation should abort and restart, but if the application is already running, this is impractical, so a negotiation takes place to reduce the resources of existing streams.API:QoSManager.QoSRequest(FlowID, FlowSpec) –> ResourceContractThe above is the basic interface to the QoS Manager. It reserves resources as specified in the FlowSpec and returns a corresponding ResourceContract.A FlowSpec is a multi-valued object, similar to Figure 15.8.A ResourceContract is a token that can be submitted to each of the resource handlers (CPU scheduler,memory manager, network driver, etc.).Application.ScaleDownCallback(FlowID, FlowSpec) -> AcceptRejectThe above is a callback from the QoS Manager to an application, requesting a change in the FlowSpec fora stream. The application can return a value indicating acceptance or rejection.15.5In order to specify the resource requirements of software components that process multimediadata, we need estimates of their processing loads. How should this information be obtained?15.5 Ans..The main issue is how to measure or otherwise evaluate the resource requirements (CPU, memory, network bandwidth, disk bandwidth) of the components that handle multimedia streams without a lot of manual testing.A test framework is required that will evaluate the resource utilization of a running component. But there isalso a need for resource requirement models of the components – so that the requirements can be extrapolated to different application contexts and stream characteristics and different hardware environments (hardware performance parameters).15.6How does the Tiger system cope with a large number of clients all requesting the same movie atrandom times?15.6 Ans..If they arrive within a few seconds of each other, then they can be placed sufficiently close together in the schedule to take advantage of caching in the cubs, so a single disk access for a block can service several clients.If they are more widely spaced, then they are placed independently (in an empty slot near the disk holding he first block of the movie at the time each request is received). There will be no conflict for resources because different blocks of the movie are stored on different disks and cubs.15.7The Tiger schedule is potentially a large data structure that changes frequently, but each cub needsan up-to-date representation of the portions it is currently handling. Suggest a mechanism for thedistribution of the schedule to the cubs.15.7 Ans..In the first implementation of Tiger the controller computer was responsible for maintaining an up-to-date version of the schedule and replicating it to all of the cubs. This does not scale well – the processing and communication loads at the controller grow linearly with the number of clients – and is likely to limit the scale of the service that Tiger can support. In a later implementation, the cubs were made collectively responsible for maintaining the schedule. Each cub holds a fragment of the schedule – just those slots that it will be playing processing in the near future. When slots have been processed they are updated to show the current viewer state and then they are passed to the next ‘downstream’ cub. Cubs retain some extra fragments for fault-tolerance purposes.When the controller needs to modify the schedule – to delete or suspend an existing entry or to insert a viewer into an empty slot – it sends a request to the cub that is currently responsible for the relevant fragment of the schedule to make the update. The cub then uses the updated schedule fragment to fulfil its responsibilities and passes it to the next downstream cub.15.8When Tiger is operating with a failed disk or cub, secondary data blocks are used in place ofmissing primaries. Secondary blocks are n times smaller than primaries (where n is the declusterfactor), how does the system accommodate this variability in block size?15.8 Ans..Whether they are large primary or smaller secondary blocks, they are always identified by a play sequence number. The cubs simply deliver the blocks to the clients in order via the ATM network. It is the clients’responsibility to assemble them in the correct sequence and then to extract the frames from the incoming sequence of blocks and play the frames according to the play schedule.。

分布式系统试题及答案

分布式系统试题及答案

分布式系统复习题库及答案1、计算机系统的硬件异构性、软件异构性主要表现在哪几方面?参考答案:计算机系统的硬件异构性主要有三个方面的表现,即:①计算机的指令系统不同。

这意味着一种机器上的程序模块不能在另一种不兼容的机器上执行,很显然,一种机器上的可执行代码程序不能在另一种不兼容的机器上执行。

②数据表示方法不同。

例如不同类型的计算机虽然都是按字节编址的,但是高字节和低字节的规定可能恰好相反。

浮点数的表示方法也常常不一样。

③机器的配置不同。

尽管机器的类型可能相同,其硬件配置也可以互不兼容。

计算机系统的软件异构性包括操作系统异构性和程序设计语言异构性。

操作系统异构性的三个主要表现方面为:①操作系统所提供的功能可能大不相同。

例如,不同的操作系统至少提供了不同的命令集。

②操作系统所提供的系统调用在语法、语义和功能方面也不相同。

③文件系统不同。

程序设计语言的异构性表现在不同的程序设计语言用不同方法在文件中存储数据。

2、由于分布计算系统包含多个(可能是不同种类的)分散的、自治的处理资源,要想把它们组织成一个整体,最有效地完成一个共同的任务,做到这一点比起传统的集中式的单机系统要困难得多,需要解决很多新问题。

这些问题主要表现在哪些方面?参考答案:①资源的多重性带来的问题。

由于处理资源的多重性,分布计算系统可能产生的差错类型和次数都比集中式单机系统多。

最明显的一个例子是部分失效问题:系统中某一个处理资源出现故障而其他计算机尚不知道,但单机系统任何一部分出现故障时将停止整个计算。

另一个例子是多副本信息一致性问题。

可见,资源多重性使得差错处理和恢复问题变得很复杂。

资源多重性还给系统资源管理带来新的困难。

②资源的分散性带来的问题。

在分布计算系统中,系统资源在地理上是分散的。

由于进程之间的通信采用的是报文传递的方式进行的,通信将产生不可预测的、有时是巨大的延迟,特别是在远程网络所组成的分布计算系统中更是这样。

例如使用卫星通信会产生270毫秒的延迟。

分布式计算原理及应用第四章部分答案

分布式计算原理及应用第四章部分答案

Chapter 42.Process 1 sends three messages successively to process 2.What is the possible order in which the messages may arrive at process 2 ifA.connectionless socket is used to send each message?B.Connection-oriented socket is used to send each message?Answer:A.process 2接收信息的顺序是不确定的,因为传输用的是无连接的套接字。

三个信息的顺序可能有以下六种:1,2,3;1,3,2;2,1,3;2,3,1;3,1,2;3,2,1。

B.process 2接收信息的顺序是确定的,因为传输用的是面向连接的套接字。

三个信息的接收顺序为:1,2,3。

4.Write a Java code fragment that may appear in a main method to open a datagram socket for receiving a datagram of up to 100 bytes,timing out in 5 seconds.If a timeout does occur,a message"timed out on receive"should be displayed on screen.Answer:import .DatagramPacket;import .DatagramSocket;import .SocketTimeoutException;public class Example1Receiver {public static void main(String[] args){if(args.length!=1){System.out.println("This program requires a command line argument.");}else{int port = Integer.parseInt(args[0]);DatagramSocket mySocket = null;final int MAX_LEN = 100;try{mySocket = new DatagramSocket(port); //获取端口号mySocket.setSoTimeout(5000); //设置超时时间byte[] buffer = new byte[MAX_LEN]; //数据缓冲区有100个字节DatagramPacket datagram =new DatagramPacket(buffer,MAX_LEN);mySocket.receive(datagram); //接收数据String message = new String(buffer);System.out.println(message);mySocket.close();}catch(SocketTimeoutException e){//socket尚未关闭,且处于连接状态超过5秒if(!mySocket.isClosed()&&mySocket.isConnected())System.out.println("读取数据超时!");//服务器等待连接超过5秒System.out.println("连接超时");}catch (Exception ex){ex.printStackTrace();}}}}6.This exercise guides you through the experiment with connectionless datagram socket via code sample Example2.a.Draw a UML class diagram to illustrate the relationship between the classes DatagramSocket,MyDatagramSocket,Example2SenderReceiver,andExample2ReceiverSender.Y ou need not supply the attributes and methods of the DatagramSocket class.pile the java files.Then start Example2ReceiverSender,followed by Example2SenderReceiver.An example of the commands for running the programs is:java Example2ReceiverSender localhost 20000 10000 msg1java Example2SenderReceiver localhost 10000 20000 msg2Describe the outcome.Why is the order of the execution of the two processes important?c.Modify the code so that the senderReceiver process sends then receives repeatedly,suspending itself for 3 seconds between each iteration.Recompile and repeat the run.Do the same with the pile and run the programs for a few minutes before terminating the programs(by entering the keystroke sequence "control-c").Describe and explain the outcome.Answer:A.MyDatagramSocketExample2ReceiverSender Example2SenderReceiver> <DatagramSocketB.Example2ReceiverSender首先接收到msg2,然后Example2SenderReceiver再接收到msg1,他们之间运行的先后顺序十分重要,因为在该例程中,使用的是无连接的传输,发送数据的一方并无法保证数据一定被接收方接收到,只有先运行receiver使其进入阻塞状态后,再运行sender,才能让信息传输顺利进行。

分布式数据库系统知识点及习题

分布式数据库系统知识点及习题

第9章分布式数据库系统9.1 基本内容分析9.1.1 本章重要概念(1)分布计算的三种形式:处理分布,数据分布,功能分布。

(2)C/S系统,工作模式,技术特征,体系结构,两层、三层、多层C/S结构。

(3)DDBS的定义、特点、优点、缺点和分类;分布式数据存储的两种形式(分片和分配)。

(4)DDB的体系结构:六层模式,分布透明性的三个层次,DDBS的组成,DDBMS的功能和组成。

(5)分布式查询处理的查询代价,基于半联接的优化策略,基于联接的优化策略。

(6)分布式数据库的并发控制和恢复中出现的问题,以及处理机制。

9.1.2 本章的重点篇幅(1)两层、三层、多层C/S结构。

(教材P365-367)(2)分布式数据存储:分片和分配。

(教材P375-377)(3)DDB的体系结构。

(教材P378的图9.10,P381的图9.12)(4)基于半联接的执行示意图。

(教材P389的图9.17)9.2 教材中习题9的解答9.1 名词解释·集中计算:单点数据和单点处理的方式称为集中计算。

·分布计算:随着计算机网络技术的发展,突破集中计算框架,DBMS的运行环境逐渐从单机扩展到网络,对数据的处理从集中式走向分布式、从封闭式走向开放式。

这种计算环境称为分布计算。

·处理分布:指系统中处理是分布的,数据是集中的这种情况。

·数据分布:指系统中数据是分布的,但逻辑上是一个整体这种情况。

·功能分布:将计算机功能分布在不同计算机上执行,譬如把DBMS功能放在服务器上执行,把应用处理功能放在客户机上执行。

·服务器位置透明性:指C/S系统向客户提供服务器位置透明性服务,用户不必知道服务器的位置,就可以请求服务器的服务。

·集中式DBS:所有工作都由一台计算机完成,这种DBS称为集中式DBS。

·DDBS:是物理上分散逻辑上集中的DBS,每一场地既能完成局部应用又能完成全局应用,这种系统称为DDBS。

分布式系统原理与范型

分布式系统原理与范型

分布式系统原理与范型1.并行计算:分布式系统中的计算任务可以在多个节点上并行执行,提高了计算速度和效率。

2.通信机制:分布式系统中的节点通过网络进行通信,可以使用消息传递或远程过程调用等通信机制。

3.数据一致性:分布式系统中对数据的读写操作需要保持一致性,避免数据的冲突和重复。

4.容错机制:分布式系统中的节点可能存在故障或意外断开连接的情况,需要通过容错机制来保证系统的可靠性。

5.负载均衡:分布式系统中的节点可能具有不同的计算和存储能力,需要通过负载均衡机制来平衡任务的分配。

6.安全性和隐私保护:分布式系统中的节点之间的通信需要进行安全性和隐私保护,防止数据的泄露和攻击。

1. 客户端-服务器模型:客户端向服务器发送请求并获取响应,服务器负责处理请求并返回结果。

这种模型适用于各种应用场景,如Web服务器和数据库管理系统。

2.对等网络模型:各个节点之间没有明确的客户端和服务器角色,彼此之间平等地进行通信和协调。

这种模型适用于文件共享、对等计算和点对点通信等应用场景。

3.消息传递模型:节点之间通过消息传递进行通信,消息被发送到消息队列中,由接收者主动从队列中获取并处理。

这种模型适用于异步通信和松耦合的应用场景。

4.流计算模型:数据通过流传递,节点对数据进行实时处理,结果可以通过流再次传递给其他节点。

这种模型适用于实时数据分析和流媒体处理等应用场景。

5.RPC模型:远程过程调用(RPC)模型是一种使得分布式系统中的节点能够像调用本地过程一样调用远程过程的方法。

这种模型适用于分布式计算和服务调用等应用场景。

总之,分布式系统的原理和范型为我们理解和设计分布式系统提供了重要的思路和方法。

在实际应用中,需要根据具体的场景和需求选择合适的原理和范型,并结合相关的技术和工具进行实现和优化。

分布式数据库系统部分课后题答案

分布式数据库系统部分课后题答案

分布式数据库系统部分课后习题答案
ASG9 ENO E2 PNO P2 RESP Analyst DUR 6
ASG10 ENO E2 PNO P1 RESP Analyst DUR 24
5.3 EMP TITLE PAY 的连接图如下: PAY1 TITLE SAL PAY2 TITLE SAL
EMP1
ENO ENAME TITLE
EMP2
ENO ENAME TITLE
EMP3
ENO ENAME TITLE
EMP4
ENO ENAME TITLE
这个图显然不是一个简单图。 我们可以通过将 PAY 关系根据 EMP 关系的分片进行诱导分片,即 PAY1 = PAY EMP1; PAY2 = PAY EMP2; PAY3 = PAY EMP3; PAY4 = PAY EMP4; 或 将 EMP 关系根据 PAY 关系的分片进行诱导分片(推荐此方案) ,即 EMP1 = EMP PAY1; EMP2 = EMP PAY2;
PROJ PNO Pห้องสมุดไป่ตู้ P2 P3 P4
Figure 5.3. Modified Example Database 5.1 p1: TITLE < “Programmer” and p2: TITLE > “Programmer”. (a) 根据{ p1, p2 }对关系 EMP 进行水平分片:EMP1 = σ TITLE < ”Programmer” (EMP); EMP2 =σ TITLE > ”Programmer” (EMP);分片结果为: EMP1 ENO E1 E3 E6 E7 ENAME J. Doe A. Lee L. Chu R. Davis TITLE Elect. Eng Mech. Eng. Elect. Eng. Mech. Eng 图 5.1.1. (b) 分片结果(EMP1, EMP2)不满足分片的正确性规则,项“E4, J. Miller, Programmer”不在任 何一个分片中,其原因是:谓词{ p1, p2 }对关系 EMP 的划分并不完全。 (c) 可以这样修改 p1 和 p2 使其对 EMP 的划分符合分片的正确性规则: p1: TITLE < “Programmer” and p2: TITLE ≥ “Programmer” 根据新的谓词得到如图 5.1.2 的分片结果。 从图 5.1.2 可以看出关系 EMP 中的每一项都属于且仅属于 EMP1 或 EMP2 中的一个, 因此这个分片满足完整性(Completeness)和互斥性(Disjointness) ;又关系 EMP = EMP1 ∪ -1EMP2 ENO E2 E5 E8 ENAME M. Smith B. Casey J. Jones TITLE Syst. Anal. Syst. Anal. Syst. Anal.
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

第一章绪论1、中间件在分布式系统中扮演什么角色?答:中间件主要是为了增强分布式系统的透明性(这正是网络操作系统所缺乏的),换言之,中间件的目标是分布式系统的单系统视图。

2、解释(分布)透明性的含义,并且给出各种类型透明性的例子。

答:分布透明性是一种现象,即一个系统的分布情况对于用户和应用来说是隐藏的。

包括:访问透明、位置透明、移植透明、重定位透明、复制透明、并发透明、故障透明和持久性透明。

3、在分布式系统中,为什么有时难以隐藏故障的发生以及故障恢复过程?答:通常,要探测一个服务器是停止服务还是该服务器的反应变慢这些情况是不可能的。

因此,一个系统可能在服务响应变慢的时候报告该服务已经停止了。

4、为什么有时候要求最大程度地实现透明性并不好?答:最大程度地实现透明性可能导致相当大的性能损失,从而导致用户无法接受。

5、什么是开放的分布式系统?开放性带来哪些好处?答:开放的分布式系统根据明确定义的规则来提供服务。

开放系统能够很容易地与其它系统协作,同时也允许应用移植到同一个系统的不同实现中。

6、请对可扩展系统的含义做出准确描述答:一个系统的可扩展包含下面几个方面:组件的数量、几何尺寸、管理域的数量与尺寸,前提是这个系统可以在上面几个方面进行增加而不会导致不可接受的性能损失。

7、可以通过应用多种技术来取得可扩展性。

请说出这些技术。

答:可扩展性可以通过分布式、复制和缓存来获得。

8、多处理器系统与多计算机系统有什么不同?答:在多处理器系统中,多个CPU访问共享的主存储器。

在多计算机系统中没有共享存储器,CPU之间只能通过消息传递来进行通信。

9、在多计算机系统中的256个CPU组成了一个16 X 16的网格方阵。

在最坏的情况下,消息的延迟时间有多长(以跳(hop)的形式给出,跳是结点之间的逻辑距离)?答:假设路由是最优的,最长的路由是从网格方阵的一个角落到对角的角落。

那么这个路由的长度是30跳。

如果一行或一列中的处理器彼此相连,则路由长度为15跳。

10、现在考虑包含256个CPU的超立方体,最坏情况下消息的延迟有多长?答:在具有256个CPUs的超立方体中,每个结点可以用一个二进制地址,范围从00000000~1111,1111。

一个hop表示地址改变了一位。

因此从0000,0000~0000,0001表示一个hop,而从0000,0001~0000,0011也是表示一个hop。

所以最长的路由有8个hop。

11、分布式操作系统与网络操作系统有什么不同?答:分布式操作系统管理多处理器和同种类的多计算机。

网络操作系统连接不同的、独立的计算机,这些计算机有自己的操作系统以便用户可以容易地使用每台计算机所提供的服务。

12、请解释如何使用微内核将操作系统组织成客户-服务器的方式。

答:微内核可以把客户端应用从操作系统服务中分离出来,方法是通过强迫每个请求都通过内核来传递。

因此,操作系统服务能够通过用户级的服务器来实现,这些用户级的服务器是作为普通的进程来运行的。

如果微内核有网络功能,这些服务器也能作为远端机器。

13、请解释基于分页的分布式共享存储器系统主要有哪些操作。

答:基于分页的DSM利用了操作系统的虚拟存储器的功能。

当一个应用程序对内存寻址时,如果该内存位置没有映射到当前物理存储器的存储器空间的时候,页错误就会发生,并将控制权转交给操作系统。

操作系统定位到适当的页,通过网络传递它的内容,并映射到物理存储器中。

从而,应用可以继续运行。

14、为什么要开发分布式共享存储器系统?你认为是什么问题给这种系统的高效率实现造成了困难?答:主要的原因是,写基于消息传递的并行和分布式程序来进行通信要比使用共享存储器难得多。

不管进行什么操作,网络中的页面传输都会发生,这导致了DSM系统效率的下降。

如果页面被不同的处理器共享,在虚拟存储系统中很容易进入和“陷入”类似的状态。

最后,DSM系统比消息传递的解决方案要慢,而且由于需要跟踪页面而变得更慢。

15、请解释什么是分布式共享存储器系统中的伪共享。

你有没有针对这个问题的解决方案?答:当数据属于两个不同且独立的处理器(可能在不同的机器上)时会发生伪共享,这时数据被映射到相同的逻辑页上。

效果是这个页面会在两个处理器之间发生交换,从而导致不明显且不必要的依赖。

解决方案是让页面更小并禁止独立的处理器共享一个页面。

16、由于存在错误,某个实验性的文件服务器有3 / 4的时间能够正常工作,而另外1 / 4的时间无法工作。

如果要确保服务至少在99%的时间可用,需要将该文件服务器复制多少次?答:令k为服务器的数量,则有(1/4)k<0.01。

即在最坏的情况下,这时所有的服务器都已关闭,发生这种情况的概率是1/100。

因此k=4。

17、什么是三层客户-服务器体系结构?答:三层客户——服务器体系结构包括三个逻辑层,每一层在理论上来说都在一台单独的机器上实现。

最高层包括了客户的用户界面,中间层包括实际的应用程序,最底层包含了被使用的数据。

18、纵向分布与横向分布有什么不同?答:纵向分布指的是多台机器组成的多层架构中各个层的分布。

从理论上说,每一层都在一台不同的机器上实现。

横向分布则处理多台机器上的一个层的分布,例如一个数据库的分布。

19、考虑一个进程链,该进程链由进程P1,P2,…,Pn构成,实现了一个多层客户-服务器体系结构。

进程Pi 是进程Pi+1的客户,Pi只有得到Pi+1的应答之后才能向Pi-1发出应答。

如果考虑到进程P1的请求-应答性能,这种组织结构主要存在什么问题?答:如果n很大的话性能会很差。

从理论上来说,两个邻接层之间的通信应该在两台不同的机器之间发生。

因此,P1和P2之间的性能由n-2次其它层之间的请求——应答过程决定。

另一个问题是如果链中的一台机器性能很差甚至临时不可达,这会立刻使最高层的性能降低。

第二章通信1、在许多分层协议中,每一层都有自己的报头。

如果每个消息前部都只有单个报头,其中包含了所有控制信息,无疑会比使用单独的多个报头具有更高的效率。

为什么不这么做?答:协议的每一层都必须和其它层相独立。

从第k+1层传送至第k层的数据同时包含了报头和数据,但是第k层协议不能对它们进行辨别。

如果使用单个大的报头来包含所有信息的话将会破坏透明性,使得一个协议层的变动会影响到其它层,这显然不是我们所希望的。

2、为什么传输层通信服务常常不适于构建分布式应用程序?答:它们通常不提供分布透明性,这意味着应用程序开发人员需要注意通信的实现,从而导致解决方案的可扩展性很差。

分布式应用程序,例如基于套接字构建的分布式应用程序,将很难移植或者和其它应用程序交互。

3、一种可靠的多播服务允许发送者向一组接收者可靠地传递消息。

这种服务是属于中间件层还是更低层的一部分?答:从理论上来说,一种可靠的多播服务可以很容易的成为传输层,甚至是网络层的一部分。

例如,不可靠的IP多播服务是在网络层实现的。

但是,由于这些服务目前尚无法应用,它们通常使用传输层的服务来实现,传输层的服务将它们放在中间件中。

如果把可扩展性加以考虑的话,只有充分考虑应用程序的需求时可靠性才能得到保证。

用更高、更特殊的网络层来实现这些服务存在一个很大的争议。

4、考虑一个带有两个整型参数的过程incr。

该过程将两个参数的值分别增加1.现在假定调用它时使用的两个参数是同一个变量,比如incr(i, i)。

如果i的初始值是0,在执行引用调用之后i将变为什么值?如果使用复制——还原调用呢?答:如果执行引用调用,指向i的指针被传入incr。

i将会被增加两次,因此最终的结果是2。

而使用复制——还原调用时,i会被两次传值,每次的初始值均为0。

两次都会增加1,因此结果均为1。

最后都复制到i,第二次的复制会覆盖第一次的,因此最终i的值为1,而不是2。

5、C语言中有一种称为联合(union)的构造,其中的记录(在C语言中称作结构)的字段可以用来保存几种可能值中的一个。

在运行时,没有可靠的办法来分辨其中保存的是那一个值。

C的这种特性是否与远程过程调用有某些相似之处?请说明理由。

答:如果运行时系统不能分辨一个字段的值类型,它就不能对该字段进行正确的封送处理。

除非有一个标签字段用来清楚的表明一个字段的值类型,联合不能在远程过程调用中使用。

这个标签字段不能被用户所控制。

6、处理RPC系统中参数转换的一种方法是,每台机器以自己系统使用的表示方式来发送参数,由另一方在必要的情况下进行转换。

可以通过首字节中的代码来表示发送消息机器所用的系统。

然而,由于要在首个字中找到开头的字节这本身也是一个问题,这种方法能行得通吗?答:首先,当一台机器发送字节0时,消息肯定已经送到。

因此目标机器可以访问字节0,而代码就在消息里面。

这种方法不考虑字节是高位优先还是低位优先的字节。

另一个方法是将代码放在第一个单词的所有字节中。

因此不管检查的是哪一个字节,代码都能被找到。

7、假定客户通过异步RPC对服务器进行调用,随后等待服务器使用另一异步RPC返回结果。

这种方法与客户端执行常规的RPC有没有什么不同?如果使用的是同步RPC而不是异步RPC,情况又如何呢?答:二者并不相同。

异步RPC向调用者返回一个通知,这意味着客户第一次调用之后,有一个额外的消息会被发送。

类似地,服务端接收到它的响应消息已经发送到客户端的通知。

如果保证通信可靠的话,两次异步RPC调用是一样的。

8、在DCE中,服务器在守护程序中注册自身。

如果换一种方法,也可以总是为它分配一个固定的端点,然后再指向服务器地址空间中对象的引用中就可以使用该端点。

这种方法的缺陷在哪里?答:这种方法的主要缺陷是向服务器分配对象变得很难。

另外,许多端点而不止一个需要被修复。

如果机器中很多都是服务器,分配固定端点不是一个好办法。

9、给出一种用来让客户端绑定到暂时远程对象的对象应用的实现示例。

答:使用Java实现的类如下:public class Object_reference {InetAddress server3address; // network address of object’s serverint server3endpoint; // endpoint to which server is listeningint object3identifier; // identifier for this objectURL client3code; // (remote) file containing client-side stubbyte[] init3data; // possible additional initialization data}Object_reference类至少需要包含对象所属的服务器的传输层地址。

相关文档
最新文档