marți, 5 noiembrie 2013

Google App Engine - intro

1. Google App Engine for Java (Gae/j)

1.1. Outline

Google offers a distributed computing framework called Google App Engine (App Engine) for making and running web provisions . Application Engine permits the dynamic distribution of framework assets for a requisition dependent upon the genuine request. At present App Engine underpins Python and Java based provisions. This incorporates Java Virtual Machine (Jvm) based dialects, e.g. Sweet or Scala. This article will blanket the App Engine for Java (Gae/j)).

1.2. Standard Api's through App Engine particular Api's

The App Engine offers habitually standard Java Api's and App Engine particular Api's for the same assignment. Assuming that you need to have the capacity to port your provision from the Appengine to different webcontainers, e.g. Tomcat or Jetty, you might as well just utilize Java standard Api.

1.3. AppEngine technologies

Application Engine utilizes the Jetty servlet compartment to have requisitions and backings the Java Servlet Api in rendition 2.4. It furnishes access to databases by means of Java Data Objects (Jdo) and the Java Persistence Api (Jpa). Out of sight App Engine utilizes Google Bigtable as the dispersed space framework for persevering provision information.

Google furnishes Memcache as a storing instrument. Engineers who need to code against the standard Java Api can utilize the Jcache usage (dependent upon Jsr 107).

1.4. Services

The App Engine furnishes some administrations. Case in point the Blobstore permits to transfer and store and serve expansive information questions (blobs) with a cutoff of 2 Gigabyte. To make a blob you transfer a document through a Http demand.

1.5. Versions

Google App Engine helps the formation of some form of your provision. In the Admin Console you can select which form ought to be dynamic. Your dynamic provision "your-name" will be receptive through the Url "". Every variant can likewise be gained entrance to for instance to test another form. The rendition are accessable by means of "" where form is for instance "2" and "most recent" is an altered string.

1.6. Restrictions

Application Engine runs a variant of Java 6 yet does not furnish all Java classes, for instance Swing and most Awt classes are not underpinned.

You can't utilize Threads or schemas which utilizes Threads. You can likewise not keep in touch with the filesystem and just read documents which are part of your provision. Certain "java.lang.system" activities, e.g. gc() or passageway() will do nothing. You can not call Jni code. Reflection is conceivable for your own classes and standard Java classes yet your can't utilize reflection to enter different classes outside your provision.

See Java Whitelist for a full rundown of upheld classes.

A servlet needs likewise to answer inside 30 seconds overall a "" is tossed.

1.7. Quotas

Google offers free hosting for sites which are not exceedingly frequented, e.g. 5 Millions online visits. The cost show for the sites that surpass thier every day standard is recorded on the Google charging documentation pages . The utilization portions of the App Engine are continually evolving in any case, around then of this composition, are around 5 millions pages sees for every month, which deciphers approx. in 6.5 Cpu hours and 1 gigabyte of outbound movement.

As of now a client can make a greatest of 10 requisitions on the Google App Engine. The client can erase existing provision in the Admin Console under Application Settings.

2. Establishment of the Google Tools for Eclipse

Google offers an Eclipse module that gives both Google App Engine and Gwt improvement proficiencies. Fix the plugins from by means of the Eclipse redesign administrator.

The establishment will likewise setup the Gwt and App Engine Sdk into your Eclipse inclination. To check this utilization Window -> Preferences -> Google -> App Engine / Web Toolkit. The Sdk are conveyed as plugins is incorporated in your Eclipse establishment registry under "/plugins/".

3. Enroll at the Google App Engine

To convey your requisition to the Google cloud you require an Appengine account. To get such a record you require a Google message account. Open the Url and login with your Google account data. You have to check your record by means of a quality telephone number. In the wake of furnishing your telephone number, Google will message you a check code by means of Sms. You will then sort the confirmation code into the check box on the web.

4. Running a provision

4.1. On the App Engine

The methodology of making a provision on the Google App Engine includes the production of a requisition on the Google App Engine site. Subsequently you can mainly make a web requisition and transfer this provision to the made requisition on the Google App Engine.

To make a provision on the App Engine press the bind "Create a requisition" and select a requisition name. You need to pick one which is still accessible. Recollect that this name since we will later utilize this within the formation of our demo provision.

4.2. Running application mainly

The Eclipse Plugin permits to run provisions for the Google App Engine mainly in an environment which reenacts nature's turf on the App Engine. You likewise have a neighborhood admin reassure which permit you to see your nearby datastore, the assignment queue, inbound message and Xmpp activity. You uncover this nearby admin support on "http://localhost:8888/_ah/admin/".

5. Persistence with JPA

Gae/j underpins Jpa (Java Persistence Api) 1.0 for persevering information. As all information on the Gae/j are saved in Bigtable a few characteristics of Jpa are not underpinned. See Jpa on Gae/j for items. On the other hand to Jpa you can additionally utilize Jdo or the low-level Api of the App Engine. The datastorage office is depicted in Datastore Java Api Overview .

How to set up JBoss AS (Application Server) on linux

This is a short step by step explanation of the setup of JBoss 7.0.2 on your Linux (explicit debian). Nowadays there is still no official Debian package for JBoss 7 out there, so we have to do a couple of steps manually.  First i describe how to download and to prepare the jboss. Secondly we do some basic configuration that you’ll be needed and at the end i will show you one of the ways to register JBoss as a service.

1. download and prepare.

Start by download  currently available version (7.0.2) of the JBoss 7.
#Web Profile version download.
Extracting files to the final location using tar.

tar zxvf jboss-as-web-7.0.2.Final.tar.gz -C /usr/local/
Now your JBoss 7 is placed inside /usr/local/jboss-as-web-7.0.2.Final/.I dont’t like that name.  It’s just cosmetics, but i prefer to rename the last part ot the path.
cd /usr/local/
mv jboss-as-web-7.0.2.Final/ jboss-7.0.2
Now important things. Some basic security and right management. I suppose  you don’t want to start your JBoss with root rights.
Therefore we need to create new user and new group named  jboss. Make them owner of your JBoss stuff.
addgroup jboss
useradd -g jboss jboss
chown -R jboss:jboss /usr/local/jboss-7.0.2/
Your jboss 7 is almost installed now.

2. Configuration and first test.

Start your brand new  Jboss 7 server with:
sudo -u jboss sh /usr/local/jboss-7.0.2/bin/ &
Now it  is testable on your local machine with http://localhost:8080.
But! maybe you trying to install that jboss on remote machine and want to access this installation remotely. I that case you need to enable remote interface of your JBoss. I assume we start by standalone configuration, so  you have to edit /usr/local/jboss-7.0.2/standalone/configuration/standalone.xml file. The easiest way is to  find  section and replace the address with 
   <interface name="management">
   <interface name="public">
Beware with this configuration you expose also the management console to the public. The console is bounded to interface named=”management” by default.  In production environments you have to put more attention to this. but now you can access your jboss from anywhere.

3. Jboss as Service

Now we have a basic configured JBoss, but i want to maintain it as a service. Unfortunately Jboss archive has no predefined init.d scripts, so i have to to it on my own. But this is not a big problem, just straightforward following some Debian conventions and useful scripts.
Ok, let’s create jboss maintenance script.
touch /etc/init.d/jboss
chmod 755 /etc/init.d/jboss
Ready! Now put following inside.
# Provides: jboss
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Management of JBoss AS v7.x
#Defining JBOSS_HOME
case "$1" in
echo "Starting JBoss AS7..."
sudo -u jboss sh ${JBOSS_HOME}/bin/ &
echo "Stopping JBoss AS7..."
sudo -u jboss sh ${JBOSS_HOME}/bin/ --connect command=:shutdown
echo "Showing server.log..."
tail -1000f ${JBOSS_HOME}/standalone/log/server.log
echo "Usage: /etc/init.d/jboss {start|stop|log}"
exit 1
;; esac
exit 0
This file is ready to use. You can use it self for manual start and stop of your jboss, you also can follow the server.log by using “log” parameter.
But let’s make it to the end, as an automatic starting service. It’s easy with update-rc.d script:
update-rc.d jboss defaults
Now your ready and your JBoss will be shutdown on machine shutdown and it should start on machine start-up.
Of course this is not the only way to start using JBoss 7. Your ideas are welcome!