Design help to schedule file polling and api call [closed] - java

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
What is the best way to schedule a java program, after searching for some time we came across below 3 ways, which is the better of these three, is something that is getting us confused and if there is any better way please let us know.
One way 1:
Create a windows task scheduler service to execute a standalone java program to fetch file info and make webService call. Like this)
Second way 2:
Create a quartz scheduler service to execute a standalone java program to fetch file info and make webService call. Like this
Third way 3:
Use TimerTask(available in java.util package) to execute task in another class.like this
Please suggest which is better way to do it.

Solution 3, would be running throughout all time and will be in memory all time.
I feel you go with solution 2, as quartz gives you OS independence and allows have more options that windows scheduler.
Don't understand the down votes as you had done your research but asking for additional suggestion though.

Related

How to handle data synchronisation between 2 Spring apps? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm looking for the optimal way to handle the following scenario, preferably some implementation that's already been made for something like this.
There are two Systems (Springboot Webapps) that are supposed to communicate which each other through a Rest-gateway. Transfers shall be handled with Json over HTTP.
1st System is the Project part, 2nd System is the Persons part and they both implement their own persistent sql-database. Both systems depend on each others data and it cannot be expected that both systems are online at all times.
What would be the best way to achieve that both systems data is always up 2 date? Is there any plugin you could recommend to handle the synchronization process which also implements scenarios like one system shutting down while sending or the other way round?
Thanks in advance!
If you can't expect both systems to be online at all times, and you don't want any downtime when one of them is down, I think that the best way to do it is to share a common database. This has some problems of its own and you should think if it's worth, maybe you would be better having two completely independent services which rely on each other and being ready to replicate one of them if it's needed.

How to make function in java that starts other function at specific time [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I need to use java (unfortunately i don't know this code well) function that will be able to start another function at specific time. For example i set time for 13 next day and function automatically starts another function. I will be very grateful if someone would help me.
You can use a timer to schedule tasks, but for schedules that are set several days in the future, you first need to answer if your application will be running that long. If not, you should look at cron jobs the native scheduler specific to your OS.
java.util.Timer#schedule
See javadoc https://docs.oracle.com/javase/8/docs/api/java/util/Timer.html#schedule-java.util.TimerTask-java.util.Date- for more details
another (preferred) option is to use
java.util.concurrent.ScheduledExecutorService#schedule

Apache spark on eclipse [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
The question I asked was marked as too broad. After searching around more I got my basics more clear. So hopefully I will be much more specific now.
Basically I was trying to run the sample examples given on eclipse rather than on terminal. My first doubt has already been answered correctly. Using setMaster("local"). I got the example running n it displayed output quite correctly. Now if I change this to setMaster("yarn-client") now it connects to yarn, also submits the job then runs it but finally I get classnotfoundexception and hence reduce not completed. If I want to use yarn-client do I need to add some extra specification for my class so that I don't get classnotfoundexception. For this entire process I used the inbuilt JavaPiSpark example program in my version of spark. Any help or suggestion is welcome.
You should use JavaSparkContext .setMaster("local") to run on your local machine or replace the "local" with a specific master URL to run on clusters.
Please refer spark programming guide - initializing-spark and master-urls

Java Timer vs. Linux Cronjob [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I'm doing automation on data fetching using Java , which approach is better for task automation? Linux cronjob or Java Timer?
for example the tasks to execute hourly, first day of week, first day of month, thanks in advance.
If you need the application to be always running for some other reason, and the data fetching happen frequently, you can consider using java task.
If you will write an application just for this purpose, or it is an application you dont need to to be always open since its not perfoming other continuos action, i'd prefer a cronjob, so you can have the app out of the memory most time.
Also, notice cronjobs are very efficent, and fully trustable. So if the data frecuency is important and is not just related to some runtime features, i'd also prefer cronjob
This is just for mentioning a few high level scenarios, but as Keppil said, it could depend on many other aspects.
It might depend on what you want, but I will say that the times I have created automated tasks I have used cron jobs or Windows scheduled tasks. As Carlos stated, the Java program would have to be running in order to even be able to perform the operations. So if it is a production application and it dies, then the jobs can't be kicked off till it is brought back up again. Also, setting up a cron job is typically easier than writing a program.
On the other had, if it is a system that you do not have admin rights to and are unable to create or edit cron jobs but are able to kick off a Java program, the Java program might be easier.
Overall, the cron job seems to be the industry "best practice" (sorry for the buzz word), but, again, it might depend on your specific situation.

How do I profile applications on Windows and Linux to get CPU and RAM usuage values? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am busy doing some research and I need to do a comparison between two methods of system monitoring. I have to compare the total memory of overhead and computation required when queries are made to an external software package (i.e one that I did not create but running on the same system) as well the overhead in my software package (written in JAVA) when including all the libraries and making all the queries.
Does anyone have any suggestions on how I can approach this task to achieve these goals? Are there any general profiling solutions available that just "plug" into your system monitor and retrieve the system statistics this way? Or just a pointer in the right direction would be more than helpful right now as I am completely stuck :/
Thanks in advance.
You can use VisualVM (For sure in Windows, but don't know about Linux) (or) You can write a simple program using JMX API.

Categories