Skip to content

Instantly share code, notes, and snippets.

View JensRantil's full-sized avatar

Jens Rantil JensRantil

View GitHub Profile
@JensRantil
JensRantil / filelisting.txt
Last active August 29, 2015 14:24
Zookeeper making lots of snapshots.
zookeeper@server:/var/lib/zookeeper/version-2# ls -lah
total 9.2G
drwxr-xr-x 2 zookeeper zookeeper 4.0K Jun 30 16:56 .
drwxr-xr-x 4 zookeeper zookeeper 4.0K May 8 17:24 ..
-rw-r--r-- 1 zookeeper zookeeper 65M Jun 30 15:02 log.10f2546e2
-rw-r--r-- 1 zookeeper zookeeper 65M Jun 30 15:25 log.10f26c9f6
-rw-r--r-- 1 zookeeper zookeeper 65M Jun 30 15:46 log.10f27ea66
-rw-r--r-- 1 zookeeper zookeeper 65M Jun 30 16:03 log.10f29064d
-rw-r--r-- 1 zookeeper zookeeper 65M Jun 30 16:03 log.10f2a6949
-rw-r--r-- 1 zookeeper zookeeper 65M Jun 30 16:28 log.10f2aaf90
@JensRantil
JensRantil / LimittingBlockingQueueDelegater.java
Last active August 29, 2015 14:25
LimittingBlockingQueueDelegater.java
package my.project.common.concurrency;
import com.google.common.base.Preconditions;
import java.util.AbstractQueue;
import java.util.Collection;
import java.util.Iterator;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.TimeUnit;
WARN 14:55:36,093 At level 1, SSTableReader(path='/var/lib/cassandra/data/XXX/YYY/XXX-YYY-jb-13742-Data.db') [DecoratedKey(-9222888731763965546, 71855c01897f456bb39064fbb422b2a5), DecoratedKey(-6917488716996414524, 311af6e84b9b4245bb8f30cbe0426711)] overlaps SSTableReader(path='/var/lib/cassandra/data/XXX/YYY/XXX-YYY-jb-13436-Data.db') [DecoratedKey(-9222888731763965546, 71855c01897f456bb39064fbb422b2a5), DecoratedKey(-6880442365347943082, 9eab2913983541fb93f6ab8bb88938af)]. This could be caused by a bug in Cassandra 1.1.0 .. 1.1.3 or due to the fact that you have dropped sstables from another node into the data directory. Sending back to L0. If you didn't drop in sstables, and have not yet run scrub, you should do so since you may also have rows out-of-order within an sstable
@JensRantil
JensRantil / curator_exception.txt
Created September 13, 2015 16:03
Curator exception trickling through to our application
Sep 10 10:02:18 10.11.1.42 myproc[17660]: [my-thread-8] org.apache.curator.ConnectionState Connection timed out for connection string (X.X.X.2:2181,X.X.X.3:2181,X.X.X.4:2181) and timeout (15000) / elapsed (15521)
Sep 10 10:02:18 10.11.1.42 org.apache.curator.CuratorConnectionLossException: KeeperErrorCode = ConnectionLoss
Sep 10 10:02:18 10.11.1.42 at org.apache.curator.ConnectionState.checkTimeouts(ConnectionState.java:197)
Sep 10 10:02:18 10.11.1.42 at org.apache.curator.ConnectionState.getZooKeeper(ConnectionState.java:87)
Sep 10 10:02:18 10.11.1.42 at org.apache.curator.CuratorZookeeperClient.getZooKeeper(CuratorZookeeperClient.java:115)
Sep 10 10:02:18 10.11.1.42 at org.apache.curator.framework.imps.CuratorFrameworkImpl.getZooKeeper(CuratorFrameworkImpl.java:492)
Sep 10 10:02:18 10.11.1.42 at org.apache.curator.framework.imps.DeleteBuilderImpl$5.call(DeleteBuilderImpl.java:238)
Sep 10 10:02:18 10.11.1.42 at org.apache.curator.framework.imps.DeleteBuilderImpl$5.call(Dele
@JensRantil
JensRantil / askpasswd.sh
Created September 22, 2015 12:55
Script to generate salted SHA512 /etc/shadow password on/for Ubuntu 12.04 LTS
#!/bin/bash
read -p "Enter username: " username
read -s -p "Enter password: " mypassword
echo
echo -n $username:$mypassword | chpasswd -S -c SHA512
@JensRantil
JensRantil / java_indentation_horror.java
Created March 16, 2012 14:15
Java indentation horror
/**
* Get a local cache manager. It's not replicated nor distributed in any
* way.
* @return
*/
public static BasicCacheHandler getCacheManager(){
//We jump through these hoops so we don't have to deploy a ehcache.xml
if (cache_manager==null) {
// Trying not to make the lock
synchronized (CacheHandler.class) {
Hi again,
I stumbled across you "Forwarded http Extension" (http://tools.ietf.org/html/draft-petersson-forwarded-for-02) a week ago and have been thinking about it a bit more; One thing that I think the draft currently is missing is a way to disclose to the backend the full URL that was used for the original request.
There are two things missing:
Which resource was requested in the original request. If a request to http://myserver.com/hello/index.jsp is proxied to http://myserver.com/hello2/index.jsp it would be highly useful for the backend to know that the original request was /hello/index.jsp and not /hello2/index.jsp. While a frontend webserver could potentially correct redirects (301s and 302s, example: http://wiki.nginx.org/HttpProxyModule#proxy_redirect) there are also occasions when the backend would like to know about the original request being made. Examples are to have correct links/URLs to media files (images, CSS, JavaScript etc.).
Which port that was used on the original request. While I hav
@JensRantil
JensRantil / gist:2692996
Created May 14, 2012 09:48
A perfect example of unnecessary comments (in default nagios configuration)
# 'check_https_hostname_on_port' command definition
define command{
command_name check_https_hostname_on_port
command_line /usr/lib/nagios/plugins/check_http --ssl -H '$HOSTNAME$' -I '$HOSTADDRESS$' -p '$ARG1$'
}
@JensRantil
JensRantil / test_files.py
Created August 11, 2012 10:03
How to check if all files were closed using Mock
import mock
files_opened = []
real_open = open # Needed since I will wrap open
def open_wrapper(*args, **kw):
opened_file = mock.MagicMock(wraps=real_open(*args, **kw))
files_opened.append(opened_file)
return opened_file
open_mock = mock.MagicMock(side_effect=open_wrapper)
open_mock.__enter__.side_effect = open_wrapper
@JensRantil
JensRantil / ddfs_xcat_-_less.txt
Created August 13, 2012 15:38
Recreation of json.loads issue
"{\"coordinates\":null,\"in_reply_to_user_id\":159938854,\"truncated\":false,\"text\":\"@dstorna \\n\\u0627\\u062e\\u0648\\u064a \\u0639\\u0628\\u062f\\u0627\\u0644\\u0644\\u0647 \\u0627\\u0644\\u0631\\u0624\\u064a\\u0629 \\u062d\\u0642 \\u0648\\u0627\\u0644\\u062a\\u0641\\u0633\\u064a\\u0631 \\u0627\\u0644\\u0627\\u0648\\u0644 \\u0644\\u0647\\u0627 \\u064a\\u0642\\u0639 \\u0642\\u062f \\u064a\\u0636\\u062d\\u0643 \\u0627\\u062d\\u062f \\u0645\\u0639\\u0643 \\u0648\\u064a\\u0641\\u0633\\u0631\\u0647\\u0627 \\u0628\\u0633\\u0648\\u0621\",\"id_str\":\"234786337595727874\",\"entities\":{\"hashtags\":[],\"urls\":[],\"user_mentions\":[{\"indices\":[0,8],\"id_str\":\"159938854\",\"name\":\"\\u0639\\u0628\\u062f\\u0627\\u0644\\u0644\\u0647 \\u0627\\u0644\\u0634\\u0644\\u0627\\u062d\\u064a\",\"screen_name\":\"dstorna\",\"id\":159938854}]},\"place\":null,\"retweet_count\":0,\"favorited\":false,\"geo\":null,\"source\":\"\\u003Ca href=\\\"http:\\/\\/twitter.com\\/download\\/iphone\\\" rel=\\\"nofollow\\\"\\u003ETwitter