Posts8 [DDIA-II] The trouble with distributed systems 1 Clocks Clock is how many times a quartz (a unit that physically vibrates) has vibrated from a set point in time. NTP is network time protocol that adjusts clocks. We have two kinds of clocks for two different kind of uses, and in both cases, NTP adjusts the clock. However, the clock adjustment strategy is differnet for each. 1. When we have two computers and see which one clicked a button firs.. 2021. 11. 30. [Effective Java] Item 45: Use streams judiciously 1 Creating streams Before I started this topic, there were some preliminaries that I had to be familiar with. You know those times when you try to get a stream of SomeType, but instead you get a stream of List instead? The following examples will clarify them: 1.1 int[] array stream Arrays.stream(int[]) - returns IntStream Arrays.stream(Integer[]) - returns Stream Stream.of(int...) - returns Str.. 2021. 11. 13. [DDIS Part II]: Distributed system - Partition Partition is a way to divide large dataset into multiple smaller datasets, such that any record appears in exactly one of such smaller datasets. Then different partitions can be stored in different nodes. This is useful because: - Scalability: request loads can be split to different nodes. The more fairly distributed partitions mean better request load balancing, hence greater scalability. Assum.. 2021. 11. 13. [Effective Java] Item 43: Prefer method reference to lambda Motivation Method reference is something I always tried to get into. However, always felt a little bit too overwhelming for me when I tried to get into it, because unlike lambda (which also took a great deal to get used to), method reference comes in different flavours (static method reference, instance method reference..) I am now a tiny bit confident that I understand about method reference. S.. 2021. 11. 8. [Effective Java] Item 42: Prefer lambda to anonymous classes In the previous post (Item 38: emulate extensible enums with interfaces), we had an enum declaration that implements different behaviour of overriden method for each enum instance. Just to refresh memory, here's what we had: An advantage of this is extreme flexibility - GradeCalculable interface's abstract method is implemented all differently for each enum instance. However, the fallpit of this.. 2021. 11. 7. [Effective Java] Item 38: emulate extensible enums with interfaces Enums cannot be extended. What does that mean? If we have an enum, and it had a method, then we cannot create another enum that implements the same method signature while being under the same type. There's a workaround for that. You can make enum implement an interface. This interface becomes the super type that can be extended by other enums. GradeCalculable Interface YearLevel Enum Advantage 1.. 2021. 11. 6. [DDIS Part II]: Distributed system - Replication Replication Distributed database can come in two flavours: partition, replication. Replication is where you have multiple copies of database stored on different nodes (machines). Replication achieves: - lower latency (we can distribute database geographically so that access time from all around the world can be minimised) - higher availability (faults can be masked, replacement of faulted machin.. 2021. 11. 5. [Effective Java] Item 37: Using EnumMap as a way to group items by enum Why should you read this article? - You want to group collection into different groups, by enum. - You want to avoid using Set[] and use Map, but want to minimise memory consumption (ie not use HashMap, but something equivalent in memory consumption to simple array that is fixed sized) Let's get started! Oftentimes, a list (or any kind of collection) might need to be grouped into separate groups.. 2021. 11. 5. 이전 1 다음