爱看书的阿东

赐他一块白色石头,石头上写着新名

引言

这几天把 ObsidianDay-Planner插件做了升级,突然发现原来的时间视图不见了。

起初个人认为是新版本的Obsidian和插件不兼容,于是选择换成旧版本,后来看了一眼Day-Planner更新日志,才发现原来作者基本把插件重做了。

更新之后的Day-Planner插件和旧版本差别挺大,个人花了不少时间熟悉新版本,本文将介绍如何快速使用和适应新版本的Day-Planner插件。

阅读全文 »

原文

https://www.baeldung.com/java-gc-logging-to-file

1. Overview

Garbage collection is a marvel of the Java programming language providing us with automatic memory management.

垃圾回收是 Java 编程语言的一个奇迹,它为我们提供了自动内存管理功能。

Garbage collection hides the details of having to manually allocate and deallocate memory.

垃圾回收隐藏了手动分配和删除内存的细节。

While this mechanism is fantastic, sometimes it doesn’t work the way we want.

虽然这种机制非常好,但有时并不能如我们所愿。

In this tutorial, we’ll explore Java’s logging options for garbage collection statistics and discover how to redirect these statistics to a file.

在本教程中,我们将探索 Java 的垃圾收集统计日志选项,并了解如何将这些统计信息重定向到文件

阅读全文 »

引言

本文介绍后台任务延迟队列的“元素” 后台任务构造器 以及Curator 对于常见的ZK节点操作封装API。后台任务构造器对应了和ZK交互的常见”后台“操作,比如创建和销毁Watch,而ZK节点操作API涉及各种建造者模式的应用。可以说,Curator 整个框架各种地方都有建造者模式的身影。

Curator 除了对于ZK本身交互和操作封装之外,还引入了Cache的概念来实现对ZooKeeper服务器端进行事件监听,本质上就是构建本地缓存,在远程节点出现”状态“变动的时候进行”联动“触发各种事件。

不过,Cache 的部分个人认为并不是很重要的内容,更多重心还是在分布式锁,再加上查询各种资料本身应用场景也比较少,因此放到了文章最后分析,读者可以按需阅读。

阅读全文 »

介绍

Curator是netflix公司开源的一套zookeeper客户端,目前是Apache的顶级项目。

和ZK的原生客户端相比,Curator的抽象层次要更高,同时简化了ZK的常用功能开发量,比如Curator自带连接重试、反复注册Watcher、NodeExistsException 异常处理等等。

根据官方的介绍,我们可以了解到它是一个用于分布式的Java客户端API工具。它基于high-level API,拥有它可以更简单易懂的指挥Zookeeper实现分布式安全应用程序开发。

Curator由一系列的模块构成,对于一般开发者而言,常用的是curator-frameworkcurator-recipes,以及广为熟知的 分布式锁

Curator 当然也包括许多扩展,比如服务发现基于Java 8异步DSL

1
2
3
Apache Curator is a Java/JVM client library for [Apache ZooKeeper](https://zookeeper.apache.org/), a distributed coordination service.

Apache Curator includes a high-level API framework and utilities to make using Apache ZooKeeper much easier and more reliable. It also includes recipes for common use cases and extensions such as service discovery and a Java 8 asynchronous DSL.

用官方的介绍来说就是:guava之于java就像curator之于zookeeper

阅读全文 »

原文

Effective Lambda Expressions in Java | by Bubu Tripathy | Medium

Introductory

Lambda expressions were introduced in Java 8 to allow functional programming in Java. They are a concise way to express functions that can be used as data and provide a more functional approach to programming. Lambda expressions can be used in a variety of ways, from simple expressions to complex functions. In this article, we will discuss 20 best practices of using lambda expressions in Java with examples for each.

阅读全文 »

介绍

事情的起因是《Who moved my cheese》这本书的一段话:

But when the Cheese story was shared with literally everyone in our organization ….

但是,当《奶酪》的故事在我们组织的每个人中流传开来时…. 这里有一个【literally】单词经过查阅之后,发现它的含义基本上都是”按字面上“,这种说法显然说不通,所以它有另一种含义,那就是 真的

渣渣英语的我,对于这段话的理解是强调事情本身是事实,实际发生的,抱着验证的疑问,这里去翻了翻知乎的说法:

literally 到底是什么意思,为什么美国人老把 literally 挂嘴边? - 知乎 (zhihu.com)

关于这个单词的讨论挺有意思的

下面是个人对于【literally】单词含义这种奇怪的变化做一个归档整理。

阅读全文 »

探索 Java 中的新 HTTP 客户端

原文

https://www.baeldung.com/java-9-http-client

1. Overview

In this tutorial, we’ll explore Java 11’s standardization of HTTP client API that implements HTTP/2 and Web Socket.

本文讲讨论Java 11 的新HTTP客户端API是如何实现 HTTP/2 和 WebSocket的。

It aims to replace the legacy HttpUrlConnection class that has been present in the JDK since the very early years of Java.

它旨在取代自 Java 诞生之初就存在于 JDK 中的传统HttpUrlConnection 类。

阅读全文 »

【Linux】Linux 性能

引言

干货不是一般的多。

参考资料

https://www.brendangregg.com/linuxperf.html

This page links to various Linux performance material I’ve created, including the tools maps on the right. These use a large font size to suit slide decks. You can also print them out for your office wall. They show: Linux observability tools, Linux static performance analysis tools, Linux benchmarking tools, Linux tuning tools, and Linux sar. Check the year on the image (bottom right) to see how recent it is.

本页链接到我制作的各种 Linux 性能材料,包括右侧的工具图。这些地图使用大号字体,适合幻灯片使用。你也可以打印出来贴在办公室墙上。它们显示 Linux 可观察性工具Linux 静态性能分析工具Linux 基准测试工具Linux 调试工具Linux sar。请查看图片(右下角)上的年份,了解其最新版本。

阅读全文 »

引言

本文介绍网络IO编程的入门部分,Java 的传统BIO Socket编程源码分析,了解如何将BIO阻塞行为accept()read() 改造为非阻塞行为,并且将结合Linux文档介绍其中的机制,文档中描述了如何处理Socketaccept,对比Java的Socket实现代码,基本可以发现和Linux行为基本一致。

废话不多说,我们直接开始。

draw.io 文件

本文涉及的个人源码分析绘图均由 draw.io 绘制,源文件如下:

链接:https://pan.baidu.com/s/1FHAYt4AxWh0Dd4qi2JKZLQ?pwd=qsmg
提取码:qsmg

image.png

阅读全文 »

原文

Generics in Java. It’s all about type safety | by Salitha Chathuranga | Medium

引言

It’s all about type safety。

所有内容都是关于线程安全。

Hi all!!!

I thought of writing a widely used but less discussed topic in Java. That is Generics! We use it, but majority of the developers don’t know about it as I have experienced.

本次编写的有关内容是讨论较少主题,“泛型”,实际上我们经常使用(实际上天天都在用),但是大部分人并不了解。

Let me clear this…have you ever used List or ArrayList in Java? Most probably, answer should be YES. Right? Without collections, we can’t even think of an easy way of handling data. So, do you remember how we define an ArrayList?

让我澄清一下……您在Java中使用过List或ArrayList吗?答案很可能是 “是”。对不对?如果没有集合,我们甚至无法想象处理数据的简单方法。那么,你还记得我们是如何定义ArrayList的吗?

阅读全文 »