add fb303 to thrift contrib

Summary: Add clean version of fb303 to thrift contrib readying for open sourcing scribe

Reviewed By: dreiss

Test Plan: bootstrap.sh, make, make install on a fresh machine and then try compiling and running scribe open source version.

Revert: OK

TracCamp Project: Thrift

DiffCamp Revision: 10841


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665634 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/contrib/fb303/java/FacebookBase.java b/contrib/fb303/java/FacebookBase.java
new file mode 100644
index 0000000..c9fe43b
--- /dev/null
+++ b/contrib/fb303/java/FacebookBase.java
@@ -0,0 +1,94 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+package com.facebook.fb303;
+
+import java.util.AbstractMap;
+import java.util.HashMap;
+import java.util.concurrent.ConcurrentHashMap;
+
+public abstract class FacebookBase implements FacebookService.Iface {
+
+  private String name_;
+
+  private long alive_;
+
+  private final ConcurrentHashMap<String,Long> counters_ =
+    new ConcurrentHashMap<String, Long>();
+
+  private final ConcurrentHashMap<String,String> options_ =
+    new ConcurrentHashMap<String, String>();
+
+  protected FacebookBase(String name) {
+    name_ = name;
+    alive_ = System.currentTimeMillis() / 1000;
+  }
+
+  public String getName() {
+    return name_;
+  }
+
+  public abstract int getStatus();
+
+  public String getStatusDetails() {
+    return "";
+  }
+
+  public void deleteCounter(String key) {
+    counters_.remove(key);
+  }
+
+  public void resetCounter(String key) {
+    counters_.put(key, 0L);
+  }
+
+  public long incrementCounter(String key) {
+    long val = getCounter(key) + 1;
+    counters_.put(key, val);
+    return val;
+  }
+
+  public AbstractMap<String,Long> getCounters() {
+    return counters_;
+  }
+
+  public long getCounter(String key) {
+    Long val = counters_.get(key);
+    if (val == null) {
+      return 0;
+    }
+    return val.longValue();
+  }
+
+  public void setOption(String key, String value) {
+    options_.put(key, value);
+  }
+
+  public String getOption(String key) {
+    return options_.get(key);
+  }
+
+  public AbstractMap<String,String> getOptions() {
+    return options_;
+  }
+
+  public long aliveSince() {
+    return alive_;
+  }
+
+  public String getCpuProfile() {
+    return "";
+  }
+
+  public com.facebook.thrift.reflection.limited.Service getLimitedReflection() {
+    return new com.facebook.thrift.reflection.limited.Service();
+  }
+
+  public void reinitialize() {}
+
+  public void shutdown() {}
+
+}