rpc获取user

back_recharge
jiahuiwen 2021-11-10 18:53:42 +08:00
parent 372c0f9f9f
commit f7baeed51e
7 changed files with 942 additions and 24 deletions

View File

@ -1,7 +1,9 @@
package com.ljsd;
import com.google.gson.Gson;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.ktbeans.KtEventUtils;
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
import com.ljsd.jieling.logic.OnlineUserManager;
@ -273,4 +275,19 @@ public class CoreService implements RPCRequestIFace.Iface {
public Set<String> getSensitiveWord(String txt, int matchType) throws TException {
return null;
}
@Override
public String getUserByRPC(int uid) throws TException {
User user = null;
try {
user = UserManager.getUser(uid, true);
} catch (Exception e) {
e.printStackTrace();
}
Gson gson = RedisUtil.getInstence().getGson();
if (user != null) {
return gson.toJson(user);
}
return "";
}
}

View File

@ -318,16 +318,16 @@ public class MongoUtil {
return mongoTemplate;
}
//初始化 数据库映射 无合服操作拦截
public MongoTemplate getMonogTemplate2(int serverId){
MongoTemplate mongoTemplate = mongoTemplateMap.get(serverId);
if(mongoTemplate == null){
String dbName = "jieling_"+serverId;
// new MongoTemplate(this.mongoDbFactory(), this.mappingMongoConverter1())
MappingMongoConverter mappingMongoConverter = (MappingMongoConverter) ConfigurableApplicationContextManager.getBean("mappingMongoConverter1");
MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(mongoClient, dbName);
mongoTemplate = new MongoTemplate(mongoDbFactory, mappingMongoConverter);
mongoTemplateMap.put(serverId,mongoTemplate);
}
return mongoTemplate;
}
// public MongoTemplate getMonogTemplate2(int serverId){
// MongoTemplate mongoTemplate = mongoTemplateMap.get(serverId);
// if(mongoTemplate == null){
// String dbName = "jieling_"+serverId;
// // new MongoTemplate(this.mongoDbFactory(), this.mappingMongoConverter1())
// MappingMongoConverter mappingMongoConverter = (MappingMongoConverter) ConfigurableApplicationContextManager.getBean("mappingMongoConverter1");
// MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(mongoClient, dbName);
// mongoTemplate = new MongoTemplate(mongoDbFactory, mappingMongoConverter);
// mongoTemplateMap.put(serverId,mongoTemplate);
// }
// return mongoTemplate;
// }
}

View File

@ -47,6 +47,9 @@ public class RedisUtil {
private StringRedisTemplate redisTemplate;
public Gson getGson() {
return gson;
}
public void init(){
redisTemplate = ConfigurableApplicationContextManager.getBean(StringRedisTemplate.class);

View File

@ -166,22 +166,13 @@ public class CrossServiceLogic {
return player;
}
try {
// 连接mongo库获取服务器id
MongoTemplate core = MongoUtil.getCoreMongoTemplate();
Query query = new Query(Criteria.where("_id").is(uid));
UserInfo userInfo = core.findOne(query, UserInfo.class);
if (userInfo == null) {
return null;
}
// 连接跨服游戏库,获取玩家信息
MongoTemplate game = MongoUtil.getInstence().getMonogTemplate2(Integer.parseInt(userInfo.getServerId()));
User user = game.findOne(query, User.class);
User user = PlayerLogic.getInstance().getUserByRpc(uid);
if (user == null) {
return null;
}
player = formatUserToPlayer(user);
RedisUtil.getInstence().setObject(getKey(player.getUserId()), player, EXPIRE);
} catch (UnknownHostException e) {
} catch (Exception e) {
e.printStackTrace();
}
return player;

View File

@ -1,5 +1,6 @@
package com.ljsd.jieling.logic.player;
import com.google.gson.Gson;
import com.ljsd.CoreService;
import com.ljsd.GameApplication;
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
@ -50,6 +51,7 @@ import com.ljsd.jieling.thrift.pool.ClientAdapterPo;
import com.ljsd.jieling.util.*;
import config.*;
import manager.STableManager;
import org.luaj.vm2.ast.Str;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rpc.protocols.CommonProto;
@ -1686,4 +1688,56 @@ public class PlayerLogic {
}
}
}
/**
* RPC user
* @param uid
* @return
* @throws Exception
*/
public User getUserByRpc(int uid) throws Exception {
Integer serverId = RedisUtil.getInstence().getObject(RedisKey.CUser_ServerId_Key, Integer.toString(uid), Integer.class, -1);
if (serverId == null) {
return null;
}
if (serverId == GameApplication.serverId) {
return UserManager.getUser(uid, true);
}
String rpcString = RedisUtil.getInstence().getObject(RedisKey.LOGIC_SERVER_INFO, Integer.toString(serverId), String.class, -1);
String[] split = rpcString.split(":");
if (split.length < 4) {
LOGGER.error("获取玩家rpc地址长度错误rpc{},玩家id{},服务器id{}", rpcString, uid, serverId);
return null;
}
String ip = rpcString.split(":")[0];
String port = rpcString.split(":")[3];
//rpc 数据调用
//String ip =csPlayer.getRpcIp();
//int port = csPlayer.getRpcPort();
StringBuilder sb = new StringBuilder();
sb.append("RPCCORE").append("|")
.append(ip).append("|")
.append(port);
ClientAdapterPo<RPCRequestIFace.Client> rPCClient = null;
String userStr = null ;
try{
rPCClient = ClientAdapterPo.getClientAdapterPo(sb.toString());
userStr = rPCClient.getClient().getUserByRPC(uid);
}catch (Exception e) {
LOGGER.error("callback=>{}", e);
} finally {
if(rPCClient != null){
rPCClient.returnObject(sb.toString());
}else{
LOGGER.info("callback=> rPCClient is null ");
return null;
}
}
if (userStr == null) {
return null;
}
Gson gson = RedisUtil.getInstence().getGson();
User user = gson.fromJson(userStr, User.class);
return user;
}
}

View File

@ -34,7 +34,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2021-10-21")
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2021-11-10")
public class RPCRequestIFace {
public interface Iface {
@ -51,6 +51,8 @@ public class RPCRequestIFace {
public Set<String> getSensitiveWord(String txt, int matchType) throws org.apache.thrift.TException;
public String getUserByRPC(int uid) throws org.apache.thrift.TException;
}
public interface AsyncIface {
@ -67,6 +69,8 @@ public class RPCRequestIFace {
public void getSensitiveWord(String txt, int matchType, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
public void getUserByRPC(int uid, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
}
public static class Client extends org.apache.thrift.TServiceClient implements Iface {
@ -236,6 +240,29 @@ public class RPCRequestIFace {
throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getSensitiveWord failed: unknown result");
}
public String getUserByRPC(int uid) throws org.apache.thrift.TException
{
send_getUserByRPC(uid);
return recv_getUserByRPC();
}
public void send_getUserByRPC(int uid) throws org.apache.thrift.TException
{
getUserByRPC_args args = new getUserByRPC_args();
args.setUid(uid);
sendBase("getUserByRPC", args);
}
public String recv_getUserByRPC() throws org.apache.thrift.TException
{
getUserByRPC_result result = new getUserByRPC_result();
receiveBase(result, "getUserByRPC");
if (result.isSetSuccess()) {
return result.success;
}
throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getUserByRPC failed: unknown result");
}
}
public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface {
public static class Factory implements org.apache.thrift.async.TAsyncClientFactory<AsyncClient> {
@ -473,6 +500,38 @@ public class RPCRequestIFace {
}
}
public void getUserByRPC(int uid, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
checkReady();
getUserByRPC_call method_call = new getUserByRPC_call(uid, resultHandler, this, ___protocolFactory, ___transport);
this.___currentMethod = method_call;
___manager.call(method_call);
}
public static class getUserByRPC_call extends org.apache.thrift.async.TAsyncMethodCall {
private int uid;
public getUserByRPC_call(int uid, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
super(client, protocolFactory, transport, resultHandler, false);
this.uid = uid;
}
public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getUserByRPC", org.apache.thrift.protocol.TMessageType.CALL, 0));
getUserByRPC_args args = new getUserByRPC_args();
args.setUid(uid);
args.write(prot);
prot.writeMessageEnd();
}
public String getResult() throws org.apache.thrift.TException {
if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
throw new IllegalStateException("Method call not finished!");
}
org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array());
org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport);
return (new Client(prot)).recv_getUserByRPC();
}
}
}
public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor<I> implements org.apache.thrift.TProcessor {
@ -492,6 +551,7 @@ public class RPCRequestIFace {
processMap.put("getHeroManagerInfo", new getHeroManagerInfo());
processMap.put("isContaintSensitiveWord", new isContaintSensitiveWord());
processMap.put("getSensitiveWord", new getSensitiveWord());
processMap.put("getUserByRPC", new getUserByRPC());
return processMap;
}
@ -620,6 +680,26 @@ public class RPCRequestIFace {
}
}
public static class getUserByRPC<I extends Iface> extends org.apache.thrift.ProcessFunction<I, getUserByRPC_args> {
public getUserByRPC() {
super("getUserByRPC");
}
public getUserByRPC_args getEmptyArgsInstance() {
return new getUserByRPC_args();
}
protected boolean isOneway() {
return false;
}
public getUserByRPC_result getResult(I iface, getUserByRPC_args args) throws org.apache.thrift.TException {
getUserByRPC_result result = new getUserByRPC_result();
result.success = iface.getUserByRPC(args.uid);
return result;
}
}
}
public static class AsyncProcessor<I extends AsyncIface> extends org.apache.thrift.TBaseAsyncProcessor<I> {
@ -639,6 +719,7 @@ public class RPCRequestIFace {
processMap.put("getHeroManagerInfo", new getHeroManagerInfo());
processMap.put("isContaintSensitiveWord", new isContaintSensitiveWord());
processMap.put("getSensitiveWord", new getSensitiveWord());
processMap.put("getUserByRPC", new getUserByRPC());
return processMap;
}
@ -954,6 +1035,57 @@ public class RPCRequestIFace {
}
}
public static class getUserByRPC<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getUserByRPC_args, String> {
public getUserByRPC() {
super("getUserByRPC");
}
public getUserByRPC_args getEmptyArgsInstance() {
return new getUserByRPC_args();
}
public AsyncMethodCallback<String> getResultHandler(final AsyncFrameBuffer fb, final int seqid) {
final org.apache.thrift.AsyncProcessFunction fcall = this;
return new AsyncMethodCallback<String>() {
public void onComplete(String o) {
getUserByRPC_result result = new getUserByRPC_result();
result.success = o;
try {
fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
return;
} catch (Exception e) {
LOGGER.error("Exception writing to internal frame buffer", e);
}
fb.close();
}
public void onError(Exception e) {
byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
org.apache.thrift.TBase msg;
getUserByRPC_result result = new getUserByRPC_result();
{
msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
}
try {
fcall.sendResponse(fb,msg,msgType,seqid);
return;
} catch (Exception ex) {
LOGGER.error("Exception writing to internal frame buffer", ex);
}
fb.close();
}
};
}
protected boolean isOneway() {
return false;
}
public void start(I iface, getUserByRPC_args args, org.apache.thrift.async.AsyncMethodCallback<String> resultHandler) throws TException {
iface.getUserByRPC(args.uid,resultHandler);
}
}
}
public static class deliveryRecharge_args implements org.apache.thrift.TBase<deliveryRecharge_args, deliveryRecharge_args._Fields>, java.io.Serializable, Cloneable, Comparable<deliveryRecharge_args> {
@ -6261,4 +6393,724 @@ public class RPCRequestIFace {
}
public static class getUserByRPC_args implements org.apache.thrift.TBase<getUserByRPC_args, getUserByRPC_args._Fields>, java.io.Serializable, Cloneable, Comparable<getUserByRPC_args> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUserByRPC_args");
private static final org.apache.thrift.protocol.TField UID_FIELD_DESC = new org.apache.thrift.protocol.TField("uid", org.apache.thrift.protocol.TType.I32, (short)1);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new getUserByRPC_argsStandardSchemeFactory());
schemes.put(TupleScheme.class, new getUserByRPC_argsTupleSchemeFactory());
}
public int uid; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
UID((short)1, "uid");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // UID
return UID;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final int __UID_ISSET_ID = 0;
private byte __isset_bitfield = 0;
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.UID, new org.apache.thrift.meta_data.FieldMetaData("uid", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserByRPC_args.class, metaDataMap);
}
public getUserByRPC_args() {
}
public getUserByRPC_args(
int uid)
{
this();
this.uid = uid;
setUidIsSet(true);
}
/**
* Performs a deep copy on <i>other</i>.
*/
public getUserByRPC_args(getUserByRPC_args other) {
__isset_bitfield = other.__isset_bitfield;
this.uid = other.uid;
}
public getUserByRPC_args deepCopy() {
return new getUserByRPC_args(this);
}
@Override
public void clear() {
setUidIsSet(false);
this.uid = 0;
}
public int getUid() {
return this.uid;
}
public getUserByRPC_args setUid(int uid) {
this.uid = uid;
setUidIsSet(true);
return this;
}
public void unsetUid() {
__isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __UID_ISSET_ID);
}
/** Returns true if field uid is set (has been assigned a value) and false otherwise */
public boolean isSetUid() {
return EncodingUtils.testBit(__isset_bitfield, __UID_ISSET_ID);
}
public void setUidIsSet(boolean value) {
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __UID_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case UID:
if (value == null) {
unsetUid();
} else {
setUid((Integer)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case UID:
return Integer.valueOf(getUid());
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case UID:
return isSetUid();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof getUserByRPC_args)
return this.equals((getUserByRPC_args)that);
return false;
}
public boolean equals(getUserByRPC_args that) {
if (that == null)
return false;
boolean this_present_uid = true;
boolean that_present_uid = true;
if (this_present_uid || that_present_uid) {
if (!(this_present_uid && that_present_uid))
return false;
if (this.uid != that.uid)
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_uid = true;
list.add(present_uid);
if (present_uid)
list.add(uid);
return list.hashCode();
}
@Override
public int compareTo(getUserByRPC_args other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetUid()).compareTo(other.isSetUid());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetUid()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.uid, other.uid);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("getUserByRPC_args(");
boolean first = true;
sb.append("uid:");
sb.append(this.uid);
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bitfield = 0;
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class getUserByRPC_argsStandardSchemeFactory implements SchemeFactory {
public getUserByRPC_argsStandardScheme getScheme() {
return new getUserByRPC_argsStandardScheme();
}
}
private static class getUserByRPC_argsStandardScheme extends StandardScheme<getUserByRPC_args> {
public void read(org.apache.thrift.protocol.TProtocol iprot, getUserByRPC_args struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // UID
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.uid = iprot.readI32();
struct.setUidIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, getUserByRPC_args struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
oprot.writeFieldBegin(UID_FIELD_DESC);
oprot.writeI32(struct.uid);
oprot.writeFieldEnd();
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class getUserByRPC_argsTupleSchemeFactory implements SchemeFactory {
public getUserByRPC_argsTupleScheme getScheme() {
return new getUserByRPC_argsTupleScheme();
}
}
private static class getUserByRPC_argsTupleScheme extends TupleScheme<getUserByRPC_args> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, getUserByRPC_args struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
BitSet optionals = new BitSet();
if (struct.isSetUid()) {
optionals.set(0);
}
oprot.writeBitSet(optionals, 1);
if (struct.isSetUid()) {
oprot.writeI32(struct.uid);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, getUserByRPC_args struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
BitSet incoming = iprot.readBitSet(1);
if (incoming.get(0)) {
struct.uid = iprot.readI32();
struct.setUidIsSet(true);
}
}
}
}
public static class getUserByRPC_result implements org.apache.thrift.TBase<getUserByRPC_result, getUserByRPC_result._Fields>, java.io.Serializable, Cloneable, Comparable<getUserByRPC_result> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUserByRPC_result");
private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRING, (short)0);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new getUserByRPC_resultStandardSchemeFactory());
schemes.put(TupleScheme.class, new getUserByRPC_resultTupleSchemeFactory());
}
public String success; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
SUCCESS((short)0, "success");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 0: // SUCCESS
return SUCCESS;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserByRPC_result.class, metaDataMap);
}
public getUserByRPC_result() {
}
public getUserByRPC_result(
String success)
{
this();
this.success = success;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public getUserByRPC_result(getUserByRPC_result other) {
if (other.isSetSuccess()) {
this.success = other.success;
}
}
public getUserByRPC_result deepCopy() {
return new getUserByRPC_result(this);
}
@Override
public void clear() {
this.success = null;
}
public String getSuccess() {
return this.success;
}
public getUserByRPC_result setSuccess(String success) {
this.success = success;
return this;
}
public void unsetSuccess() {
this.success = null;
}
/** Returns true if field success is set (has been assigned a value) and false otherwise */
public boolean isSetSuccess() {
return this.success != null;
}
public void setSuccessIsSet(boolean value) {
if (!value) {
this.success = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case SUCCESS:
if (value == null) {
unsetSuccess();
} else {
setSuccess((String)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case SUCCESS:
return getSuccess();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case SUCCESS:
return isSetSuccess();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof getUserByRPC_result)
return this.equals((getUserByRPC_result)that);
return false;
}
public boolean equals(getUserByRPC_result that) {
if (that == null)
return false;
boolean this_present_success = true && this.isSetSuccess();
boolean that_present_success = true && that.isSetSuccess();
if (this_present_success || that_present_success) {
if (!(this_present_success && that_present_success))
return false;
if (!this.success.equals(that.success))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_success = true && (isSetSuccess());
list.add(present_success);
if (present_success)
list.add(success);
return list.hashCode();
}
@Override
public int compareTo(getUserByRPC_result other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetSuccess()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("getUserByRPC_result(");
boolean first = true;
sb.append("success:");
if (this.success == null) {
sb.append("null");
} else {
sb.append(this.success);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class getUserByRPC_resultStandardSchemeFactory implements SchemeFactory {
public getUserByRPC_resultStandardScheme getScheme() {
return new getUserByRPC_resultStandardScheme();
}
}
private static class getUserByRPC_resultStandardScheme extends StandardScheme<getUserByRPC_result> {
public void read(org.apache.thrift.protocol.TProtocol iprot, getUserByRPC_result struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 0: // SUCCESS
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.success = iprot.readString();
struct.setSuccessIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, getUserByRPC_result struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.success != null) {
oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
oprot.writeString(struct.success);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class getUserByRPC_resultTupleSchemeFactory implements SchemeFactory {
public getUserByRPC_resultTupleScheme getScheme() {
return new getUserByRPC_resultTupleScheme();
}
}
private static class getUserByRPC_resultTupleScheme extends TupleScheme<getUserByRPC_result> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, getUserByRPC_result struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
BitSet optionals = new BitSet();
if (struct.isSetSuccess()) {
optionals.set(0);
}
oprot.writeBitSet(optionals, 1);
if (struct.isSetSuccess()) {
oprot.writeString(struct.success);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, getUserByRPC_result struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
BitSet incoming = iprot.readBitSet(1);
if (incoming.get(0)) {
struct.success = iprot.readString();
struct.setSuccessIsSet(true);
}
}
}
}
}

View File

@ -104,5 +104,6 @@ service RPCRequestIFace{
bool isContaintSensitiveWord(1:string txt, 2:i32 matchType);
//
set<string> getSensitiveWord(1:string txt, 2:i32 matchType);
string getUserByRPC(1:i32 uid);
}