我使用micro服务和jrchjar点击“rediscli--pipe”,并通过setinputstream(data)连接数据;
shell执行器.java
/*
* Open a new session, with your username, host and port Set the
* password and call connect. session.connect() opens a new
* connection to remote SSH server. Once the connection is
* established, you can initiate a new channel. this channel is
* needed to connect to remotely execution program
*/jsch = new JSch();
session = jsch.getSession(CommonConstants.CACHE_SERVER_USERNAME, CommonConstants.CACHE_SERVER_IP, port);
session.setConfig("StrictHostKeyChecking", "no");
session.setPassword(CommonConstants.CACHE_SERVER_PASSWORD);
session.connect();
// create the excution channel over the session
channelExec = (ChannelExec) session.openChannel(CommonConstants.EXEC_TYPE);
// Gets an InputStream for this channel. All data arriving in as
// messages from the remote side can be read from this stream.
in = channelExec.getInputStream();
// Set the command that you want to execute
// In our case its the remote shell script
initialFile = new File(path);
targetStream = new FileInputStream(initialFile);
channelExec.setInputStream(targetStream);
channelExec.setCommand(RedisConstants.REDIS_CLI_PIPE);
channelExec.setErrStream(System.err);
// Execute the command
channelExec.connect();
// Read the output from the input stream we set above
reader = new BufferedReader(new InputStreamReader(in));
String line;
// Read each line from the buffered reader and add it to result list
// You can also simple print the result here
LOG.info(logId + MessageConstants.RESPONSE_FROM_REDIS + MessageConstants.START);
while ((line = reader.readLine()) != null) {
LOG.info(logId + CommonConstants.DOUBLE_COLON + line);
result.add(line);
}
LOG.info(logId + MessageConstants.RESPONSE_FROM_REDIS + MessageConstants.END);
// retrieve the exit status of the remote command corresponding to
// this channel
int exitStatus = channelExec.getExitStatus();
finalResult = checkExitStatus(channelExec, exitStatus, logId);
// Safely disconnect channel and disconnect session. If not done
// then it may cause resource leak
channelExec.disconnect();
session.disconnect();
-执行此代码后,从redis服务器获取错误
All data transferred. Waiting for the last reply...
ERR Protocol error: too big inline request
Error reading from the server: Connection reset by peer
数据.txt
HMSET email:cache email:variable:EN '{"data":[{"id":1,"variableName":"Channel Shop Name","variableDisplay":"${ChannelShopName}}]}.....'
-但是在上面的行中,hmset值是巨大的,所以在最后一个命令中得到上面的错误,这个命令有大量的数据,否则工作正常。
-data.txt文件中有一半的数据正在添加到redis服务器,但是有大量数据的命令抛出了这个错误。
-还尝试将命令转换为resp(redis protocol)格式
* 4
$5
HMSET
$17
application:cache
$7
DESC_EN
$12006
{"data":[{"id":1,"name":"Dashboard","imagePath":"../assets/icons/sidebar/dashboard.svg","routerLink":"user/dashboard","htmlId":"dashboard","submenus":[]}]}
但同样的错误来自redis服务器:
All data transferred. Waiting for the last reply...
ERR Protocol error: too big inline request
Error reading from the server: Connection reset by peer
请建议解决方案。。。。。
暂无答案!
目前还没有任何答案,快来回答吧!