コード例 #1
0
ファイル: testioreflect.py プロジェクト: jivega/avro
 def nextdata(self, schm, d=0):
   if schm.gettype() == schema.RECORD:
     clazz = reflectio.gettype(schm, _PKGNAME)
     result = clazz()
     for field in schm.getfields().values():
       result.__setattr__(field.getname(), self.nextdata(field.getschema(),d))
     return result
   else:
     return testio.RandomData.nextdata(self, schm, d)
コード例 #2
0
ファイル: testioreflect.py プロジェクト: vjykumar/avro
 def nextdata(self, schm, d=0):
     if schm.gettype() == schema.RECORD:
         clazz = reflectio.gettype(schm, _PKGNAME)
         result = clazz()
         for field in schm.getfields().values():
             result.__setattr__(field.getname(),
                                self.nextdata(field.getschema(), d))
         return result
     else:
         return testio.RandomData.nextdata(self, schm, d)
コード例 #3
0
ファイル: testipcreflect.py プロジェクト: vjykumar/avro
#http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.

import socket, struct
import avro.schema as schema
import avro.reflectio as reflectio
import avro.reflectipc as reflectipc
import avro.ipc as ipc
import testipc, testio, testioreflect

TestRecord = reflectio.gettype(testipc.PROTOCOL.gettypes().get("TestRecord"), 
                               testioreflect._PKGNAME)
TestError = reflectio.gettype(testipc.PROTOCOL.gettypes().get("TestError"), 
                              testioreflect._PKGNAME, ipc.AvroRemoteException)

class TestImpl(object):

  def hello(self, req):
    return unicode('goodbye')

  def echo(self, req):
    return req

  def echoBytes(self, req):
    return req

  def error(self):
コード例 #4
0
ファイル: ipc.py プロジェクト: vjykumar/avro
_PKGNAME = "org.apache.avro.ipc."
_HANDSHAKE_FILE_DIR = os.path.dirname(__file__).__str__() + os.path.sep
_HANDSHAKE_REQUEST_SCHEMA = schema.parse(
    open(_HANDSHAKE_FILE_DIR + "HandshakeRequest.avsc").read())
_HANDSHAKE_RESPONSE_SCHEMA = schema.parse(
    open(_HANDSHAKE_FILE_DIR + "HandshakeResponse.avsc").read())
_HANDSHAKE_REQUESTOR_WRITER = reflectio.ReflectDatumWriter(
    _PKGNAME, _HANDSHAKE_REQUEST_SCHEMA)
_HANDSHAKE_REQUESTOR_READER = reflectio.ReflectDatumReader(
    _PKGNAME, _HANDSHAKE_RESPONSE_SCHEMA)
_HANDSHAKE_RESPONDER_WRITER = reflectio.ReflectDatumWriter(
    _PKGNAME, _HANDSHAKE_RESPONSE_SCHEMA)
_HANDSHAKE_RESPONDER_READER = reflectio.ReflectDatumReader(
    _PKGNAME, _HANDSHAKE_REQUEST_SCHEMA)
_HandshakeRequest = reflectio.gettype(_HANDSHAKE_REQUEST_SCHEMA, _PKGNAME)
_HandshakeResponse = reflectio.gettype(_HANDSHAKE_RESPONSE_SCHEMA, _PKGNAME)
_HANDSHAKE_MATCH_BOTH = "BOTH"
_HANDSHAKE_MATCH_CLIENT = "CLIENT"
_HANDSHAKE_MATCH_NONE = "NONE"
_REMOTE_HASHES = dict()
_REMOTE_PROTOCOLS = dict()

_META_SCHEMA = schema.parse("{\"type\": \"map\", \"values\": \"bytes\"}")
_META_WRITER = genericio.DatumWriter(_META_SCHEMA)
_META_READER = genericio.DatumReader(_META_SCHEMA)


class RequestorBase(object):
    """Base class for the client side of a protocol interaction."""
    def __init__(self, localproto, transceiver):