私は2台のマシン(Intel Atom(TM)CPU D525)を持っており、それぞれが異なるOS(1つのWindows 7と1つのubuntu 10.04)を実行しています。
Windows 7 マシンから Ubuntu マシンにイメージのスタックを送信したいと考えています。
私は今それを行うためにマルチスレッドを使用しています。私は以下のコードを添付しました:
public class RshScp implements Runnable
{
private StreamHandlers streamHandlers = new StreamHandlers();
private String screenFileName;
private int clientIndex;
private SingletonServer ss = null;
public RshScp(String screenFileName, int clientIndex, SingletonServer ss)
{
this.screenFileName = screenFileName;
this.clientIndex = clientIndex;
this.ss = ss;
}
public void run()
{
sendFileToClient();
}
public void sendFileToClient()
{
try
{
DisplayClient dc = null;
dc = ss.getClient(clientIndex);
String execution = sshFileRSH(dc.getHostName(), dc.getUserName(), screenFileName, dc.getRemoteDirectory(), dc.getLocalDirectory());
log.write(execution);
Process p1 = Runtime.getRuntime().exec(execution);
InputStreamReader isr = new InputStreamReader(p1.getInputStream());
streamHandlers.checkStreamOutput("From RshScp", isr);
} catch(Exception e){}
}
//Function to set the RSH SCP command
private String sshFileRSH(String hostName, String userName, String localFileNames, String remoteDirName, String localJobDirectory)
{
String fileTransferCommand = "scp " + localFileNames;
//String fileTransferCommand = "rsync --partial --progress --rsh=ssh " + localFileNames[0] + " " + localFileNames[1] + " " + localFileNames[2];
String destinationCommand = userName + "@" + hostName + ":" + remoteDirName;
String executionCommand = "";
executionCommand = fileTransferCommand + " " + destinationCommand;
return executionCommand;
} // end function
}//end while class
ファイルを複数のクライアントに送信しようとすると、速度が遅いことがわかりました。接続してクライアントにファイルを送信するのに 5 秒かかります。また、画像が失われることもあります。
マルチスレッドを遅くする実際に何が起こっているか知っている人はいますか? 接続と送信を高速化できるソリューションはありますか?