четверг, 27 июня 2013 г.

MySQL table size statistics

If you need to monitor and analyze your MySQL databases size over time you can automate this process.
1) create the database
CREATE DATABASE stat   DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;

2) create the table
CREATE  TABLE `stat`.`sizeTable` (
  `idsizeTable` INT NOT NULL AUTO_INCREMENT ,
  `insertdate` DATE NOT NULL ,
  `databaseName` VARCHAR(45) NOT NULL ,
  `sizeMB` DOUBLE NOT NULL ,
  PRIMARY KEY (`idsizeTable`) ,
  INDEX `dateIndex` (`insertdate` ASC) )
ENGINE = InnoDB;

3) schedule the sql to collect statistics:
create event stat_db_evt
on schedule
every 24 hour
do
insert into stat.sizeTable (insertdate,databaseName, sizeMB) SELECT NOW() as insertdate, table_schema databaseName, sum( data_length + index_length ) / 1024 / 1024 sizeMB  FROM information_schema.TABLES GROUP BY table_schema;

Thar is all. This script will run every 24 hours and collect the statistics into the table, which you can analyze later.

пятница, 14 июня 2013 г.

OCPJP 7 Passed!

Yesterday I have passed 1z0-804 and earned the OCPJP status! Yeah!
So, what did I use for my preparation:
  1. Book Oracle Certified Professional Java SE 7 Programmer Exams by Ganesh and Sharma.
  2. Tests from http://enthuware.com.
It took me 3 months for preparation.

пятница, 3 мая 2013 г.

Java 7 Concurrency Cookbook

Have read Java 7 Concurrency Cookbook.
A very good book about concurrency in Java.
Every feature is accompanied with an example.
Most important thing is that examples are clear and resemble some real problems.
When working with an examples one should be very careful, because of the typos in the text. So it's better to consult errata on the publisher's site.
Also you can get 2 free chapters and source code on the publisher's site.

вторник, 9 апреля 2013 г.

Spring WS 2.1.0. Expose WSDL with external schema.

It is a good practice to keep schema external to your wsdl.
In Spring WS documentation it is not clearly mentioned how to publish wsdl with external schema.
After some time searching google i managed to found the solution:
<!-- WSDL -->
  <sws:static-wsdl id="BookingFacadeService" location="/WEB-INF/wsdl/BookingFacadeService.wsdl"  />
 
<!-- Schema -->
  <bean
        id="BookingFacadeService_schema"
        class="org.springframework.xml.xsd.SimpleXsdSchema">
        <property
            name="xsd"
            value="/WEB-INF/wsdl/BookingFacadeService_schema.xsd">
        </property>
    </bean>

BookingFacadeService.wsdl is my wsdl which include the external schema BookingFacadeService_schema.xsd.

Manipulate XML with Ant

Sometimes it is necessary to manipulate xml configs with Ant.
This can be done with XMLTask. A great tutorial about this ant task can be found here.

Software in Government

Did you know that http://dorogi.mos.ru is made with:
1) Spring security
2) Apache Wicket
3) Oracle Application Server 11.

пятница, 29 марта 2013 г.

четверг, 28 марта 2013 г.

Tricky Swagger

Hello.
I was faced with a task to create a documentation for our new developing REST service. Search revealed two technologies at hand: JSON-WSP and Swagger.
I liked more Swagger,  because:
1) I can dynamically define documentation with annotations in java
2) relatively simple syntax allows to define the documentation by hand
3) there is a good application Swagger UI which allows to explore the service documentation and more important play with your api.

So here are some tricky moments I was faced during the development of specification and using Swagger UI:
1) If you use Swagger UI with documents other than English then you have to insert into Swagger UI index file the meta 'Content-Type' tag.
2) For your convenience set the 'discoveryUrl' in Swagger UI to your resource listing file.
3) When developing the documentation by hand check your json with validators like http://jsonlint.com/. Because errors in Swagger UI are not displayed.
4) When defining parameters in spec you can use path, query, body, or header AND form. The latter allows you to send json into multipart request. The 'form' argument is not mentioned  in https://github.com/wordnik/swagger-core/wiki/Parameters.
5) When defining you api you should point out the 'responseClass'. If you want your method to return an array of objects you can use the following construction: responseClass: 'List[Item]', where Item is your domain model. This moment is not well documented in documentation.

That's all for now.