Java Code Examples for com.akaxin.proto.core.CoreProto#ErrorInfo

The following examples show how to use com.akaxin.proto.core.CoreProto#ErrorInfo . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NettyClientHandler.java    From openzaly with Apache License 2.0 6 votes vote down vote up
@Override
	protected void channelRead0(ChannelHandlerContext ctx, RedisCommand redisCmd) throws Exception {
		String version = redisCmd.getParameterByIndex(0);
		String action = redisCmd.getParameterByIndex(1);
		byte[] params = redisCmd.getBytesParamByIndex(2);

		CoreProto.TransportPackageData packageData = CoreProto.TransportPackageData.parseFrom(params);
		CoreProto.ErrorInfo errInfo = packageData.getErr();
		Command command = new Command();
		command.setHeader(packageData.getHeaderMap());
		command.setParams(packageData.getData().toByteArray());

//		logger.info("netty client channel handler command={}", command.toString());

		NettyClientHandler.this.nettyClient
				.handleResponse(new RedisCommandResponse(redisCmd, errInfo.getCode(), errInfo.getInfo()));
	}
 
Example 2
Source File: PushClient.java    From openzaly with Apache License 2.0 6 votes vote down vote up
private static byte[] getResponseBytes(RedisCommand redisCommand) {
	try {
		String version = redisCommand.getParameterByIndex(0);
		String action = redisCommand.getParameterByIndex(1);
		byte[] params = redisCommand.getBytesParamByIndex(2);
		logger.debug("get package bytes from platform {},{},{}", version, action, params);
		if (CommandConst.ACTION_RES.equals(action)) {
			CoreProto.TransportPackageData packageData = CoreProto.TransportPackageData.parseFrom(params);
			CoreProto.ErrorInfo error = packageData.getErr();
			if ("success".equals(error.getCode())) {
				return packageData.getData().toByteArray();
			}
		}
	} catch (Exception e) {
		logger.error("get package bytes eror,redisCommand={}", redisCommand.toString());
	}
	return null;
}
 
Example 3
Source File: PlatformClientHandler.java    From openzaly with Apache License 2.0 6 votes vote down vote up
@Override
protected void channelRead0(ChannelHandlerContext ctx, RedisCommand redisCmd) throws Exception {
	String version = redisCmd.getParameterByIndex(0);
	String action = redisCmd.getParameterByIndex(1);
	byte[] params = redisCmd.getBytesParamByIndex(2);

	CoreProto.TransportPackageData packageData = CoreProto.TransportPackageData.parseFrom(params);
	CoreProto.ErrorInfo errInfo = packageData.getErr();
	Command command = new Command();
	command.setHeader(packageData.getHeaderMap());
	command.setParams(packageData.getData().toByteArray());

	// logger.info("netty client channel handler command={}", command.toString());

	PlatformClientHandler.this.nettyClient
			.handleResponse(new RedisCommandResponse(redisCmd, errInfo.getCode(), errInfo.getInfo()));
}
 
Example 4
Source File: NettyClientHandler.java    From openzaly with Apache License 2.0 6 votes vote down vote up
@Override
	protected void channelRead0(ChannelHandlerContext ctx, RedisCommand redisCmd) throws Exception {
		String version = redisCmd.getParameterByIndex(0);
		String action = redisCmd.getParameterByIndex(1);
		byte[] params = redisCmd.getBytesParamByIndex(2);

		CoreProto.TransportPackageData packageData = CoreProto.TransportPackageData.parseFrom(params);
		CoreProto.ErrorInfo errInfo = packageData.getErr();
		Command command = new Command();
		command.setHeader(packageData.getHeaderMap());
		command.setParams(packageData.getData().toByteArray());

//		logger.info("netty client channel handler command={}", command.toString());

		NettyClientHandler.this.nettyClient
				.handleResponse(new RedisCommandResponse(redisCmd, errInfo.getCode(), errInfo.getInfo()));
	}
 
Example 5
Source File: ChannelWriter.java    From openzaly with Apache License 2.0 6 votes vote down vote up
public static void writeAndClose(final Channel channel, CommandResponse response) {
	CoreProto.TransportPackageData.Builder packageDataBuilder = CoreProto.TransportPackageData.newBuilder();
	CoreProto.ErrorInfo errorInfo = CoreProto.ErrorInfo.newBuilder().setCode(response.getErrCode())
			.setInfo(String.valueOf(response.getErrInfo())).build();
	packageDataBuilder.setErr(errorInfo);

	Map<Integer, String> header = new HashMap<Integer, String>();
	header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION);
	packageDataBuilder.putAllHeader(header);

	if (response.getParams() != null) {
		packageDataBuilder.setData(ByteString.copyFrom(response.getParams()));
	}
	channel.writeAndFlush(new RedisCommand().add(response.getVersion()).add(response.getAction())
			.add(packageDataBuilder.build().toByteArray()))
			.addListener(new GenericFutureListener<Future<? super Void>>() {

				@Override
				public void operationComplete(Future<? super Void> future) throws Exception {
					channel.close();
				}
			});
}
 
Example 6
Source File: ChannelWriter.java    From openzaly with Apache License 2.0 6 votes vote down vote up
public static void write(Channel channel, CommandResponse response) {
	CoreProto.TransportPackageData.Builder packageDataBuilder = CoreProto.TransportPackageData.newBuilder();
	CoreProto.ErrorInfo errorInfo = CoreProto.ErrorInfo.newBuilder().setCode(response.getErrCode())
			.setInfo(String.valueOf(response.getErrInfo())).build();
	packageDataBuilder.setErr(errorInfo);

	Map<Integer, String> header = new HashMap<Integer, String>();
	header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION);
	packageDataBuilder.putAllHeader(header);

	if (response.getParams() != null) {
		packageDataBuilder.setData(ByteString.copyFrom(response.getParams()));
	}
	channel.writeAndFlush(new RedisCommand().add(response.getVersion()).add(response.getAction())
			.add(packageDataBuilder.build().toByteArray()));
}
 
Example 7
Source File: ApiRequestHandler.java    From openzaly with Apache License 2.0 6 votes vote down vote up
private void tellClientSessionError(final Channel channel) {
	// response
	CoreProto.TransportPackageData.Builder packageBuilder = CoreProto.TransportPackageData.newBuilder();
	// header
	Map<Integer, String> header = new HashMap<Integer, String>();
	// 站点业务版本(proto版本)
	header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION);
	packageBuilder.putAllHeader(header);
	// errCode
	CoreProto.ErrorInfo errInfo = CoreProto.ErrorInfo.newBuilder().setCode(ErrorCode2.ERROR_SESSION.getCode())
			.setInfo(ErrorCode2.ERROR_SESSION.getInfo()).build();
	packageBuilder.setErr(errInfo);

	// 协议版本 CommandConst.PROTOCOL_VERSION=1.0
	String protocolVersion = CommandConst.PROTOCOL_VERSION;
	String action = CommandConst.ACTION_RES;
	channel.writeAndFlush(
			new RedisCommand().add(protocolVersion).add(action).add(packageBuilder.build().toByteArray()))
			.addListener(new GenericFutureListener<Future<? super Void>>() {

				public void operationComplete(Future<? super Void> future) throws Exception {
					channel.close();
				}
			});
}
 
Example 8
Source File: PlatformClient.java    From openzaly with Apache License 2.0 6 votes vote down vote up
private static byte[] getResponseBytes(RedisCommand redisCommand) {
	try {
		String version = redisCommand.getParameterByIndex(0);
		String action = redisCommand.getParameterByIndex(1);
		byte[] params = redisCommand.getBytesParamByIndex(2);
		logger.debug("get package bytes from platform {},{},{}", version, action, params);
		if (CommandConst.ACTION_RES.equals(action)) {
			CoreProto.TransportPackageData packageData = CoreProto.TransportPackageData.parseFrom(params);
			CoreProto.ErrorInfo error = packageData.getErr();
			if ("success".equals(error.getCode())) {
				return packageData.getData().toByteArray();
			}
		}
	} catch (Exception e) {
		logger.error("get package bytes eror,redisCommand={}", redisCommand.toString());
	}
	return null;
}
 
Example 9
Source File: PushClient.java    From openzaly with Apache License 2.0 6 votes vote down vote up
private static byte[] getResponseBytes(RedisCommand redisCommand) {
	try {
		String version = redisCommand.getParameterByIndex(0);
		String action = redisCommand.getParameterByIndex(1);
		byte[] params = redisCommand.getBytesParamByIndex(2);
		logger.debug("get package bytes from platform {},{},{}", version, action, params);
		if (CommandConst.ACTION_RES.equals(action)) {
			CoreProto.TransportPackageData packageData = CoreProto.TransportPackageData.parseFrom(params);
			CoreProto.ErrorInfo error = packageData.getErr();
			if ("success".equals(error.getCode())) {
				return packageData.getData().toByteArray();
			}
		}
	} catch (Exception e) {
		logger.error("get package bytes eror,redisCommand={}", redisCommand.toString());
	}
	return null;
}
 
Example 10
Source File: PlatformClientHandler.java    From openzaly with Apache License 2.0 6 votes vote down vote up
@Override
protected void channelRead0(ChannelHandlerContext ctx, RedisCommand redisCmd) throws Exception {
	String version = redisCmd.getParameterByIndex(0);
	String action = redisCmd.getParameterByIndex(1);
	byte[] params = redisCmd.getBytesParamByIndex(2);

	CoreProto.TransportPackageData packageData = CoreProto.TransportPackageData.parseFrom(params);
	CoreProto.ErrorInfo errInfo = packageData.getErr();
	Command command = new Command();
	command.setHeader(packageData.getHeaderMap());
	command.setParams(packageData.getData().toByteArray());

	// logger.info("netty client channel handler command={}", command.toString());

	PlatformClientHandler.this.nettyClient
			.handleResponse(new RedisCommandResponse(redisCmd, errInfo.getCode(), errInfo.getInfo()));
}
 
Example 11
Source File: PushClient.java    From wind-im with Apache License 2.0 6 votes vote down vote up
private static byte[] getResponseBytes(RedisCommand redisCommand) {
	try {
		String version = redisCommand.getParameterByIndex(0);
		String action = redisCommand.getParameterByIndex(1);
		byte[] params = redisCommand.getBytesParamByIndex(2);
		logger.debug("get package bytes from platform {},{},{}", version, action, params);
		if (CommandConst.ACTION_RES.equals(action)) {
			CoreProto.TransportPackageData packageData = CoreProto.TransportPackageData.parseFrom(params);
			CoreProto.ErrorInfo error = packageData.getErr();
			if ("success".equals(error.getCode())) {
				return packageData.getData().toByteArray();
			}
		}
	} catch (Exception e) {
		logger.error("get package bytes eror,redisCommand={}", redisCommand.toString());
	}
	return null;
}
 
Example 12
Source File: ChannelWriter.java    From openzaly with Apache License 2.0 6 votes vote down vote up
public static void writeAndClose(final Channel channel, CommandResponse response) {
	CoreProto.TransportPackageData.Builder packageDataBuilder = CoreProto.TransportPackageData.newBuilder();
	CoreProto.ErrorInfo errorInfo = CoreProto.ErrorInfo.newBuilder().setCode(response.getErrCode())
			.setInfo(String.valueOf(response.getErrInfo())).build();
	packageDataBuilder.setErr(errorInfo);

	Map<Integer, String> header = new HashMap<Integer, String>();
	header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION);
	packageDataBuilder.putAllHeader(header);

	if (response.getParams() != null) {
		packageDataBuilder.setData(ByteString.copyFrom(response.getParams()));
	}
	channel.writeAndFlush(new RedisCommand().add(response.getVersion()).add(response.getAction())
			.add(packageDataBuilder.build().toByteArray()))
			.addListener(new GenericFutureListener<Future<? super Void>>() {

				@Override
				public void operationComplete(Future<? super Void> future) throws Exception {
					channel.close();
				}
			});
}
 
Example 13
Source File: ChannelWriter.java    From openzaly with Apache License 2.0 6 votes vote down vote up
public static void write(Channel channel, CommandResponse response) {
	CoreProto.TransportPackageData.Builder packageDataBuilder = CoreProto.TransportPackageData.newBuilder();
	CoreProto.ErrorInfo errorInfo = CoreProto.ErrorInfo.newBuilder().setCode(response.getErrCode())
			.setInfo(String.valueOf(response.getErrInfo())).build();
	packageDataBuilder.setErr(errorInfo);

	Map<Integer, String> header = new HashMap<Integer, String>();
	header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION);
	packageDataBuilder.putAllHeader(header);

	if (response.getParams() != null) {
		packageDataBuilder.setData(ByteString.copyFrom(response.getParams()));
	}
	channel.writeAndFlush(new RedisCommand().add(response.getVersion()).add(response.getAction())
			.add(packageDataBuilder.build().toByteArray()));
}
 
Example 14
Source File: ApiRequestHandler.java    From openzaly with Apache License 2.0 6 votes vote down vote up
private void tellClientSessionError(final Channel channel) {
	// response
	CoreProto.TransportPackageData.Builder packageBuilder = CoreProto.TransportPackageData.newBuilder();
	// header
	Map<Integer, String> header = new HashMap<Integer, String>();
	// 站点业务版本(proto版本)
	header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION);
	packageBuilder.putAllHeader(header);
	// errCode
	CoreProto.ErrorInfo errInfo = CoreProto.ErrorInfo.newBuilder().setCode(ErrorCode2.ERROR_SESSION.getCode())
			.setInfo(ErrorCode2.ERROR_SESSION.getInfo()).build();
	packageBuilder.setErr(errInfo);

	// 协议版本 CommandConst.PROTOCOL_VERSION=1.0
	String protocolVersion = CommandConst.PROTOCOL_VERSION;
	String action = CommandConst.ACTION_RES;
	channel.writeAndFlush(
			new RedisCommand().add(protocolVersion).add(action).add(packageBuilder.build().toByteArray()))
			.addListener(new GenericFutureListener<Future<? super Void>>() {

				public void operationComplete(Future<? super Void> future) throws Exception {
					channel.close();
				}
			});
}
 
Example 15
Source File: PlatformClient.java    From openzaly with Apache License 2.0 6 votes vote down vote up
private static byte[] getResponseBytes(RedisCommand redisCommand) {
	try {
		String version = redisCommand.getParameterByIndex(0);
		String action = redisCommand.getParameterByIndex(1);
		byte[] params = redisCommand.getBytesParamByIndex(2);
		logger.debug("get package bytes from platform {},{},{}", version, action, params);
		if (CommandConst.ACTION_RES.equals(action)) {
			CoreProto.TransportPackageData packageData = CoreProto.TransportPackageData.parseFrom(params);
			CoreProto.ErrorInfo error = packageData.getErr();
			if ("success".equals(error.getCode())) {
				return packageData.getData().toByteArray();
			}
		}
	} catch (Exception e) {
		logger.error("get package bytes eror,redisCommand={}", redisCommand.toString());
	}
	return null;
}
 
Example 16
Source File: PlatformClientHandler.java    From wind-im with Apache License 2.0 6 votes vote down vote up
@Override
protected void channelRead0(ChannelHandlerContext ctx, RedisCommand redisCmd) throws Exception {
	String version = redisCmd.getParameterByIndex(0);
	String action = redisCmd.getParameterByIndex(1);
	byte[] params = redisCmd.getBytesParamByIndex(2);

	CoreProto.TransportPackageData packageData = CoreProto.TransportPackageData.parseFrom(params);
	CoreProto.ErrorInfo errInfo = packageData.getErr();
	Command command = new Command();
	command.setHeader(packageData.getHeaderMap());
	command.setParams(packageData.getData().toByteArray());

	// logger.info("netty client channel handler command={}", command.toString());

	PlatformClientHandler.this.nettyClient
			.handleResponse(new RedisCommandResponse(redisCmd, errInfo.getCode(), errInfo.getInfo()));
}
 
Example 17
Source File: NettyClientHandler.java    From wind-im with Apache License 2.0 6 votes vote down vote up
@Override
	protected void channelRead0(ChannelHandlerContext ctx, RedisCommand redisCmd) throws Exception {
		String version = redisCmd.getParameterByIndex(0);
		String action = redisCmd.getParameterByIndex(1);
		byte[] params = redisCmd.getBytesParamByIndex(2);

		CoreProto.TransportPackageData packageData = CoreProto.TransportPackageData.parseFrom(params);
		CoreProto.ErrorInfo errInfo = packageData.getErr();
		Command command = new Command();
		command.setHeader(packageData.getHeaderMap());
		command.setParams(packageData.getData().toByteArray());

//		logger.info("netty client channel handler command={}", command.toString());

		NettyClientHandler.this.nettyClient
				.handleResponse(new RedisCommandResponse(redisCmd, errInfo.getCode(), errInfo.getInfo()));
	}
 
Example 18
Source File: ChannelWriter.java    From wind-im with Apache License 2.0 6 votes vote down vote up
public static void writeAndClose(final Channel channel, CommandResponse response) {
	CoreProto.TransportPackageData.Builder packageDataBuilder = CoreProto.TransportPackageData.newBuilder();
	CoreProto.ErrorInfo errorInfo = CoreProto.ErrorInfo.newBuilder().setCode(response.getErrCode())
			.setInfo(String.valueOf(response.getErrInfo())).build();
	packageDataBuilder.setErr(errorInfo);

	Map<Integer, String> header = new HashMap<Integer, String>();
	header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION);
	packageDataBuilder.putAllHeader(header);

	if (response.getParams() != null) {
		packageDataBuilder.setData(ByteString.copyFrom(response.getParams()));
	}
	channel.writeAndFlush(new RedisCommand().add(response.getVersion()).add(response.getAction())
			.add(packageDataBuilder.build().toByteArray()))
			.addListener(new GenericFutureListener<Future<? super Void>>() {

				@Override
				public void operationComplete(Future<? super Void> future) throws Exception {
					channel.close();
				}
			});
}
 
Example 19
Source File: ChannelWriter.java    From wind-im with Apache License 2.0 6 votes vote down vote up
public static void write(Channel channel, CommandResponse response) {
	CoreProto.TransportPackageData.Builder packageDataBuilder = CoreProto.TransportPackageData.newBuilder();
	CoreProto.ErrorInfo errorInfo = CoreProto.ErrorInfo.newBuilder().setCode(response.getErrCode())
			.setInfo(String.valueOf(response.getErrInfo())).build();
	packageDataBuilder.setErr(errorInfo);

	Map<Integer, String> header = new HashMap<Integer, String>();
	header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION);
	packageDataBuilder.putAllHeader(header);

	if (response.getParams() != null) {
		packageDataBuilder.setData(ByteString.copyFrom(response.getParams()));
	}
	channel.writeAndFlush(new RedisCommand().add(response.getVersion()).add(response.getAction())
			.add(packageDataBuilder.build().toByteArray()));
}
 
Example 20
Source File: PlatformClient.java    From wind-im with Apache License 2.0 6 votes vote down vote up
private static byte[] getResponseBytes(RedisCommand redisCommand) {
	try {
		String version = redisCommand.getParameterByIndex(0);
		String action = redisCommand.getParameterByIndex(1);
		byte[] params = redisCommand.getBytesParamByIndex(2);
		logger.debug("get package bytes from platform {},{},{}", version, action, params);
		if (CommandConst.ACTION_RES.equals(action)) {
			CoreProto.TransportPackageData packageData = CoreProto.TransportPackageData.parseFrom(params);
			CoreProto.ErrorInfo error = packageData.getErr();
			if ("success".equals(error.getCode())) {
				return packageData.getData().toByteArray();
			}
		}
	} catch (Exception e) {
		logger.error("get package bytes eror,redisCommand={}", redisCommand.toString());
	}
	return null;
}