0

I have two servers, one that runs my program written in Java (Server A) and one that stores a graph (Server B) that must be continuously accessed by Server A. To access Server B you must ssh with a username and password using Server B's IP address. As of now I have failed to find a method to continuously access a directory on a different server and I am wondering if anyone knows a method that lets me do this (or if it is not possible, if there is a workaround).

I have looked into SSH libraries, but they all seem to only give you access to the directory for a brief amount of time. I need continuos access because I write and read from the graph on Server B all the time. I basically want to make a proxy directory on Server A that actually refers/links to the directory on Server B:

graphDb = new EmbeddedGraphDatabase("/192.168.1.**/media/graphDB");

Any help would be great.

Community
  • 1
  • 1
JBP
  • 1
  • 1
  • 1
    Could you mount Server B and access it as if it were a local drive? – Alper Akture Jul 30 '12 at 23:27
  • Could you describe the Network scenario and technologies? – Picarus Jul 30 '12 at 23:33
  • Related: http://stackoverflow.com/questions/14617/java-what-is-the-best-way-to-sftp-a-file-from-a-server – leonbloy Jul 30 '12 at 23:35
  • Both servers are linux 2.6.32 based running CentOS 6.2. Server A is accessible publicly because it will host the website. Server B is only accessible to servers/computers connected to the network. FTP access doesn't seem suitable because it allows you to manipulate files (copy, remove, move) but not necessarily edit the files continuously. At least that is how i see it. Mounting might do the trick! – JBP Jul 31 '12 at 00:55

2 Answers2

2

Probably unrelated option:

If client and server are Linux machines, you can use rsync to synchronize files between them. In that way you have a copy of the files on server A. The rsync command could be executed from the Java program or periodically from a cronjob on server A.

German
  • 3,560
  • 7
  • 32
  • 34
1
  • You could write your own client/server service, so that the server service provide you with the means to send data over the network to. It tends to be a lot of work though.
  • You could write your self a "heart beat" service on the client that tests the SSH connection and reestablishes it if it closes
  • You could "test" the ssh connection before you writing/reading from the connection
  • You could do as AlperAkture suggests (and mount the directory as a remote drive)
MadProgrammer
  • 343,457
  • 22
  • 230
  • 366