Skip to content

Instantly share code, notes, and snippets.

loadbalancer <-> NB : Load Balance me
NB.shape: cloud
NB -- backend -> DB
DB --> NB
backend {
plugins {
id 'org.springframework.boot' version '3.0.0'
id 'io.spring.dependency-management' version '1.1.0'
id 'org.jetbrains.kotlin.jvm' version '1.7.21'
id 'org.jetbrains.kotlin.plugin.spring' version '1.7.21'
}
{
"size" : 0,
"aggs": {
"groupByCid": {
"terms": {
"field": "cid.keyword",
"size": 1000,
},
"aggs": {
"groupByOpName": {
@ssouris
ssouris / HotThreadsResponse.log
Created May 18, 2020 20:23
Hot Threads API response
::: {node1.mycompany.net}{9GFXG3OWTsqz-dzQQblUmw}{UUtKg-5cSuaZuKtQAjfnMA}{10.48.112.217}{10.48.112.217:9300}{di}{aws_az=us-west-1b, xpack.installed=true}
Hot threads at 2020-05-18T20:16:02.896Z, interval=500ms, busiestThreads=3, ignoreIdleThreads=true:
6.1% (30.3ms out of 500ms) cpu usage by thread 'elasticsearch[node1.mycompany.net][write][T#2]'
unique snapshot
java.base@13.0.2/java.util.stream.Streams$ConcatSpliterator.<init>(Streams.java:705)
java.base@13.0.2/java.util.stream.Streams$ConcatSpliterator$OfRef.<init>(Streams.java:773)
java.base@13.0.2/java.util.stream.Stream.concat(Stream.java:1380)
app//org.elasticsearch.common.util.concurrent.ThreadContext$ThreadContextStruct.putResponseHeaders(ThreadContext.java:522)
app//org.elasticsearch.common.util.concurrent.ThreadContext$ThreadContextStruct.access$1900(ThreadContext.java:440)
@Autowired
lateinit var petRepository: PetRepository
fun goToOwnersIndex() : Mono<ServerResponse> {
return ok().html().render("owners/index",
mapOf("owners" to ownersRepository.findAll().map { Pair(it, emptySet<Pet>()) },
"pets" to petRepository.findAll().collectMultimap { it.owner }))
}
// using type inference
fun goToOwnersIndex() = ok().html().render("owners/index",
mapOf("owners" to ownersRepository.findAll().map { Pair(it, emptySet<Pet>()) },
fun LocalDate.toStr(format:String = "dd/MM/yyyy") = DateTimeFormatter.ofPattern(format).format(this)
fun String.toDate(format:String = "dd/MM/yyyy") = LocalDate.parse(this, DateTimeFormatter.ofPattern(format))
@Test
fun `Test LocalDate#toStr extension method`() {
Assert.assertEquals(LocalDate.of(1970, 1, 1).toStr(), "01/01/1970")
}
@FunctionalInterface
public interface RouterFunction<T extends ServerResponse> {
Mono<HandlerFunction<T>> route(ServerRequest request);
...
}
public interface Servlet {
...
public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException;
...
}
@FunctionalInterface
public interface HandlerFunction<T extends ServerResponse> {
Mono<T> handle(ServerRequest request);
}