8/9/2019 Ros Chelle
1/251
Season of mists and mellow
fruitfulness,
8/9/2019 Ros Chelle
2/251
Everything You Wanted to
Know
About Writing Async,Concurrent HTT
A!!s in "ava
8/9/2019 Ros Chelle
3/251
Agenda
#ostly this$
8/9/2019 Ros Chelle
4/251
Agenda
And this$
8/9/2019 Ros Chelle
5/251
Agenda
And this$
8/9/2019 Ros Chelle
6/251
8/9/2019 Ros Chelle
7/251
What 0rog1
8/9/2019 Ros Chelle
8/251
What 0rog1
8/9/2019 Ros Chelle
9/251
What 0rog1
8/9/2019 Ros Chelle
10/251
What 0rog1
8/9/2019 Ros Chelle
11/251
SERVE BINARIES FOR A LIVI
8/9/2019 Ros Chelle
12/251
CONCURRENT DOWNLOADS
Y U NO SUPPORT THEM?!
8/9/2019 Ros Chelle
13/251
2e3uirements
4!arallel 5le 6ownloads
4arallel 5le !arts4interru!t)!ause)resume
4rogress events4Chec%sums caching
8/9/2019 Ros Chelle
14/251
0irst Association for 7concurrent
downloader8
8/9/2019 Ros Chelle
15/251
8/9/2019 Ros Chelle
16/251
9uc%y day$ 6ownload managerwritten in 'ava:
8/9/2019 Ros Chelle
17/251
ONE DOES NOT SIMPLY
EMBED JDM
8/9/2019 Ros Chelle
18/251
9et;s loo% if we can use it:
t;s an a!!, not a lib
8/9/2019 Ros Chelle
19/251
WANT CONCURRENT DOWNLO
WRITE IT YOURSELF
8/9/2019 Ros Chelle
20/251
WHY WONT YOU JUST
USE URLCONNECTION?
8/9/2019 Ros Chelle
21/251
"ava(net(urlconnection
/( Bloc%ing streams
8/9/2019 Ros Chelle
22/251
8/9/2019 Ros Chelle
23/251
What we;re loo%ing for
8/9/2019 Ros Chelle
24/251
What is >T going to ta%e
8/9/2019 Ros Chelle
25/251
Welcome to the reactor
8/9/2019 Ros Chelle
26/251
4 !attern for lightweight
concurrency
4 Event driven
4Threads reuse
4 Dses nonbloc%ing >o
8/9/2019 Ros Chelle
27/251
riginal !attern
htt!$))www(dre(vanderbilt(edu)Fschmidt)60)reactorsiemens(!df
8/9/2019 Ros Chelle
28/251
Guess the author by thediagram
htt!$))gee(cs(oswego(edu)dl)c!'
8/9/2019 Ros Chelle
29/251
In Java,Reactor means
NIO
8/9/2019 Ros Chelle
30/251
Selector as a multi!leer
8/9/2019 Ros Chelle
31/251
"ava version 2egistering
SocketChannel channel=
SocketChannel.open();
socketChannel.connect(new
InetSocketAddress("http://remote.com
", 80));
...Selector selector = Selector.open();
channel.configureBlocking(false);
SelectionKey k=
8/9/2019 Ros Chelle
32/251
"ava version 6is!atcher
while (!Thread.interrupted()) {
selector.select();
Set selected =selector.selectedKeys();
Iterator it =
selected.iterator();
while (it.hasNext())
SelectionKey k= (SelectionKey)
(it.next();
((Runnable)
8/9/2019 Ros Chelle
33/251
Handling reactor events is com!le
4=eed to maintain state
4Bu@ering 4 assemblingchun%s
4Coordinating async events
HTTP NIO FRAMWORKS
8/9/2019 Ros Chelle
34/251
HTTP NIO FRAMWORKS
DO THE HEAVY LIFTING
8/9/2019 Ros Chelle
35/251
=io libraries
4#ost of them are servers
4=etty, griIIly, etc(
4A!ache #ina
4A!ache HTT com!onentsasyncclient
4=ing htt! client
8/9/2019 Ros Chelle
36/251
4Client and server nio
library4Evolved from netty
49atest release ctober
-
8/9/2019 Ros Chelle
37/251
8/9/2019 Ros Chelle
38/251
=io libraries
4#ost of them are servers
4=etty, griIIly, etc
4A!ache #ina
4A!ache HTT com!onentsasyncclient
4=ing htt! client
8/9/2019 Ros Chelle
39/251
8/9/2019 Ros Chelle
40/251
=ing;s async htt! client
8/9/2019 Ros Chelle
41/251
8/9/2019 Ros Chelle
42/251
8/9/2019 Ros Chelle
43/251
Here it is:
8/9/2019 Ros Chelle
44/251
8/9/2019 Ros Chelle
45/251
8/9/2019 Ros Chelle
46/251
HAC Conce!ts
42e3uest !roducer
42es!onse consumer
try (CloseableHttpAsyncClient asyncHttpClient = HttpAsyncClients.createDefault()) {
8/9/2019 Ros Chelle
47/251
asyncHttpClient.start();Futurefuture = asyncHttpClient.execute(
HttpAsyncMethods.createet("http://oss.jfrog.org/api/system/ping")!newAsyncByteConsumer() {
"#$errideprotected void onResponseRecei$ed(final HttpResponse response) {
%yste&.out.println(response.'et%tatusine().'etReasonhrase());*
"#$errideprotected voidonByteReceived(final Char+u,,er bu,! final -#Control ioctrl) { *
"#$errideprotected void releaseResources() { *
"#$errideprotectedHttpResponse buildResult(final HttpContext context) {return (HttpResponse) context.'etAttribute("http.response");
*
*!null);
HttpResponse response = future.get();*
8/9/2019 Ros Chelle
48/251
8/9/2019 Ros Chelle
49/251
Choosing between ning and htt!asyncclient
8/9/2019 Ros Chelle
50/251
PAll !roblems in com!uterscience can be solved byanother level of
indirectionP 6avidWheeler
8/9/2019 Ros Chelle
51/251
pulic interface " ttp#rovider$ ow nload" andler{
void onResponseRecei$ed(int statusCode! M ap< %trin'!ist< %trin'> > headers);
oolean on+ytesRecei$ed(+yte+u,,er bu,);
void onFailed(/hro0 able error);
void onCanceled();
void onCo& pleted();*
8/9/2019 Ros Chelle
52/251
Head to head
0eature)9ibrary
=ing client Htt! Async Client
#aturity Good Qery new ?early
-
8/9/2019 Ros Chelle
53/251
erformance1
Small 5le #edium 5le 9arge 5le
8/9/2019 Ros Chelle
54/251
2fc-R
8/9/2019 Ros Chelle
55/251
8/9/2019 Ros Chelle
56/251
Confused1
" t d t % *
8/9/2019 Ros Chelle
57/251
"ust read some stac%over*ow?and im!rove your re! as you go
for
8/9/2019 Ros Chelle
58/251
discoveringthat range
header islost on
redirect
HTTP WAR STORIES
8/9/2019 Ros Chelle
59/251
Vuestion:
What should
be contentlength when
usingcom!ression1
8/9/2019 Ros Chelle
60/251
8/9/2019 Ros Chelle
61/251
8/9/2019 Ros Chelle
62/251
htt!s$))github(com)htt!-)htt!-s!ec)issues)+R
8/9/2019 Ros Chelle
63/251
Vuestion:
Why when redirected to C6=all the chun%s start from Iero1
8/9/2019 Ros Chelle
64/251
HttpAsyncClient+uilder builder = HttpAsyncClients.custo& ();11 add redirect strate'y that copies 2ran'e2 headers! i, exist
uilder.setRedirect%trategy(ne0 $ efaultRedirect%trategy(){" # $erridepublic Http3riRe4uest 'etRedirect(HttpRe4uest re4uest! HttpResponse
response! HttpContext context)Http3riRe4uest redirectRe4uest = super.'etRedirect(re4uest! response!
context);11 copy 2Ran'e2 headers! i, existHeader56 ran'eHeaders = re4uest.'etHeaders(HttpHeaders.RA78);
i, (ran'eHeaders 9= null) {,or (Header header : ran'eHeaders) {
redirectRe&uest.add" eader(header);
**return redirectRe4uest;
**);
8/9/2019 Ros Chelle
65/251
Vuestion:
How many
simultaneousconnections should
> o!en1
HTTP 1 1 GOES LIKE:
8/9/2019 Ros Chelle
66/251
HTTP 1.1 GOES LIKE:
CAN YOU PLEASE LIMIT
TO CONNECTIONS?
8/9/2019 Ros Chelle
67/251
BROWSERS GO LIKE:
8/9/2019 Ros Chelle
68/251
URL ENCODING?
8/9/2019 Ros Chelle
69/251
URL ENCODING?
8/9/2019 Ros Chelle
70/251
Vuestion:
What;s
wrongwith the
followingcode1
8/9/2019 Ros Chelle
71/251
public static StringencodeDrl?String urlStr D29Encoder(encode?urlStr, "UTF-"N
(((O
6ecoded D29s cannot be
8/9/2019 Ros Chelle
72/251
6ecoded D29s cannot bereencoded to the same form
http:11exa& ple.co& 14uery= ab= = c
Cannot be decoded bac a,ter it 0 asencoded:
http:11exa& ple.co& 14uery= a ?@b= = c
6on;t use
http://example.com/?query=a&b==chttp://example.com/?query=a&b==chttp://example.com/?query=a&b==chttp://example.com/?query=a&b==chttp://example.com/?query=a&b==chttp://example.com/?query=a&b==chttp://example.com/?query=a&b==c8/9/2019 Ros Chelle
73/251
6on t use'ava(net(D29Encoder
7Dtility class for HT#9 formencoding( This class contains static
methods for converting a String tothe application/x-www-form-urlencoded #>#E format(
0or more information about HT#9form encoding, consult the HT#9s!eci5cation(8
8/9/2019 Ros Chelle
74/251
AHC Alternatives
or'.apache.http.client.utils.3R-+uilder
or'.apache.http.client.utils.3R8ncoded3tils
8/9/2019 Ros Chelle
75/251
8/9/2019 Ros Chelle
76/251
Vuestion:
How do >
close asoc%et
correctly1
How hard can it be to close a
8/9/2019 Ros Chelle
77/251
How hard can it be to close asoc%et1
h f % l i
8/9/2019 Ros Chelle
78/251
The art of soc%et closing
htt!$))www(safariboo%sonline(com)library)view)htt!the
Halfclosed$ no new
8/9/2019 Ros Chelle
79/251
Half closed$ no newcustomers
=ever bloc% in soc%et
8/9/2019 Ros Chelle
80/251
=ever bloc% in soc%etclose?
The other side e!ects
you to clean u! nicely >t will give u! on time
outYou will wait ?forever
I ALWAYS CLOSE
8/9/2019 Ros Chelle
81/251
I ALWAYS CLOSE
CONNECTIONS
AND WHEN I DO IT I USE
TRY"WITH"RESOURCES
2 b 1
8/9/2019 Ros Chelle
82/251
2emember1
V ti :
8/9/2019 Ros Chelle
83/251
Vuestion:
How can >write 5le!artsconcurrently1
4 Write to se!arate 5les
8/9/2019 Ros Chelle
84/251
Write to se!arate 5les,
combine on 5nish4 Write to same 5le,
see%ing to the right!osition
WHY WONT YOU JUST USE
8/9/2019 Ros Chelle
85/251
WHY WON T YOU JUST USE
JAVA IO RANDOMACCESSFILE?!
8/9/2019 Ros Chelle
86/251
DSE 0il Ch l
8/9/2019 Ros Chelle
87/251
DSE 0ileChannel
>m!lements %eeable+yteChannel
a$a.nio.channels.'ileChannelB w rite( a$a.nio.+yte+u,,er src! lon'
position)
8/9/2019 Ros Chelle
88/251
0il 9 %i
8/9/2019 Ros Chelle
89/251
0ile 9oc%ing
0ile loc%ing 9e els
8/9/2019 Ros Chelle
90/251
0ile loc%ing 9evels
4Q# level
4S level
S level 0ile loc%ing
8/9/2019 Ros Chelle
91/251
S level 0ile loc%ing
#ulti!le downloader instanceswriting to the same 5le
=eeded for writing$
artial download 5le ersistent download !rogress
S 9evel 0ile 9oc%ing
8/9/2019 Ros Chelle
92/251
Fileoc loc = ,ileChannel.tryoc(); 11 onshared: (! on'.M ADEA38!
false)if (loc = = null) {
throw new#$erlappin'Fileoc8xception(); * return loc;*
gEclusive
S 9evel 0ile 9oc%ing 4
8/9/2019 Ros Chelle
93/251
private Fileoc loc(FileChannel ,ileChannel)throw s-# 8xception {
Fileoc loc = ,ileChannel.tryoc(on'.M AX_VALUEG!!false); if (loc = = null) { throw new # $erlappin'Fileoc8xception(); * return loc;*
gAdvisory eclusive
WT01:
Q# 9evel 0ile 9oc%ing
8/9/2019 Ros Chelle
94/251
Q# 9evel 0ile 9oc%ing
WHY DO YOU NEEDLOCKS
IF YOU WRITE TO
DIFFERENT PARTS OF
Q# 9evel 0ile 9oc%ing
8/9/2019 Ros Chelle
95/251
Q# 9evel 0ile 9oc%ing
4revent same Q# threads writing tothe 5le when we started closing it
4Closing se3uence$42elease 5le loc%s
4Close channels
42ename a 5le to itXs 5nal name?remove (!art
4Erase !rogress info
Q# 9evel 0ile 9oc%ing
8/9/2019 Ros Chelle
96/251
Q# 9evel 0ile 9oc%ing
ReentrantReadI riteoc.Readoc w rite*o'ile+oc,= r0 l.readoc();ReentrantReadI riteoc.I riteoc close'ile+oc,=r0 l.0 riteoc();
public $oid close() thro0 s -# 8xception { this.close'ile+oc,.loc,();*
public int 0 rite(int part-ndex! +yte+u,,er bu,) { i, (9this.w rite*o'ile+oc,.try+oc,()) { thro0 ne0 -lle'al%tate8xception(2File is bein'closed2);
*
What;s net1
8/9/2019 Ros Chelle
97/251
What s net1
htt!)-
8/9/2019 Ros Chelle
98/251
htt!)-
4 #ostly standardiIing GoogleXs s!dy4 Header com!ression
4 multi!leing4 rioritiIation
4 Server !ush
4 n the way clear some stu@4 E(g( com!ressed content length
Ease the load
8/9/2019 Ros Chelle
99/251
Ease the load
9in%s:
8/9/2019 Ros Chelle
100/251
9in%s:
2T0#$ 20C -R
=o Than% you:
http://www.w3.org/Protocols/rfc2616http://www.amazon.com/HTTP-The-Definitive-Guide-Guides/dp/1565925092http://www.safaribooksonline.com/library/view/http-the-definitive/1565925092/http://jeewanthad.blogspot.co.il/2013/02/reactor-pattern-explained-part-1.htmlhttp://gee.cs.oswego.edu/dl/cpjslides/nio.pdfhttp://gee.cs.oswego.edu/dl/cpjslides/nio.pdfhttp://jeewanthad.blogspot.co.il/2013/02/reactor-pattern-explained-part-1.htmlhttp://www.safaribooksonline.com/library/view/http-the-definitive/1565925092/http://www.amazon.com/HTTP-The-Definitive-Guide-Guides/dp/1565925092http://www.w3.org/Protocols/rfc26168/9/2019 Ros Chelle
101/251
=o, Than% you:
8/9/2019 Ros Chelle
102/251
A Vuic% Tourof Logos
The 9ogical A!!eal
So what eactly is logic1 Who
8/9/2019 Ros Chelle
103/251
So what eactly is logic1 Whocares1>nformally, logic is about saying things that ma&esense.You can thin% of it in that way if you li%e(
7>tXs !retty sunny today, so you should wear sunscreen(8
0ormally, logic is the art of arguing 4not li%e a 5ght or debate, but by
using the information we already%now to draw new and usefulconclusions(
7>f itXs sunny today, you should wear sunscreen(>ndeed it is sunny today(
Therefore, you should wear sunscreen(8
8/9/2019 Ros Chelle
104/251
7But wait( That 'ust loo%ed li%e the
eact same thing you said before,you hac%(8
ell, yes( But thatXs how an argument loo%s in starm: You can brea% down anyargument into thisat ma%es it easier to thin% about(
>f itXs sunny today, you should wear sunscre
>t is sunny today(
Therefore, you should wear sunscreen(
remises)
givens
Conclusion
?remises always come 5rst, and the conclusion always come
How about a more com!le
8/9/2019 Ros Chelle
105/251
How about a more com!leargument1
t also has seeds(
/( >f a fruit is fuIIy, itXs either a %iwi or a !each(
+( eaches have a !itN they donXt have seeds(.( So the fruit canXt be a !each(
R( So the fruit must be a %iwi(
Which of the above sentences is a conclusion
How about a more com!le
8/9/2019 Ros Chelle
106/251
How about a more com!leargument1
t also has seeds(
/( >f a fruit is fuIIy, itXs either a %iwi or a !each(
+( eaches have a !itN they donXt have seeds(.( So the fruit canXt be a !each(
R( So the fruit must be a %iwi(
Good logic lets us cobble together lots ofdi@erent !ieces of information, and tell from
them whatXsprobably or defnitely true.
8/9/2019 Ros Chelle
107/251
But what counts as 7good logic81
That argument was good ?made sense, becausethe conclusion followed from the !remises( WeXllsee what this means in a moment(
Why donXt we loo% at a badargument1
8/9/2019 Ros Chelle
108/251
But what counts as 7good logic81
Some !eo!le have fallen o@ cli@s and lived(
erefore, if > 'um! o@ this cli@, > will de5nitely be
7Comeon(Whatcould
!ossibly
8/9/2019 Ros Chelle
109/251
But what counts as 7good logic81
Some !eo!le have fallen o@ cli@s and lived(
erefore, if > 'um! o@ this cli@, > will de5nitely be
his argument is wea%( Although the !remiseis tXs easy to thin% of ways ?very !ainful ways that
nclusioncould be false( The easiest way to s!ogic is to do 'ust that$ try to thin% of another wa
hiloso!hers call these counterexamples(
8/9/2019 Ros Chelle
110/251
But what counts as 7good logic81
9etXs loo% at two %inds ofarguments(
'.6eductive reasoning$ All interns can breathe 5re( Sohili! can breathe 5re(
>s there a !iece of the !uIIle missing1
8/9/2019 Ros Chelle
111/251
But what counts as 7good logic81
9etXs loo% at two %inds of arguments(
'.6eductive reasoning$
All interns can breathe 5re( hili!is an intern( So hili! canbreathe 5re(
ometimes you may encounter 7hidden8 statemnd ideas, which the writer snea%s in but doesnXty outright(
8/9/2019 Ros Chelle
112/251
But what counts as 7good logic81
9etXs loo% at two %inds of arguments(
'.6eductive reasoning$
All interns can breathe 5re( hili!is an intern( So hili! canbreathe 5re(
Are the !remisestrue1
>f so, then the conclusionXs100% guaranteed true(=o getting around it:
8/9/2019 Ros Chelle
113/251
But what counts as 7good logic81
9etXs loo% at two %inds of arguments(
(.>nductive reasoning$
> touched a stove and it burned me( > did this
5fty times, and the same thing ha!!ened(Sothe
net time > touch the stove, it will burn me(
Are the !remisestrue1
>f so, then the conclusionXsprobably true( There mightstill be ece!tions(
9>KE WHAT1
8/9/2019 Ros Chelle
114/251
How is this useful to me1
9i%e #r( #organ said, the ability toma%e strong logical arguments will
become more and more im!ortantlater on in high school and college(
athos and ethos are still valuable:But your audience will be a lot betterat 3uestioning them( 9ogos is handybecause, if you use it well, it canXt
8/9/2019 Ros Chelle
115/251
How is this useful to me1
But even better is the su!er!ower to s!ot weaklogic(
=et time you watch TQ or go online ?with your!arentsX !ermission, of course, try to %ee! trac%of how many di@erent arguments are being!itched to you by ads( How much info is given to
ou1 How much is left out1
8/9/2019 Ros Chelle
116/251
What time is it1
Adven wait, no( Activity time:
air o@ into grou!s of four( Each grou! will receive an eamf a !oor argument ?these may be either inductive or deduc
ith your grou!, you will have . minutes to try to come u!ne countere)ample one way in which the argumentould be wrong, even if the !remises are de5nitely true(
o%e it full of holes:lso, choose a grou! re!resentative to tell us your reasonin
>tXs K to imagine unli%ely or weird e!lanationsNonXt be afraid to thin% outside the bo(
8/9/2019 Ros Chelle
117/251
Some eam!les$
RGU!"#$7> !ulled an allnighter studying for last wee%Xs bst, and > ended u! with an A( Tiredness must ma%e me sma
&U"#!R$What if you got an A because you actually studiedr maybe the test was going to be easy for you all along1
RGU!"#$7>f > !lay with 6adXs !ower tools, heXll yell at me
ut 6ad isyelling at me for something( So > guess > must halayed with the !ower tools(8
&U"#!R$What if heXs yelling at you for a di@erent reason$cratching the car, or hammerthrowing the cat onto the roo
8/9/2019 Ros Chelle
118/251
*ohn +eats
8/9/2019 Ros Chelle
119/251
PTo ,utumnP is a !oemby English2omantic!oet"ohn Keats?/< ctober
8/9/2019 Ros Chelle
120/251
PTo AutumnP is the 5nal wor% in a grou!of !oems %nown as
KeatsXs P
8/9/2019 Ros Chelle
121/251
8/9/2019 Ros Chelle
122/251
The imagery is richly achieved throughthe !ersoni5cationof Autumn
http://en.wikipedia.org/wiki/Personificationhttp://en.wikipedia.org/wiki/Personification8/9/2019 Ros Chelle
123/251
!oem
Season of mists and mellowfruitfulness
8/9/2019 Ros Chelle
124/251
fruitfulness,
8/9/2019 Ros Chelle
125/251
lose bosom-friend of thematuring sun
onspiring with him how to loadand bless
8/9/2019 Ros Chelle
126/251
ith fruit the vines that roundthe thatch-eves run
8/9/2019 Ros Chelle
127/251
To bend with a!!les the mossXd
cottage trees
8/9/2019 Ros Chelle
128/251
cottagetrees,
,nd $ll all fruit withripeness to the core
8/9/2019 Ros Chelle
129/251
To swell the gourd, and !lum! thehaIel shells
8/9/2019 Ros Chelle
130/251
With a sweet %ernelN to setbudding more
8/9/2019 Ros Chelle
131/251
budding more,
And still more, later *owers forthe bees
8/9/2019 Ros Chelle
132/251
the bees,
8/9/2019 Ros Chelle
133/251
-their clammy cells.
8/9/2019 Ros Chelle
134/251
Who hath not seen thee oft amidthy store1
8/9/2019 Ros Chelle
135/251
thy store1
Sometimes whoever see%sabroad may 5nd
8/9/2019 Ros Chelle
136/251
abroad may 5nd
Thee sitting careless on a granary*oor
8/9/2019 Ros Chelle
137/251
*oor,
Thy hair softlifted by thewinnowing wind
8/9/2019 Ros Chelle
138/251
winnowing wind
r on a halfrea!;d furrowsound aslee!
8/9/2019 Ros Chelle
139/251
sound aslee!,
6rowsed with the fume of !o!!ies, whilethy hoo%
8/9/2019 Ros Chelle
140/251
thy hoo%
S!ares the net swath and all itstwinZd *owers$
8/9/2019 Ros Chelle
141/251
twinZd *owers$
And sometimes li%e a gleaner thoudost %ee!
8/9/2019 Ros Chelle
142/251
dost %ee!
Steady thy laden head across abroo%N
8/9/2019 Ros Chelle
143/251
broo%N
3patient loo&3
8/9/2019 Ros Chelle
144/251
Thou watchest the last ooIings,hours by hours(
8/9/2019 Ros Chelle
145/251
y
Where are the songs of S!ring1 Ay,where are they1
8/9/2019 Ros Chelle
146/251
e e a e ey
8/9/2019 Ros Chelle
147/251
8/9/2019 Ros Chelle
148/251
8/9/2019 Ros Chelle
149/251
en n a wa u c o r e smagnats mourn
8/9/2019 Ros Chelle
150/251
-sallows3 borne aloft
8/9/2019 Ros Chelle
151/251
r sin&ing as the light windives or dies
8/9/2019 Ros Chelle
152/251
sin%ing
And fullgrown lambs loud bleat fromhilly bournN
8/9/2019 Ros Chelle
153/251
y N
edgecric%ets singN and now withreble soft
8/9/2019 Ros Chelle
154/251
8/9/2019 Ros Chelle
155/251
8/9/2019 Ros Chelle
156/251
8/9/2019 Ros Chelle
157/251
8/9/2019 Ros Chelle
158/251
lose bosom-friend of thematuring sun
onspiring with him how to load andbless
8/9/2019 Ros Chelle
159/251
ith fruit the vines that round the thatch-eves run
8/9/2019 Ros Chelle
160/251
To bend with a!!les the mossXd cottage
trees,
8/9/2019 Ros Chelle
161/251
,nd $ll all fruit with ripeness to the core
8/9/2019 Ros Chelle
162/251
To swell the gourd, and !lum! thehaIel shells
8/9/2019 Ros Chelle
163/251
With a sweet %ernelN to set buddingmore,
8/9/2019 Ros Chelle
164/251
And still more, later *owers for thebees,
8/9/2019 Ros Chelle
165/251
Dntil they thin% warm days will nevercease,
8/9/2019 Ros Chelle
166/251
8/9/2019 Ros Chelle
167/251
Who hath not seen thee oft amid thystore1
8/9/2019 Ros Chelle
168/251
Sometimes whoever see%s abroadmay 5nd
8/9/2019 Ros Chelle
169/251
Thee sitting careless on a granary*oor,
8/9/2019 Ros Chelle
170/251
Thy hair softlifted by the winnowingwind
8/9/2019 Ros Chelle
171/251
r on a halfrea!;d furrow soundaslee!,
8/9/2019 Ros Chelle
172/251
6rowsed with the fume of !o!!ies, while thyhoo%
8/9/2019 Ros Chelle
173/251
S!ares the net swath and all itstwinZd *owers$
8/9/2019 Ros Chelle
174/251
And sometimes li%e a gleaner thoudost %ee!
8/9/2019 Ros Chelle
175/251
Steady thy laden head across abroo%N
8/9/2019 Ros Chelle
176/251
- 3
patient loo&3
8/9/2019 Ros Chelle
177/251
Thou watchest the last ooIings, hoursby hours(
8/9/2019 Ros Chelle
178/251
Where are the songs of S!ring1 Ay, whereare they1
8/9/2019 Ros Chelle
179/251
8/9/2019 Ros Chelle
180/251
While barrZd clouds bloom the softdying day
8/9/2019 Ros Chelle
181/251
And touch the stubble!lains withrosy hueN
8/9/2019 Ros Chelle
182/251
en n a wa u c o r e sma gna smourn
8/9/2019 Ros Chelle
183/251
8/9/2019 Ros Chelle
184/251
r sin&ing as the light windives or dies
8/9/2019 Ros Chelle
185/251
sin%ing
And fullgrown lambs loud bleat from hillybournN
8/9/2019 Ros Chelle
186/251
8/9/2019 Ros Chelle
187/251
The redbreast whistles from a gardencroftN
8/9/2019 Ros Chelle
188/251
An gat er ng swa ows tw tter n t es%ies(
8/9/2019 Ros Chelle
189/251
8/9/2019 Ros Chelle
190/251
8/9/2019 Ros Chelle
191/251
Trusses
Element 0ormulation by QirtualWor%
8/9/2019 Ros Chelle
192/251
Dse virtual wor% to derive elementsti@ness matri based on assumeddis!lacements
rinci!le of virtual wor% states that if ageneral structure that is in e3uilibriumwith its a!!lied forces deforms due to aset of small com!atible virtual
dis!lacements, the virtual wor% done ise3ual to its virtual strain energy ofinternal stresses(
8/9/2019 Ros Chelle
193/251
8/9/2019 Ros Chelle
194/251
We now assume a sim!le dis!lacementfunction to de5ne the dis!lacement ofevery material !oint in the element(
Dsually use low order !olynomials
Hereu J a< \ a-x
uis aial dis!lacement
a
8/9/2019 Ros Chelle
195/251
The constants are found by im!osingthe %nown nodal dis!lacements ui, u(
at nodes iand(
ui ) a< * a-xi
u( ) a< * a-x(
ui, u(are nodal dis!lacements
xi, (are nodal coordinates
8/9/2019 Ros Chelle
196/251
8/9/2019 Ros Chelle
197/251
8/9/2019 Ros Chelle
198/251
Strain is given by
where ]B^ is a matri relating strainto nodal dis!lacement ?matri of
derivatives of sha!e function
[ ] [ ]
du d[N]{d} [B]{d}
dx dx
1B 1 1
L
= = =
=
8/9/2019 Ros Chelle
199/251
=ow ) !, )) !]B^dOE
Stress and strain are constant in a
member 6e5ne internal virtual strain energy
for a set of virtual dis!lacements
dO to beT
e ! " # d =
8/9/2019 Ros Chelle
200/251
- J virtual strain- J stress level at e3uilibrium
d-J volume
Qirtual wor% of nodal forces is'eJ dO
#O
Then, virtual wor% is given by
( ) { } { }T T
d$ d % =
Substituting and rearranging gives
8/9/2019 Ros Chelle
201/251
Canceling dO#gives ]%^dOJ/Owhere
0or thermal !roblem
( ) ( )T ToT T T T T
o
[B]{ d} &[B]{d} & d { d} {% }
{ d} [B] &[B]{d}d { d} [B] & d$ { d} {% }
=
= +
[ ] [ ] [ ]' B B= T
V
E dV
{ } { } o 1( % &)1 = +
oT =
8/9/2019 Ros Chelle
202/251
for a truss we get
this formulation method also a!!liesto -d and /d elements
[ ]' =
EA
L
1 1
1 1
cedure for 6irect Sti@ness #ethod ?6is!lacement #eth
1. *is+retize into %inite elements, denti%y nodes, elements
and num-er them in order
8/9/2019 Ros Chelle
203/251
and num-er them in order.
2. *e$elop element sti%%ness matri+es [e] %or all the
elements.
/. )ssem-le element sti%%ness matri+es to 0et the 0lo-alsti%%ness matrix "[] [e]#. The size o% o% 0lo-al
sti%%ness matrix total d.o.% o% the stru+ture in+ludin0 at
-oundary nodes. )ssem-ly is done -y mat+hin0 element
displa+ement 3ith 0lo-al displa+ements. )lso de$elopappropriate %or+e $e+tor "-y addin0 element %or+e $e+tors#
su+h that e4uation o% the type [] {u}{(} is o-tained.
5. )pply 'inemati+ -oundary +onditions. 6ithout applyin0
- d diti [ ] ill - i l " i i
rocedure for 6irect Sti@ness #ethod
8/9/2019 Ros Chelle
204/251
-oundary +onditions, [] 3ill -e sin0ular. "minimum
num-er o% -oundary +onditions re4uired is to arrest 78i0id
Body9 displa+ements#.
:. ;ol$e %or un'no3n displa+ements {u} " {u} [] n+e displa+ements are determined %ind
"a# rea+tions -y pi+'in0 up appropriate ro3s %rom thee4uation {(}[] {u}, "-# (ind element %or+es {%}[e]
{ue}, "+# &lement stresses 0i$en -y {e} [*][B]{ue}.
8/9/2019 Ros Chelle
205/251
1 2 3
F1
, u1
F2, u2 F3, u3
Boundary Conditions
u1=0, u2=0
-A, 9, E A, 9, E
8/9/2019 Ros Chelle
206/251
[ ]
2 ?2
)& ?2 2@1 ?1L
?1 1
=
8/9/2019 Ros Chelle
207/251
8/9/2019 Ros Chelle
208/251
2eactions
{ } [ ]
{ } [ ]
1
/
A)& PL 2P
( 2 ?2 A 1L /)& /
A
A)& PL P
( A ?1 1 1L /)& /
A
= =
= =
Element 0orces
f< f-&lement 1
8/9/2019 Ros Chelle
209/251
A, 9, E
-A, 9, E
A, 9, E
1 1
2 2
21
/2
% u1 ?12)&% ?1 1 uL
1 ?1 A 2p /2)& PL
?1 1 1 2p /L /)&&lement 2
u% 1 ?1)&
u% ?1 1L
1 ?1)&
?1L
=
=
=
1 p /PL
1 A p //)&
=
2P
/
2P
/
P
/
P
/
8/9/2019 Ros Chelle
210/251
8/9/2019 Ros Chelle
211/251
8/9/2019 Ros Chelle
212/251
8/9/2019 Ros Chelle
213/251
u< u- u- u/
[ ] [ ]1 2
&lement 1 &lement 2
1 1 1 1)& )&
1 1 1 1L L
= =
8/9/2019 Ros Chelle
214/251
8/9/2019 Ros Chelle
215/251
8/9/2019 Ros Chelle
216/251
8/9/2019 Ros Chelle
217/251
6irect Element 0ormulation
8/9/2019 Ros Chelle
218/251
truss element acts li%e
8/9/2019 Ros Chelle
219/251
AJ cross section area !J modulus of elasticity
LJ length
k AE
L=
8/9/2019 Ros Chelle
220/251
Assume dis!lacements are muchsmaller than overall geometry vertical dis!lacements of horiIontal
member !roduce no vertical force
Sti@ness matri is written in localelement coordinates aligned alongelement ais
want sti@ness matri for arbitraryorientation
8/9/2019 Ros Chelle
221/251
rotate coordinate systems usingrotation matri ]2^ dis!lacement com!onents in global
coordinates are related to
dis!lacement com!onents in localcoordinates by dOJ]2^dO dO J dis!lacement in global
coordinates d;O J dis!lacement in local element
coordinates
AE
y
i jui ui
vi vj
pi
Pj
ij
8/9/2019 Ros Chelle
222/251
L
x
st
'
A1 +olumn '
A
=
rd
'
A/ +olumn
'
A
=
A
8/9/2019 Ros Chelle
223/251
th A5 +olumnA
A
=
nd
A
A2 +olumn
A
A
=
8/9/2019 Ros Chelle
224/251
start with member onxais, elemente3uations are
or %;Od;OJf;O =ote thatye3uations are all Iero
i i
i i
C C
C C
u D p D' A ' A
$ D 4 DA A A A
u D p D' A ' A$ D 4 DA A A A
=
x
y y
pj uj
vj
j
8/9/2019 Ros Chelle
225/251
pi ui
x
i
vi
i i i i i i
i i i i i i
at node i
u D u +os" # $ sin" # p D p +os" # 4 sin" #
$ D u sin" # $ +os" # 4 D 4 sin" # 4 +os" #
= + = +
= + = +
At node i
8/9/2019 Ros Chelle
226/251
A similar matri can be obtained at node '
i i
i i
u D u+os sin$ D sin +os $
=
i i
i i
p D p+os sin4 D sin +os 4
=
i i
i i
C C
C
u D u+os sin A A
$ D $sin +os A A
u D uA A +os sin
A A sin +os$ D
=
C$
8/9/2019 Ros Chelle
227/251
#atri ]2^ is$+os sin
sin +os
+os sin
sin +os
A A
A A
A A
A A
A A
A A
A A
A A
=
c s
s c
c s
s c
8/9/2019 Ros Chelle
228/251
Similarly , force com!onents arerelated by O J ]2^O
9ocal force dis!lacement relation is
]%;^d;O J f;O global force dis!lacement relation is]%^]2^dO J ]2^O
using fact that ]2^
Top Related