| 30 |
ashish |
1 |
#!/usr/bin/env python
|
|
|
2 |
|
|
|
3 |
#
|
|
|
4 |
# Licensed to the Apache Software Foundation (ASF) under one
|
|
|
5 |
# or more contributor license agreements. See the NOTICE file
|
|
|
6 |
# distributed with this work for additional information
|
|
|
7 |
# regarding copyright ownership. The ASF licenses this file
|
|
|
8 |
# to you under the Apache License, Version 2.0 (the
|
|
|
9 |
# "License"); you may not use this file except in compliance
|
|
|
10 |
# with the License. You may obtain a copy of the License at
|
|
|
11 |
#
|
|
|
12 |
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
13 |
#
|
|
|
14 |
# Unless required by applicable law or agreed to in writing,
|
|
|
15 |
# software distributed under the License is distributed on an
|
|
|
16 |
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
17 |
# KIND, either express or implied. See the License for the
|
|
|
18 |
# specific language governing permissions and limitations
|
|
|
19 |
# under the License.
|
|
|
20 |
#
|
|
|
21 |
|
|
|
22 |
import time
|
|
|
23 |
import FacebookService
|
|
|
24 |
import thrift.reflection.limited
|
|
|
25 |
from ttypes import fb_status
|
|
|
26 |
|
|
|
27 |
class FacebookBase(FacebookService.Iface):
|
|
|
28 |
|
|
|
29 |
def __init__(self, name):
|
|
|
30 |
self.name = name
|
|
|
31 |
self.alive = int(time.time())
|
|
|
32 |
self.counters = {}
|
|
|
33 |
|
|
|
34 |
def getName(self, ):
|
|
|
35 |
return self.name
|
|
|
36 |
|
|
|
37 |
def getVersion(self, ):
|
|
|
38 |
return ''
|
|
|
39 |
|
|
|
40 |
def getStatus(self, ):
|
|
|
41 |
return fb_status.ALIVE
|
|
|
42 |
|
|
|
43 |
def getCounters(self):
|
|
|
44 |
return self.counters
|
|
|
45 |
|
|
|
46 |
def resetCounter(self, key):
|
|
|
47 |
self.counters[key] = 0
|
|
|
48 |
|
|
|
49 |
def getCounter(self, key):
|
|
|
50 |
if self.counters.has_key(key):
|
|
|
51 |
return self.counters[key]
|
|
|
52 |
return 0
|
|
|
53 |
|
|
|
54 |
def incrementCounter(self, key):
|
|
|
55 |
self.counters[key] = self.getCounter(key) + 1
|
|
|
56 |
|
|
|
57 |
def setOption(self, key, value):
|
|
|
58 |
pass
|
|
|
59 |
|
|
|
60 |
def getOption(self, key):
|
|
|
61 |
return ""
|
|
|
62 |
|
|
|
63 |
def getOptions(self):
|
|
|
64 |
return {}
|
|
|
65 |
|
|
|
66 |
def getOptions(self):
|
|
|
67 |
return {}
|
|
|
68 |
|
|
|
69 |
def aliveSince(self):
|
|
|
70 |
return self.alive
|
|
|
71 |
|
|
|
72 |
def getCpuProfile(self, duration):
|
|
|
73 |
return ""
|
|
|
74 |
|
|
|
75 |
def getLimitedReflection(self):
|
|
|
76 |
return thrift.reflection.limited.Service()
|
|
|
77 |
|
|
|
78 |
def reinitialize(self):
|
|
|
79 |
pass
|
|
|
80 |
|
|
|
81 |
def shutdown(self):
|
|
|
82 |
pass
|