《Java面试手册》
《Java面试手册》
1.Java
1. 知
样
1) 知
( )
2) 知(1)
(2)
2. 知
1. 知
2. 知
3. 知
is-a class dog extends animal, dog is a
animal.
⾃ -
4. 知
3. 知
们
样
样 样
1. 知
2. 知
(upcast) JVM (downcast)
2.Java
1. Java Java C C++
Java
2. Java Java 然
样 implements
3. Java Java Internet Java
样java net 会 URL然URLConnection然
Socket然ServerSocket Java RMI样
4. Java Java 然 然是了 Java
Java
5. Java Java Java
知 样 ClassLoader 然
:https://blog.csdn.net/shenzixincaiji/article/details/82766104
3. JDK JRE
JDK知Java Development Kit Java Java
JRE知Java Runtime Environment Java Java
4.Java
Tips:boolean 4 1
Java
友
⽣ Java
知
1.
2.
看想
5. main private
”main public ” idea public
void: main
String args 为
7.== equals
== String
.
== comparison : true
== comparison : true
Using equals method : true
false
Using equals method :true
8.Object
Object Object
clone Cloneable
CloneNotSupportedException
equals Object ==
getClass final
wait wait()
wait(long timeout)
1然 notify
2然 notifyAll
3然 interrupt
4然
5然 InterruptedException
notify
notifyAll
toString 为
知https://www.cnblogs.com/remember-forget/p/5971962.html
9. Java ?
Java 知
10.while do
while 事 do/while
事 do
11.char ?
Java Unicode Unicode 16 char 16
Tips: default
13.float f=3.4;
3.4 样double 样float 样down-casting
情 float f =(float)3.4; float f =3.4F
14.short s1 = 1; s1 = s1 + 1; short s1 = 1; s1 += 1;
short s1 = 1; s1 = s1 + 1又 1 int s1+1 int
short short s1 = 1; s1 += 1又+= 为 Java
又Java s1+= 1; s1 = (short)(s1 + 1)
15.& &&
1. &知(1) 又(2)
2.&&:
&&,
16.IntegerCache
System.out.println(a==b);
System.out.println(c==d);
}
}
true
false
/**
* Cache to support the object identity semantics of autoboxing for
values between
* -128 and 127 (inclusive) as required by JLS.
*
* The cache is initialized on first usage. The size of the cache
* may be controlled by the {@code -XX:AutoBoxCacheMax=<size>} option.
* During VM initialization, java.lang.Integer.IntegerCache.high property
* may be set and saved in the private system properties in the
* sun.misc.VM class.
*/
static {
// high value may be configured by property
int h = 127;
String integerCacheHighPropValue =
sun.misc.VM.getSavedProperty("java.lang.Integer.IntegerCache.high");
if (integerCacheHighPropValue != null) {
try {
int i = parseInt(integerCacheHighPropValue);
i = Math.max(i, 127);
// Maximum array size is Integer.MAX_VALUE
h = Math.min(i, Integer.MAX_VALUE - (-low) -1);
} catch( NumberFormatException nfe) {
// If the property cannot be parsed into an int, ignore
it.
}
}
high = h;
private IntegerCache() {}
}
17.Locale
Locale
final
final 又
final ⼼
知 private final
2. finally
finally
finally 知
try try finally
try jvm system.exit(n) finally 样
finally return try catch return return
finally return
3. finalize
finalize() Object protected
GC
finalize() 知
java finalize
finalize() JVM finalize
finalize() GC Roots
finalize GC 样 finalize
19.hashCode() equals()
知
1.equals() hashCode() 友
equals样 hashCode()
hash
2.hashCode() equals() 友
hashCode() hashcode 样 hash
hashCode()
样PS知 知
1. 知
equals hashCode又
2然 友
hashCode HashTable然HashMap然HashSet hash
hashCode
3然 hashCode 友
equals hashCode
“ ” hashCode
hashMap然hasoTable hashSet “ ”
hashCode hashCode
HashMap key hashCode equals true
hashCode equal ObjectA ObjectB name
hashCode name hashCode equals false
5然 hashCode?
hashCode
hashCode equals get hashCode hashCode false
知https://blog.csdn.net/xlgen157387/article/details/88087963
20. ?
现
现 “ ” 现 ” “
现
2
package com.test;
System.out.println("修改⽼老老师的信息后——————");
// 修改⽼老老师的信息
teacher.setName("Games");
System.out.println(student1.getTeacher().getName());
System.out.println(student2.getTeacher().getName());
}
}
拷⻉贝后
edgar
18
riemann
27
修改⽼老老师的信息后——————
Games
Games
知 student1 student2 student1 student2
teacher 现
现 现 现 现 , 现
现 现 现 现
package com.test;
// 改为深复制:
Student3 student = (Student3) super.clone();
// 本来是浅复制,现在将Teacher对象复制⼀一份并重新set进来
student.setTeacher((Teacher2) student.getTeacher().clone());
return student;
}
}
拷⻉贝后
edgar
18
riemann
27
修改⽼老老师的信息后——————
Games
riemann
知
student1 student2 student1 student2 teacher
teacher student1 , 现
21.Java
String然StringBuffer然StringBuilder
23. final
final
24.static 5
样1 样abstract 样static 友
(2) 样static 友
(3) static 友
static ⼼
样4 友
然
new new
然 又
样 然
又
天
样
26.Java
1
2 SoftReference
ReferenceQueue 是了
JVM
3 WeakReference
知
是了 ⽆
4 PhantomReference
是了 没
是了
样ReferenceQueue 是了
28. Java , ?
Java
29. Java ?
Java
30. ?
Serializable ,
31. ?
transient :
32.Java
⽣ 知
java ⽣ 知1.⽣ 又2.
java
1.Java
Collection Java
Set
List List
Queue然Dequeue然SortedSet然SortedMap ListIterator
2.Collection Collections
Collection
List然Set
Collections
知 Collections. sort(list)
4.Collections.sort
Java 6 Arrays.sort() Collections.sort() MergeSort Java 7
TimSort
6.HashMap Hashtable
样1 HashMap⼼ key value null HashTable ⼼
样5 HashTable 事 Map
CocurrentHashMap
7. HashMap TreeMap
Map 然 然 HashMap
HashMap key TreeMap
8. HashMap
HashMap Hash put(key,value) get(key) key
HashMap key. hashCode() hash hash value bucket
hash hash HashMap hash
value hash
9. HashSet
HashSet HashMap HashSet HashMap HashSet
HashSet HashMap HashSet
⼼
10.ArrayList LinkedList
知ArrayList LinkedList
知ArrayList LinkedList LinkedList
知 LinkedList ArrayList
ArrayList
都 ArrayList
LinkedList
12.ArrayList Vector
ArrayList Vector
样1
样2
ArrayList Vector
样1 Vector ArrayList 事
CopyOnWriteArrayList
样2 ArrayList Vector
样3 ArrayList Collections
13.Array ArrayList
Array ArrayList
Array ArrayList ⾃
Array ArrayList addAll然removeAll然iteration ArrayList
15.LinkedHashMap ?
LinkedHashMap HashMap Iterator LinkedHashMap
16.HashMap
HashMap + + 样JDK1.8
知 友 友
(2) HashMap
Java HashMap
Hash
知
map.put("美团","⼩小美");
就 Hash 就 Hash
⼀
就 们 hash Hash map
Hash 就 样Node[] table 友 Hash ⾃
Hash
HashMap JDK1.8
样 8
HashMap 然 然
1. 就
然 然 就 HashMap
HashMap
hash
HashMap
hash ( + ):
⽅方法⼀一:
static final int hash(Object key) { //jdk1.8 & jdk1.7
int h;
// h = key.hashCode() 为第⼀一步 取hashCode值
// h ^ (h >>> 16) 为第⼆二步 ⾼高位参与运算
return (key == null) ? 0 : (h = key.hashCode()) ^ (h >>> 16);
}
⽅方法⼆二:
static int indexFor(int h, int length) { //jdk1.7的源码,jdk1.8没有这个⽅方法,但
是实现原理理⼀一样的
return h & (length-1); //第三步 取模运算
}
Hash 知 key hashCode
hashCode() Hash
hash
HashMap 知
table
n table
2.HashMap put
HashMap put
. table[i] null resize() ⾃ 又
活. table[i] 8 8
又 key value 又
. size threshold ⾃
JDK1.8HashMap put :
48 ++modCount;
49 // 步骤⑥:超过最⼤大容量量 就扩容
50 if (++size > threshold)
51 resize();
52 afterNodeInsertion(evict);
53 return null;
54 }
3.⾃
transfer() Entry
现 Entry
JDK1.8 2 ⾃ ( ⾃
2 ) 2
n table 样a ⾃ key1 key2 key 样b
⾃ key1 key2 key hash1 key1
hash 1bit 0 1
resize bucket
JDK1.8 JDK1.7 rehash 时
JDK1.8
JDK1.8 resize :
17.HashMap
HashMap ( JDK1.7
)知
new Thread("Thread1") {
public void run() {
map.put(7, "B");
System.out.println(map);
};
}.start();
new Thread("Thread2") {
public void run() {
map.put(3, "A);
System.out.println(map);
};
}.start();
}
}
18.JDK1.8 JDK1.7
HashMap key hash Hash
getKey O(1) Hash Hash
Hash 就
O(n) O(lgn) 个 JDK1.8
JDK1.7
Hash
Key 知
Key(int value) {
this.value = value;
}
@Override
public int compareTo(Key o) {
return Integer.compare(this.value, o.value);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass())
return false;
Key key = (Key) o;
return value == key.value;
}
@Override
public int hashCode() {
return value;
}
}
size HashMap样1然10然100然……
10000000 ⽤ ⾃ 知
getKey get
key
知
Hash
Key hashCode HashMap
知
//…
@Override
public int hashCode() {
return 1;
}
}
main 知
18.HashMap ?
(1) ⾃ HashMap map
map ⾃
(2) 1
https://zhuanlan.zhihu.com/p/21673805
https://www.jianshu.com/p/939b8a672070
https://www.jianshu.com/p/c45b6d782e91
https://blog.csdn.net/Mrs_chens/article/details/92761868
https://blog.csdn.net/riemann_/article/details/87217229
https://blog.csdn.net/qq_34626097/article/details/83053004
https://blog.csdn.net/u010887744/article/details/50575735
&
1.error exception
error java
Java 下
exception 爱还然
2. 5 RuntimeException
(1)Java.lang.NullPointerException ; 知
(2)Java.lang.NumberFormatException 为 ; 知 为
为
(3)Java.lang.IndexOutOfBoundsException
(4)Java.lang.IllegalArgumentException
(5)Java.lang.ClassCastException
3.throw throws ?
throw知
(1)throw
(2)throw throw
throws知
(1)@throws
(2)throws 爱
(3)throws
4.Java
:
( (CheckedException)) ( (UnCheckedException))
5.
Exception RuntimeException
throw
initCause
6.Java
: try catch throws
1. try catch:
try{} catch{} 爱
2.throw throws知
throw throw
我
throws
7. Java ?
Java 样reflection
Java
8.
1. JDBC 会以
2. Web Sevlet
3. Eclispe 道
4. 发 Spring
9.java
又
又
又
又
10.Java
java.lang.Class; //类
java.lang.reflect.Constructor;//构造⽅方法
java.lang.reflect.Field; //类的成员变量量
java.lang.reflect.Method;//类的⽅方法
java.lang.reflect.Modifier;//访问权限
11.
知
知 ⼩知 JVM java
12. ?
1.
Class.forName(“ ”); 知com.mysql.jdbc.Driver Driver jvm
https://blog.csdn.net/qq_37875585/article/details/89340495
https://www.cnblogs.com/whoislcj/p/6038511.html
IO&NIO
1. IO
现
(process)
2.java
知 为 然 知 然
3.
1. 为 IO
年 样
2. IO 为 为 为
4.
BufferedInputStream BufferedOutputStream
为 BufferedReader BufferedWriter
5. IO
不 IO然 不 IO然 IO然 以 IO IO
6. IO blocking IO
IO 不 现
recvfrom kernel
IO 我 知 现 样 IO
UDP 我 知
现 kernel block
blocking IO IO block
7. I/O nonblocking IO
不 I/O 不 I/O
I/O
CPU
不 IO IO IO
不 IO
CPU 又 CPU (select
poll ) I/O 不
I/O 不 IO IO 不
select select IO
epoll IO 又
8.I/O (IO multiplexing)
I/O IO, select poll epoll
socket socket functon 不
IO不 不 IO IO
IO 又 IO
( )
select
IO IO bloking IO
socket 不 socket select不 不 IO socket IO 不
9. I/O
为 SIGIO sigaction
不
SIGIO recvfrom
10. I/O(asynchronous IO)
IO ( )
aio_read样Posix I/O aio lio 然 然
样 read 3 然
不 I/0 现
read kernel
asynchronous read block kernel
现 kernel
signal read
11.NIO IO
NIO New IO 会 JDK1.4 NIO IO
NIO NIO IO Java API NIO
NIO NIO
12.NIO IO
NIO 么 IO ⼈ NIO NIO
NIO IO 友
NIO
IO
⼀
13.NIO
channel然buffer然selector
14. channel
Channel样 然
Java NIO I/O
I/O I/O
FileChannel然SocketChannel
知
Stream 样 InputStream OutputStream
不 I/O
15.Java NIO ?
FileChannel知
DatagramChannel: UDP
SocketChannel知TCP
ServerSocketChannel知 TCP
16.Buffer ?
NIO byte Buffer API
17. Buffer
buffer 知ByteBuffer然CharBuffer然DoubleBuffer然FloatBuffer然IntBuffer然
LongBuffer然ShortBuffer 可 样4 8 Boolean buffer
MappedByteBuffer
18.buffer
1 然 buffer
2 然 buffer.flip()
3 然 buffer
4 然 buffer.clear() buffer.compact()
// 创建⼀一个容量量为48的ByteBuffer
ByteBuffer buf = ByteBuffer.allocate(48);
// 从channel中读(取数据然后写)⼊入buffer
int bytesRead = inChannel.read(buf);
// 下⾯面是读取buffer
while (bytesRead != -1) {
buf.flip(); // 转换buffer为读模式
System.out.print((char) buf.get()); // ⼀一次读取⼀一个byte
buf.clear(); //清空buffer准备下⼀一次写⼊入
}
19.Selector ?
Selector样 样
select()
20.
4 知
Accept知
Connect知
Read知
Write知
21. Selector
不 I/O 样 不 I/O 样 CPU Selector
起 不 Selector
Read select()
CPU
22.Selector Channel
https://www.cnblogs.com/sharing-java/p/10791802.html
https://blog.csdn.net/zengxiantao1994/article/details/88094910
https://www.cnblogs.com/xueSpring/p/9513266.html
1. ?
2.
3. ?
1. Thread
2. Runnable
3. Callable Future
5. NEW
new Thread start
6. RUNNABLE
start runnable
cpu 样RUNNABLE)
7. RUNNING
cpu
8. BLOCKED
9. TERMINATED
TERMINATED
TERMINATED :
JVM Crash
10.
11.i—————— System.out.println()
:
private int i = 5;
@Override
public void run() {
System.out.println("i=" + (i——————) + " threadName=" +
Thread.currentThread().getName());
}
t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
}
}
i=5 threadName=Thread-1
i=2 threadName=Thread-5
i=5 threadName=Thread-2
i=4 threadName=Thread-3
i=3 threadName=Thread-4
println() :
12.
System.out.println(Thread.currentThread().getName());
13.
public class XKThread extends Thread {
@Override
public void run() {
System.out.println("run run run is " + this.isAlive() );
}
}
}
14.sleep()
sleep() “ ” 样
15. ?
jdk1.5 TimeUnit, sleep
2 22 55 899
Thread.sleep(8575899L);
TimeUnit.HOURS.sleep(3);
TimeUnit.MINUTES.sleep(22);
TimeUnit.SECONDS.sleep(55);
TimeUnit.MILLISECONDS.sleep(899);
16.
run
Thread.interrupt() ,
17.interrupted isInterrupted
interrupted : ,
isInterrupted 知
18.yield
cpu cpu
cpu
:(cpu )
@Override
public void run() {
long beginTime = System.currentTimeMillis();
int count = 0;
for (int i = 0; i < 50000000; i++) {
count = count + (i + 1);
}
long endTime = System.currentTimeMillis();
System.out.println("⽤用时 = " + (endTime - beginTime) + " 毫秒! ");
}
⽤用时 = 20 毫秒!
yield (cpu )
@Override
public void run() {
long beginTime = System.currentTimeMillis();
int count = 0;
for (int i = 0; i < 50000000; i++) {
Thread.yield();
count = count + (i + 1);
}
long endTime = System.currentTimeMillis();
System.out.println("⽤用时 = " + (endTime - beginTime) + " 毫秒! ");
}
}
:
19.
cpu cpu
Java 1 10 5 知
java.lang.IllegalArgumentException
20.
a b b a
21.
Thread.sleep(2000);
low.stop();
high.stop();
System.out.println("low = " + low.getCount());
System.out.println("high = " + high.getCount());
} catch (InterruptedException e) {
e.printStackTrace();
}
@Override
public void run() {
while (true) {
count++;
}
}
}
@Override
public void run() {
while (true) {
count++;
}
}
}
low = 1193854568
high = 1204372373
22.
Java
23.
Java 下
JVM
24.Java
GC样是了
25.
Thread.setDaemon(true)
PS:Daemon
@Override
public void run() {
try {
SleepUtils.sleep(10);
} finally {
System.out.println("Java⼩小咖秀 daemonThread finally run …");
}
}
}
}
finally
26.
样 Java
27.join
join join a, b , a
b blocked
28. synchronized?
synchronized
29.synchronized jvm
monitor enter monitor exit
30.synchronized ?
31.synchronized ?
—————>
—————> Class
—————> synchonized
32.Java
synchronized Java 下 3 (Word)
2
Tips:32 下 4
33.Java
34.Java
32 JVM Mark Word
35.Mark Word
Mark Word
64 下 Mark Word 64bit
36.
Java SE 1.6 “ ” “
Java SE 1.6 4 知 然 然 然
37.
吃 ID, cas
Mark Word
Mark Word
1样 ), cas cas
38.
java6 7
-XX:BiasedLockingStartupDelay=0
39.
JVM :-XX:-UseBiasedLocking=false,
Tips:
40.
jvm 吃 Mark
Word cas Mark Word
到
41.
cas displaced Mark Word
42.
43.
44.Java
Java cas JVM CAS CMPXCHG
到CAS CAS
45.CAS 3
ABA
46. ABA
知
cas A, B,
A, cas
47.CAS
jvm pause
然 (de-pipeline), cpu
0
然 cpu cpu
48.CAS
然
49.volatile
volatile synchronized, “ “
50. /
51.wait
wait() wait() Object
“ ” wait()
wait
wait()
52.notify
notify() Object
wait
notify
53.notify/notifyAll
notify notifyAll
54. /
synchronized(obj) {
while(条件不不满⾜足) {
obj.wait();
}
执⾏行行对应逻辑
}
synchronized(obj) {
改变条件
obj.notifyAll();
}
55.ThreadLocal
56.ThreadLocal
get(), set(T)
未设置过值
Java⼩小咖秀
Tips: null
知
public class ThreadLocalExt extends ThreadLocal{
@Override
protected Object initialValue() {
return "Java⼩小咖秀";
}
Java⼩小咖秀
58.Lock
Java5 synchronized Java5
Lock
59.Lock synchronized
60. ReentrantLock
61.
不
然 n n
62.ReentrantLock
:
63.
为
FIFO
64.
Java ReentrantReadWriteLock
65.LockSupport
不
66.Condition
Object Lock /
67.Condition
:
68.ArrayBlockingQueue?
不 FIFO
69.PriorityBlockingQueue?
不 不 不
70.DelayQueue?
不 Delayed
Comparable
71.Java
ConcurrentHashMap然CopyOnWriteArrayList 然CopyOnWriteArraySet 然
ConcurrentLinkedQueue然
ConcurrentLinkedDeque然ConcurrentSkipListMap然ConcurrentSkipListSet然ArrayBlockingQueue然
LinkedBlockingQueue然LinkedBlockingDeque然PriorityBlockingQueue然SynchronousQueue然
LinkedTransferQueue然DelayQueue
72.ConcurrentHashMap
HashMap,java7 16 Java8
CAS 8 样 jdk
73.ConcurrentLinkedQueue
cas
样 jdk
74.
不 不
1然 不 知 不
2然 不 知
75.
不
然
76.Java
77.Fork/Join
java7 发
发
78.
他
他
他 他
79.
知
80.Java Atomic ?
AtomicBoolean:
AtomicInteger:
AtomicLong:
81.Java Atomic ?
AtomicIntegerArray:
AtomicLongArray:
AtomicReferenceArray:
AtomicIntegerArray:
82.Java Atomic ?
AtomicReference :
AtomicReferenceFieldUpdater:
AtomicMarkableReference: boolean
AtomicMarkableReference(V initialRef,boolean initialMark)
83.Java Atomic ?
AtomiceIntegerFieldUpdater:
AtomiceLongFieldUpdater:
AtomiceStampedFieldUpdater:
84.JDK
: CountDownLatch然CyclicBarrier然Semaphore
: Exchanger
85.CountDownLatch
⼼
CountDownLatch int n n
:
countDown() : n 1
await() : 不 n 0
tips: 0 0 await 不
86.CyclicBarrier
样 不
吧
87.CountDownLatch CyclicBarrier
CountDownLatch知
知 n
CyclicBarrier知
知 样 reset() )
知n
88.Semaphore
89.Exchanger
Exchanger
exchange() exchange
Exchanger
90.
知
知
知 然 然
91.
1然 -> ->
2然 -> ->
3然 ->
->
4然
92.
1.corePoolSize:
2.maximumPoolSize: ⼼
3.keepAliveTime:
5.workQueue: 不
不 知
ArrayBlockingQueue: 不
LinkedBlockingQueue: 不
SynchronizedQueue: 不
PriorityBlockingQueue: 不
6.threadFactory知
7. handler:
AbortPolicy
AbortPolicy:
CallerRunsPolicy:
DiscardOldestPolicy:
DiscardPolicy:
RejectedExecutionHandler
93.
execute() submit()
execute():
94.
shutdown() shutdownNow()
interrupt
shutdownNow STOP,
shutdown shutdown
shutdown shutdownNow
95.
cpu 然IO
知
cpu , n+1
io 2n
io cpu
->
->
Runtime.getRuntime().availableProcessors() cpu
96.Executor
JDK5 Runnable Callable, Executor发
97.Executor
ThreadPoolExecutor : Executors
3 ThreadPoolExecutor知SingleThreadExecutor然FixedThreadPool然
CachedThreadPool
ScheduledThreadPoolExecutor 知 Executors
2 ScheduledThreadPoolExecutor知ScheduledThreadPoolExecutor然
SingleThreadScheduledExecutor
98.FixedThreadPool
corePoolSize ,keepAliveTime
0
1. corePoolSize,
2. corePoolSize, LinkedBlockingQueue
3. 1 LinkedBlockingQueue
LinkedBlockingQueue 样 Integer.MAX_VALUE)
1. corePoolSize corePoolSize
2.maxnumPoolSize
3.keepAliveTime
5. OOM
99.SingleThreadExecutor
worker Executor
FixedThreadPool.
100.CachedThreadPool
2. maximumPool maximumPool
SynchronousQueue.poll (keepAliveTime TimeUnit.NANOSECONDS) ⽇1
CachedThreadPool execute()
3. ⽇2 SynchronousQueue.poll (keepAliveTime
TimeUnit.NANOSECONDS) poll SynchronousQueue 60
60 ( ⽇1)
; 60 ,
CachedThreadPool
太Java 感
太Java 感
太Java 感
JVM
2.
java -XX:+TraceClassLoading
Java -verbose
3. class 10 ?
MagicNumber
Version
Constant_pool
Access_flag
This_class
Super_class
Interfaces
Fields
Methods
Attributes
4. jvm
5.
然
然 然 然 也 们
6.Java
下 Java 又
然 然 然
吃 下
7.
下 下 下 Java
下 Native
8.Java
Java 下 Java 下
Tips知 JIT 然
9.
下 然 然 然
10.
Class 然 然 然
样Constant PoolTable 为
11. StackOverflowError?
下 ⼼ StackOverflowError
12.Java7 Java8
Java8 样Metaspace 样Native memory)
13.
(Heap) 样Stack) Java 后
Java
14.
下 Java 下
OutOfMemoryError
15.
OutOfMemoryError
16.
gc roots 是了
17.
18. OutOfMemoryError
下 ⾃ OutOfMemoryError
19. StrackOverflowError?
20. ?
-XX:MaxDirectMemorySize Java
21.Java
= + Java8 Permanent Generation
22.Edem : from : to ?
Edem : from : to = 8 : 1 : 1
–XX:SurvivorRatio
23.
GC 是了 GC 是了
是了 我
24. ?
a, a, a 1 1
0
25.
(
)
instanceOopDesc Mark World 是了
26.JVM
- 样Mark_Sweep)
(Copying)
- 好 样Mark-Compact)
27. -
知
是了
28.
:
29. -
30.
下 是了 “ ”
31.
是了 是了
32.Stop The World?
是了 Sun "Stop The World"
33.Serial ?
stop the world 是了 stop the world ,
34.PartNew ?
Serial Serial
“-XX:+UseParNewGC” ParNew
36.Parallel Scavenge?
PartNew
(Thoughput CPU /CPU
= /( +是了 ))
CPU
2 , cpu
: -XX:MaxCcPauseMillis -XX:GCTimeRatio
37.Parallel Old ?
Parallel Scavenge - JDK 1.6
38.CMS ?
Concurrent Mar Sweep
- 是了
39.CMS ?
1. (stop the world)
2.
3. (stop the world)
4.
GC Roots
Gc Roots Tracing
41.CMS
知
cpu
是了
42.G1 ?
Garbage First jdk 1.6_update14 g1
G1 -
M 是了
N java(rtsj) 是了
42. G1
是了 g1 Java
样 然 没 是了
⼼ 是了
43.
jps (Jvm process status tool ), ps
下 (Main Class,main()
下 ID
-q lvmid,
-m 下 main()
-l Jar Jar
-v 下 JVM
44.
jstat(JVM Statistics Montoring Tool) 下
下 然 然是了 然jit
interval
count
option 下 3 知
是了
45.jstat
-class 然 然
-gcutil -gc
-gccause -gcutil GC
-gcnew GC
-gcnewcapacity -gcnew
-gcold GC
-gcoldcapacity -gcold
-compiler jit 然
45. ?
jinfo(Configuration Info for Java) 下
jps -v 下
46.
jmap(Memory Map for Java) 样 heapdump dump
finalize Java 然
-heap Java 然 然
-histo 然 然
-F 下 -dump dump
47.
jhat ( JVM Heap Analysis Tool) jmap
48.
jstack(Stack Trace for Java) 下 样 thread dump
javacore 下
-F
-l
-m C/C++
49.
JConsole VisualVM JDK
50. ?
-感 -感 -感 -感 -感 -感
知
太 JVM & G1 GC感
太 Java 下 知JVM ⼦感
太 Java 下 知JVM 最 感
Linux
1. Linux
UNIX · · 1991
Minix Unix POSIX Unix 然 然
CPU Unix 然 32 64
2.Linux
3.
然
4. shell
GNU bash shell linux
shell
5.bash
linux shell GNU man linux
man
6.
7. ?
知 下 下
着 (/) /usr/local
知⼼
: /usr/local
➜ local ls
Caskroom Frameworks bin go lib sbin var
Cellar Homebrew etc include opt share
➜ local cd go
( ):
为(.) : ;
为(..) :
8.
pwd
9.
: cd destination
destination :
10. ? ?
ls 知
➜ local ls
Caskroom Frameworks bin go lib sbin var
Cellar Homebrew etc include opt share
ls , ls -F
样 /) 样 /)
ls -R
11. ?
:touch
: touch …
➜ test touch a
➜ test ls
a
➜ test touch b c
➜ test ls
a b c
知mkdir
: mkdir …
➜ test mkdir aa
➜ test mkdir bb cc
➜ test ls
a aa b bb c cc
➜ test ls -F
a aa/ b bb/ c cc/
12. ? ?
: rm destination
-i ,-r -f
rm ,
➜ xktest rm jdk
rm: jdk: is a directory
➜ xktest rm -r jdk
➜ xktest ls
rm -i , -i
rm -rf 说**
13.
➜ xktest ls java*
javaxiaokaxiu
javaxiaokaxiu java (tab) javaxiaokaxiu,
14.
: cp source target
target -i
,n y
➜ xktest cp a c
➜ xktest cp -i a c
overwrite c? (y/n [n]) y
➜ xktest ls
a c
15.
知 mv soucre target
➜ xktest ls
➜ xktest touch java
➜ xktest ls
java
➜ xktest mv java java1.8
➜ xktest ls
java1.8
➜ xktest ls
java1.8
➜ xktest mkdir jdk
➜ xktest mv java1.8 jdk
➜ xktest ls -R
jdk
./jdk:
java1.8
16.
下 下
17. ?
: file destination
18.
: cat destination
-n -b 样 )
3 start
4 stop
5 restart
6 end
19.
: tail destination
10 -n n
: head destination
10 -n n
20. ?
sort sort
为
: sort destination
sort -n -n
sort -M Jan然Feb然Mar -M
21.
: grep [options] pattern [file]
-v
stop
end
-n
-c
22. ?
23. ?
.gz
好 : gzip destination
: gunzip destination
➜ apache gunzip tomcat.gz
➜ apache ls
tomcat
24.Linux ?
zip 好 ⽣ tar
25. ?
history
26. ? ?
alias -p
[root@iz2ze76ybn73dvwmdij06zz ~]# alias -p
alias cp='cp -i'
alias egrep='egrep —color=auto'
alias fgrep='fgrep —color=auto'
alias grep='grep —color=auto'
alias l.='ls -d .* —color=auto'
alias ll='ls -l —color=auto'
27.
bash shell (environment variable) shell
⼼ shell
bash shell :
知 shell shell
知 shell
28. ?
/etc/passwd
UID( )
ID(GID)( )
( )
HOME
shell
29.
[root@iz2ze76ybn73dvwmdij06zz ~]# useradd -D//查看系统默认创建⽤用户信息
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
[root@iz2ze76ybn73dvwmdij06zz ~]# useradd xiaoka//添加⽤用户
30.
31. ? ?
[root@iz2ze76ybn73dvwmdij06zz xiaoka]# ls -l
总⽤用量量 0
-rw-r—r— 1 root root 0 4⽉月 21 13:17 a
-rw-r—r— 1 root root 0 4⽉月 21 13:17 b
-rw-r—r— 1 root root 0 4⽉月 21 13:17 c
-rw-r—r— 1 root root 0 4⽉月 21 13:17 d
-rw-r—r— 1 root root 0 4⽉月 21 13:17 e
1然 :
-
d
l
c 为
b
n
2然 为 :
r
w
x
3然 3 3 :
31. ?
chmod options mode file
32. ?
33. ?
: yum list installed
34. ?
35.vim ?
:
们 :
h: 为
j: ( )
k: ( )
l: 为
vim :
PageDown( Ctrl+F):
PageUp( Ctrl+B):
G:
num G: num
gg:
vim:
q:
q!:
w filename:
wq:
36. ?
df 年
-m 快 G g
[root@iz2ze76ybn73dvwmdij06zz ~]# df
⽂文件系统 1K-块 已⽤用 可⽤用 已⽤用% 挂载点
devtmpfs 1931568 0 1931568 0% /dev
tmpfs 1940960 0 1940960 0% /dev/shm
tmpfs 1940960 720 1940240 1% /run
tmpfs 1940960 0 1940960 0% /sys/fs/cgroup
/dev/vda1 41152812 9068544 30180560 24% /
tmpfs 388192 0 388192 0% /run/user/0
du 然 然 年
[root@iz2ze76ybn73dvwmdij06zz src]# du
4 ./debug
4 ./kernels
12
37. ?
ps
ps
[root@iz2ze76ybn73dvwmdij06zz ~]# ps
PID TTY TIME CMD
10102 pts/0 00:00:00 bash
10131 pts/0 00:00:00 ps
38.
ps top
3 : 1 然 5 15
1 15
39. ?
Ctrl + c
40.
Ctrl + c
41. ?
kill TERM(
42.
ping ping ( IMCP ECHO REQUEST)
⼼
ping 样 1
43. ?
netstat -ntulp|grep 8080
-t (tcp) tcp
-u (udp) udp
-n
-l Listen( )
-p
44.
find ( )
find
name :
:
[root@iz2ze76ybn73dvwmdij06zz ~]# find ~ -type d | wc -l
7340
find :b 然c 为 然d 然f 然l 为
45.
centos7
然 :/etc/hostname
46. ip 8080 ?
47. ip ?
/etc/hosts
48. sed 5 ? ?
5 :
:
[root@xiaoka ~]# cat story
Long ago a lion and a bear saw a kid.
They sprang upon it at the same time.
The lion said to the bear, “I caught this kid first, and so this is mine.”
[root@xiaoka ~]# cat story
They sprang upon it at the same time.
The lion said to the bear, “I caught this kid first, and so this is mine.”
为 :
49. ?
tomcat :
50. awk 2 3 ?
➜ apache awk 'NR==3{print $(NF-2)}' story
this
➜ apache cat story
Long ago a lion and a bear saw a kid.
They sprang upon it at the same time.
The lion said to the bear, “I caught this kid first, and so this is mine.”
太 Linux 感
太 感
太Linux shell ( 3 感
太Linux 感
Mysql
1. ?
会 “ 然 得会” 然 然
然
2. ?
知
3.MySql ?
MyISAM然 InnoDB然BDB然MEMORY然MERGE然EXAMPLE然NDB Cluster然 ARCHIVE然CSV然
BLACKHOLE然FEDERATED
Tips:InnoDB BDB
4. 2
1.Myisam Mysql create
Myisam
MyISAM 年 ⾃ .frm ( )
然.MYD (MYData )然.MYI (MYIndex )
io
2.InnoDB 然 这 也 Myisam
InnoDB 年
6.
, ENGINE=xxx
6.
: ,
.
:
2. InnoDB: ACID
3. Memory: RAM
4. Merge:⼼ MySQL DBA MyISAM , 1
得 VLDB
7.
:
: , :
1. MyISAM
MyISAM
2. MEMORY
MEMORY CHAR VARCHAR
CHAR
3. InnoDB
VARCHAR
InnoDB (
) CHAR VARCHAR
CHAR
VARCHAR VARCHAR 年 I/O
9.Mysql
mysql 为 ( show character set mysql 为 )
然 会然 为
10. ?
, 为 为 然
,
11.
会 然 会
12.
1. WHERE
SELECT
2. ⼰ ⼰
3. ,
CHAR(200) 10 20 为 ⼰
4. n MySQL n
(
n 为 )
5. 年
, ,
MySQL
MySQL
13.MySql ?
1. BTREE
2. HASH
3. FULLTEXT
4. R-Tree
1然 样clustered index
2然 样non-clustered index
1. 知
2. 知 + 样 null
3. 知 + 样 null +
4. 知
5. 知
14.Hash B+ :
hash hash , , hash ,
.B+ ⼀ . ,
, .
hash ( ), .
hash hash , , .
B+ 来 ( , , ), .
hash , .
hash . hash .AAAA
AAAAB .
hash , B+ 为 ( 什 , )
.
hash , . , , hash
, . B+ , ,
.
, , B+ . hash .
15. ?
, 多 , ,
.
16. ?
17.MySQL id ?
id
18.sql
: 为 sql sql
19. 3NF ?
1NF 会
2NF ⼰ ⼰ ⼰
3NF 今 今
20. NULL ?
NULL , ''( 为) NOT NULL ⼼
21. ?
会 MySQL
22. 4
4 样ACID 知
Atomicity
Consistency
Isolation 会⼼
Durability
23.
READ_UNCOMMITTED
然 然
READ_COMMITTED
然
REPEATABLE_READ
样
然 然
SERIALIZABLE
然 然
24.InnoDB ?
样REPEATABLE-READ
25.
会
会
26.
27.
28.
:
username知
host知 localhost 为%
password知
databasename: 会
tablename: *
29.
desc table_name;
30.Mysql
1.delete : 很
3.drop:
31.like ?
Xxx% %xxx
32.
33.
34.
( ) ‘ ’
35.
36.
样 +
-感 什 -> 什
37. ?
38.Mysql
39.
40.
NULL
为 like 为. %xxx
mysql .
, , 为 , .
41.MVVC
MVCC InnoDB MVCC
样
样system version number
42.sql
会
sql
sql “ ”
sql
43. select ?
explain sql;
44.explain
然 id
SQL
id
然select_type
然table
<unionM,N>: id M N UNION
: id N FROM
: id N
然type
1然system
2然const
join const
会
3然eq_ref
ref ref
eq_ref ref
4然ref
ref 样
5然 fulltext
mysql
6然ref_or_null
ref null
7然index_merge
and or
ref_or_null range
8然unique_subquery
where in
IN ref知
value IN (SELECT primary_key FROM single_table WHERE some_expr)
9然index_subquery
unique_subquery
10然range
=, <>, >, >=, <, <=, IS NULL, <=>, BETWEEN, IN() like 为
11然index
12然all
然possible_keys
然Key
key MySQL 样 )
然key_len
然ref
然rows
rows mysql 样
然Extra
MySQL , 知
Using where:
mysql
很
Using temporary知 MySQL
Using filesort知MySQL “ ”
Using join buffer知
知https://www.jianshu.com/p/8fab76bbf448
45.MySql
16
46. ?
会 , ,
ID . , .
NULL columns require additional space in the rowto record whether their values are NULL. For
MyISAM tables, each NULL columntakes one bit extra, rounded up to the nearest byte.
null , 为 .
48.varchar(10) int(10)
varchar 10 , , int 10 ,
10 0新 . ,int(1) int(10) ,
49. ?
(View) 下 会
: 然
很
: ⼼
: ⽤
;
50.count(*) ?
MyISAM : 年 count(*)
InnoDB : count(*)
太 MySQL感
太 MySql感
太MySQL 样 5 )感
太MySQL 感
知MySQL 45
Spring
1.Spring ?
Spring发 Spring JavaBean
EJB 然 更 Java Spring
2.Spring
20
3.Spring
4.Spring ?
知
Spring
IOC Spring, 更 更
5. Spring5
spring5 发 java8
http/2
Spring Web MVC API
Spring WebFlux
Kotlin
6.IOC?
然 ( )然 然
7. ?
Spring IoC
8.IOC
1.
2.setter
3. 样
9.IOC
知
更 然
⽇
样 Spring
10.bean ?
1.Spring bean
9. bean ,
11.Spring
xml
Java
13. AOP( )
AOP Aspect Oriented Programming 好 知
14.
(Before):
(After):
(After-returning):
(After-throwing):
要 (Around):
16. Pointcut)?
AOP发 ⼼
( )
17. (Aspect)?
18. (Weaving)?
19. Introduction
︎ ⼼
20.
知 AspectJ
知 JVM
AspectJ 5 (load-time weaving LTW)
知 AOP
Spring AOP
21.AOP
JDK CgLib AOP
CgLib
22. MVC
MVC Model View Controller (model)次 (view)次 (controller) 好
然 然
MVC 然
23. SpringMVC?
SpringMVC Spring发 MVC 发
24.SpringMVC
DispatcherServlet
25.SpringMVC
DispatcherServlet : 的
Handler : ,
ViewResolver :
26.SpringMVC
1. DispatcherServlet
3. 吧
5. Handler
8. ViewResolver View
9. View DispatcherServlet
10.DispatcherServlet View 给
11.DispatcherServlet
27.SpringMVC
1. Spring
2. (jsp,freemaker)
3.
4.
5. 去
Tips:Jsp
28. bean
29.Spring
(component scanning):Spring bean
(autowiring):Spring bean
30.
no -
byName 知
byType 知
default知 default-autowire
31. Bean
@Component
@Service
@Repository
@Controller
32. Java
⼼
⼼
String
< map >
33.Spring ORM
1. Hibernate
2. iBatis
3. JPA (Java Persistence API)
4. TopLink
5. JDO (Java Data Objects)
6. OJB
34.@Repository
Dao bean
35.@Value ?
然 然
36.@Controller ?
37.
@Aspect
38. web
@RequestMapping
39.@ResponseBody
response body json然xml
40.@ResponseBody + @Controller =?
@RestController
41.
@PathVariable
42.@Cacheable
43.
@CacheEvict
44.@Component
⽣
45.BeanFactory ApplicationContext
46.@Qualifier
bean
@Qualifier @Autowired bean
47. ?
@Transaction
48.Spring
知
xml
样 @Transaction
49.
让
50.Spring
太Spring in action 4感
太SPRING 感
太Spring 感
太Spring5 感
https://spring.io
Mybatis
1. Mybatis?
MyBatis SQL 然 发
JDBC MyBatis XML
MyBatis SQL SQL SQL
Java
2.Hibernate
Hibernate POJO 会 xml 会
pojo 会
xml
会 xml
Session
Session
3.Hibernate
sql
sql sql pojo
4.Mybatis
1. sql
2. jdbc sql
3. sql Java sql
4. jdbc, sql
5. 会orm
5.Mybatis ?
sql sql
sql 会 会
6. Mybatis?
然 发 Mybatis
7.Mybatis
SqlSessionFactoryBuilder( ): SqlSessionFactory
SqlSessionFactory样 : SqlSession
8.#{} ${}
${} 为 #{} #{} sql
9.Mybatis 9
if
c h o o s e (when 然 oterwise)
trim (where然 set)
foreach
bind
10.xml
select|insert|updae|delete|resultMap|parameterMap|sql|include|selectKey 9
sql sql
11.Mybatis
知 sql
知 sql sql
12.Mybatis sql
Mybatis sql Xml sql
sql
13.Mybatis ? ?
1 Mybatis RowBounds sql
Mybatis
2 知 Mybatis 吧 吧
sql sql
知select from student 吧 sql 知select t. from 样select from student t
limit 0 10
14. ?
知
int insert( );
Xml知
sql
</insert>
15. Mapper ?
MyBatis Mapper
16. xml ?
xml
17.
mapUnderscoreToCamelCase=true
18.
然 : order_num
然 真 17
19.
association 让
column: ( ) 让 column={propl=coll ,
prop2=col2}, propl prop2 让
20.like
样1 '%${value}%'
样2 CONCAT('%',#{value},'%')
样4 bind
LIKE #{pattern}
21.Mybatis
EnumTypeHandler EnumOrdinalTypeHandler
<typeHandlers>
<typeHandler handler="org.apache.ibatis.type.EnumOrdinalTypeHandler"
javaType="枚举类(com.xx.StateEnum)"/>
</typeHandlers>
22.SqlSessionFactoryBuilder ?
xml Java SqlSessionFactoryBuilder SessionFactory,
SessionFactory,
23. ?
Map < select > flushCache=true
24.
<settings>
〈 !⼀一其他⾃自⼰己直⼀一 〉
<setting name=” cacheEnabled” value=” true ” />
</settings>
true
false
25. Mybatis
1 Mybatis ParameterHandler然ResultSetHandler然StatementHandler然
Executor 4 Mybatis 吧
吧 4 吧
InvocationHandler invoke() 吧 吧
2 Mybatis Interceptor intercept()
吧
26.
eviction ( )
LRU( ):
IFO( 〉:
SOFT( ): 是了
WEAK ( ): 是了
27.Mybatis Xml id ?
namespace id namespace
EhCache
年
下 年
RMI然 API
.
知
太 MyBatis 感
太 MyBatis 感
太MyBatis 感
Nginx
1. nginx?
Nginx HTTP IMAP/POP3/SMTP
:http://nginx.org
2.nginx
; 为 . ⼀
. FastCGI ⼀ . gzipping, byte ranges, chunked
responses, SSI-filter filter FastCGI SSI
SSL TLSSNI.
Nginx 博 , 7*24
Nginx ⾃
Upstream Filter
⼀
3.nginx ?
nginx
nginx -s stop nginx -s quit
./sbin/nginx -s reload( ) service nginx reload
.nginx -c /usr/local/nginx/conf/nginx.conf
nginx nginx -v
nginx -t
nginx -h
4. ?
events {
# multi_accept on;
}
5.nginx
5
1. 样
down
2.
weight
3.IP_hash 样IP
ip hash session
4.url_hash
5.fair
6.nginx ?
master-worker master-worker master
worker
7.
#
error_page 500 502 503 504 /50x.html;
8. ?
location =
location = /get {
#规则 A }
9.
location
= ^~, /
10.
location = / {
proxy_pass http://tomcat:8080/index
11.
location ~* \.(js|css|jpg|jpeg|gif|png|swf)$ {
if (-f $request_filename) {
expires 1h;
break;
}
}
12.
location ^~/path/ {
deny all;
}
13.nginx
http upstream webserver proxy-web
webserver 然 ; serverr
下 下 web location url
web web server
14.
Upstream proxy_nginx {
server{
listen 80;
server_name xiaoka.com;
location / {
15.
http {
……….
keepalive_timeout 60; ###设置客户端连接保持会话的超时时间,超过这个时间,服务器器会关闭
该连接。 tcp_nodelay on;
\####打开 tcp_nodelay,在包含了了 keepalive 参数才有效
client_header_timeout 15; ####设置客户端请求头读取超时时间,如果超过这个时间,客户端
还没有发送任何数据, Nginx 将返回“Request time out(408)”错误
client_body_timeout 15;
\####设置客户端请求主体读取超时时间,如果超过这个时间,客户端还没有发送任何数据, Nginx 将
返回“Request time out(408)”错误
send_timeout 15; ####指定响应客户端的超时时间。这个超过仅限于两个连接活动之间的时间,如
果超过这 个时间,客户端没有任何活动,Nginx 将会关闭连接。
…… }
16.
知 好
知 好
太Nginx 感
太Nginx Web 感
太 nginx感
Redis
1.Redis ?
Redis 样BSD 会
NoSQl 会
2.Redis ?
&
3.Redis
4. Redis NoSQL
MongoDB然MemcacheDB然Cassandra然CouchDB然Hypertable然Leveldb
5.Redis Memcache
memcached k/v redis (
6)
memcached 也 redis 年
redis VM
redis value 年
6.Redis
们知 为 样String 然 样hash)然 样list)然 (set)然 (zset)
HyperLogLog然 然
7.Redis
然 然 然 然 然 然 然Sentinel
8. Redis ,
1. Redis 好
2. 好Redis
3. redis
4. redis
5.
6.
docker 那
docker pull redis
9.redis
10. Redis
1. :
./redis-server
2. : redis-server 样
3. :
./redis-server /opt/redis/redis.conf
11.Redis
redis redis.conf
redis
12.Redis
1. :
redis
2. 知
13. redis
Kill -9 pid ( , )
redis shutdown
14.
exists key
15.
del key
16.redis
redis I/O
17.
512MB
18.redis
16
19.redis
RDB然AOF然
20.RDB ?
RDB样Redis DataBase)
Tips: 年
21.RDB
:
bgsave:redis fork 不
fork我
save xsecends n:
x n RDB
flushall :
22.RDB
rdb Redis
也
Redis RDB也 AOF
23.RDB
RDB
RDB fork() Redis
24.
config set save ""
25.AOF
AOF(append only file) rdb aof
aof
26. AOF ?
27. AOF?
知
appendonly yes
28.AOF
1. aof_buf
2.AOF
3. AOF AOF 好
4. redis AOF 也
30.AOF
知
知( )
: 样error) OOM command not allowed
when used memory,
43.Redis
Redis Sentinel( )
44.Redis
Twemproxy然Redis Cluster然Codis
45.Redis Cluster
0~16383
46.Redis ?
setnx (set if not exists),
del lock
这 友
, 友
Redis set
47.
1970 中 中 很
Tips:
48.
知
1:
2: 中 很
49.
会
50.
这知
太Redis : ⼦感
太Redis 感
太Redis 感
https://redis.io/
Dubbo
1. Dubbo?
Dubbo Java RPC 发 Apache
知http://dubbo.apache.org/en-us/
2. Dubbo?
:
Web ⾃ 样
发
netty
3.Dubbo 3
4. Dubbo
5.Dubbo ?
6. Dubbo ?
1.
2.
3.
4.
5. ⼀
6.
7.
8.Dubbo
然 然 好 然
9. jdk
jdk1.6+
10.
Zookeeper
11.Dubbo
12.
知
JVM -D 博 dubbo 又
XML, XML dubbo.properties 又
Properties
13.
14.Dubbo
4
JVM System Properties -D
Externalized Configuration
ServiceConfig然ReferenceConfig
dubbo.properties
15.
16.Dubbo
⼀( )
RoundRobin ⼀
⼀
⼀
17.
(version)
18.
xml
-D
java -Dcom.alibaba.xxx.XxxService=dubbo://localhost:20890
.properties
java -Ddubbo.resolve.file=xxx.properties
com.alibaba.xxx.XxxService=dubbo://localhost:20890
19.
20.Dubbo
1. Spring
2. Java API
21.Dubbo
dubbo://( )
rmi://
hessian://
http://
webservice://
thrift://
memcached://
redis://
rest://
22.Dubbo ?
dubbo netty
24.Dubbo ?
dubbo hessian2
rmi java
http json
25.
group group
26.Dubbo
不
Dubbo NIO 不
Future
27.Dubbo ?
Zipkin
Pinpoint
SkyWalking
Dubbox ⾃
29.Dubbox
REST 样HTTP + JSON/XML)
Kryo FST Java
让 Tomcat HTTP remoting
Spring
ZooKeeper
30.io
cpu +1
31.dubbo://
NIO
32.
zookeeper
34.
ls :
ls:
ls -l:
ls XxxService:
ls -l XxxService:
35.Dubbo
36. Dubbo
dubbo
知http://dubbo.apache.org/en-us/
SpringBoot
1. SpringBoot?
Spring Boot Spring “ ”
Spring Boot Spring
2.SpringBoot
Spring
让 Tomcat Jetty Undertow样 博WAR
“starter”
Spring 3rd Party会
XML
3. SpringBoot
Web http://start.spring.io
Spring Tool Suite
IntelliJ IDEA
Spring Boot CLI
4.SpringBoot ?
@SpringBootApplication
@SpringBootConfiguration: @Configuration
@EnableAutoConfiguration:
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@ComponentScan:Spring
5. yaml?
YAML样/ˈjæmәl/ camel 真 YAML
知C 然Python然Perl
6.SpringBoot ?
1.properties
java.xiaokaxiu.name = xiaoka
2.yml
java:
xiaokaxiu:
name: xiaoka
7.SpringBoot
1. main
2. java -jar
3. mvn/gradle
8.SpringBoot
Tomcat/Jetty
9.SpringBoot
1.
2. java:comp/env JNDI
3. JVM
4.
5. random.* ( ${random. long})
6. application.properties appliaction.yml
7. application.properties appliaction.yml
8. @PropertySource
9.
tips:
10.application.properties application.yml ? ?
1. /config
2.
3. config
4. Classpath
,
11.SpringBoot ?
@EnableAutoConfiguration ( )
AutoConfigurationImportSelector META-
INF/spring.factories jar
12.SpringBoot
spring-boot-devtools
Spring Loaded
Jrebel
博
13.bootstrap.yml application.yml?
bootstrap.yml application.yml
14.SpringBoot ?
yml :
server :
port : 8888
properties:
server.port = 8888
1:
2:
15. SpringBoot ?
1. spring-boot-starter-parent
2. spring-boot-dependencies
16.SpringBoot Spring ?
:
@ImportResource(locations = {"classpath:spring.xml"})
17.SpringBoot ?
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
18. Bean
/beans
19. ?
/shutdown
endpoints:
shutdown:
enabled: true
properties
20. ?
/info
21.
@PatchMapping
@PostMapping
@GetMapping
@PutMapping
@DeleteMapping
22.SpringBoot starter
starter
23.SpringBoot Mybatis?
mybatis-spring-boot-starter
24. SpringProfiles?
(dev)然 样test 然 (prod)
Spring Profiles ⼼ 样dev test prod bean
25. ?
application-{profile}.properties/yml application.properties,
application.properties知
application-dev.properties知
application-test.properties知
application.prop-properties知
26.
yml知
spring:
profiles:
active: dev
properties:
spring.profiles.active=dev
27.
@SpringBootTest
28.SpringBoot ?
@ControllerAdvice
@ExceptionHandler
太SpringBoot 样 4 感
太Spring Boot 感
太 Spring Boot 2.x感
https://spring.io/projects/spring-boot
Kafka
1. kafka?
Apache Kafka Apache
2.kafka 3
3.kafka
4.kafka ?
1.
2.
3. ⾃
4.
5. Kafka Streams
6.
7.
8.
9. 好
5.kafka 5 Api?
Producer API
Consumer API
Streams API
Connector API
Admin API
6. Broker ?
Kafka kafka (Broker)
7. Producer ?
Producer
Producer ?
8. Consumer ?
kafka
9. Topic ?
kafka
10. Partition ?
Topic (Partition)
11.
Broker, Broker
12. (Replication)?
样 1
13. (Record)?
kafka
14.kafka
然 然 没然 然 然
15.kafka
SSD 年 年
地年 出 SSD
16. RAID ?
今 年
⼀
17.
18.Broker
log.dirs
log.dir
19.
log.dirs
20. ?
auto.create.topics.enable
21. kafka
producer.send(msg) producer.send(msg, callback)
acks = all
retries
unclean.leader.election.enable = false
replication.factor >= 3
min.insync.replicas > 1
replication.factor > min.insync.replicas
22.
partitioner.class
partition
23.kafka
Producer 然Broker
24.kafka
会 样
25. kafka
JMXTool
Kafka Manager
Burrow
JMXTrans + InfluxDB + Grafana
Confluent Control Center
太Kafka 感
太kafka ⼦感
知Kafka
http://kafka.apache.org/
SpringCloud
1. SpringCloud?
Spring Cloud 样
Cloud Foundry
2.
SOA 只
知
1然
2然 ⾃
3.SpringCloud ?
Spring Cloud ⾃ 样
4.SpringCloud ?
Eureka :
Ribbon 知 ⼀
Hystrix :
Feign: REST
Zuul :
Config :
5.SpringCloud
HTTP
6.SpringCloud Dubbo ?
7.Eureka
REST
8.
知
9.
“
”
10.
REST 样
样DOWN
11.
样 60s)
( 90s)
12.
15 85%,
也
13.Ribbon ?
⼀ ⼀
14.Ribbon ?
@LoadBalanced
15.Ribbon
RandomRule :
RoundRobinRule :
RetryRule :
WeightedResponseTimeRule :
ClientConfigEnabledRoundRobinRule : choose
⾃
BestAvailableRule : ⼀ 很
PredicateBasedRule : 很
AvailabilityFilteringRule 知 很
ZoneAvoidanceRule : PredicateBasedRule 很
ZoneAvoidancePredicate 很 AvailabilityPredicate 很
16.
⼿
这
17.
18. Hystrix?
⼿ 成 ⼿ 会 ,
19. Hystrix
,
( 这 )
(Failfast) 也
(Fallback)
然
20.Hystrix
HystrixCommand HystrixObservableCommand
21.
@EnableHystrix
22. Feign?
Feign 然 HTTP
23.Feign
1.feign
2.feign ribbon ⼀
3. Hystrix ⼿
24. Config?
然Git
Subversion
25.Config ?
Config Server :
Config Client :
26. Zuul?
Zuul , , , 发 Zuul Netflix
Web
27. Zuul ?
好
28.Zuul
很
29.Zuul
4
pre :
route :
error :
error 很
30. Sleuth?
Dapper log-based 没 Zipkin HTrace SpringCloud
没
31.Sleuth
爱还 Zipkin
32. Bus?
然 样 Spring Cloud Config
博
33.eureka zookeeper
A: C: P:
Zookeeper CP Eureka AP
Eureka Zookeeper
微三
34. Stream?
Redis,Rabbit然Kafka
35.
SpringCloud
太Java 感
太Spring Cloud 感
太Spring Cloud 感
太Spring Cloud 感
https://spring.io/projects/spring-cloud
https://www.springcloud.cc/
https://mp.weixin.qq.com/s/z0k922U6jwXe5VYlz33gaA
:https://www.zhihu.com/question/25002833 ThoughtWorks
种 IT 然 HR
HR “
” 30 知
fashion 然
友
去
去
PDF 天
样eg. 然 上
)
/ / / / / /
:
去 HR
QQ 样
Github 样
&
STAR STAR
友 BAT友 友
开 1 知
XX样 2013.06 —
会 web
博
ay 2010.03 — 2013.03
1然MOGU
2然 JAVA
java server , ,
然ip 然
3然 Solr
XXX
1然
kafka , kafka , ,
, ,
storm , ,
, pv然uv ,
在 js , go 2然hadoop
2然 CDH ,
MapReduce , , , ,
, , 点
3然 quartz2 , review
4然 会 , 点, mycat , 会 ,
,
5然 java web , , ,
java , ,
, 不
&
知
开
1
, 家 过
又 有 又
能
: , 国 ,
,
: , , 们 ,
们 , , ,
: , Google然Stack over flow
, 然 然 REPL
,
: , Twitter ,Github
Trending Podcast然Hacker News然Reddit TechRadar
: 然 , , 然
出 : , 美 ,么
然 然
Ruby on Rails知
Agile/Lean知
ReactJS知
Docker知
AWS知
1. HR
2. :太 感太 感太 感
3. : Stack Over flow Google Developer Group
4. 然 :
https://github.com/github
http://www.oschina.net/
https://www.cnblogs.com/
https://itunes.apple.com/app/battle-of-crab/id1121917063?l=en&amp;mt=8
: offer