Distributed ComputingCMSC 433Distributed Computing• Computations running across multiplemachines• Computations that shouldn’t fail justbecause one machine failsCommunications• Generally, TCP and UDP• TCP: stream-based two waycommunication• UDP: one way packet communication– no built in acknowledgement• Multicast UDP: broadcast packetcommunication to local networkIP terminology• IP address– hostname• Port– port space for UDP and TCP are separate– each service typically has a standard portfor initiating communicationTCP Server Sockets• bound to a particular port• accept() waits for a connection requeston that port– returns a standard Socket for furthercommunication– ServerSocker can be immediately reusedInetAddress• InetA d dress.getByName(h)– static factory for InetAddress• InetA d dress.getLoc a lHost( )– gets local host name (does DNS)• InetAddress.getByName(“127.0.0.1”)– gets local loopback address, no DNSSocket• new Socket(InetAddress a, int port)– creates a TCP socket connection to aserver socket at the specified address andport• For each socket, you can callgetInputStream()getOutputStream()Streams• You should all know InputStream,OutputStream, Reader, Writer• DataOutputStream adds writeInt,writeLong, writeDouble, writeUTF• DataInputStream provides matchingread methodsObject Streams• ObjectOutputStream andObjectInputStream allow objects to besent– any serializable object• Any object that implements Serializablecan be serialized– if all of its fields are serializableObject graphs• Writing to an object output streamwrites a graph of objects– writing a map sends all the elements– writing one node of a graph sends allconnected nodes• Reconstructed into an isomorphic graphpotential problems• You write a class that received doesn’thave– error• You write a different version of a classthan the receiver has– maybe OKRMI• Remote method invocation• Provides remote proxies for objects– invoke method on local proxy/stub– method is invoked over the network, usingobject serialization– wait for responseremote code base• RMI provides an extension to objectserialization• allows you to provide a URL from whichyour classes can be downloaded inreceived doesn’t have
View Full Document