Πέμπτη 27 Ιανουαρίου 2011

Amazon EC2 Instances Backed-Up to S3

There are several steps in order to backup your ami to S3 bucket. All the commands should be executed inside the AMI.


1. upload key-xxxxxxxxxxx.pem and cert-xxxxxxxxxxxxx.pem to the box ex. /root/key-xxxxxxxxx.pem

2. run the command inside the ami(the amazon tools are pre-installed) ec2-bundle-vol -d /mnt -k /root/pk-xxxxxxx.pem --cert /root/cert-xxxxxxxx.pem -u

3. When the (2) command is completed there should be an image manifest file inside the /mnt dir

4. Upload to S3 ec2-upload-bundle -b -m /mnt/image.manifest.xml -a access_key -s secret_access_key --retry

Παρασκευή 15 Οκτωβρίου 2010

Ubuntu Linux Enable Compiz Fusion

In order to make Ubuntu Linux look cool, you need to install the compiz fusion plugins.
Open a new terminal window and type:


sudo apt-get install compiz compiz-plugins compiz-gnome compiz-core emerald compiz-fusion-plugins-main compiz-fusion-plugins-extra fusion-icon compizconfig-settings-manager


When the installation is complete all the effects are available under the System->Preferences->CompizConf Settings Manager.

Τρίτη 3 Αυγούστου 2010

PosterGenius for Mac has entered private beta testing


PosterGenius™, the first application specifically designed for the creation of scientific posters, has been developed to be compatible with Macs and Mac OS X.

PosterGenius for Mac has now entered private beta testing. If you would like to participate, click here.

Τετάρτη 10 Μαρτίου 2010

Apache HttpClient 4.x Monitoring File Upload

There are quite a few articles on the web which are implementing the monitoring of a file upload with HttpClient 3.x. Since 4.0 release the API has been changed and HttpClient component is incompatible with the previous versions. Digging a bit into the source code i came up with the following implementation.

In order to capture the file upload progress there is a need for controlling the data send over the output stream.

Ex.
FileBody fooBin = new FileBody(new File("/foo.png"));

The class FileBody contains a method writeTo(OutputStream out) which is responsible for the byte transfer over the output stream. In order to capture the bytes send, the FileBody class should be inherited and the writeTo method should be overridden as shown below.

Simple listener:

public interface IFileUploadProgressListener{
public void blockSend(int blockSize);
}

Inherited FilePart Class:

@Override
public void writeTo(OutputStream out) throws IOException {
if (out == null) {
throw new IllegalArgumentException("Output stream may not be null");
}
InputStream in = new FileInputStream(getFile());
try {
byte[] tmp = new byte[4096];
int l;
while ((l = in.read(tmp)) != -1) {
out.write(tmp, 0, l);
if(this.progressListener != null){
this.progressListener.blockSend(4096);
}

}
out.flush();
} finally {
in.close();
}
}


In this example i use a simple interface as a progress listener. When a block of bytes is sent over the output stream the listener informs any class which implements it.

Παρασκευή 24 Ιουλίου 2009

Capture user principal in OpenSSO

You can capture the user principal by using the openssoclientSDK.

Add clientSDK into your classpath (openssoclientSDK.jar). Deploy the opensso-client-jdk15.war (you can use the appropriate war for your jre).
Start your application server and open open-sso-client webapp and follow the instructions in this documentation http://docs.sun.com/app/docs/doc/820-3748/gieyu?a=view

Use the following code into the Servlet,

SSOTokenManager ssoTokenManager = SSOTokenManager.getInstance();
SSOToken ssoToken = ssoTokenManager.createSSOToken(request);
Principal principal = ssoToken.getPrincipal();
principal.getName();


Common Errors:

SSO Exception Invalid Session: Service URL not found:session
Solution: Deploy and configure the open-sso-client webapp

If you getting redirection error(infinite loops):
Login into the SSO server check/uncheck (depends on the server) the encode cookie value.

Τρίτη 23 Ιουνίου 2009

JBoss Application Server Listening to all IPs

When you start the JBoss Application Server usually it is not visible to other machines on the local network like other Web Server/Servlet Containers such as Apache or Apache Tomcat. In order to make JBoss available to all IP addresses, you should place an extra parameter to the start up Script. The extra parameter is -b 0.0.0.0 which allows any IP to communicate with the JBoss.

Ex. Windows Client

run.bat -b 0.0.0.0



You can restrict the JBoss availability to certain IP address by using the same command -b XXX.XXX.XXX.XXX.

Hibernate and MySQL Database Connections

Hibernate and MySql connection lost

The hibernate when it is combined with MySQL commonly produces errors like Communication Link Failure or Last Packet sent to server XX ms ago or Socket Write Error etc. These problems often caused due to the timeout values of the MySQL server. When hibernate tries to re-connect to the Server there is no active connection to use and as a result an exception is thrown.

A common situation you may put your self in is to build a web app and everything work fine but when you return the following day you are facing exceptions. When you restart the server everything works fine again, but after a short amount of time you are facing the same exceptions.

There is a solution for this,

Change the hibernate's cfg.xml file and put the following lines,


<property name="connection.provider_class">
org.hibernate.connection.C3P0ConnectionProvider</property>

<property name="c3p0.max_size">100</property>
<property name="c3p0.idleConnectionTestPeriod">300</property>




Also do not forget to put c3p0-x.xx.x.jar into your classpath or server's lib folder.