Skip to content

Instantly share code, notes, and snippets.

@daschl
daschl / alldocs
Created August 7, 2014 10:24
language missing
{
rows: [
{
doc: {
meta: {
id: "_design/beer",
rev: "1-5d0a1739"
},
json: {
language: "javascript",
  1. Getting Started ==================

This getting started guide acts as a foundational introduction into the Couchbase Java SDK. You learn how to install it properly and write a basic sample application that highlights important aspects. At the end of this guide you are able to start exploring further documentation on your own or proceed with a tutorial where a full-blown, production grade application is built.

2.a Installation

Currently, the Java SDK is in a beta release state, so you need to include the Couchbase Maven Repository if you want to pull it in automatically. Here is a typical pom.xml that you can copy and paste:

@daschl
daschl / format.java
Created August 26, 2014 13:23
collect and format
Diagnostics {
gc.ps marksweep.collectionCount=0,
gc.ps marksweep.collectionTime=0,
gc.ps scavenge.collectionCount=2,
gc.ps scavenge.collectionTime=1,
heap.pendingFinalize=0,
heap.used=init = 268435456(262144K) used = 1095344(1069K) committed = 268435456(262144K) max = 3817865216(3728384K),
mem.physical.free=1653268480,
mem.physical.total=17179869184,
mem.swap.free=1567358976,
queryTemplate = ViewQuery.from("design", "view");
processViewOptions(queryTemplate, vopts.getInner());
long iterRemaining = getPrivopts().iterCount;
while (isCancelled == false) {
boolean gotException = false;
long beginTime = System.currentTimeMillis();
String curView;
/**
* Copyright (C) 2014 Couchbase, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
List<JsonDocument> foundDocs = Observable
.from(Arrays.asList("id1", "id2"))
.flatMap(new Func1<String, Observable<JsonDocument>>() {
@Override
public Observable<JsonDocument> call(String id) {
return bucket.async().get(id);
}
})
.toList()
.timeout(5, TimeUnit.SECONDS)
@daschl
daschl / gist:90ff8a66635d2ee3cbcc
Created October 8, 2014 00:46
GC Logging flags
Mandatory:
----------
-XX:+PrintGCDetails
-XX:+PrintGCApplicationStoppedTime
-XX:+PrintGCApplicationConcurrentTime
-XX:+PrintTenuringDistribution
-XX:+PrintGCDateStamps
-Xloggc:<pathtofile>
/**
* Copyright (C) 2014 Couchbase, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@daschl
daschl / gist:db9fcc9d2b932115b679
Last active August 26, 2020 23:17
Draft: Writing Code for Production

Writing Resilient Reactive Applications

This guide is a first draft (that will end up in the official docs) on writing resilient code for production with the Couchbase Java SDK. At the end, the reader will be able to write code that withstands bugs, latency issues or anything else that can make their application fail.

Note that lots of concepts can be applied for both synchronous and asynchronous access. When necessary, both patterns are discussed separately. Also, the focus is on database interaction, but if you are using RxJava as part of your stack you can apply most of the principles there as well (and should!).

RxJava 101 Recap: Cold and Hot Observables

When working with Observables, it is important to understand the difference between cold and hot. Cold Observables will start to emit events once a Observer subscribes, and will do it "fresh" for each Observer. Hot Observables instead are starting to emit data as soon as it becomes available, and will return the same (or parts of the same)

@daschl
daschl / gist:8c6a935d8cb596a2f230
Created December 1, 2014 11:09
stack swallowed
Stack Trace Count
java.lang.Throwable.<init>(String) 686,336
java.lang.Exception.<init>(String) 686,336
java.lang.RuntimeException.<init>(String) 686,336
java.lang.IllegalStateException.<init>(String) 686,336
com.couchbase.client.deps.io.netty.util.IllegalReferenceCountException.<init>(String) 686,336
com.couchbase.client.deps.io.netty.util.IllegalReferenceCountException.<init>(int, int) 686,336
com.couchbase.client.deps.io.netty.buffer.AbstractReferenceCountedByteBuf.release() 686,336
com.couchbase.client.deps.io.netty.handler.codec.memcache.binary.AbstractBinaryMemcacheMessage.release() 680,263
com.couchbase.client.deps.io.netty.handler.codec.memcache.binary.DefaultFullBinaryMemcacheRequest.release() 680,263