当前位置: 首页>>代码示例>>Java>>正文


Java TType类代码示例

本文整理汇总了Java中org.apache.thrift.protocol.TType的典型用法代码示例。如果您正苦于以下问题:Java TType类的具体用法?Java TType怎么用?Java TType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TType类属于org.apache.thrift.protocol包,在下文中一共展示了TType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import org.apache.thrift.protocol.TType; //导入依赖的package包/类
@Override
public boolean process(TProtocol in, TProtocol out) throws TException {
	TMessage msg = in.readMessageBegin();
	Controller<?, ?> fn = (Controller<?, ?>) this.beanFactory
			.getBean(msg.name);
	if (fn == null) {
		if (LOGGER.isWarnEnabled()) {
			LOGGER.warn("Invalid request: failed to find interface="
					+ msg.name + ", from: " + getInetAddress(in));
		}

		TProtocolUtil.skip(in, TType.STRUCT);
		in.readMessageEnd();
		TApplicationException x = new TApplicationException(
				TApplicationException.UNKNOWN_METHOD,
				"Invalid method name: '" + msg.name + "'");
		out.writeMessageBegin(new TMessage(msg.name,
				TMessageType.EXCEPTION, msg.seqid));
		x.write(out);
		out.writeMessageEnd();
		out.getTransport().flush();
		return true;
	}
	process(msg.seqid, msg.name, in, out, fn);
	return true;
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:27,代码来源:TProtobufProcessor.java

示例2: process

import org.apache.thrift.protocol.TType; //导入依赖的package包/类
@Override
public final boolean process(final TProtocol in, final TProtocol out)
    throws TException {
  final TMessage msg = in.readMessageBegin();
  final ProcessFunction<LocatorServiceImpl, ?> fn = this.fnMap
      .get(msg.name);
  if (fn != null) {
    fn.process(msg.seqid, in, out, this.inst);
    // terminate connection on receiving closeConnection
    // direct class comparison should be the fastest way
    return fn.getClass() != LocatorService.Processor.closeConnection.class;
  }
  else {
    TProtocolUtil.skip(in, TType.STRUCT);
    in.readMessageEnd();
    TApplicationException x = new TApplicationException(
        TApplicationException.UNKNOWN_METHOD, "Invalid method name: '"
            + msg.name + "'");
    out.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION,
        msg.seqid));
    x.write(out);
    out.writeMessageEnd();
    out.getTransport().flush();
    return true;
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:27,代码来源:LocatorServiceImpl.java

示例3: read

import org.apache.thrift.protocol.TType; //导入依赖的package包/类
/**
 * 读取操作
 */
@Override
public void read(TProtocol iprot) throws TException {
	if (!"org.apache.thrift.scheme.StandardScheme".equals(iprot.getScheme().getName()))
		throw new TApplicationException("Service scheme must be 'org.apache.thrift.scheme.StandardScheme' !");
	TField schemeField;
	iprot.readStructBegin();
	while (Boolean.TRUE) {
		schemeField = iprot.readFieldBegin();
		if (schemeField.type == TType.STOP)
			break;
		if (schemeField.type == TType.STRING)
			str = iprot.readString();
		else
			throw new TApplicationException("field type must be 'String' !");
		iprot.readFieldEnd();
	}
	iprot.readStructEnd();
}
 
开发者ID:venwyhk,项目名称:ikasoa,代码行数:22,代码来源:AbstractThriftBase.java

示例4: process

import org.apache.thrift.protocol.TType; //导入依赖的package包/类
@Override
public boolean process(TProtocol in, TProtocol out) throws TException {
  TMessage msg = in.readMessageBegin();
  ProcessFunction fn = processMap.get(msg.name);
  if (fn == null) {
    TProtocolUtil.skip(in, TType.STRUCT);
    in.readMessageEnd();
    TApplicationException x = new TApplicationException(TApplicationException.UNKNOWN_METHOD, "Invalid method name: '"+msg.name+"'");
    out.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));
    x.write(out);
    out.writeMessageEnd();
    out.getTransport().flush();
    return true;
  }
  fn.process(msg.seqid, in, out, iface);
  return true;
}
 
开发者ID:adityayadav76,项目名称:internet_of_things_simulator,代码行数:18,代码来源:TBaseProcessor.java

示例5: parseStruct

import org.apache.thrift.protocol.TType; //导入依赖的package包/类
public void parseStruct(JSONArray fieldsList,
                        Object request) throws TProtocolException, JSONException {
    if (!(request instanceof JSONObject)) {
        raiseExpected("JSON Object", request);
    }
    JSONObject jsonObject = (JSONObject) request;

    Iterator<String> it = jsonObject.keys();
    while (it.hasNext()) {
        String key = it.next();
        Object value = jsonObject.get(key);
        JSONObject fieldInfo = findInJsonArray(fieldsList, NAME_KEY, key);
        if (fieldInfo == null) {
            throw new TProtocolException(TProtocolException.INVALID_DATA,
                    new Exception("Unexpected key " + key));
        }

        byte fieldType = stringToTypeId(fieldInfo.getString(TYPE_ID_KEY));
        add(key, fieldType, (short) fieldInfo.optInt(KEY_KEY, 0));
        parse(fieldInfo, value, TYPE_ID_KEY, TYPE_KEY);
    }
    add("", TType.STOP, (short) -1);
}
 
开发者ID:degupta,项目名称:human_readable_json_protocol,代码行数:24,代码来源:HumanReadableJsonProtocol.java

示例6: write

import org.apache.thrift.protocol.TType; //导入依赖的package包/类
public void write(org.apache.thrift.protocol.TProtocol oprot, Log_args struct) throws org.apache.thrift.TException {
  struct.validate();

  oprot.writeStructBegin(STRUCT_DESC);
  if (struct.messages != null) {
    oprot.writeFieldBegin(MESSAGES_FIELD_DESC);
    {
      oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.messages.size()));
      for (LogEntry _iter3 : struct.messages)
      {
        _iter3.write(oprot);
      }
      oprot.writeListEnd();
    }
    oprot.writeFieldEnd();
  }
  oprot.writeFieldStop();
  oprot.writeStructEnd();
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:20,代码来源:scribe.java

示例7: read

import org.apache.thrift.protocol.TType; //导入依赖的package包/类
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, Log_args struct) throws org.apache.thrift.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  BitSet incoming = iprot.readBitSet(1);
  if (incoming.get(0)) {
    {
      org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
      struct.messages = new ArrayList<LogEntry>(_list5.size);
      for (int _i6 = 0; _i6 < _list5.size; ++_i6)
      {
        LogEntry _elem7; // required
        _elem7 = new LogEntry();
        _elem7.read(iprot);
        struct.messages.add(_elem7);
      }
    }
    struct.setMessagesIsSet(true);
  }
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:20,代码来源:scribe.java

示例8: writeFieldBegin

import org.apache.thrift.protocol.TType; //导入依赖的package包/类
@Override
public void writeFieldBegin(TField field) throws TException {
  if (field.type == TType.STOP) {
    return;
  }
  try {
    currentType = thriftFieldIdToParquetField[field.id];
    if (currentType == null) {
      throw new ParquetEncodingException("field " + field.id + " was not found in " + thriftType + " and " + schema.getType());
    }
    final int index = currentType.getIndex();
    recordConsumer.startField(currentType.getName(), index);
    currentProtocol = children[index];
  } catch (ArrayIndexOutOfBoundsException e) {
    throw new ParquetEncodingException("field " + field.id + " was not found in " + thriftType + " and " + schema.getType());
  }
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:18,代码来源:ParquetWriteProtocol.java

示例9: setTraceHeader

import org.apache.thrift.protocol.TType; //导入依赖的package包/类
public void setTraceHeader(ThriftHeader headerKey, Object value) throws TException {
    byte headerType = headerKey.getType();
    if (headerType == TType.STRING) {
        // skipped Strings are read as byte buffer.
        // see org.apache.thrift.protocol.TProtocolUtil.skip(TProtocol, byte, int)
        this.thriftHeaders.put(headerKey, byteBufferToString((ByteBuffer)value));
    } else if (headerType == TType.I64) {
        this.thriftHeaders.put(headerKey, (Long)value);
    } else if (headerType == TType.I16) {
        this.thriftHeaders.put(headerKey, (Short)value);
    } else if (headerType == TType.BOOL) {
        this.thriftHeaders.put(headerKey, (Boolean)value);
    } else {
        throw new TProtocolException("Invalid pinpoint header type - " + headerType);
    }
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:17,代码来源:ThriftRequestProperty.java

示例10: writeTraceHeader

import org.apache.thrift.protocol.TType; //导入依赖的package包/类
public void writeTraceHeader(ThriftHeader headerKey, TProtocol oprot) throws TException {
    Object headerValue = this.thriftHeaders.get(headerKey);
    if (headerValue == null) {
        return;
    }
    byte headerType = headerKey.getType();
    TField traceField = new TField(headerKey.name(), headerKey.getType(), headerKey.getId());
    oprot.writeFieldBegin(traceField);
    try {
        if (headerType == TType.STRING) {
            // these will be read as byte buffer although it's probably safe to just use writeString here.
            // see org.apache.thrift.protocol.TProtocolUtil.skip(TProtocol, byte, int)
            oprot.writeBinary(stringToByteBuffer((String)headerValue));
        } else if (headerType == TType.I64) {
            oprot.writeI64((Long)headerValue);
        } else if (headerType == TType.I16) {
            oprot.writeI16((Short)headerValue);
        } else if (headerType == TType.BOOL) {
            oprot.writeBool((Boolean)headerValue);
        } else {
            throw new TProtocolException("Invalid pinpoint header type - " + headerType);
        }
    } finally {
        oprot.writeFieldEnd();
    }
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:27,代码来源:ThriftRequestProperty.java

示例11: getTField

import org.apache.thrift.protocol.TType; //导入依赖的package包/类
private TField getTField(Object thriftObject, String fieldName) throws TException {
	try {
     Map<String, ThriftField> classFields = getClassFields(thriftObject);
     ThriftField thriftField = classFields.get(fieldName);

     if(thriftField==null) {
       // Empty field -> skip
       return new TField();
     }

     byte type = thriftField.fieldMetaData.valueMetaData.type;
     short id = thriftField.tfieldIdEnum.getThriftFieldId();

     // An enum type is deserialized as an I32
     if (TType.ENUM == type) {
       type = TType.I32;
     }

     return new TField("", type, id);
   } catch (Exception exp) {
		throw new TException("Unexpected getTField fieldName=" + fieldName, exp);
	}
}
 
开发者ID:BreizhBeans,项目名称:ThriftMongoBridge,代码行数:24,代码来源:TBSONProtocol.java

示例12: write

import org.apache.thrift.protocol.TType; //导入依赖的package包/类
public void write(TProtocol oprot) throws TException {
  TStruct struct = new TStruct("TApplicationException");
  TField field = new TField();
  oprot.writeStructBegin(struct);
  if (getMessage() != null) {
    field.name = "message";
    field.type = TType.STRING;
    field.id = 1;
    oprot.writeFieldBegin(field);
    oprot.writeString(getMessage());
    oprot.writeFieldEnd();
  }
  field.name = "type";
  field.type = TType.I32;
  field.id = 2;
  oprot.writeFieldBegin(field);
  oprot.writeI32(type_);
  oprot.writeFieldEnd();
  oprot.writeFieldStop();
  oprot.writeStructEnd();

}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:23,代码来源:TApplicationException.java

示例13: process

import org.apache.thrift.protocol.TType; //导入依赖的package包/类
public boolean process(TProtocol in, TProtocol out) throws TException {
  TMessage msg = in.readMessageBegin();
  ProcessFunction fn = processMap.get(msg.name);
  if (fn == null) {
    TProtocolUtil.skip(in, TType.STRUCT);
    in.readMessageEnd();
    TApplicationException x = new TApplicationException(TApplicationException.UNKNOWN_METHOD, "Invalid method name: '"+msg.name+"'");
    out.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));
    x.write(out);
    out.writeMessageEnd();
    out.getTransport().flush();
    return true;
  }
  fn.process(msg.seqid, in, out, iface);
  return true;
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:17,代码来源:TBaseProcessor.java

示例14: process

import org.apache.thrift.protocol.TType; //导入依赖的package包/类
@Override
public final boolean process(final TProtocol in, final TProtocol out)
    throws TException {
  final TMessage msg = in.readMessageBegin();
  final ProcessFunction<GFXDServiceImpl, ?> fn = this.fnMap.get(msg.name);
  if (fn != null) {
    fn.process(msg.seqid, in, out, this.inst);
    // terminate connection on receiving closeConnection
    // direct class comparison should be the fastest way
    // TODO: SW: also need to clean up connection artifacts in the case of
    // client connection failure (ConnectionListener does get a notification
    // but how to tie the socket/connectionNumber to the connectionID?)
    return fn.getClass() != GFXDService.Processor.closeConnection.class;
  }
  else {
    TProtocolUtil.skip(in, TType.STRUCT);
    in.readMessageEnd();
    TApplicationException x = new TApplicationException(
        TApplicationException.UNKNOWN_METHOD, "Invalid method name: '"
            + msg.name + "'");
    out.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION,
        msg.seqid));
    x.write(out);
    out.writeMessageEnd();
    out.getTransport().flush();
    return true;
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:29,代码来源:GFXDServiceImpl.java

示例15: write

import org.apache.thrift.protocol.TType; //导入依赖的package包/类
/**
 * 写入操作
 */
@Override
public void write(TProtocol oprot) throws TException {
	if (!"org.apache.thrift.scheme.StandardScheme".equals(oprot.getScheme().getName()))
		throw new TApplicationException("Service scheme must be 'org.apache.thrift.scheme.StandardScheme' !");
	oprot.writeStructBegin(getTStruct());
	if (str != null) {
		oprot.writeFieldBegin(new TField("value", TType.STRING, (short) 0));
		oprot.writeString(str);
		oprot.writeFieldEnd();
	}
	oprot.writeFieldStop();
	oprot.writeStructEnd();
}
 
开发者ID:venwyhk,项目名称:ikasoa,代码行数:17,代码来源:AbstractThriftBase.java


注:本文中的org.apache.thrift.protocol.TType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。