简体   繁体   English

两台机器上运行的进程之间的通信

[英]communication between processes running on two machines

So, I have two Linux machines, I am running a java code on machine A and doing ssh to run some simulation on machine B. What are the ways in which I can pass the result back to machine A when it is done with computations (I do not want to use a db). 因此,我有两台Linux机器,我在机器A上运行一个Java代码,并通过ssh在机器B上运行一些模拟。通过计算完成后,可以将结果传递回机器A的方式是什么(我不想使用数据库)。 The results are mainly Status messages of each module, if it performed as expected or not. 结果主要是每个模块的状态消息,无论是否按预期执行。 Also how to track the status of simulation running of machine B (I can check pid of process, if it exists then the job is running, but is there any better method). 还有如何跟踪机器B的模拟运行状态(我可以检查进程的pid,如果存在,则该作业正在运行,但是有什么更好的方法)。 Machine B has some security restrictions, like I can not open a port etc. 机器B有一些安全限制,例如我无法打开端口等。

Using jSCH 使用jSCH

    JSch shell = new JSch();
    session = shell.getSession(userName, serverIP, 22);  
    session.setPassword(password);

        session.setTimeout(timeout);
        java.util.Properties config = new java.util.Properties();
        config.put("StrictHostKeyChecking", "no");
        session.setConfig(config);
        session.connect();      

        channel = session.openChannel("shell");  
        input = new InputStreamReader(channel.getInputStream(), encoding);  
        output = new PrintStream(channel.getOutputStream());  

        channel.connect(); 

            output.write ("/home/test/runCommand");

            // result
            while ((ch = input.read () != -1) {....}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM