Copy files from multiple remote servers using JAVA - java

I need some advice and some suggestions on which approach to follow to create my application.
Objective :
Copy log files from around 14 to 16 remote servers to a client application, which would be used for monitoring purposes.
I know I can write a Multi-threaded or thread-pooled server-client application in java, but would that be feasible?
Or if there is a way that allows the java client application to log-in to the server and copy files from it all by itself, just as we use 'SCP'.
(Is it even possible?)
Or if there is a much better of handling such issues.
Which approach would be better and why?
Edit:
I want to copy files from a remote server, and the question is that whether should I use a client-server socket program to do so, or a library such as JSch?

Maybe you can consider my advise. I once programmed it the other way around. Copying files to one central file server. The program was installed on several servers.
This was implemented with Spring Integration. I've created a message channel with an outbound ftp channel adapter. This setup did the job with little implementation and configuration.
I know Spring Integration for FTP is also using JSCH under the hood.

Related

JSF web application to monitor client resources

I have to provide a way in which a server will monitor its client's resources (i.e. cpu usage and ram) and store the data in a database.
I am learning about the JSF right now and aim to develop a web application that will use OperatingSystemMXBean methods on the client to get the resources of that machine. The problem is that I am not sure if this is the right approach to the task or even possible to do it with the JSF - operatingSystemMXBean combo.
My question - is it possible to do it this way? And if yes, is this approach worth the effort or is there a far simpler way of doing it.
Thank you.
You can not run java code on the client side. As you are new to JSF you should read more about this technology. The java codes that you write in jsf pages compile in the server side and the result will pass to client browser. If you want to get client resources like ram and cpu you need third party apps on the client side. Maybe there were some plugins that installs on client browser to do this(or you write your own) that you should search more about this. And also another approach is that you write a program which installs in the client pc to send his resources information to your server over internet.

How to implement a socket for a Java EE application in Tomcat

I've a Python application for data analysis and a Java EE application for web monitoring. Now I need to establish a durable communication between them, in order to transfer the analysis result from python to java.
Since both of the applications are located at the same server, I want to implement a TCP socket. As for the data volume, there're about 10 sensors' data transferred per second. I'm using Tomcat 8.0 for Java EE and a simple script for python. So my questions are :
Is socket implementation a good idea ?
If yes, how to implement it, can somebody give me a tutorial or example ?
If not, what should I do next ?
Additional information
I saw a related question on StackOverflow How to serve a socket from a Java EE application, there're some propositions :
Implement a Connector (JCA). But I think the target runtime is JBoss rather than Tomcat.
Implement a Java Naming and Directory Interface (JNDI). That's what I'm trying as you can see as my previous question Why JNDI resource can only be called once in Tomcat? People use JNDI for using resources, e.g. db connection. So I'm not sure if it's a good way for realtime communication. And I've met many troubles by learning it.
I thought about web-socket. But does it mean I need a python server as well ?
I believe there is a hundred way to do it to share data between these technologies. But for Java you should keep it simple. In Tomcat you don't need to write a socket implementation, you just need a basic Servlet implementation. So basically for your questions.
Is socket implementation a good idea ?
Shortly NO.
If yes, how to implement it, can somebody give me a tutorial or
example ?
Already answered NO.
If not, what should I do next ?
Write a basic servlet application who listen an server url address. Your phyton script is just a client. In phyton site you just send a POST request to servlet url and in Java side get the request read your data and process it. You can start to learn Servlet from Mkyong.

Javafx web client with a server

I have to make a final project (Software Engineering) which should be on web (I chose javafx over HTML5). The project's purpose is to learn people typing blindly. The user gets a sentence and he should rewrite it. The application should save all the information of users so that is why I need a server.
I have got some questions:
Can I use simple java socket server with javafx?
If the answer is yes, are there web hosting services that support simple socket server? I heard something about tomcat or something like this. If the answer is no, what other choices do I have?
What is the best plugin for eclipse to work with javafx? I mean, I need a designer.
Another thing that I need from the server is to send sound files to the client, which type of java server allows it?
Can I use simple java socket server with javafx?
Yes. It's a Java application, after all, and you can open a socket (client or server).
If the answer is yes, are there web hosting services that support simple socket server? I heard something about tomcat or something like this. If the answer is no, what other choices do I have?
You should not focus on this. Instead, try to create a set of (REST) services. Your application in the server side (Jetty, Tomcat or whatever) will be the producer and your Java FX application will be a consumer of these services.
What is the best plugin for eclipse to work with javafx? I mean, I need a designer.
This is off topic because it falls into personal preference. I don't know about such a designer. And IMO I prefer to design in my head and just write the code I come up with that.
Another thing that I need from the server is to send sound files to the client, which type of java server allows it?
A sound file is a file, after all, and a file is just a byte[] that will be sent through the net. Learn how to handle this when creating/consuming your services.

Know any embeddable NNTP servers?

I'm writing a bit of code that uses the Apache NNTP Client to fetch articles from an NNTP server. Once the code ships, we'll use an Apache James server to read the articles from. But to test the code, I'm looking for an embedded Java NNTP server, so I don't have to mock every server call. Are there any good ones I can use? Google seems to have failed me.
My requirements are as follows:
A server I can start from within the code.
Tests can be run out-of-the-box on different machines without additional setup. (Once I commit the code, a remote build machine needs to be able to run the test cases).
Any other inspired suggestions are also welcome.
There is sonews, which seems to be active and supports a suprising lot of database backends. I didn't look at it further, so I can't tell if you can embed it.

What is the best way to create a client-server application with a Java Web Start program?

Ok so I have created an application, which is a Java Web Start application, but I have determined that I will need to write data to the server machine, hence the need for an additional server application. Pretty much I want the client to send different strings in order to process a clients requests in varying ways (eg create a new user file on the server machine or send user data read from a file to the client machine).
I was thinking of possibly using sockets, but if there is a better way then I'm all for that. Also I assume that whatever I do use, I will need to use threading in order to process many simultaneous requests, is this correct?
For your purpose you better create a webservice which communicates over http for exchanging data. I would recommend doing this in Java or maybe creating a WCF in C#.
Tutorials in Eclipse for java webservice: http://www.vogella.com/articles/REST/article.html#first_project
In netbeans: http://netbeans.org/kb/docs/websvc/jax-ws.html
The first tutorial is a restful service which is pretty popular and easy to grasp.
Good luck!

Categories