blob: f8bc58c98c227438845d7642d52b9dec3c1dacc7 [file] [log] [blame]
pwyckoff99b000b2008-04-03 19:30:55 +00001// Copyright (c) 2006- Facebook
2// Distributed under the Thrift Software License
3//
4// See accompanying file LICENSE or visit the Thrift site at:
5// http://developers.facebook.com/thrift/
6
7package com.facebook.fb303;
8
9import java.util.AbstractMap;
10import java.util.HashMap;
11import java.util.concurrent.ConcurrentHashMap;
12
13public abstract class FacebookBase implements FacebookService.Iface {
14
15 private String name_;
16
17 private long alive_;
18
19 private final ConcurrentHashMap<String,Long> counters_ =
20 new ConcurrentHashMap<String, Long>();
21
22 private final ConcurrentHashMap<String,String> options_ =
23 new ConcurrentHashMap<String, String>();
24
25 protected FacebookBase(String name) {
26 name_ = name;
27 alive_ = System.currentTimeMillis() / 1000;
28 }
29
30 public String getName() {
31 return name_;
32 }
33
34 public abstract int getStatus();
35
36 public String getStatusDetails() {
37 return "";
38 }
39
40 public void deleteCounter(String key) {
41 counters_.remove(key);
42 }
43
44 public void resetCounter(String key) {
45 counters_.put(key, 0L);
46 }
47
48 public long incrementCounter(String key) {
49 long val = getCounter(key) + 1;
50 counters_.put(key, val);
51 return val;
52 }
53
54 public AbstractMap<String,Long> getCounters() {
55 return counters_;
56 }
57
58 public long getCounter(String key) {
59 Long val = counters_.get(key);
60 if (val == null) {
61 return 0;
62 }
63 return val.longValue();
64 }
65
66 public void setOption(String key, String value) {
67 options_.put(key, value);
68 }
69
70 public String getOption(String key) {
71 return options_.get(key);
72 }
73
74 public AbstractMap<String,String> getOptions() {
75 return options_;
76 }
77
78 public long aliveSince() {
79 return alive_;
80 }
81
82 public String getCpuProfile() {
83 return "";
84 }
85
pwyckoff99b000b2008-04-03 19:30:55 +000086 public void reinitialize() {}
87
88 public void shutdown() {}
89
90}