blob: c4772f706a98512ca1c9c53a694161e24002c91a [file] [log] [blame]
David Reiss5ddabb82010-10-06 17:09:37 +00001#!/usr/bin/env python
Jens Geyer72a714e2025-08-26 22:12:07 +02002
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 Reiss5ddabb82010-10-06 17:09:37 +000022import sys
23import time
24from thrift.transport import TTransport
25from thrift.transport import TSocket
26from thrift.protocol import TBinaryProtocol
27from thrift.server import THttpServer
28from aggr import Aggr
29
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090030
David Reiss5ddabb82010-10-06 17:09:37 +000031class AggrHandler(Aggr.Iface):
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090032 def __init__(self):
33 self.values = []
David Reiss5ddabb82010-10-06 17:09:37 +000034
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090035 def addValue(self, value):
36 self.values.append(value)
David Reiss5ddabb82010-10-06 17:09:37 +000037
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090038 def getValues(self, ):
39 time.sleep(1)
40 return self.values
David Reiss5ddabb82010-10-06 17:09:37 +000041
42processor = Aggr.Processor(AggrHandler())
43pfactory = TBinaryProtocol.TBinaryProtocolFactory()
44THttpServer.THttpServer(processor, ('', int(sys.argv[1])), pfactory).serve()