/tags/release-0.1-rc2/hive/external/service/lib/py/fb303/FacebookBase.py

# · Python · 82 lines · 43 code · 20 blank · 19 comment · 1 complexity · 62f0514c89ed3aeaf59015c90307a725 MD5 · raw file

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