David Reiss | 5ddabb8 | 2010-10-06 17:09:37 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
Jens Geyer | 72a714e | 2025-08-26 22:12:07 +0200 | [diff] [blame^] | 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 | |
David Reiss | 5ddabb8 | 2010-10-06 17:09:37 +0000 | [diff] [blame] | 22 | import sys |
| 23 | import time |
| 24 | from thrift.transport import TTransport |
| 25 | from thrift.transport import TSocket |
| 26 | from thrift.protocol import TBinaryProtocol |
| 27 | from thrift.server import THttpServer |
| 28 | from aggr import Aggr |
| 29 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 30 | |
David Reiss | 5ddabb8 | 2010-10-06 17:09:37 +0000 | [diff] [blame] | 31 | class AggrHandler(Aggr.Iface): |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 32 | def __init__(self): |
| 33 | self.values = [] |
David Reiss | 5ddabb8 | 2010-10-06 17:09:37 +0000 | [diff] [blame] | 34 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 35 | def addValue(self, value): |
| 36 | self.values.append(value) |
David Reiss | 5ddabb8 | 2010-10-06 17:09:37 +0000 | [diff] [blame] | 37 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 38 | def getValues(self, ): |
| 39 | time.sleep(1) |
| 40 | return self.values |
David Reiss | 5ddabb8 | 2010-10-06 17:09:37 +0000 | [diff] [blame] | 41 | |
| 42 | processor = Aggr.Processor(AggrHandler()) |
| 43 | pfactory = TBinaryProtocol.TBinaryProtocolFactory() |
| 44 | THttpServer.THttpServer(processor, ('', int(sys.argv[1])), pfactory).serve() |