1 / 32

Sistem Terdistribusi

Sistem Terdistribusi. ARMIN LAWI S2 TEKNIK INFORMATIKA UNHAS. Outline Materi. Pengantar Pemrograman Jaringan dalam Java Paket java.net, multithreading , Vektor dan Serialisasi Berkas Invokasi dan Modifikasi Obyek Terdistribusi Remote Method Invocation (RMI)

sveta
Download Presentation

Sistem Terdistribusi

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. Sistem Terdistribusi ARMIN LAWI S2 TEKNIK INFORMATIKA UNHAS S2-Teknik Informatika UNHAS

  2. Outline Materi • PengantarPemrogramanJaringandalam Java • Paket java.net, multithreading, VektordanSerialisasiBerkas • InvokasidanModifikasiObyekTerdistribusi • Remote Method Invocation (RMI) • Common Object Request Broker Architecture (CORBA) • Modifikasi Database via Java Method • Servlet, JavaServer Pages (JSP) dan JavaBeans • ServletdanJavaServer Pages (JSP) • JavaBeans dan Enterprise JavaBeans (EJB) • Web Services • eXtended Markup Language (XML) • Simple Object Access Protocol (SOAP) • Web Services Description Language (WSDL) • Universal Description Discovery and Integration (UDDI) S2-Teknik Informatika UNHAS

  3. Referensi Utama • Jan Graba (2007), An Introduction to Network Programming, 2nd Ed., Springer Science. • Jan Graba (2003), An Introduction to Network Programming, Addison-Wesley. • Steve Graham, et. al. (2005), Building Web Services with Java: Making Sense of XML, SOAP, WSDL and UDDI, 2nd Ed., Sams Publishing. S2-Teknik Informatika UNHAS

  4. Pengenalan Java S2-Teknik Informatika UNHAS

  5. Apa itu Java? • Menerapkan compiler dan interpreter program.java program.class javac program.java public class myCetak { public static void main(String args[]) { System.out.println(“Hello World!”); } } -------------------- ------------------------------------- --------------------------- ----------------------------- ------------------------- ------------------- compiler java program bytecode 11010101… interpreter S2-Teknik Informatika UNHAS

  6. Karakteristik Multi-platform program.java program.class public class myCetak { public static void main(String args[]) { System.out.println(“Hello World!”); } } -------------------- ------------------------------------- --------------------------- ----------------------------- ------------------------- ------------------- compiler interpreter interpreter interpreter interpreter JVM Windows Linux Solaris MacOS S2-Teknik Informatika UNHAS

  7. Software yang dibutuhkan • Java Standrd Edition (SE) Development Kit (JDK) Dapat didownload gratis di http://developers.sun.com/downloads/ • JDK yang digunakan pada MK ini adalah versi terbaru saat ini: JDK1.6.0 update 10 • Text Editor: Notepad, Edit, dll Java IDE: Jcreator, Eclipse, NetBeans, dll S2-Teknik Informatika UNHAS

  8. OOP dan Java • Java adalah bahasa pemrograman murni berbasis object-oriented (OO) • OOP: Program bekerja atas interaksi atau komunikasi antar obyek (object interprocess) • OO-program dapat dipandang sebagai sistem tersebar (distributed system) S2-Teknik Informatika UNHAS

  9. Apa itu obyek? • Segala sesuatu dapat dipandang sbg obyek • Karateristik obyek • Memiliki atribut sebagai status (state/variable) • Memiliki tingkah laku (behavior) atau method variabel/ state method/ behavior Object model S2-Teknik Informatika UNHAS

  10. Bagaimana membuat obyek • Obyek dikonstruksi/dirancang dari prototipe atau blueprint yang telah ditetapkan (class) • Contoh: resep  class kue  obyek Kue 1 Resep Bahan: 1 kg gula 2 sdk mentega dan sterusnya. Cara Membuat: Campur semua lalu panaskan dan seterusnya Kue 2 S2-Teknik Informatika UNHAS

  11. Contoh oop dalam java class mhs { private String nama; private String nim; private String ttl; private String agama; public mhs(String nama, String nim, String m, String agama) { this.nama = nama; this.nim = nim; this.ttl = ttl; this.agama = agama; } public String getNama() { return this.nama; } public String getNim() { return nim; } public static void main(String args[]) { mhs m = new mhs(“Armin”, “132133693”, “19”, “Islam”) ; System.out.println(“Nama =“ + m.getNama()); } } variabel/ state konstruktor method/ behavior obyek m S2-Teknik Informatika UNHAS

  12. Ciri-ciri oop • Abstraksi (abstraction) Pengabstrakan atau penyembunyian kerumitan dari suatu proses • Pembungkusan (encapsulation) Abstraksi dilakukan dengan cara pembungkusan (kapsulasi) semua kode dan data kedalam satu entitas tunggal (obyek) • Pewarisan (inheritance) Implementasi khusus dalam OOP yang dapat menurunkan prilaku ke sub-class atau menerima prilaku dari super-class • Kebanyak-rupaan (polymorphism) Kemampuan obyek mengungkap banyak hal melalui suatu cara yang sama. Obyek dapat menjalankan prilaku-prilaku atau metode-metode yang diturunkan dari beberapa superclassnya S2-Teknik Informatika UNHAS

  13. Pemrograman Jaringan S2-Teknik Informatika UNHAS

  14. Paket java.net • Paket utama java.net memuat berbagai kelas yang berguna bagi programmer dalam mengimplementasi pemrograman berbasis jaringan dengan mudah S2-Teknik Informatika UNHAS

  15. InetAddress class • Salah satu kelas java.net yang menangani alamat Internet (Internet address) baik sebagai host name atau IP Address. • Static method getByName dari kelas ini menggunakan DNS untuk mengembalikan alamat internet dari sebuah host name tertentu sebagai obyek InetAddress. • getByName membuang hasil pengecekan exception UnknownHostException jika host name tidak ditemukan  harus ditangani dengan pernyataan catch. S2-Teknik Informatika UNHAS

  16. Contoh-1: IPFinder import java.net.*; import java.io.*; public class IPFinder { public static void main(String[] args) throws IOException { String host; BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); System.out.print("\n\nEnter host name: "); host = input.readLine(); try { InetAddress address = InetAddress.getByName(host); System.out.println("IP address: "+ address); } catch (UnknownHostException e) { System.out.println("Could not find " +host); } } } core package method class exception S2-Teknik Informatika UNHAS

  17. Hasil Eksekusi Contoh-1 S2-Teknik Informatika UNHAS

  18. Contoh-2: MyLocalIPAddress import java.net.*; public class MyLocalIPAddress { public static void main(String[] args) { try { InetAddress address = InetAddress.getLocalHost(); System.out.println(address); } catch (UnknownHostException e) { System.out.println("could not find local address!"); } } method S2-Teknik Informatika UNHAS

  19. Hasil Eksekusi Contoh-2 S2-Teknik Informatika UNHAS

  20. Paket, Kelas dan Method yang Penting Diketahui S2-Teknik Informatika UNHAS

  21. Important Java Packages java.netTCP/IP networking java.io I/O streams & utilities java.rmiRemote Method Invocation java.security Security policies java.lang Threading classes S2-Teknik Informatika UNHAS

  22. Java Sockets Programming • Java menggunakan BSD-style sockets untuk antarmuka dengan layanan TCP/IP (paket java.net) • Java membedakan socket-socket UDP, TCP server & TCP client • Behind-the-scenes classes do the actual work & can be updated or swapped out transparently S2-Teknik Informatika UNHAS

  23. IP Addresses & Hostnames • java.net.InetAddress class • Represents a single IP address • Factory class – no public constructor • Performs transparent DNS lookups or reverse lookups • java.net.UnkownHostException thrown if DNS system can’t find IP address for specific host S2-Teknik Informatika UNHAS

  24. TCP Server Sockets • java.net.ServerSocket class • Binds to a local port to listen for initial connections • Can be bound to a local IP for multi-homed machines • accept() method returns a java.net.Socket, not an integer descriptor S2-Teknik Informatika UNHAS

  25. TCP Client Sockets • java.net.Socket class • Combines socket with socket options (timeout, linger, keep alive, no delay, etc) • Encapsulates a java.io.InputStream and a java.io.OutputStream – can be retrieved for use in a layered I/O system S2-Teknik Informatika UNHAS

  26. UDP Sockets • java.net.DatagramSocket class • Java makes no distinction between client/server for UDP sockets • Connected mode UDP supported in Java 2 • Can be bound to both a local port & a local IP address – multi-homed support • Supports some socket options (timeout, buffer size) S2-Teknik Informatika UNHAS

  27. UDP Datagrams • java.net.DatagramPacket class • Expects a byte array of data • Address optional for connected-mode UDP • This class is final – can’t be extended! • java.net.DatagramSocket instances can only send instances of java.net.DatagramPacket S2-Teknik Informatika UNHAS

  28. Threading • Java doesn’t support the notion of forking processes; how do we support concurrency? • Java was designed to support multi-threading! • In server environments we can spawn new threads to handle each client • Thread groups allow for collective control of many threads S2-Teknik Informatika UNHAS

  29. Java Servlets • Servlets are the Java analog to CGI • Advantages of servlets: full access to other Java APIs, persistence between invocations, guaranteed portability • Servlets can be generic services or specific to HTTP S2-Teknik Informatika UNHAS

  30. HTTP Servlets • javax.servlet.http.HttpServlet class • Uses HTTP to receive requests and generate responses • Full support for all HTTP methods, cookies, sessions, persistent connections • Servlets can be chained – example: de-blink servlet S2-Teknik Informatika UNHAS

  31. Java Applets • Client-side Java programs that run in a browser • Applets have special security restrictions called the applet sandbox • Only applets loaded over the network are subject to the applet sandbox • The applet sandbox is controlled by a java.lang.SecurityManager S2-Teknik Informatika UNHAS

  32. Remote Method Invocation (RMI) • RMI is the Java analog to RPC • RMI servers use a naming service (rmiregistry) to register remote objects • RMI servers use a special security policy implemented by RMISecurityManager • The default RMI transport mechanism is via TCP sockets – this is transparent to RMI code! • Any object transferred in an RMI call must implement the Serializable interface S2-Teknik Informatika UNHAS

More Related