The latest slide deck about Java NIO.2 from *instinctools Java developer Alexandr Brui. You can find here Java NIO.2 design, work with data, selector & channels, reading & writing and many more.
The latest slide deck about Java NIO.2 from *instinctools Java developer Alexandr Brui. You can find here Java NIO.2 design, work with data, selector & channels, reading & writing and many more.
A short presentation about practical aspects of asynchronous data transfer with Netty
HTML version: http://vcherkassky.github.com/reveal.js/netty.html
Additional resources (from last slide):
* https://github.com/netty/netty
* http://seeallhearall.blogspot.co.uk/2012/05/netty-tutorial-part-1-introduction-to.html
Done with reveal.js: https://github.com/hakimel/reveal.js/
Overview of socket API.
A network socket is an interface for an application to connect to a host‘s network stack (part of the OS). Sockets provide an abstraction of the network. Applications use the transport services available on the socket interface for communication with a peer application.
Transport protocol such as TCP, UDP or SCTP offer different levels of service. TCP for example provides reliable stream-oriented transport service while UDP more reflects the best-effort kind of service provided by the underlying IP protocol layer.
Sockets are bound to a transport address. For TCP/IP sockets this means an IP address and port number.
Sockets provide only very basic data transport services without any higher level functions like parameter marshaling or serialization. These functions have to be performed by the applications. These functions are often hidden in middleware platforms like distributed object technologies (CORBA, RMI, DCOM) or web service frameworks (WCF, JAX-WS).
Multicast sockets make the IP multicast capability accessible to applications. Multicast sockets are often used for streaming services where multiple applications are recipients of the same data packets.
A short presentation about practical aspects of asynchronous data transfer with Netty
HTML version: http://vcherkassky.github.com/reveal.js/netty.html
Additional resources (from last slide):
* https://github.com/netty/netty
* http://seeallhearall.blogspot.co.uk/2012/05/netty-tutorial-part-1-introduction-to.html
Done with reveal.js: https://github.com/hakimel/reveal.js/
Overview of socket API.
A network socket is an interface for an application to connect to a host‘s network stack (part of the OS). Sockets provide an abstraction of the network. Applications use the transport services available on the socket interface for communication with a peer application.
Transport protocol such as TCP, UDP or SCTP offer different levels of service. TCP for example provides reliable stream-oriented transport service while UDP more reflects the best-effort kind of service provided by the underlying IP protocol layer.
Sockets are bound to a transport address. For TCP/IP sockets this means an IP address and port number.
Sockets provide only very basic data transport services without any higher level functions like parameter marshaling or serialization. These functions have to be performed by the applications. These functions are often hidden in middleware platforms like distributed object technologies (CORBA, RMI, DCOM) or web service frameworks (WCF, JAX-WS).
Multicast sockets make the IP multicast capability accessible to applications. Multicast sockets are often used for streaming services where multiple applications are recipients of the same data packets.
- Practical exercises on the use of UDP protocol using Java language
- References
YouTube link :
https://www.youtube.com/playlist?list=PLtDIUAtyP4lhV7CsYfLuIx26UeG4J-ujZ
GitHub :
https://github.com/Ghadeerof
This is all about socket programming in java using TCP and UDP socket and an example of simple Echo Server.
Also includes concepts of the socket, Socket class and methods and use of those.
Frequency .java Word frequency counter package frequ.pdfarshiartpalace
Frequency .java
/**
* Word frequency counter
*/
package frequency;
import java.util.Iterator;
/**
*
* @author UMD CS
*/
public class Frequency implements Iterable{
private Node first;
private int N;
Frequency(){
N = 0;
first = null;
}
@Override
public Iterator iterator() {
return new ListIterator();
}
/**
*
* List iterator
*
*/
private class ListIterator implements Iterator{
private Node current;
private int index ;
ListIterator(){
current = first;
index = 0;
}
@Override
public boolean hasNext() {
return current != null;
}
public String next() {
if(!hasNext()){
return null;
}
String word = current.key;
int count = current.count;
String r = \"(\"+word + \",\" + Integer.toString(count)+\")\";
current = current.next;
return r;
}
@Override
public void remove() {
}
}
/**
*
* Node class
*
*/
private class Node {
private String key;
private int count;
private Node next;
Node(String item){
key = item;
count = 1;
next = null;
}
@Override
public String toString(){
return \"(\"+key +\",\"+count+\")\";
}
}
/*
* Inserts a word into the linked list. If the word exists, increment the
* count by q.
*/
public void insert(String word){
if(word.equals(\"\")){
return;
}
//TODO
/*
* implement here
*/
}
/**
*
* @param str input string
* This method splits a string into words and pass the words to insert method
*
*/
public void insertWords(String str){
String delims = \"[ .,?!\'\\\"()}{;/<>&=#-:\\\\ _]+\";
String[] words = str.split(delims);
for(String s: words){
s = s.toLowerCase();
insert(s);
}
}
/**
* prints the word frequency list
*/
public void print(){
Node c = first;
while(c != null){
System.out.print(\"(\"+c.key + \",\" + c.count+\")\");
c = c.next;
}
System.out.print(\"\ \");
}
}
--------------------------------------------------------------------------------------------------------------------
------------------------------------------------------
WordFrequency.java
package frequency;
import utils.In;
import utils.Stopwatch;
/**
*
* @author UMD CS
*/
public class WordFrequency {
/**
* @param input source
* @param
* This method receives input resource and return the word frequency string
* DO NOT CHANGE THIS METHOD.
*/
public static String freq(String inputSource, int maxLines){
In in;
// Frequency class can only count the frequency of strings. DO NOT CHANGE THIS.
Frequency freq = new Frequency();
int MAX = 100;
String inputSourceName = inputSource;
try {
in = new In(inputSourceName);
while (!in.isEmpty()) {
String s = in.readLine();
//System.out.println(s);
freq.insertWords(s);
}
}
catch (Exception e) {
e.printStackTrace();
}
StringBuilder strFrequency = new StringBuilder();
int cnt = 0;
for(String s: freq){
strFrequency.append(s);
strFrequency.append(\",\");
cnt++;
if(cnt >= maxLines){break;}
}
return strFrequency.toString();
}
/**
*
*/
public static void main(String[] args) {
In in;
Frequency freq = new Frequency();
int MAX = 100;
// String inputSourceName =
\"http://www.cs.umd.edu/class/summer2015/cmsc132/projects/P3_WordFrequency/test1.html\";
String .
Poche chiacchiere e tanto codice per cercare rendere la nostra vita di
sviluppatori più divertente.
Parleremo di JAX-RS, le annotazioni, l'MVC che mette a disposizione e
l'integrazione di Jersey con Guice.
Useremo AOP per gestire log, transazioni e con l'aiuto di Infinispan
limiteremo le chamate concorrenti sul nostro cluster.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
The field of Information retrieval (IR) is currently undergoing a transformative shift, at least partly due to the emerging applications of generative AI to information access. In this talk, we will deliberate on the sociotechnical implications of generative AI for information access. We will argue that there is both a critical necessity and an exciting opportunity for the IR community to re-center our research agendas on societal needs while dismantling the artificial separation between the work on fairness, accountability, transparency, and ethics in IR and the rest of IR research. Instead of adopting a reactionary strategy of trying to mitigate potential social harms from emerging technologies, the community should aim to proactively set the research agenda for the kinds of systems we should build inspired by diverse explicitly stated sociotechnical imaginaries. The sociotechnical imaginaries that underpin the design and development of information access technologies needs to be explicitly articulated, and we need to develop theories of change in context of these diverse perspectives. Our guiding future imaginaries must be informed by other academic fields, such as democratic theory and critical theory, and should be co-developed with social science scholars, legal scholars, civil rights and social justice activists, and artists, among others.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
2. UDP
Low-level, connectionless
No reliability guarantee
TCP
Connection-oriented
Not as efficient as UDP
Pemrograman Terdistribusi Sistem Terdistribusi (IKH331) 2
3. The sending/receiving point-
Class DatagramSocket
void close() : close a datagram socket
int getLocalPort() : returns the port number on which
socket is bound
InetAddress getLocalAddress() : returns the local
address to which the socket is bound
void receive(DatagramPacket p) : blocks until a
datagram is received and the packet’s buffer contains the data
received
void send(DatagramPacket p) : sends a datagram
packet from this socket
Pemrograman Terdistribusi Sistem Terdistribusi (IKH331) 3
4. //Datagram Server
public class DatagramServer {
public static void main(String[] args) {
DatagramPacket datapacket, returnpacket;
int port = 2018;
int len = 1024;
try {
DatagramSocket datasocket = new DatagramSocket(port);
byte[] buf = new byte[len];
datapacket = new DatagramPacket(buf, buf.length);
while (true) {
try {
datasocket.receive(datapacket);
returnpacket = new DatagramPacket(
datapacket.getData(),
datapacket.getLength(),
datapacket.getAddress(),
datapacket.getPort());
datasocket.send(returnpacket);
} catch (IOException e) {
System.err.println(e);
}
}
} catch (SocketException se) {
System.err.println(se);
}
}
}
Pemrograman Terdistribusi Sistem Terdistribusi (IKH331) 4
5. //Datagram Client
public class DatagramClient {
public static void main(String[] args) {
String hostname;
int port = 2018;
int len = 1024;
DatagramPacket sPacket, rPacket;
InetAddress ia = InetAddress.getByName(hostname);
DatagramSocket datasocket = new DatagramSocket();
BufferedReader stdinp = new BufferedReader(
new InputStreamReader(System.in));
while (true) {
String echoline = stdinp.readLine();
if (echoline.equals("done")) break;
byte[] buffer = new byte[echoline.length()];
buffer = echoline.getBytes();
sPacket = new DatagramPacket(buffer, buffer.length, ia,
port);
datasocket.send(sPacket);
byte[] rbuffer = new byte[len];
rPacket = new DatagramPacket(rbuffer, rbuffer.length);
datasocket.receive(rPacket);
String retstring = new String(rPacket.getData());
System.out.println(retstring);
} catch (IOException e) {
System.err.println(e);
}
} // while
} } // end main
Pemrograman Terdistribusi Sistem Terdistribusi (IKH331) 5
6. A connection is set up between the sender and the
receiver
Class Socket
Socket(String host, int port) : creates a stream socket
and connects it to the specified port number on the host
InputStream getInputStream() : returns an input stream for
reading bytes from this socket
OutputStream getOutputStream() : returns an output
stream for writing bytes to this socket
Pemrograman Terdistribusi Sistem Terdistribusi (IKH331) 6
7. Creates a server side socket on the specified
port
class ServerSocket
InetAddress getInetAddress() :
returns the address to which this socket is
connected
Socket accept() : blocking method which
waits for a connection to be made and accepts it
Pemrograman Terdistribusi Sistem Terdistribusi (IKH331) 7
8. Maps a name to the host and port number
Create a server socket
Listen for incoming connections (accept())
Pemrograman Terdistribusi Sistem Terdistribusi (IKH331) 8
9. //NameServer
public class NameServer {
NameTable table;
public NameServer() {
table = new NameTable();
}
void handleclient(Socket theClient) {
BufferedReader din = new BufferedReader
(new InputStreamReader(theClient.getInputStream()));
PrintWriter pout = new PrintWriter(theClient.getOutputStream());
String getline = din.readLine();
StringTokenizer st = new StringTokenizer(getline);
String tag = st.nextToken();
if (tag.equals("search")) {
...
} else if (tag.equals("insert")) {
...
}
}
public static void main(String[] args) {
NameServer ns = new NameServer();
System.out.println("NameServer started:");
ServerSocket listener = new ServerSocket(Symbols.ServerPort);
while (true) {
Socket aClient = listener.accept();
ns.handleclient(aClient);
aClient.close();
}
}
}
Pemrograman Terdistribusi Sistem Terdistribusi (IKH331) 9
10. //Client for name server
public class Name {
BufferedReader din;
PrintStream pout;
public void getSocket() throws IOException {
Socket server = new Socket(Symbols.nameServer, Symbols.ServerPort);
din = new BufferedReader(new InputStreamReader(server.getInputStream()));
pout = new PrintStream(server.getOutputStream());
}
public int insertName(String name, String hname, int portnum){
getSocket();
pout.println("insert " + name + " " + hname + " " + portnum);
pout.flush();
return Integer.parseInt(din.readLine());
}
public PortAddr searchName(String name) throws IOException {
getSocket();
pout.println("search " + name);
pout.flush();
String result = din.readLine();
StringTokenizer st = new StringTokenizer(result);
int portnum = Integer.parseInt(st.nextToken());
String hname = st.nextToken();
return new PortAddr(hname, portnum);
}
public static void main(String[] args) {
Name myClient = new Name();
myClient.insertName("hello1", "birch.ece.utexas.edu", 1000);
PortAddr pa = myClient.searchName("hello1");
System.out.println(pa.gethostname() + ":" + pa.getportnum());
}
}
Pemrograman Terdistribusi Sistem Terdistribusi (IKH331) 10
11. Methods can be called by another JVM on a
different host
Interface is remote if it extends Remote
Remote object implements a remote
interface and extends UnicastRemoteObject
public interface NameService extends Remote {
public int search(String s) throws RemoteException;
public int insert(String s, String hostName, int portNumber)
throws RemoteException;
public int getPort(int index) throws RemoteException;
public String getHostName(int index) throws RemoteException;
}
Pemrograman Terdistribusi Sistem Terdistribusi (IKH331) 11
12. // A name service implementation
public class NameServiceImpl extends UnicastRemoteObject
implements NameService {
. . .
public NameServiceImpl() throws RemoteException {
}
public int search(String s) throws RemoteException {
. . .
}
public int insert(String s, String hostName, int portNumber)
throws RemoteException {
. . .
}
public int getPort(int index) throws RemoteException {
return ports[index];
}
public String getHostName(int index) throws RemoteException {
return hosts[index];
}
public static void main(String args[]) {
// create security manager
System.setSecurityManager(new RMISecurityManager());
NameServiceImpl obj = new NameServiceImpl();
Naming.rebind("MyNameServer", obj);
System.out.println("MyNameServer bound in registry");
}
}
Pemrograman Terdistribusi Sistem Terdistribusi (IKH331) 12
13. import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
public class NameServiceImpl extends UnicastRemoteObject
implements NameService {
final int maxSize = 100;
private String[] names = new String[maxSize];
private String[] hosts = new String[maxSize];
private int[] ports = new int[maxSize];
private int dirsize = 0;
public NameServiceImpl() throws RemoteException {
}
public int search(String s) throws RemoteException {
for (int i = 0; i < dirsize; i++)
if (names[i].equals(s)) return i;
return -1;
}
Pemrograman Terdistribusi Sistem Terdistribusi (IKH331) 13
14. public int insert(String s, String hostName, int
portNumber)
throws RemoteException {
int oldIndex = search(s); // is it already there
if ((oldIndex == -1) && (dirsize < maxSize)) {
names[dirsize] = s;
hosts[dirsize] = hostName;
ports[dirsize] = portNumber;
dirsize++;
return 1;
} else
return 0;
}
public int getPort(int index) throws RemoteException
{
return ports[index];
}
Pemrograman Terdistribusi Sistem Terdistribusi (IKH331) 14
16. Primitive types are passed by value
Objects (that are not remote)
They are serialized and then passed by value.
At the other end the objects are deserialized
Any references inside the object are also
serialized
Remote Objects
Passed as remote references (stubs)
Pemrograman Terdistribusi Sistem Terdistribusi (IKH331) 16
17. Obtain a reference for the remote object
URL for the remote object is specified as
rmi://host:port/name
Pemrograman Terdistribusi Sistem Terdistribusi (IKH331) 17
18. //A RMI client program
import java.rmi.*;
public class NameRmiClient {
public static void main(String args[]) {
try {
NameService r = (NameService)
Naming.lookup("rmi://linux02/MyNameServer");
int i = r.insert("p1", "tick.ece", 2058);
int j = r.search("p1");
if (j != -1)
System.out.println(r.getHostName(j) + ":" +
r.getPort(j));
} catch (Exception e) {
System.out.println(e);
}
}
}
Pemrograman Terdistribusi Sistem Terdistribusi (IKH331) 18
19. Vijay Garg, "Concurrent and Distributed
Programming in Java"
Source code
http://users.ece.utexas.edu/~garg/jbk.html
http://tjerdastangkas.blogspot.com/search/la
bel/ikh331
Pemrograman Terdistribusi Sistem Terdistribusi (IKH331) 19