├── 101.txt
├── ALL.payload
├── CRaC_checkpoints.txt
├── Collections.txt
├── Google_guava.txt
├── GraalVM.txt
├── JSON.txt
├── JVM.txt
├── QA_and_testing.txt
├── RXJAVA.txt
├── TODO.txt
├── TornadoVM.txt
├── async_reactive.txt
├── concurrent_programming.txt
├── containerization.txt
├── debug_and_profiling.txt
├── functional_java.txt
├── gradle.txt
├── input_output.txt
├── jakarta_EE.txt
├── jee_war_apps.txt
├── jhipster.txt
├── maven.txt
├── monitorization.txt
├── monitorization_micrometer.txt
├── monitorization_opentelemetry.txt
├── persistence.payload
├── persistence_HikariCP.txt
├── persistence_JPA_Hibernate.txt
├── persistence_Jooq.txt
├── persistence_QueryDSL.txt
├── persistence_mybatis.txt
├── persistence_non_classified.txt
├── persistence_speedment.txt
├── persistence_stalactite.txt
├── security.txt
├── tomcat.txt
├── vertx.txt
├── whats_new.txt
└── who_is_who.txt
/ALL.payload:
--------------------------------------------------------------------------------
1 | 101.txt
2 | functional_java.txt
3 | Collections.txt
4 | Google_guava.txt
5 | input_output.txt
6 | JSON.txt
7 | QA_and_testing.txt
8 | security.txt
9 | persistence.payload
10 | RXJAVA.txt
11 | async_reactive.txt
12 | concurrent_programming.txt
13 | debug_and_profiling.txt
14 | jee_war_apps.txt
15 | maven.txt
16 | containerization.txt
17 | gradle.txt
18 | CRaC_checkpoints.txt
19 | monitorization.txt
20 | monitorization_opentelemetry.txt
21 | monitorization_micrometer.txt
22 | JVM.txt
23 | whats_new.txt
24 | TornadoVM.txt
25 | vertx.txt
26 | ../cryptography/java_cryptography.txt
27 | who_is_who.txt
28 | GraalVM.txt
29 | jhipster.txt
30 | TODO.txt
31 | eclipse_microprofile.txt
32 |
--------------------------------------------------------------------------------
/CRaC_checkpoints.txt:
--------------------------------------------------------------------------------
1 | [[{scalability.JVM.CRAC,DevOps.CrAC]]
2 | # CrAC Project: Coordinate and Restore Checkpoints in running JVMs.
3 |
4 | * Summary from
5 | by Gerrit Grunwald, JUG Leader.
6 | *
7 | *
8 |
9 | * CrAC will not make apps run faster, but it avoid the JVM start-up and warm-up
10 | providing much better scalability when the process is restarted
11 | frequently.
12 | * It's probably a better alternative to GraalVM since we continue
13 | to have all the standard monitorization tools of an standard JVM
14 | environment.
15 | * primary aim: develop a new standard mechanism-agnostic API to
16 | notify Java programs about the checkpoint and restore events.
17 |
18 |
19 | * Currently (2024) only available on Linux.
20 |
21 | ## SpringBoot (3.2+) Automatic Checkpoint
22 |
23 | NOTE: A JVM with support for CRaC is needed (ex. Azul Zulu 21.0.1 + CRaC)
24 |
25 | ```
26 | | $ sudo chown root:root $JAVA_HOME/lib/criu # fix permission to use Linux
27 | | $ sudo chmod u+s $JAVA_HOME/lib/criu # CRIU (Checkpoint/Restore in
28 | | # Userspace)
29 | | $ editor build.gradle.kts # or similar in maven
30 | | ...
31 | | dependencies {
32 | | + implementation 'org.crac:crac:1.4.0' // gradle, similar for Maven
33 | | └─────────┬─────────┘
34 | | In linux it just invoke the native jdk.crac API of the underlying
35 | | JDK (supported by Linux CRIU), on MacOSX/Win it implements the API.º
36 | | ... }
37 | |
38 | | $ R_DIR_01="/tmp/jvmCheckpoint/app01" # folder for stored checkpoint for app01
39 | | $ mkdir -p ${R_DIR_01}
40 | |
41 | | $ ./gradlew assemble # or ./gradle clean build
42 | |
43 | | $ S_OPTS="-Xms512m ..." # Standard JVM startup options.
44 | | $ C_OPTS="" # <·· Checkpoint Options for JVM startup
45 | | # STEP 1): Create checkpoint and exists ---------
46 | | $ java \
47 | | -Dspring.context.checkpoint=onRefresh \
48 | | -XX:CRaCCheckpointTo=${R_DIR_01} \
49 | | -jar .../myapp.jar
50 | | └──┬─────────────────────────────────┘
51 | | Creates checkpoint right before the application is started
52 | | during the LifecycleProcessor.onRefresh phase.
53 | | """ all non-lazy initialized singletons have been
54 | | instantiated and InitializingBean#afterPropertiesSet
55 | | callbacks have been invoked; but the lifecycle has
56 | | not started, and the ContextRefreshedEvent has not
57 | | yet been published. """
58 | |
59 | | # STEP 2): startup using the existing Checkpoint --
60 | | $ java \
61 | | -XX:CRaCRestoreFrom=${R_DIR_01} \
62 | | -jar .../myapp.jar
63 | |
64 | ```
65 | * startup time now is >10x faster with no code changes !!! [[{PM.low_code}]]
66 | * The previous checkpoint only contains the Spring framework code and not
67 | the application code.
68 |
69 | * WARN: See comments with problems in the original post when the image contains
70 | external resources (tcp/DDBB connections,...)
71 | * Q: "... Were you able to verify how was it performing with the DB connections
72 | using manual checkpoint..."
73 | A: Nope, but feel free to test that and share the results.
74 | * I try on a demo app using a simple controller calling a JPA object in database.
75 | ```
76 | org.springframework.context.ApplicationContextException: Failed to take CRaC checkpoint
77 | ...
78 |
79 | Caused by: java.lang.Exception: This file descriptor was created by
80 | HikariPool-1 connection adder at epoch:1701351807255 here
81 | ...
82 | ```
83 | * ... Same issue
84 | ```
85 | ... jdk.internal.crac.impl.CheckpointOpenSocketException: tcp localAddr
86 | 172.18.0.6 localPort 46868 remoteAddr 172.18.0.3 remotePort 6379
87 | ```
88 |
89 | ## Manual Checkpoint (after App warmup)
90 |
91 | * Checkpoint creation:
92 | ```
93 | | # STEP 1: Start JVM with Checkpoint enabled
94 | | $ java \
95 | | -XX:CRaCRestoreFrom=${R_DIR_01}
96 | | $ java -jar .../myapp.jar 1>app.log 2>&1 &
97 | |
98 | | ... wait now for warmup, maybe invoking some REST APIs ...
99 | |
100 | | # STEP 2: Checkpoint and stop the running app.
101 | | $ jcmd .../myapp.jar JDK.checkpoint
102 | |
103 | | # STEP 3: Restart with the new checkpoint after warmup.
104 | | $ java \
105 | | -XX:CRaCRestoreFrom=${R_DIR_01}
106 | | $ java -jar .../myapp.jar 1>app.log 2>&1 &
107 | ```
108 |
109 | * startup time now is >40x faster with no code changes. !!!
110 | The app is still running on a normal JVM (vs GraalVM).
111 | [[{PM.low_code}]]
112 |
113 | [[{DevOps.containarization.CRaC]]
114 | ## Running containerized Java Apps with CRaC
115 |
116 | *
117 | [[DevOps.containarization.CRaC}]]
118 |
119 |
120 | ## Se also
121 |
122 | * Checkpointing outside the JVM
123 |
124 | * Checkpoint inside JVM HOW-TO
125 |
126 |
127 | * Checkpointing with Linux CRIU:
128 |
129 | ```
130 | | CONSOLE 1 | CONSOLE 2
131 | | $ setsid java -XX:-UsePerfData \ | $ sudo criu dump -t $pid \ ← stops and checkpoint
132 | | -XX:+UseSerialGC Scooby | --shell-job -o dump.log app
133 | | |
134 | | | $ sudo restore --shell-job \ ← Restore app
135 | | | -d -vvv -o restore.log
136 | ```
137 | [[}]]
138 |
139 | [[scalability.JVM.CRAC}]]
140 |
--------------------------------------------------------------------------------
/Collections.txt:
--------------------------------------------------------------------------------
1 | [[{data_structures.101,java_lang.101,scalability.101,doc_has.decission_tree,doc_has.diagram,qa.data]]
2 | # Collections
3 |
4 | ## Collections 101
5 |
6 | ### COLLECTION DECISSION TREE
7 | ```
8 | | ┌──────────┐
9 | | │ Allows │
10 | | ┌─── YES ─────┤Duplicates├── NO ───────┐
11 | | │ List to └──────────┘ Set to │
12 | | │ be selected be selected │
13 | | │ v
14 | | v ┌───────────┐☜ order established at
15 | | ┌─────────────────────┐ │ Maintains │ write time
16 | | │ Unknown number │ │ INSERTION │
17 | | ┌─NO─┤of elements will be ├YES─┐ ┌───YES───┤ ORDER ? ├──NO──┐ order requested
18 | | │ │added and/or index │ │ │ └───────────┘ │ at read time
19 | | │ │based search will not│ │ v ↓ ☟
20 | | │ │be frequent? │ │ LinkedHashSet ┌────────────┐
21 | | │ └─────────────────────┘ │ │ Mantains │
22 | | v v ┌─NO─┤ READ ORDER ├YES┐
23 | | ArrayList LinkedList │ │(alpha,...)?│ │
24 | | │ └────────────┘ │
25 | | │ │
26 | | v v
27 | HashSet TreeSet
28 | ```
29 |
30 | ### Collection Comparative
31 |
32 | ```
33 | | Standard non-concurrent SDK:
34 | | ┌──────────────────────────────────────────────────────────────────────────────────────────
35 | | │ IMPLEMENTATIONS
36 | | ├──────────────────────────────────────────────────────────────────────────────────────────
37 | | │ Hash Table │ Resizable Array │Balanced Tree │ Linked List │ HashTable+LinkedList
38 | | │ │ │ │ │
39 | | ┌───────┼───────────────────┼───────────────────┼──────────────┼─────────────┼─────────────────────
40 | | │ │ HashSet │ │ TreeSet │ │ LinkedHashSet
41 | | │ │ │ │ │ │
42 | | ├───────┼───────────────────┼───────────────────┼──────────────┼─────────────┼─────────────────────
43 | | │ │ │ ArrayList │ │ LinkedList │
44 | | │ │ │ Vector │ │ LinkedList │
45 | | ├───────┼───────────────────┼───────────────────┼──────────────┼─────────────┼─────────────────────
46 | | │