If I'm using Play! to build a scala web app, how can I connect to a remote instance, run a map reduce job there? I have the scripts for the map reduce job, just not sure how I can connect to the instance within play and run the map reduce job on the instance using parameter data I get from the user through the web app?
Related
I'm looking for some suggestions on how I could manage external dependencies when I want to run my Play framework based app locally.
I have a Play based application that connects to a database to look up application data. In order to run this against a specific environment, it is not a problem, but what if say I want to run this locally? With the current setup, if there is no database available, my app would just not start! I mean, without a database running my application also has no meaning as I could not do anything without data!
I'm using MongoDB as my database, so I see the following possibilities to enable running my application locally!
Use in memory mode from MongoDB
Use some sort of docker container to run a MongoDB instance locally
Is there any other possibility that is worth exploring?
I create an instance of the Apache Service but when when I try to bring up it's console the console page hangs indefinitely with a spinning cursor.
For this stage of the Bluemix Apache Spark beta, you can only create apps from the Spark Starter boilerplate at the top of the catalog. A Spark Starter app will automatically create an instance of the Apache Spark service and will give you access to that service instance strictly for the purpose of using Jupyter/IPython notebooks. Later on in the beta, you should expect more functionality to be made available; and direct usage of a spark service instance is quite possible ;-)
Once you create an app from the Spark Starter boilerplate, you can click on the route/URL from the dashboard for the app and that will take you into a home page for that app. The Launch button you see there will take you to the Jupyter/IPython notebook server that utilizes the Apache Spark bluemix service.
I'm currently experimenting about building a self-contained web app that runs with embedded server. To run the app is just simply by executing
java -jar application.jar -Dserver.port=80
The thing is, starting the application from executing the line above until it can really listen to incoming requests needs a lot of time. In the sample above, I'm using Java's Spring Boot example, but it can be other libraries or other language.
With that problem above, deploying by killing the current server PID, symlink the new artifact, and then running the new artifact will have a slight downtime.
Another constraint is that, I can only have one instance at one time. So provisioning a new instance then deploying the new artifact into the new instance and then switch the instances from the load-balancer is out of question.
So, how do I do this?
I am beginner for Google App Engine.
I have simple java application with a class in which there is main method which executes some threads.
Actually, it's Java application which is used to execute some back-end activities.
On my Linux server, i have created a cron job which executes this class at some specific time interval.
Now, I want to move this application to Google App Engine.
I did search about that and what i find is i have to convert this java application to web application to deploy on GAE.
Please guide me how i can deploy JAR to GAE.
Thanks
Yes, your java application needs to be a web application. That is, you'd need to have a WEB-INFO directory within your jar, with the correct xml files (i.e. web.xml and appengine-web.xml).
Please, start by following one of the tutorials here:
https://cloud.google.com/appengine/docs/java/gettingstarted/introduction
You also mentioned that you use threads in your application. I believe that on App Engine you cannot just create threads, and instead you need to rely on the provided threads api:
https://cloud.google.com/appengine/docs/java/javadoc/com/google/appengine/api/ThreadManager
Thus, some of your code will need to be changed to use such an api.
Finally ! i figured out the solution without using Google App Engine and just using Google Compute Engine.
I created a JAR and put it into my home folder using SFTP.
After that i created a cron file at /etc/cron.d/myfile as below
*/10 * * * * myusername java -jar /home/myusername/myjar.jar
Then i reload the crontab
sudo service cron reload
That's it ! Thanks for your input and interest !
If you mean just a simple JAR with a main method, that won't work. Your application has to be a web service that responds to requests.
Check this link to create an app using JAR file:
APP-ENGINE
You cannot deploy a single jar file to App Engine. You can deploy an application.
This tutorial explains how to create an App Engine project in Java:
https://cloud.google.com/appengine/docs/java/gettingstarted/introduction
Yes, you can only deploy web applications to Google App Engine, so you may have to convert your class into a Servlet class if you want to deploy it to App engine.
You can use the Servlet's url if you are looking to execute it as a cron job, so you can configure this url in a file cron.xml by specifying the frequency and time when cron job should be executed before deploying.
You can use the link below which will guide you through the steps :
http://www.vogella.com/tutorials/GoogleAppEngineJava/article.html
Google's documentation on Cron Job :
https://cloud.google.com/appengine/docs/java/config/cron
You can not however use threads when working with App Engine.
I have a Play! 2 application where I have defined some jobs. These jobs interact with external web services and with the database, hence they need a running application to work.
I would like to be able to launch these jobs as SBT tasks from the Play console. SO I have followed the guide to define my own tasks and I am able to define simple tasks. What I cannot do is importing from the application namespace. I guess this makes some sense - in the context of SBT we may not have an application running.
Is there some way to write an SBT task where an application is launched and one has access to the application namespace?
Don't know if you still need an answer, have you tried to use the Play console?
$ play console
It loads all your application classes so you can use them as you wish.
See http://www.playframework.com/documentation/2.1.0/PlayConsole for more information :)