1 / 47

Übung zur Vorlesung TK3 Organisatorisches

Übung zur Vorlesung TK3 Organisatorisches. FG Telekooperation Prof. Dr. Max Mühlhäuser Daniel Schreiber. Inhalt. Programming a chatclient Making it context-aware Building an abstract user interface (AUI) for it interface is automatically adapted for different devices. Timeline.

Download Presentation

Übung zur Vorlesung TK3 Organisatorisches

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Übung zur Vorlesung TK3Organisatorisches FG Telekooperation Prof. Dr. Max Mühlhäuser Daniel Schreiber

  2. Inhalt • Programming a chatclient • Making it context-aware • Building an abstract user interface (AUI) for it interface is automatically adapted for different devices

  3. Timeline 07. April – Vorstellung Übung 1 14. April – Q&A Übung 1 21. April 28. April – Abgabe Übung 1 / Vorstellung Übung 2 05. Mai – Q&A Übung 2 12. Mai 19. Mai – Abgabe Übung 2 / Vorstellung Übung 3 26. Mai – Q&A Übung 3, Zwischenklausur 02. Juni 09. Juni - Abgabe Übung 3 / Vorstellung Übung 4 16. Juni - Q&A Übung 4 23. Juni 30. Juni – Q&A Klausur, Abgabe Übung 4 09. Juli – Klausur

  4. Organisation • Homepage: http://www.tk.informatik.tu-darmstadt.de/index.php?id=tk3uebung0 Username: tk3student Password: mundo2008 • Forum für eure Diskussionen: http://www.fachschaft.informatik.tu-darmstadt.de/forum/index.php?f=380 • Fragestunden nach Bedarf (eMail an schreiber@tk.informatik.tu-darmstadt.de)werden auf der Homepage bekannt gegeben

  5. Organisation • Anmeldung über das WebReg System • Programmierung in zweier oder dreier Gruppen • Sendet eine eMail mit den Namen, Matrikelnummern und Studiengängen (Diplom, Master) (!!!!) aller Gruppenmitglieder an schreiber@tk.informatik.tu-darmstadt.de

  6. Organisation • Tutor: Henning Pohl • Email: HenningPohl@gmail.com

  7. What You Need to Do In each assignment, return the following: • Java source code including Javadoc (for every public method) • Presentation of your solution • Text file with names and matrikel numbers of all people in the group • Send as a zip-file via email to your tutor

  8. Übung zur Vorlesung TK3Übung 1: Publish Subscribe und MundoCore FG Telekooperation Prof. Dr. Max Mühlhäuser Daniel Schreiber

  9. Introduction: Meeting Scenario • Personal Area Networking • Tablet PCs are availablefor users

  10. Meeting Scenario • Personal Area Networking • User carries personal device • Tablet PC becomes personalized by association

  11. Meeting Scenario • Personal Area Networking • User carries personal device • Tablet PC becomes personalized by association • Spontaneous Networking • User accesses smart items or devices in the room

  12. Meeting Scenario • Personal Area Networking • User carries personal device • Tablet PC becomes personalized by association • Spontaneous Networking • User accesses smart items or devices in the room • Users exchange personal information (business card)without using infrastructure

  13. Meeting Scenario • Personal Area Networking • User carries personal device • Tablet PC becomes personalized by association • Spontaneous Networking • User accesses smart items or devices in the room • Users exchange personal information (business card)without using infrastructure • Infrastructure-based Networking • Internet access

  14. Mundo Reference Architecture • ME = Minimal Entity • US = User aSsociable • IT = smart Item • MINE = My Individual Network Environment • WE = Wireless group Environment • THEY = Telecooperative Hierarchical ovErlaY network THEY IT ME WE ME US MINE US ME US

  15. Middleware • Middleware is a layer between the operating system and applications • Why Middleware? • Pull communication related code out of applications • Abstract from hardware, platforms, languages and networks

  16. Communication in distributed systems

  17. Towards loosely coupled systems • Space decoupling • parties don‘t know each other • 1-to-many comm. Possible  Interaction model: Callback • Time decoupling: • parties not (necessarily)active at same time  Interaction model: Message Queues • Flow decoupling • event production & consumption main control flow (?)  Interaction model: Publish / Subscribe • 1, 2, 3: coordination & synchronization drastically reduced

  18. Concepts: Publish/Subscribe subscribe Topic • Here: Topic-based Publish/Subscribe • Interested parties can subscribe to a topic (channel) • Applications post messages explicitly to specific topics • Each message may have multiple receivers • Full decoupling in space, time, and flow publish notify Subscriber Publisher unsubscribe Publisher Publisher Subscriber

  19. Classification of Pub/Sub Mechanisms • Subscription Mechanism • Channel-based (=Topic-based) Subscription • Content-based Subscription • Subject-based Subscription (limited form of Content-based sub.)

  20. Channel-based Subscription • Channel-based Subscription =Topic-based • Interested parties can subscribe to a channel • Application posts messages explicitly to a specific channel

  21. Content-based Subscription • Define filters on the whole content of notification • More freedom in encoding data upon which filters can be applied • More information for event service to set up routing information

  22. Subject-based Subscription • Limited form of Content-based Subscription • Notifications contain a well-known attribute – the subject – that determines the subscription • Subject (= header of notification) is visible to event service, remaining information is opaque • Subscription is • (Limited form of) Regular Expressions over Strings (TIB, JEDI) • (Limited form of) SQL92 Queries (JMS) • Filtering is done in the Router Network!

  23. Data Model • Notification • ni is the attribute name • ti is the attribute type, and • vi is the value • All data models can be mapped to this representation • Hierarchical messages in which attributes may be nested are flattened by using a dotted naming scheme, e.g., consists of a nonempty set of attributes An attribute is a triple                      , where (level,Integer,3)                                                  can be rewritten as

  24. Attribute Filters • An attribute filter is a simple filter that imposes a constraint on the value and type of a single attribute. It is defined as a tuplewhere • n is the name of the attribute to test • t is the expected value type, • op is the test operator, and • c is a constant that serve as parameter for the operator • An attribute a matches an attribute filter A, iff A=(level,Integer,>,4) (na, ta, va)EA  (na=level)  (ta=Integer)  (va>4)

  25. Filters • A filter is a stateless boolean predicatethat is applied to a notification n • If evaluates to        , we say that notification nmatches filter F(n) • Filters that only consist of a single attribute filter are called simple filters, and filters containing multiple attribute filters are called compound filters • A notification nmatches a filter F, iff it satisfies all attribute filters of F:

  26. Matching: Example • NotificationFilter • (event,String,“alarm“)matches (event,String,=,“alarm“) • (date,Time,02:40:03) • (event,String,“alarm“) not matches(event,String,=,“alarm“) • (date,Time,02:40:03) (level,Integer,>,3)

  27. Übung zur Vorlesung TK3Übung 1: Aufgaben FG Telekooperation Prof. Dr. Max Mühlhäuser Daniel Schreiber

  28. Aufgabe 1 • Command line chatclient using MundoCore and Publish Subscribe • Every client should have an associated identifier (here Max and Erwin) • Every message should be assigned a globally unique index • You do not need to consider concurrency (two messages may be sent simultaneously) or bootstrapping (a new node does not know the current index in the network)

  29. Lösungsidee Client 1 Client 2 Group-Chat GemeinsamerKanal Client 3 ...

  30. Installation • You need • Java1.5 or higher • Apache Ant • Zip from Homepage (www.tk.informatik.tu-darmstadt.de/index.php?id=tk3uebung0) • Additional MundoCore Information • http://www.tk.informatik.tu-darmstadt.de/index.php?id=mundocore • Wiki: leda.tk.informatik.tu-darmstadt.de/cgi-bin/twiki/view/Mundo

  31. Programmgerüst class ChatTest { publicstaticvoid main(String args[]) { Mundo.init(); ChatService cs = new ChatService(); Mundo.registerService(cs); cs.run(); Mundo.shutdown(); } } class ChatService extends Service { ChatService() { } publicvoid init() { ... // called upon initialization } publicvoid run() { ... // selfdefined method for starting and interpreting commandline interaction } publicvoid received(Message msg, MessageContext ctx) { ... // defines how to handle incoming messages } }

  32. Objekte • Session • Verwaltet Publisher, Subscriber, exportierte undimportierte Objekte • Entkopplung von Empfang und Verarbeitung vonNachrichten (Active Object Pattern) • Nur ein Message Handler (aller Subscriber) zurgleichen Zeit aktiv Service Session Publisher Subscriber

  33. Senden von Nachrichten (1) • Erstellen eines Publisher-Objekts: publicvoid init() { … publisher = getSession().publish("lan", "chat"); … } • Jeder Service hat automatisch eine Session • Eine Session sorgt dafür, dass Nachrichten in der richtigen Reihenfolge ankommen • Parameter für publish: zone, kanalname • Zone: "rt" für Nachrichten innerhalb des lokalen Prozesses (runtime) "lan" für ganzes Overlay-Netz

  34. Empfangen von Nachrichten (1) • Erstellen eines Subscriber-Objekts: publicvoid init() { … subscriber = getSession().subscribe("lan", "chat"); subscriber.setReceiver(this); subscriber.enable(); … } • Services können Nachrichten, an denen sie interessiert sind, abonnieren • subscribe hat die gleichen Parameter wie publish

  35. Senden von Nachrichten (2) • Senden einer Nachricht: TypedMap map = new TypedMap(); map.putString("message", message); publisher.send(new Message(map)); • TypedMap: Map typisierter Objekte, die durch einen key identifiziert werden

  36. Empfangen von Nachrichten (2) • Zu jeden Subscriber gehört ein Receiver-Objekt • die received Methode des Receivers wird aufgerufen, sobald eine Nachricht empfangen wurde • Receiver-Callback: publicvoid received(Message msg, MessageContext ctx) { System.out.println(msg.getMap().getString("message")); } • msg entspricht der Map, die von publisher.send abgeschickt wurde • Feature von MundoCore: Für Nachrichten, die der Client selbst geschickt hat wird received nicht automatisch aufgerufen (auch wenn der Client diesen Kanal subskribiert hat)

  37. node.conf.xml (1) • Muss sich im Ordner befinden aus dem das Programm gestartet wird • Detailierte Dokumentation im Tutorial • Ein Client verbindet sich automatisch mit allen anderen die den gleichen primary port haben!! • Benötigt z.B. um Netzwerkkonfigurationen (wo nach weiteren Mundo Clients gesucht wird) zu ändern • Node Discovery über UDP Broadcast • Broadcastadresse und Netzmaske können angepasst werden (häufig bei VPN notwendig) • Rechner können einzeln angegeben werden

  38. node.conf.xml (2) <NodeConfig xsi:type="map"> <IPTransportService xsi:type="map"> <discovery xsi:type="map" activeClass="org.mundo.net.IPTransportService$OptDiscovery"> <primaryPort xsi:type="xsd:int">4242</primaryPort> <answerBroadcasts xsi:type="xsd:boolean">true</answerBroadcasts> <broadcasts xsi:type="xsd:array"> <object xsi:type="map" activeClass="org.mundo.net.IPTransportService$OptBroadcast"> <broadcast>130.83.163.255</broadcast> <netmask>255.255.255.0</netmask> </object> </broadcasts> <hosts xsi:type="xsd:array"> <object xsi:type="map" activeClass="org.mundo.net.IPTransportService$OptHost"> <name>pcmelanie.tk.informatik.tu-darmstadt.de</name> </object> </hosts> </discovery> </IPTransportService> </NodeConfig>

  39. Aufgabe 2 • Make yourself familiar with inspect tool (part of the MundoCore distribution) • Log some messages exchanged between chatclients • Add the main:passive partof a message to your assignment

  40. inspect - usage • Located in inspect folder • At first usage you have to run ant • You can start inspect from this folder with run.bat • Open Connections of the inspect node • Rightclick on the chatnode, choose “Inspect node” • Open Services of the new node • Select the ChatService • Rightclick on the chat channel, choose “Open channel” • All messages send over this channel will be logged in this window

  41. inspect • The first displayed node is inspect itself • Connections contains the connections the node has • Services lists all running services on the node • ERS Imports lists all services the node is subscribed to • ERS Exports lists all channels the node can publish to • Config shows the currently valid configuration of the node (node.conf.xml extended by defaultvalues) • Log contains the log messages on the finest level

  42. Aufgabe 1.3 • Integrate logging in your application • Only messages of Loglevel SEVERE are printed on the console, to change this use following commandline parameter: -Dmc.logLevel=<loglevel> • To filter logmessages use -Dmc.logCategoryFilter=<name or prefix of the logger> • To log the messages in a logfile -Dmc.logFile=<logfile> • Example: java -Dmc.logCategoryFilter=myLog -Dmc.logFile=log.txt -Dmc.logLevel=FINE ChatTest

  43. Aufgabe 1.4 • Connect the given AWT interface with your service • For that purpose use the frame given by UIControler.java (the parts where you need to modify are marked with “//TODO”) • Because there is no user handling yet, all communication is realized as groupchat using the user “Default” (already contained in UIControler.java)

  44. Given files • ContactList.java and ChatWindow.java represent the AWT interface • UIControler specifies a frame for the interaction between service and interface. This file has to be modified in the exercise • Contact.java specifies the status constants and represents a contact consisting of a name and a status value(can also be modified)

  45. Methods you might need… For example: window.addText(“erwin”,”red”, “hello”) For example: contactList.openChat(“max”) If a chatwindow with Max is already opened, it gets the focus This method returns the corresponding ChatWindow object Keys for updateContactView contain names of allcontacts (here “max” and “nicky”)

  46. Methods invoked by the UI Most methods are not needed now, the only method you need to implement is sendMessage(…) add own methods and modify the constructor

  47. Starting the UIControler class ChatTest { publicstaticvoid main(String args[]) { Mundo.init(); String nickname = args.length>0? args[0] : “Max"; ChatService cs = new ChatService(nickname); Mundo.registerService(cs); UIControler controler = new UIControler(nickname,…); } }

More Related