Skip to content

Instantly share code, notes, and snippets.

@mwkang
mwkang / StaticHostProvider.java
Created February 21, 2017 06:24
java client does a reverse dns lookup when connecting
Index: src/java/main/org/apache/zookeeper/client/StaticHostProvider.java
===================================================================
--- src/java/main/org/apache/zookeeper/client/StaticHostProvider.java (revision 1450278)
+++ src/java/main/org/apache/zookeeper/client/StaticHostProvider.java (working copy)
@@ -116,8 +116,7 @@
InetAddress resolvedAddresses[] = InetAddress.getAllByName((ia!=null) ? ia.getHostAddress():
address.getHostName());
for (InetAddress resolvedAddress : resolvedAddresses) {
- tmpList.add(new InetSocketAddress(resolvedAddress
- .getHostAddress(), address.getPort()));
private boolean isBetterSelection(List<StoreFile> bestSelection,
long bestSize, List<StoreFile> selection, long size, boolean mightBeStuck) {
if (mightBeStuck && bestSize > 0 && size > 0) {
// Keep the selection that removes most files for least size. That penaltizes adding
// large files to compaction, but not small files, so we don't become totally inefficient
// (might want to tweak that in future). Also, given the current order of looking at
// permutations, prefer earlier files and smaller selection if the difference is small.
final double REPLACE_IF_BETTER_BY = 1.05;
double thresholdQuality = ((double)bestSelection.size() / bestSize) * REPLACE_IF_BETTER_BY;
return thresholdQuality < ((double)selection.size() / size);
jps | awk '$2 != "Jps" {print $1}' | xargs kill
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
[INFO] Zeppelin ...........................................
@mwkang
mwkang / hbase hbaseid
Created August 9, 2016 05:42
/hbase/hbaseid 주키퍼에 접근할 수 없을 때 발생하는 stacktrace
2016-08-02 11:34:31,836 ERROR [main] zookeeper.ZooKeeperWatcher: hconnection-0x6c302a1d0x0, quorum=localhost:2181, baseZNode=/hbase Received unexpected KeeperException, re-throwing exception
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/hbaseid
at org.apache.zookeeper.KeeperException.create(KeeperException.java:99)
at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:1102)
at org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper.exists(RecoverableZooKeeper.java:220)
at org.apache.hadoop.hbase.zookeeper.ZKUtil.checkExists(ZKUtil.java:416)
at org.apache.hadoop.hbase.zookeeper.ZKClusterId.readClusterIdZNode(ZKClusterId.java:65)
at org.apache.hadoop.hbase.client.ZooKeeperRegistry.getClusterId(ZooKeeperRegistry.java:102)
at org.apache.hadoop.hbase.client.ConnectionImplementation.retrieveClusterId(ConnectionImplementation.java:443)
@Override
public int getProgress(InterpreterContext context) {
open();
return intp.getProgress(context);
}
@mwkang
mwkang / internedstrings.java
Created May 16, 2016 09:01
test for interned strings
{
List<String> set = Lists.newArrayList();
for (int i = 0; i < 5; i++) {
String a = new String("a");
String b = "a";
System.out.println(System.identityHashCode(a));
System.out.println(System.identityHashCode(b));
set.add("c");
System.out.println("?? =====> " + System.identityHashCode(set.get(0)));
set.clear();
@mwkang
mwkang / gem
Created February 28, 2016 05:06
sudo gem install -n /usr/local/bin GEM_NAME_HERE
@mwkang
mwkang / bash
Created February 28, 2016 05:02
GEM_HOME=/usr/local/bin