Moly to Holly

Post on 01-Jun-2018

227 views 0 download

transcript

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 1/212

A Quick Tour

of Logos

  The Logical Appea

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 2/212

So what exactly is logic? Who

cares?Informally, logic is about saying things that makesense. ou can think of it in that way if you like!

"It#s pretty sunny to$ay, so you shoul$ wear sunscreen!%

&ormally, logic is the art of arguing ' notlike a (ght or $ebate, but by using the

information we alrea$y know to $rawnew an$ useful conclusions!

"If it#s sunny to$ay, you shoul$ wear sunscreen!In$ee$ it is sunny to$ay!

 Therefore, you shoul$ wear sunscreen!%

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 3/212

")ut wait! That *ust looke$ like the exact

same thing you sai$ before, you hack!%

Well, yes! )ut that#s how an argument looks i

form+ ou can break $own any  argument intothat makes it easier to think about!

If it#s sunny to$ay, you shoul$ wear sunscree

It is sunny to$ay! ------------------------------------------- 

 Therefore, you shoul$ wear sunscreen!

.remises/gi0ens

1onclusion

2.remises always come (rst, an$ the conclusion always c

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 4/212

4ow about a more complex

argument?5! This piece of fresh fruit is fu66y!

7! It also has see$s!

8! If a fruit is fu66y, it#s either a kiwi or a peach!9! .eaches ha0e a pit they $on#t ha0e see$s!

:! So the fruit can#t be a peach!

;! So the fruit must be a kiwi!

Which of the abo0e sentences is a conclusion?

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 5/212

4ow about a more complex

argument?5! This piece of fresh fruit is fu66y!

7! It also has see$s!

8! If a fruit is fu66y, it#s either a kiwi or a peach!9! .eaches ha0e a pit they $on#t ha0e see$s!

:! So the fruit can#t be a peach!

;! So the fruit must be a kiwi!

<oo$ logic lets us cobble together lots of $i=erent pieces of information, an$ tell from

them what#s probably or defnitely true.

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 6/212

)ut what counts as "goo$

logic%? That argument was goo$ 2ma$e sense3, becausethe conclusion followe$ from the premises! We#llsee what this means in a moment!

Why $on#t we look at a bad argument?

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 7/212

)ut what counts as "goo$

logic%?Some people ha0e fallen o= cli=s an$ li0e$!

Therefore, if I *ump o= this cli=, I will $e(nitely be (

"1ome on!What coul$possibly gowrong?%

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 8/212

)ut what counts as "goo$

logic%?Some people ha0e fallen o= cli=s an$ li0e$!

Therefore, if I *ump o= this cli=, I will $e(nitely be (

 This argument is weak! Although the premise iit#s easy to think of ways 20ery painful ways3 t

conclusion coul$ be false! The easiest way tologic is to $o *ust that> try to think of another

2.hilosophers call these counterexamples3!

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 9/212

)ut what counts as "goo$

logic%?Let#s look at two kin$s of arguments!

1. e$ucti0e reasoning>

  All interns can breathe (re! So .hilipcan breathe (re!

Is there a piece of the pu66le missing?

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 10/212

)ut what counts as "goo$

logic%?Let#s look at two kin$s of arguments!

1. e$ucti0e reasoning>

  All interns can breathe (re! .hilip is anintern! So .hilip can breathe (re!

Sometimes you may encounter "hi$$en% statan$ i$eas, which the writer sneaks in but $oesay outright!

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 11/212

)ut what counts as "goo$

logic%?Let#s look at two kin$s of arguments!

1. e$ucti0e reasoning>

  All interns can breathe (re! .hilip isan intern! So .hilip can breathe(re!

  Are the premises true?If so, then the conclusion#s100% guaranteed true!@o getting aroun$ it+

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 12/212

)ut what counts as "goo$

logic%?Let#s look at two kin$s of arguments!

2. In$ucti0e reasoning>

  I touche$ a sto0e an$ it burne$ me! I $i$ this(fty times, an$ the same thing happene$! So

thenext time I touch the sto0e, it will burn me! 

Are the premises true?If so, then the conclusion#s probably true! There mightstill be exceptions!

LIB W4AT?

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 13/212

4ow is this useful to me?

Like Cr! Corgan sai$, the ability to makestrong logical arguments will become more

an$ more important later on in high schoolan$ college!

.athos an$ ethos are still 0aluable+ )ut

your au$ience will be a lot better atDuestioning them! Logos is han$y because,if you use it well, it can#t really be$ispro0e$!

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 14/212

4ow is this useful to me?

)ut e0en better is the superpower to spotweak  logic!

@ext time you watch TE or go online 2withyour parents# permission, of course3, try tokeep track of how many $i=erent argumentsare being pitche$ to you by a$s! 4ow muchinfo is gi0en to you? 4ow much is left out?

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 15/212

What time is it?

A$0enF wait, no! Acti0ity time+

.air o= into groups of four! Bach group will recei0e an eof a poor argument 2these may be either in$ucti0e or $

With your group, you will ha0e : minutes to try to comone counterexample F one way in which the argumecoul$ be wrong, e0en if the premises are $e(nitely true.oke it full of holes+

Also, choose a group representati0e to tell us your reas

2It#s G to imagine unlikely or weir$ explanations$on#t be afrai$ to think outsi$e the box!G$$ly enough, logic has 0ery little to $o with facts!3

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 16/212

Some examples>

 ARGU!"#$ "I pulle$ an allFnighter stu$ying for last weetest, an$ I en$e$ up with an A! Tire$ness must make me

&U"#!R$ What if you got an A because you actually stGr maybe the test was going to be easy for you all along

 ARGU!"#$ "If I play with a$#s power tools, he#ll yell at

)ut a$ is yelling at me for something! So I guess I musplaye$ with the power tools!%

&U"#!R$ What if he#s yelling at you for a $i=erent reasscratching the car, or hammerFthrowing the cat onto the

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 17/212

John Keats

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 18/212

"To Autumn" is a poem by EnglishRomantic poet John Keats (31

October 1795 – 23 ebr!ary 121#$

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 19/212

"%o &!t!mn" is the 'inal or) in agro!p o' poems )non as

Keats*s "119 o+es"$

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 20/212

"%o &!t!mn" is a poem o' threestan,as- each o' ele.en lines$ /ritten

in 119- the str!ct!re is that o' ano+al hymn- ha.ing three clearly

+e'ine+ sections correspon+ing to the0lassical +i.isions o' strophe-

antistrophe- an+ epo+e

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 21/212

%he imagery is richly achie.e+

thro!gh the personi'ication o' &!t!mn

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 22/212

Poem

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 23/212

eason o' mists an+ mello 'r!it'!lness-

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 24/212

Close bosom-friend of the maturingsun;

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 25/212

Conspiring with him how to load and bless

With f it th i th t d th th t h

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 26/212

With fruit the vines that round the thatch-evesrun;

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 27/212

%o ben+ ith apples the moss*+ cottage

trees-

A d fill ll f it ith i t th

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 28/212

And fill all fruit with ripeness to thecore;

%o sell the go!r+ an+ pl!mp the ha,el

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 29/212

%o sell the go!r+- an+ pl!mp the ha,elshells

/ith t ) l t t b ++i

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 30/212

/ith a seet )ernel to set b!++ingmore-

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 31/212

 &n+ still more- later 'loers 'or the bees-

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 32/212

4ntil they thin) arm +ays ill ne.er cease-

For ummer has o!er brimm!d their clamm"

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 33/212

For ummer has o er-brimm d their clamm"cells#

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 34/212

/ho hath not seen thee o't ami+ thy store

ometimes hoe.er see)s abroa+ may

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 35/212

ometimes hoe.er see)s abroa+ may'in+

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 36/212

%hee sitting careless on a granary 'loor-

%hy hair so't li'te+ by the innoing

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 37/212

%hy hair so'tli'te+ by the innoingin+

Or on a hal' reap6+ '!rro so!n+

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 38/212

Or on a hal'reap + '!rro so!n+asleep-

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 39/212

rose+ ith the '!me o' poppies- hile thy hoo)

pares the ne8t sath an+ all its tin+

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 40/212

pares the ne8t sath an+ all its tin+'loers:

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 41/212

 &n+ sometimes li)e a gleaner tho! +ost )eep

tea+y thy la+en hea+ across a

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 42/212

tea+y thy la+en hea+ across abroo)

$r b" a c"der-press% with patient loo&%

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 43/212

" " p % p %

%ho! atchest the last oo,ings- ho!rs by

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 44/212

g yho!rs$

/here are the songs o' pring &y here are

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 45/212

/here are the songs o' pring &y- here arethey

%hi ) t ' th th h t th i t

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 46/212

%hin) not o' them- tho! hast thy m!sic too-;

/hil b + l + bl th 't + i +

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 47/212

/hile barr+ clo!+s bloom the so't+ying +ay

 &n+ to!ch the st!bbleplains ith rosyh!e

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 48/212

h!e

%hen in a ail'!l choir the small gnats mo!rn

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 49/212

Among the river-sallows% bornel ft

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 50/212

aloft

r sin&ing as the light wind lives or

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 51/212

g gies;

sin)ing

&n+ '!ll gron lambs lo!+ bleat 'rom hilly bo!rn

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 52/212

 &n+ '!llgron lambs lo!+ bleat 'rom hilly bo!rn

<e+gecric)ets sing an+ no ith treble so't

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 53/212

g g

%he re+breast histles 'rom a gar+encro't

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 54/212

cro't

n ga er ng sa os er n es)ies$

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 55/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 56/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 57/212

E.erything =o! /ante+ to Kno

About Writing Async,

1oncurrent 4TT. Appsin Ha0a

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 58/212

 &gen+a

>ostly this:

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 59/212

 &gen+a

 &n+ this:

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 60/212

 &gen+a

 &n+ this:

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 61/212

 &bo!t yo!r spea)er 

I * b a r uc h

g i  t  h u b !c  o m 

 /   *  b a r  u c  h link$!in/*baruch

stacko0erJow!com/users/9K7K:8

/h t

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 62/212

/hat rog

/h t

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 63/212

/hat rog

/h t

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 64/212

/hat rog

/h t

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 65/212

/hat rog

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 66/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 67/212

eDuirements

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 68/212

eDuirements

' parallel (le ownloa$s

' .arallel (le parts

' interrupt/pause/resume

' .rogress e0ents

' 1hecksums caching

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 69/212

irst &ssociation 'or ?conc!rrent

+onloa+er@

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 70/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 71/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 72/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 73/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 74/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 75/212

Ha0a net urlconnection

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 76/212

 Ha0a!net!urlconnection

5! Cemory wasteful 2bu=ering3

7! Cinimal A.I

8! )locking streams

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 77/212

What weMre looking for

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 78/212

What we re looking for

5! Async/nonFblocking

7! B0ent callbacks

What is IT going to take

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 79/212

What is IT going to take

5! eactor

7! nio

/elcome to the reactor

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 80/212

/elcome to the reactor 

' pattern for lightweight

concurrency

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 81/212

concurrency

' B0ent $ri0en

' Threa$s reuse

' Nses nonFblocking Io

Original pattern

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 82/212

Original pattern

http:DD$+re$.an+erbilt$e+!Dschmi+tDFDreactor

siemens p+'

G!ess the a!thor by the +iagram

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 83/212

y g

http:DDgee cs osego e+!D+lDcpBsli+e

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 84/212

In Java,Reactor meansNIO

elector as a m!ltiple8er 

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 85/212

p

Ja.a .ersion Registering

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 86/212

g g

SocketChannel channel= SocketChannel.open();

socketChannel.connect(new

  InetSocketAddress("http://remote.com",

80));

...

Selector selector = Selector.open();

channel.configureBlocking(false);

SelectionKey k = channel.register(selector,SelectionKey.OP_READ);

k.attach(handler);

Ja.a .ersion ispatcher 

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 87/212

p

while (!Thread.interrupted()) {

selector.select();

Set selected = selector.selectedKeys();

Iterator it = selected.iterator();while (it.hasNext())

  SelectionKey k = (SelectionKey)

(it.next();

  ((Runnable)(k.attachment())).run();  selected.clear();

}

4an$ling reactor e0ents iscomplex

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 88/212

complex

'@ee$ to maintain state

')u=ering ' assembling

chunks

'1oor$inating async e0ents

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 89/212

@io libraries

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 90/212

'Cost of them are ser0ers'@etty, gri66ly, etc!

'Apache Cina'Apache 4TT. components

asyncclient'@ing http client

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 91/212

'1lient an$ ser0er nio library

'B0ol0e$ from netty'Latest release Gctober 7K57

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 92/212

@io libraries

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 93/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 94/212

Hing6s async http client

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 95/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 96/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 97/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 98/212

try 2Async4ttp1lient async4ttp1lient O new Async4ttp1lient233 P  Listenable&utureesponseR future Oasync4ttp1lient!prepare<et2  "http://oss.jfrog.org/api/system/ping"3!execute2

A 1 l ti 4 $l 23 P

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 99/212

  new Async1ompletion4an$leresponseR23 P

  G0erri$e  public esponse on1omplete$2esponse response3 P  System!out !println2response!getesponse)o$y233  return response 

  G0erri$e  public void onThrowable2Throwable t3 P  t!printStackTrace23    3  esponse response O future!get23

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 100/212

4A1 1oncepts

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 101/212

'eDuest pro$ucer'esponse consumer

try   (CloseableHttpAsyncClient asyncHttpClient = HttpAsyncClients.createDefault()) {asyncHttpClient.start();Future<HttpResponse>  future   = asyncHttpClient.execute(

HttpAsyncMethods.createet("http://oss.jfrog.org/api/system/ping")!new AsyncByteConsumer<HttpResponse>() {

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 102/212

"#$errideprotected void  onResponseRecei$ed(final  HttpResponse response) {

%yste&.out.println(response.'et%tatusine().'etReasonhrase());*

"#$errideprotected void onByteReceived(final  Char+u,,er bu,!  final  -#Control ioctrl) { *

"#$errideprotected void  releaseResources() { *

"#$errideprotected  HttpResponse buildResult(final  HttpContext context) {

return  (HttpResponse) context.'etAttribute("http.response");*

*! null);HttpResponse response =  future.get();

*

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 103/212

0hoosing beteen ning an+ httpasyncclient

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 104/212

All problems in computer

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 105/212

science can be sol0e$ byanother le0el of in$irection

a0i$

Wheeler

pulic interface "ttp#rovider$ownload"andler {

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 106/212

  void onResponseRecei$ed(int statusCode! Map<%trin'!ist<%trin'>> headers);

  oolean on+ytesRecei$ed(+yte+u,,er bu,);

  void onFailed(/hro0able error);

  void onCanceled();

  void onCo&pleted();*

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 107/212

Fer'ormance

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 108/212

http:DDblogs$atlassian$comD213D7Dhttpclientper'orm

R'c2L1L: a !ni.erse o' its on

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 109/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 110/212

0on'!se+

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 111/212

J!st rea+ some stac)o.er'lo(an+ impro.e yo!r rep as yo! go#

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 112/212

And that onefor

discoveringthat range

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 113/212

header is loston redirect

M!estionC

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 114/212

/hat sho!l+be contentlength hen

!singcompression

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 115/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 116/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 117/212

https:DDgith!b$comDhttp2Dhttp2specDiss!esDL

M!estionC

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 118/212

/hy hen re+irecte+ to 0Hall the ch!n)s start 'rom ,ero

HttpAsyncClient+uilder builder = HttpAsyncClients.custo&();11 add redirect strate'y that copies 2ran'e2 headers! i, existuilder.setRedirect%trategy(ne0 $efaultRedirect%trategy() {

"#$erride

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 119/212

"public 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;

**);

M!estionC

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 120/212

<o many sim!ltaneo!sconnections sho!l+ N

open

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 121/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 122/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 123/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 124/212

M!estionC

/h t6

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 125/212

/hat6srong ith

the'olloing

co+e

bli t ti t i

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 126/212

public static tringenco+e4rl(tring !rltr#   4RAEnco+er$encode(!rltr-.TF-/#  $$$P

eco+e+ 4RAs cannot bereenco+e+ to the same 'orm

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 127/212

http:11exa&ple.co&14uery=ab==c

Cannot be decoded bac a,ter it0as encoded:

http

:11exa&ple.co&14uery=a?@b==c

on6t !se Ba.a$net$4RAEnco+er

?4tilit l ' <%>A '

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 128/212

?4tility class 'or <%>A 'ormenco+ing$ %his class containsstatic metho+s 'or con.erting a

tring to the application/x-www-form-urlencoded >N>E'ormat$

or more in'ormation abo!t <%>A'orm enco+ing- cons!lt the <%>Aspeci'ication$@

 &<0 &lternati.es

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 129/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 130/212

M!estionC

< + N

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 131/212

<o +o Nclose a

soc)etcorrectly

<o har+ can it be to close a soc)et

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 132/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 133/212

<al'close+: no ne c!stomers

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 134/212

He.er bloc) in soc)et close(#

%he other si+e e8pects

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 135/212

%he other si+e e8pectsyo! to clean !p nicely

Nt ill gi.e !p on time o!t

=o! ill ait ('ore.er#

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 136/212

Remember

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 137/212

M!estionC

<o can N

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 138/212

<o can Nrite 'ile partsconc!rrently

' Write to separate (les,combine on (nish

Write to same (le seeking to

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 139/212

' Write to same (le, seeking tothe right position

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 140/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 141/212

4E ile0hannel

Nmplements %eeable+yteChannel

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 142/212

Nmplements %eeable+yteChannel

a$a.nio.channels.'ileChannelBwrite(  a$a.nio.+yte+u,,er src!lon' position)

+onloa+ progress trac)ing

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 143/212

ersistentileFrogressNn'o

a.e the total si,e- sha1- n!mber o' parts

tate o' each part (o''set- si,e- complete+$$$#

ileFrogressNn'o

ileFartFrogressNn'oQ

ile Aoc)ing

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 144/212

&ile locking Le0els

'EC le0el

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 145/212

EC le0el'GS le0el

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 146/212

Fileoc loc ,ileChannel tr oc()

O Ae.el ile Aoc)ing E8cl!si.e

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 147/212

Fileoc loc = ,ileChannel.tryoc();  11onshared: (!on'.MADEA38! false)

if (loc == null) {

  throw new#$erlappin'Fileoc8xception();  *  return loc;*

private Fileoc loc(FileChannel ,ileChannel) throws

O Ae.el ile Aoc)ing – &+.isory e8cl!si.e

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 148/212

private Fileoc loc(FileChannel ,ileChannel) throws-#8xception {  Fileoc loc =,ileChannel.tryoc(on'. MAX_VALUE G ! ! false);

  if (loc == null) {  throw new #$erlappin'Fileoc8xception();  *  return loc;*

/%C

I> Ae.el ile Aoc)ing

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 149/212

EC Le0el &ile Locking

' .re0ent same EC threa$s writing tothe (le when we starte$ closing it

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 150/212

g

' 1losing seDuence>

' elease (le locks

' 1lose channels

' ename a (le to it#s (nal name2remo0e !part3

' Brase progress info

I> Ae.el ile Aoc)ingReentrantReadIriteoc.Readoc write*o'ile+oc, =

r0l.readoc();ReentrantReadIriteoc.Iriteoc close'ile+oc, =

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 151/212

r0l.0riteoc();

public $oid close() thro0s -#8xception {

  this.close'ile+oc,.loc,();*

public int 0rite(int part-ndex! +yte+u,,er bu,) {  i, (9this.write*o'ile+oc,.try+oc,()) {

  thro0 ne0 -lle'al%tate8xception(2File isbein' closed2);  *  ...*

/hat6s ne8t

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 152/212

http/7

' Costly stan$ar$i6ing <oogle#ssp$y

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 153/212

p y

' 4ea$er compression

' multiplexing' .rioriti6ation

' Ser0er push

' Gn the way clear some stu= ' B!g! compresse$ content length

Ease the loa+

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 154/212

Ain)sC

R%>: R0 2L1L4lti t b ) *TTP Th , fi iti 1 id

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 156/212

A Quick Tour

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 157/212

A Quick Tourof Logos

  The Logical Appea

So what exactly is logic? Whocares?

Informally, logic is about saying things that makesense. ou can think of it in that way if you like!

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 158/212

"It#s pretty sunny to$ay, so you shoul$ wear sunscreen!%

&ormally, logic is the art of arguing ' not like a (ghtor $ebate, but by using the information we alrea$yknow to $raw new an$ useful conclusions!

"If it#s sunny to$ay, you shoul$ wear sunscreen!In$ee$ it is sunny to$ay! Therefore, you shoul$ wear sunscreen!%

")ut wait! That *ust looke$ like the exactsame thing you sai$ before, you hack!%

Well yes )ut that#s how an argument looks i

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 159/212

Well, yes! )ut that s how an argument looks iform+ ou can break $own any  argument intothat makes it easier to think about!

If it#s sunny to$ay, you shoul$ wear sunscree

It is sunny to$ay! ------------------------------------------- 

 Therefore, you shoul$ wear sunscreen!

.remises/gi0ens

1onclusion

2.remises always come (rst, an$ the conclusion always c

4ow about a more complexargument?

5! This piece of fresh fruit is fu66y!7! It also has see$s!

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 160/212

8! If a fruit is fu66y, it#s either a kiwi or a peach!

9! .eaches ha0e a pit they $on#t ha0e see$s!

:! So the fruit can#t be a peach!

;! So the fruit must be a kiwi!

Which of the abo0e sentences is a conclusion?

4ow about a more complexargument?

5! This piece of fresh fruit is fu66y!7! It also has see$s!

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 161/212

8! If a fruit is fu66y, it#s either a kiwi or a peach!

9! .eaches ha0e a pit they $on#t ha0e see$s!

:! So the fruit can#t be a peach!

;! So the fruit must be a kiwi!

<oo$ logic lets us cobble together lots of $i=erent pieces of information, an$ tell from

them what#s probably or defnitely true.

)ut what counts as "goo$ logic%?

 That argument was goo$ 2ma$e sense3, becausethe conclusion followe$ from the premises! We#llsee what this means in a moment!

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 162/212

see what this means in a moment!

Why $on#t we look at a bad argument?

)ut what counts as "goo$ logic%?

Some people ha0e fallen o= cli=s an$ li0e$!

Therefore if I *ump o= this cli= I will $e(nitely be (

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 163/212

Therefore, if I *ump o= this cli=, I will $e(nitely be (

"1ome on!

What coul$possibly gowrong?%

)ut what counts as "goo$ logic%?

Some people ha0e fallen o= cli=s an$ li0e$!

Therefore if I *ump o= this cli= I will $e(nitely be (

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 164/212

Therefore, if I *ump o= this cli=, I will $e(nitely be (

 This argument is weak! Although the premise iit#s easy to think of ways 20ery painful ways3 tconclusion coul$ be false! The easiest way tologic is to $o *ust that> try to think of another

2.hilosophers call these counterexamples3!

)ut what counts as "goo$ logic%?

Let#s look at two kin$s of arguments!1. e$ucti0e reasoning>

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 165/212

1. e$ucti0e reasoning>

  All interns can breathe (re! So .hilipcan breathe (re!

Is there a piece of the pu66le missing?

)ut what counts as "goo$ logic%?

Let#s look at two kin$s of arguments!1. e$ucti0e reasoning>

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 166/212

1. e$ucti0e reasoning>

  All interns can breathe (re! .hilip is anintern! So .hilip can breathe (re!

Sometimes you may encounter "hi$$en% statan$ i$eas, which the writer sneaks in but $oe

say outright!

)ut what counts as "goo$ logic%?

Let#s look at two kin$s of arguments!1. e$ucti0e reasoning>

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 167/212

g

  All interns can breathe (re! .hilip isan intern! So .hilip can breathe(re!

 Are the premises true?If so, then the conclusion#s

100% guaranteed true!@o getting aroun$ it+

)ut what counts as "goo$ logic%?

Let#s look at two kin$s of arguments!2. In$ucti0e reasoning>

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 168/212

  I touche$ a sto0e an$ it burne$ me! I $i$this

(fty times, an$ the same thing happene$! 

So thenext time I touch the sto0e, it will burn me! 

Are the premises true?If so, then the conclusion#s

 probably true! There mightstill be exceptions! LIB W4AT?

4ow is this useful to me?

Like Cr! Corgan sai$, the ability to makestrong logical arguments will become more

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 169/212

strong logical arguments will become morean$ more important later on in high schoolan$ college!

.athos an$ ethos are still 0aluable+ )utyour au$ience will be a lot better atDuestioning them! Logos is han$y because,if you use it well, it can#t really be$ispro0e$!

4ow is this useful to me?

)ut e0en better is the superpower to spotweak  logic!

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 170/212

@ext time you watch TE or go online 2withyour parents# permission, of course3, try to

keep track of how many $i=erent argumentsare being pitche$ to you by a$s! 4ow muchinfo is gi0en to you? 4ow much is left out?

What time is it?

A$0enF wait, no! Acti0ity time+.air o= into groups of four! Bach group will recei0e an e

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 171/212

g p g pof a poor argument 2these may be either in$ucti0e or $

With your group, you will ha0e : minutes to try to comone counterexample F one way in which the argumecoul$ be wrong, e0en if the premises are $e(nitely true.oke it full of holes+Also, choose a group representati0e to tell us your reas

2It#s G to imagine unlikely or weir$ explanations$on#t be afrai$ to think outsi$e the box!G$$ly enough, logic has 0ery little to $o with facts!3

Some examples>

 ARGU!"#$ "I pulle$ an allFnighter stu$ying for last weetest, an$ I en$e$ up with an A! Tire$ness must make me

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 172/212

&U"#!R$ What if you got an A because you actually stGr maybe the test was going to be easy for you all along

 ARGU!"#$ "If I play with a$#s power tools, he#ll yell at)ut a$ is yelling at me for something! So I guess I musplaye$ with the power tools!%

&U"#!R$ What if he#s yelling at you for a $i=erent reasscratching the car, or hammerFthrowing the cat onto the

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 173/212

John Keats

"To Autumn" is a poem by EnglishRomantic poet John Keats (31

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 174/212

Romantic poet John Keats (31October 1795 – 23 ebr!ary 121#$

"%o &!t!mn" is the 'inal or) in agro!p o' poems )non as

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 175/212

gro!p o' poems )non asKeats*s "119 o+es"$

"%o &!t!mn" is a poem o' threestan,as- each o' ele.en lines$ /ritten

in 119- the str!ct!re is that o' ano+al hymn- ha.ing three clearly

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 176/212

o+al hymn- ha.ing three clearly+e'ine+ sections correspon+ing to the

0lassical +i.isions o' strophe-antistrophe- an+ epo+e

%he imagery is richly achie.e+th h th i'i ti ' & t

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 177/212

thro!gh the personi'ication o' &!t!mn

Poem

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 178/212

Poem

eason o' mists an+ mello 'r!it'!lness-

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 179/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 180/212

Close bosom-friend of the maturingsun;

Conspiring with him how to load and bless

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 181/212

With fruit the vines that round the thatch-evesrun;

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 182/212

%o ben+ ith apples the moss*+ cottagetrees-

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 183/212

And fill all fruit with ripeness to thecore;

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 184/212

%o sell the go!r+- an+ pl!mp the ha,el

shells

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 185/212

/ith a seet )ernel to set b!++ingmore-

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 186/212

 &n+ still more- later 'loers 'or the bees-

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 187/212

4ntil they thin) arm +ays ill ne.er cease-

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 188/212

For ummer has o!er-brimm!d their clamm"cells#

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 189/212

/ho hath not seen thee o't ami+ thy store

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 190/212

ometimes hoe.er see)s abroa+ may'in+

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 191/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 192/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 193/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 194/212

rose+ ith the '!me o' poppies- hile thy hoo)

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 195/212

pares the ne8t sath an+ all its tin+'loers:

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 196/212

 &n+ sometimes li)e a gleaner tho! +ost )eep

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 197/212

tea+y thy la+en hea+ across a broo)

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 198/212

$r b" a c"der-press% with patient loo&%

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 199/212

%ho! atchest the last oo,ings- ho!rs byho!rs$

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 200/212

/here are the songs o' pring &y- here arethey

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 201/212

%hin) not o' them- tho! hast thy m!sic too-;

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 202/212

/hile barr+ clo!+s bloom the so't+ying +ay

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 203/212

 &n+ to!ch the st!bbleplains ith rosy h!e

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 204/212

%hen in a ail'!l choir the small gnats mo!rn

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 205/212

Among the river-sallows% borne

aloft

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 206/212

r sin&ing as the light wind lives ories;sin)ing

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 207/212

 &n+ '!llgron lambs lo!+ bleat 'rom hilly bo!rn

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 208/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 209/212

%he re+breast histles 'rom a gar+en

cro't

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 210/212

n ga er ng sa os er n e

s)ies$

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 211/212

8/9/2019 Moly to Holly

http://slidepdf.com/reader/full/moly-to-holly 212/212