<commit_before>package com.x.program.center.jaxrs.command;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.net.Socket;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;

import org.glassfish.jersey.media.multipart.FormDataContentDisposition;

import com.hankcs.hanlp.corpus.io.IOUtil;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.config.Nodes;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.gson.XGsonBuilder;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.Crypto;


public class ActionUploadFile  extends BaseAction {
    private static Logger logger = LoggerFactory.getLogger(CommandAction.class);

	ActionResult<Wo> execute(EffectivePerson effectivePerson,HttpServletRequest request, String ctl, String nodeName , String nodePort, InputStream fileInputStream, FormDataContentDisposition disposition) throws Exception {
			ActionResult<Wo> result = new ActionResult<>();	
			Wo wo  = null;
			String curServer = request.getLocalAddr();
			ByteArrayInputStream byteArrayInputStream = null;
			byte[] byteArray = IOUtil.readBytesFromOtherInputStream(fileInputStream);
			fileInputStream.close();
			if(nodeName.equalsIgnoreCase("*")) {
				Nodes nodes = Config.nodes();
				for (String node : nodes.keySet()){
					//先其他服务器
					if(!node.equalsIgnoreCase(curServer)) {
						if(nodes.get(node).getApplication().getEnable() || nodes.get(node).getCenter().getEnable()){
							 byteArrayInputStream = new ByteArrayInputStream(byteArray);
					      wo = executeCommand( ctl,  node ,  nodes.get(node).nodeAgentPort(),  byteArrayInputStream, disposition);
						}
					}
				   //后当前服务器
				    if(nodes.get(curServer).getApplication().getEnable() || nodes.get(curServer).getCenter().getEnable()){
				        	 byteArrayInputStream = new ByteArrayInputStream(byteArray);
					      wo = executeCommand( ctl,  curServer ,  nodes.get(curServer).nodeAgentPort(),  byteArrayInputStream, disposition);
			        }
				}
			}else {
				
			     wo = executeCommand( ctl,  nodeName ,  Integer.parseInt(nodePort),  fileInputStream, disposition);
			}
			
			result.setData(wo);
			return result;
	}

	synchronized private Wo executeCommand(String ctl , String nodeName ,int nodePort,InputStream fileInputStream, FormDataContentDisposition disposition) throws Exception{
		Wo wo = new Wo();
		wo.setNode(nodeName);
		wo.setStatus("success");
		try (Socket socket = new Socket(nodeName, nodePort)) {
			socket.setKeepAlive(true);
			socket.setSoTimeout(5000);
			DataOutputStream dos = null;
			DataInputStream dis  = null;
			try {<commit_msg>'修复一个错误'<commit_after>package com.x.program.center.jaxrs.command;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.net.Socket;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;

import org.glassfish.jersey.media.multipart.FormDataContentDisposition;

import com.hankcs.hanlp.corpus.io.IOUtil;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.config.Nodes;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.gson.XGsonBuilder;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.Crypto;


public class ActionUploadFile  extends BaseAction {
    private static Logger logger = LoggerFactory.getLogger(CommandAction.class);

	ActionResult<Wo> execute(EffectivePerson effectivePerson,HttpServletRequest request, String ctl, String nodeName , String nodePort, InputStream fileInputStream, FormDataContentDisposition disposition) throws Exception {
			ActionResult<Wo> result = new ActionResult<>();	
			Wo wo  = null;
			String curServer = request.getLocalAddr();
			ByteArrayInputStream byteArrayInputStream = null;
			byte[] byteArray = IOUtil.readBytesFromOtherInputStream(fileInputStream);
			fileInputStream.close();
			if(nodeName.equalsIgnoreCase("*")) {
				Nodes nodes = Config.nodes();
				for (String node : nodes.keySet()){
					//先其他服务器
					if(!node.equalsIgnoreCase(curServer)) {
						if(nodes.get(node).getApplication().getEnable() || nodes.get(node).getCenter().getEnable()){
							 byteArrayInputStream = new ByteArrayInputStream(byteArray);
					      wo = executeCommand( ctl,  node ,  nodes.get(node).nodeAgentPort(),  byteArrayInputStream, disposition);
						}
					}
				   //后当前服务器
				    if(nodes.get(curServer).getApplication().getEnable() || nodes.get(curServer).getCenter().getEnable()){
				        	 byteArrayInputStream = new ByteArrayInputStream(byteArray);
					      wo = executeCommand( ctl,  curServer ,  nodes.get(curServer).nodeAgentPort(),  byteArrayInputStream, disposition);
			        }
				}
			}else {
				
			     wo = executeCommand( ctl,  nodeName ,  Integer.parseInt(nodePort),  byteArrayInputStream, disposition);
			}
			
			result.setData(wo);
			return result;
	}

	synchronized private Wo executeCommand(String ctl , String nodeName ,int nodePort,InputStream fileInputStream, FormDataContentDisposition disposition) throws Exception{
		Wo wo = new Wo();
		wo.setNode(nodeName);
		wo.setStatus("success");
		try (Socket socket = new Socket(nodeName, nodePort)) {
			socket.setKeepAlive(true);
			socket.setSoTimeout(5000);
			DataOutputStream dos = null;
			DataInputStream dis  = null;
			try {
{'fraction_non_alphanumeric': 0.11409836065573771, 'fraction_numerical': 0.0013114754098360656, 'mean_word_length': 4.58188472095151, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6748843', 'n_tokens_mistral': 2029, 'n_tokens_neox': 1808, 'n_words': 340}