Saturday, 29 July 2017

Camel HTTP endpoint Timeout configuration using Apache HttpClient

I have used  Apache HttpClient for a timeout in Camel HTTP end point.It specifically for HTTP calls.

We have various types of timeouts
  1. The Connection Timeout – the time to establish the connection with the remote host
  2. The Socket Timeout – the time to waiting for data – after the connection was established; maximum time wait for response
  3. The Connection Manager Timeout (http.connection-manager.timeout) – the time to wait for a connection from the connection manager/pool
I have used Socket Timeout to handle timeouts in Camel HTTP endpoint.Below things based on Spring DSL.We can do the same way in Java DSL.

Syntax :

{{HTTPURL}}?httpClient.soTimeout=50(Timout in milliseconds)

Syntax with Camel route:

   <route id="BLOG_TIMEOUT">
        <from uri="direct:blog.start"/>
         <to  uri="{{HTTPURL}}?httpClient.soTimeout=50(Timout in milliseconds)" />
        <to uri="direct:blog.end"/>
    </route>

BLOG_TIMEOUT -- route id
direct:blog.start -- from uri
{{HTTPURL}}?httpClient.soTimeout=50(Timout in milliseconds) -- http enpoint with socket timeout 
blog.start - one more endpoint

Tuesday, 23 June 2015

Faster Databases Import & Export Process in MySQL

Normally We are exporting and Importing Mysql database using .sql format.It's exporting and importing process speed depend on size of Database.But while using compress format increase the speed of export.

 Use of  gzip we can increase speed of import and export process of mysql databases.

  For Export Database

   mysqldump -uroot -p database_name | gzip -v > database_name.sql.gz

 For Import Database

    zcat database_name.sql.gz | mysql -uroot -p database_name


These comments very useful for database size is very large.

  

Wednesday, 13 November 2013

Resolving NameAlreadyBoundException in Jasper

If you are running multiple instances of JasperReports Server v5.x in same machine we may encountered this NameAlreadyBoundException 10990 exception.

Root cause is


Caused by: java.io.IOException: Cannot bind to URL
[rmi://localhost:10990/jasperserver]:
javax.naming.NameAlreadyBoundException: jasperserver [Root exception is
java.rmi.AlreadyBoundException: jasperserver]
at javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:826)
at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:431)
at org.springframework.jmx.support.ConnectorServerFactoryBean.afterPropertiesSet(ConnectorServerFactoryBean.java:187)
at
 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at
 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 26 more
Caused by: javax.naming.NameAlreadyBoundException: jasperserver [Root exception is java.rmi.AlreadyBoundException: jasperserver]
at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:139)
at com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:226)
at javax.naming.InitialContext.bind(InitialContext.java:419)
at javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:643)
at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:426)
... 29 more
Caused by: java.rmi.AlreadyBoundException: jasperserver
at sun.rmi.registry.RegistryImpl.bind(RegistryImpl.java:153)
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:409)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at sun.rmi.transport.Transport$1.run(Transport.java:174)
at java.security.AccessController.doPrivileged(Native Method)



Solution for above is 

On one of the instances,

Change the port number on ../jasperserver-pro/WEB-INF/js.diagnostic.properties

Change the default diagnostic port 10990 to 10991(or some thing like 10992,10993).

Now you have one instance running on port 10990 and another running on port 10991.

Database Remote Access

Remote Access of DataBase in Different Host by use of following comment


mysql > GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'%' IDENTIFIED BY ‘PASSWORD’;

Example :
mysql > GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY ‘root’;

above command gives access for all privileges. we can grand specific privilege also.


1. Select permission

mysql> GRANT SELECT ON *.* TO 'USERNAME'@'%' IDENTIFIED BY ‘PASSWORD’;

2. Select and update permission

mysql> GRANT SELECT,UPDATE ON *.* TO 'USERNAME'@'%'  IDENTIFIED BY ‘PASSWORD’;


Monday, 28 October 2013

Recover error : 1005 Can't create table 'tmp_db' (errno: 13)

While Altering table or changing Storage Engine of Database we may be got this error.
It happens probably due to Permission denied by MySQL.

less /etc/group
and then less /etc/passwd
find mysql user and group name, probably both are named mysql

change to mysql dir, probably var/lib/mysql and then type cd .. to go a dir under.

chown -R mysql:mysql ./mysql/

And also change permission of /tmp file 


By default the temporary file are directed to /tmp partition.
The permission in /tmp is different.

$ ls -ltrh /tmp
drwxr-xr-x  4 root root      4096 Jan 24 04:02 tmp


The group has no write permission on /tmp folder.

Fix :

Changed the permission of the /tmp folder and made the installation again

chmod 777 /tmp/

$ ls -ltrh /tmp

drwxrwxrwx  4 root root      4096 Jan 24 04:02 tmp


Recover Table Crash in Mysql (MYISAM ENGINE) (Got error 134 from storage engine)

Some time you can't repair table using repair command.It will show error like  "Can’t create new tempfile: ‘*.TMD file" .So we have to recover that table particular table or all tables of database.

For that you have to use the following command to do:

First go to the library file path of Mysql


/var/lib/mysql/Particular_db_name:

1.For single table recover

            myisamchk -r -f  TABLENAME.MYI
2.For ALL table recove

            myisamchk -r -f  *.MYI





Repair Table in Mysql

You will get error like Db_Name.Table_Name marked as crashed  while exporting dump to Mysql.
For that you have to manually repair table use of following command

REPAIR TABLE TABLE_NAME