tag:blogger.com,1999:blog-23726895846095510682024-03-13T21:31:45.397+05:30Uttesh Tech BlogsI will blog about new technologies and resolving issues we face daily while developing the web application. util methods which will help in code reuse.Anonymoushttp://www.blogger.com/profile/02258593205933843635noreply@blogger.comBlogger68125tag:blogger.com,1999:blog-2372689584609551068.post-45021605803253214422018-05-04T22:44:00.000+05:302018-05-04T22:44:52.604+05:30Upgrade to angular 6<div dir="ltr" style="text-align: left;" trbidi="on">
<p><b>How to upgrade/update to angular 6 ?</b></p>
<p>
<span>
By using the angular cli we can upgrade to angular 6, below are the steps to upgrade
</span>
<ol>
<li> Update the NodeJS version to 8.9+ </li>
<li> Update Angular cli to latest version</li></br>
<pre>
npm uninstall -g @angular/cli
npm cache verify
npm cache clean
npm install -g @angular/cli@next
npm install typescript@2.7.2
</pre>
</ol>
</p>
<br /></div>
utteshhttp://www.blogger.com/profile/03890216292485985349noreply@blogger.com0tag:blogger.com,1999:blog-2372689584609551068.post-35859122137938406242018-04-16T16:39:00.000+05:302018-04-16T16:39:05.200+05:30MongoDB – Allow remote access<div dir="ltr" style="text-align: left;" trbidi="on">
By default, MongoDB doesn’t allow remote connections. to enable the remote access bind the ip address of the machine in <i>mongod.conf</i>.</br>
in linux /etc/mongod.conf
<pre>
# network interfaces
net:
port: 27017
bindIp: ip-address of the machine // by default it will be 127.0.0.1
</pre>
<br /></div>
utteshhttp://www.blogger.com/profile/03890216292485985349noreply@blogger.com0tag:blogger.com,1999:blog-2372689584609551068.post-48788925300266483952018-02-14T14:43:00.000+05:302018-02-14T17:51:11.123+05:30How to make @requestparam optional in spring<div dir="ltr" style="text-align: left;" trbidi="on">
<h4> Question:</h4>
<p> Make spring endpoint with optional request parameters</p>
<h4> Solution:</h4>
<p>To make the request parameter optional on the spring controller, user JAVA 8 feature Option type or set required attribute to false.
<pre>
public void count(@RequestParam(name="name") Optional<String> name){
if (name.isPresent()) {
String name= name.get()
....
}
}
</pre>
</p>
<br /></div>
utteshhttp://www.blogger.com/profile/03890216292485985349noreply@blogger.com0tag:blogger.com,1999:blog-2372689584609551068.post-79930527537811449522018-02-11T23:50:00.000+05:302018-02-11T23:50:25.212+05:30@angular/platform-browser/src/browser/transfer_state.d.ts (34,40): ',' expected.<div dir="ltr" style="text-align: left;" trbidi="on">
<h4> Error: </h4>
<p>
`ERROR in [at-loader] ./node_modules/@angular/platform-browser/src/browser/transfer_state.d.ts:34:40
TS1005: ',' expected.
ERROR in [at-loader] ./node_modules/@angular/platform-browser/src/browser/transfer_state.d.ts:34:42
TS1139: Type parameter declaration expected.
ERROR in [at-loader] ./node_modules/@angular/platform-browser/src/browser/transfer_state.d.ts:34:46
TS1109: Expression expected.
ERROR in [at-loader] ./node_modules/@angular/platform-browser/src/browser/transfer_state.d.ts:34:51
TS1005: ')' expected.
ERROR in [at-loader] ./node_modules/@angular/platform-browser/src/browser/transfer_state.d.ts:34:59
TS1005: ';' expected.
ERROR in [at-loader] ./node_modules/@angular/platform-browser/src/browser/transfer_state.d.ts:34:60
TS1128: Declaration or statement expected.
ERROR in [at-loader] ./node_modules/@angular/platform-browser/src/browser/transfer_state.d.ts:34:73
TS1005: '(' expected.
ERROR in [at-loader] ./node_modules/@angular/platform-browser/src/browser/transfer_state.d.ts:34:42
TS2532: Object is possibly 'undefined'.
ERROR in [at-loader] ./node_modules/@angular/platform-browser/src/browser/transfer_state.d.ts:34:48
TS2304: Cannot find name 'key'.
ERROR in [at-loader] ./node_modules/@angular/platform-browser/src/browser/transfer_state.d.ts:34:53
TS2304: Cannot find name 'string'.
ERROR in [at-loader] ./node_modules/@angular/platform-browser/src/browser/transfer_state.d.ts:34:62
TS2693: 'StateKey' only refers to a type, but is being used as a value here.`
</p>
<h4>Solution: </h4>
<p>
Update your typescript dependency to the latest version
<pre>
"devDependencies": {
.....
"typescript": "^2.6.1"
}
</pre>
</p>
<br /></div>
utteshhttp://www.blogger.com/profile/03890216292485985349noreply@blogger.com0tag:blogger.com,1999:blog-2372689584609551068.post-73242605217206310112018-02-05T12:20:00.000+05:302018-02-05T12:21:38.983+05:30MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe"<div dir="ltr" style="text-align: left;" trbidi="on">
<h4> Error: </h4> MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe"
<h4> Solution </h4>
<p> This error will be thrown on the windows machine for the node module build, to resolve this issue, run/install the windows build tools.
Run from the administrative CMD or PowerShell!
<pre>
npm install --global --production windows-build-tools
</pre>
<br /></div>
utteshhttp://www.blogger.com/profile/03890216292485985349noreply@blogger.com0tag:blogger.com,1999:blog-2372689584609551068.post-59832764579923776952018-01-19T21:10:00.000+05:302018-01-19T21:10:01.878+05:30Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain<div dir="ltr" style="text-align: left;" trbidi="on">
<h4> Issue:</h4>
<p>
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain.
Bitbucket pipeline or Jenkins console output, the build is failed – “Could not find org.gradle.wrapper.GradleWrapperMain”
</p>
<h4> Solution: </h4>
<p>
This error will be thrown when gradlew build unable to find the <i>gradle</i> folder which contains the <i>gradle-wrapper.jar</i> file, if the generated gradle-wrapper.jar is not check-in/commit to bitbucket please check-in or add the file.
</br>
<ul><i>gradle folder structure:</i></ul>
<pre>|---gradle
|---wrapper
|---gradle-wrapper.jar
|---gradle-wrapper.properties
|---gradlew
|---gradlew.bat
</pre>
</p>
<br /></div>
utteshhttp://www.blogger.com/profile/03890216292485985349noreply@blogger.com0tag:blogger.com,1999:blog-2372689584609551068.post-69077610558652560712017-09-01T23:29:00.000+05:302017-09-01T23:29:19.499+05:30guacd:"Error: Protocol Security Negotiation Failure"Guacamole server is unable to make rdp connection with windows system and guacd library will throw this exception because windows remote desktop setting is not enabled.
<br/><br/>
<b>Enable remote desktop setting:</b>
<br/><br/>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh66iwgpGM3wXXGszjqMMZ3GeTjwMvCI8OI-06l1x_lTenAWt6NoMYVqkAwD32cEkvc2dnjp6t2vitOgeuxVPUm3vUW92gHsgpdV1QzEllcuf1zH6b4BUUhqwbeWG5xNKjTHFjJXKnPLvN7/s1600/system_settings.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh66iwgpGM3wXXGszjqMMZ3GeTjwMvCI8OI-06l1x_lTenAWt6NoMYVqkAwD32cEkvc2dnjp6t2vitOgeuxVPUm3vUW92gHsgpdV1QzEllcuf1zH6b4BUUhqwbeWG5xNKjTHFjJXKnPLvN7/s320/system_settings.png" width="320" height="144" data-original-width="1364" data-original-height="615" /></a>
<br/><br/>
this will solve the problem, if not make sure firewall ,antivirus and windows defender are turned-off as well in-case.utteshhttp://www.blogger.com/profile/03890216292485985349noreply@blogger.com0tag:blogger.com,1999:blog-2372689584609551068.post-41920231720454388432017-08-20T15:56:00.000+05:302017-08-20T15:56:56.617+05:30error 10 cordova google plus login ionic<div dir="ltr" style="text-align: left;" trbidi="on">
<br /></div>
Below are the reason for the error 10.
<ol>
<li>Android key and web client id not used properly.</li>
<li>Missing debug key in .android folder of windows system</li>
<li>Missing SHA1 key in the fire base console.</li>
<li>Apk not using the generated debug key.</li>
</ol>
Before going further first we will check the firebase account,google console and system environments are set properly
<ol>
<li>If firebase account is not setup, follow the steps
Goto <a href="https://console.firebase.google.com and create new project" target="_blank">click here</a> and create new project</li>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_4CgH2_OdTYojfdJhsTbQ5LP_XGzZpGnP8LOcpcAWOdl09B9UKCT-rB7_Rnrow1IleE-L1qXHhx9rLuG_SnpfYTwW6b6VfVLScX5KHqyB18CbEgQn53hPsYv8COWhBWDLZGx-gO_6GUyi/s1600/create+project.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_4CgH2_OdTYojfdJhsTbQ5LP_XGzZpGnP8LOcpcAWOdl09B9UKCT-rB7_Rnrow1IleE-L1qXHhx9rLuG_SnpfYTwW6b6VfVLScX5KHqyB18CbEgQn53hPsYv8COWhBWDLZGx-gO_6GUyi/s320/create+project.png" width="320" height="150" data-original-width="1366" data-original-height="642" /></a>
<br/>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6IrZsyHPqeW-KTTbRJX-e0u9TCDblWcuGjKuuGdzXa2jZF7FWBBD-sZdNi6ZeCv4OlOSyBedxSj5SJc7GAFBuUNHoLSw_WBWgzDVrspNaUa0Fvd9F9JOgdAyILbZU08ZDXSOltjnNqLlV/s1600/add+firebase.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6IrZsyHPqeW-KTTbRJX-e0u9TCDblWcuGjKuuGdzXa2jZF7FWBBD-sZdNi6ZeCv4OlOSyBedxSj5SJc7GAFBuUNHoLSw_WBWgzDVrspNaUa0Fvd9F9JOgdAyILbZU08ZDXSOltjnNqLlV/s320/add+firebase.png" width="320" height="208" data-original-width="794" data-original-height="516" /></a>
<li> Copy the config details and use in ionic app.</li>
<li> Goto Authentication and click on SIG-IN METHOD and enable google provider</li>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHhRsMrdg8GBa9TsawUCvkxGrK1H13L7oHG7mU42AyZS-mbIcmeVMMe0V26hf4FH6H25e7pqtPsE1pineGor3wkIz1O1N48Rehyphenhyphen3gsjHbsoz3easF_xLsOMFBxGyEqi8mo86Mg3Jf58XgR/s1600/firebase_authentication.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHhRsMrdg8GBa9TsawUCvkxGrK1H13L7oHG7mU42AyZS-mbIcmeVMMe0V26hf4FH6H25e7pqtPsE1pineGor3wkIz1O1N48Rehyphenhyphen3gsjHbsoz3easF_xLsOMFBxGyEqi8mo86Mg3Jf58XgR/s320/firebase_authentication.png" width="320" height="150" data-original-width="1366" data-original-height="642" /></a>
<li> Once the google authentication is enabled, fire base will automatically generate the web client id and secret for the app</li>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKB3HYZ4gtTrXKrEIpwWbONsmfcNVLgTf-iMLERJ79SRXpzhFpPxukW4jy_34G4QrxR4QIoo8FnOCphY49jeQ3t7LR6uQXTi6rziHyLBENmt1ZC0T81ys19rtloXo64hYVqlFrDq5r2ASW/s1600/googlr_web_client_details.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKB3HYZ4gtTrXKrEIpwWbONsmfcNVLgTf-iMLERJ79SRXpzhFpPxukW4jy_34G4QrxR4QIoo8FnOCphY49jeQ3t7LR6uQXTi6rziHyLBENmt1ZC0T81ys19rtloXo64hYVqlFrDq5r2ASW/s320/googlr_web_client_details.png" width="320" height="192" data-original-width="973" data-original-height="585" /></a>
<li>
<li> Observe the google note on the how to add SHA-1 key to the android application. <a href="https://developers.google.com/android/guides/client-auth">SHA-1 config</a></li>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDHONa3nuQrCEXFYZVEQPNsedNE9U9MwN-S4TRuewDlOe4VOgN5SVBBd6awdgrImY7gFVSQ-x2f8GR1K-1auniHkLodeeH-ig9yYt5wgXWdwoWaSakAlZdX0qUz4rxPcLgXNM5GJz2tzPP/s1600/sha1+link.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDHONa3nuQrCEXFYZVEQPNsedNE9U9MwN-S4TRuewDlOe4VOgN5SVBBd6awdgrImY7gFVSQ-x2f8GR1K-1auniHkLodeeH-ig9yYt5wgXWdwoWaSakAlZdX0qUz4rxPcLgXNM5GJz2tzPP/s320/sha1+link.png" width="320" height="46" data-original-width="621" data-original-height="90" /></a>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguwsyWQZsL1mwGTZ-h_ls9po4uYzVoDVCteIvMer57MDBFiCuOY6beVijKN5Z9dZ5TR6QC4dPX5LXAnJtgcFK4oqzQZpptXq4r9zWlNglJ38oSJJsPy682QpaDlAeEu-jPU7Pfcux7Kpqg/s1600/SHA-1+Config.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguwsyWQZsL1mwGTZ-h_ls9po4uYzVoDVCteIvMer57MDBFiCuOY6beVijKN5Z9dZ5TR6QC4dPX5LXAnJtgcFK4oqzQZpptXq4r9zWlNglJ38oSJJsPy682QpaDlAeEu-jPU7Pfcux7Kpqg/s320/SHA-1+Config.png" width="320" height="243" data-original-width="881" data-original-height="668" /></a>
<li> Now its time to choose the application from fire base start page, add,configure the app and add the generated SHA-1 key to the app.
</li>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBYohmofw44GVNQlHOiIJ-nJLxSJ0bq1eGEby7LBvs6NjNBkBp4Q-74uirl4Bc7tsLfA7g3EdPcg9b-XfXd4uJzxDkXdPipBWHH6-tFCO3EhrT3l-Qf_wgx77Frdu8gfdGo0rnt56YwOIM/s1600/register_app.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBYohmofw44GVNQlHOiIJ-nJLxSJ0bq1eGEby7LBvs6NjNBkBp4Q-74uirl4Bc7tsLfA7g3EdPcg9b-XfXd4uJzxDkXdPipBWHH6-tFCO3EhrT3l-Qf_wgx77Frdu8gfdGo0rnt56YwOIM/s320/register_app.png" width="320" height="295" data-original-width="685" data-original-height="632" /></a>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhygZLCpn8t_j-JoP8H6AXvsvydhK4OthPS4gMoHWVK6CGcIDjIFa2jMK0-wZ6NlUhSKkHbpHyEnR8KlQpd7aSdCdA3WC1t91Ko9T8_2V8j2hxsdbn1SyngWHaKMVcToxecdUcE0NQ7J_Ty/s1600/download_config.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhygZLCpn8t_j-JoP8H6AXvsvydhK4OthPS4gMoHWVK6CGcIDjIFa2jMK0-wZ6NlUhSKkHbpHyEnR8KlQpd7aSdCdA3WC1t91Ko9T8_2V8j2hxsdbn1SyngWHaKMVcToxecdUcE0NQ7J_Ty/s320/download_config.png" width="320" height="298" data-original-width="696" data-original-height="648" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyRVY2_hlZaMdJrwd-ZTBUMw2yUW0uo1Hc5WuqTq9081RlVaPZy71mQXy3IQ_HJPr3cZx1pclQVih45rFawf4GE6O8C4zVXcEdmD51JRB_w0elV0fNYwq9BaT4Uftq_CVot9ucZOeVQyPD/s1600/build.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyRVY2_hlZaMdJrwd-ZTBUMw2yUW0uo1Hc5WuqTq9081RlVaPZy71mQXy3IQ_HJPr3cZx1pclQVih45rFawf4GE6O8C4zVXcEdmD51JRB_w0elV0fNYwq9BaT4Uftq_CVot9ucZOeVQyPD/s320/build.png" width="320" height="291" data-original-width="695" data-original-height="631" /></a>
</ol>
Now basic setup done and assume your able to build and install app in mobile but unable to login through the google plus and getting error 10, to resolve the issue check the below conf are correct as mentioned above.
</br></br></br>
<hr>
</br>
<b> Validate below steps to solve error 10 issue </b>
<span>
<h4>1. Android key and web client id not used properly:</h4>There are 2 types of keys android and client id. if the SHA-1 key is generate in the environment setup and added to the app in the firebase, then only a android key will be generate and added in google console.
go to <a href="https://console.developers.google.com" target="_blank">google developer console</a> to get the android key.
</br>
<b>Android Key</b>: This key will be configured in config.xml and package.json file as reserve client id in the application and SHA-1 key configured to these android key should be used for signing the app apk file.
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmwQZmlY_PEbGXscIUJ3N3TvtFw30P2cI472cNJ8pvlLjNMgmRzVY_JxTy-tLCsr5YrRGxnIFRgx34xQY6TziKLzycy9OZz1gTZKbC8Fxs9z5crIfNU6wJpBaFHspfiiL5RQO5soXW9rXK/s1600/google_console.png" imageanchor="1"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmwQZmlY_PEbGXscIUJ3N3TvtFw30P2cI472cNJ8pvlLjNMgmRzVY_JxTy-tLCsr5YrRGxnIFRgx34xQY6TziKLzycy9OZz1gTZKbC8Fxs9z5crIfNU6wJpBaFHspfiiL5RQO5soXW9rXK/s320/google_console.png" width="320" height="139" data-original-width="1354" data-original-height="589" /></a>
</br>
click on edit icon of the android key and check is the same SHA-1 key is configured same as fire base app.
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuLMp5GiY-jsdimWMBHI_Ziap4CffxkN-OoV0XONa0tPPH1dI-Xy6QLWtkK-bzKlN3cuMbXiXNKgpClpZt-wYQ_m816sPoNsSzovuOgkhABIi4V84lt9koz0prYkbttnD6O2ntp1jucdKv/s1600/google_console_edit.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuLMp5GiY-jsdimWMBHI_Ziap4CffxkN-OoV0XONa0tPPH1dI-Xy6QLWtkK-bzKlN3cuMbXiXNKgpClpZt-wYQ_m816sPoNsSzovuOgkhABIi4V84lt9koz0prYkbttnD6O2ntp1jucdKv/s320/google_console_edit.png" width="320" height="134" data-original-width="1366" data-original-height="571" /></a>
</br>
config.xml:
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbLTvLqzSly5sU-JwC8ewAiFwjmEtVjct1XHZETQwmInFK2POxbtXL1DqUfkGtLYR_Ma446RQFylvLO-iYOaKN1atZ3Mb-vt-YfryU2bZ52t1xg4dYguhrfpqAAeV6pvx7CYoIvzaCIvRu/s1600/config.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbLTvLqzSly5sU-JwC8ewAiFwjmEtVjct1XHZETQwmInFK2POxbtXL1DqUfkGtLYR_Ma446RQFylvLO-iYOaKN1atZ3Mb-vt-YfryU2bZ52t1xg4dYguhrfpqAAeV6pvx7CYoIvzaCIvRu/s320/config.png" width="320" height="20" data-original-width="1083" data-original-height="67" /></a>
</br></br>
package.json:
</br>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlRZF3Str66hejGmz-CWuxCkC3ZQ-rbeoY6renL2XXpeS6Fcx8YEqPHw25PUfHHGK7aRZMpPYp4IJR3tjxKJoyx9fODYqZSlS56mGSWwXaLDx5zgAnNV2NzfhyphenhyphenUzvUfrqmAeJtPjDNIm-E/s1600/package_jspn.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlRZF3Str66hejGmz-CWuxCkC3ZQ-rbeoY6renL2XXpeS6Fcx8YEqPHw25PUfHHGK7aRZMpPYp4IJR3tjxKJoyx9fODYqZSlS56mGSWwXaLDx5zgAnNV2NzfhyphenhyphenUzvUfrqmAeJtPjDNIm-E/s320/package_jspn.png" width="320" height="102" data-original-width="909" data-original-height="289" /></a>
</span>
<b>Web client Id</b>: This key will be generated by fire base on creation of the app or we can create manually.
<p>
Configure the web client with the app and use in the app code to authenticate the user.
</p>
<h4>2. Missing debug key in .android folder of windows system </h4>
Make sure you generate debug/release key and placed in <i>.android</i> folder under user and same copy should be placed under <i>app folder</i>.
<h4>3.Missing SHA1 key in the fire base console. </h4>
Make sure same SHA-1 key used across fire base app, google console and in .android folder in building system. any mismatch in SHA-1 key will lead to error 10.
check same package is configure in the fire base for app and config.xml file.
<h4>4.Apk not using the generated debug key.</h4>
Validate the apk is generate using the configured debug/release SHA-1 key, by using the below command we can validate the apk is using the proper key.
<blockquote>keytool -list -printcert -jarfile android-debug.apk</blockquote>
If none of the above did not worked to solve the problem, try below miscellaneous steps to resolve the issue, its not standard practice or procedure but solve the issue in some weird scenarios.
<h4>Miscellaneous steps.</h4>
<ol>
<li> if your not using the android studio, try to add your app to android studio and configure, it will configure debug key setting properly and build apk.</li>
<li>Don't reverse your client_id i.e. like com.googleusercontent.apps.xxx, use as it is, some times it solves the issue </li>
<li>Use android key from google developer console in code as web client_id and config.xml,package.json, which is acceptable and solves the issue </li>
</ol>
utteshhttp://www.blogger.com/profile/03890216292485985349noreply@blogger.com2tag:blogger.com,1999:blog-2372689584609551068.post-45354149801065238992016-01-13T11:24:00.003+05:302016-01-13T16:16:02.200+05:30Remove or Filter Stopping/Stemming words using java<div dir="ltr" style="text-align: left;" trbidi="on">
<p>For the better indexing or searching the data in the big text chunk we need to filter the unwanted words from the data to get the better performance on the search by indexing only the logical words.</p>
<b>What is Stopping Words?<i></i></b>
<p> Stopping words are the words which will be used to make the sentence along with consonants/verbs i.e. where is my car? in this "where/is/my" are the stopping words which are not required for the search.</p>
<b>What is Stemming Words?<i></i></b>
<p> Stemmer are the words which will make the action word along with stopping words.
i.e Stopping Word + "ing/tion/ational/ization/ation....etc" : going/standing </p>
<p> I was looking of the library to achieve the filtering of the stopping/stemming words, Not found much on googling, decided to go through the stopping/stemming words blogs/white papers and algorithms, started writing small util library to do the filtering by using java and its available on maven repository and full source on github.</p>
<b><i><blockquote>Exude Library</blockquote> </i></b>
<p>This is simple library for removing/filtering the stopping,stemming words from the text data, this library is in very basic level of development need to work on for later changes.</p>
This is the part of maven repository now,Directly add in pom following.</br></br>
<pre style="background:#042029;color:#839496"> <<span style="color:#268bd2;font-weight:700">dependency</span>>
<<span style="color:#268bd2;font-weight:700">groupId</span>>com.uttesh</<span style="color:#268bd2;font-weight:700">groupId</span>>
<<span style="color:#268bd2;font-weight:700">artifactId</span>>exude</<span style="color:#268bd2;font-weight:700">artifactId</span>>
<<span style="color:#268bd2;font-weight:700">version</span>>0.0.2</<span style="color:#268bd2;font-weight:700">version</span>>
</<span style="color:#268bd2;font-weight:700">dependency</span>>
</pre>
Download latest version of exude <a href="https://repo1.maven.org/maven2/com/uttesh/exude/0.0.2/">download</a>
</br></br>
<blockquote><b>Features:</b></blockquote>
1.Filter stopping words from given text/file/link</br>
2.Filter stemming words from given text/file/link</br>
3.Get swear words from given text/file/link</br>
</br>
<blockquote><b>How Exude library works:</b></blockquote>
Step 1: Filter the duplicate words from the input data/file. </br>
Step 2: Filter the stopping words from step1 filtered data. </br></br>
Step 3: Filter the stemmer/swear words from step2 filtered data using the Porter algorithm which is used for suffix stripping.
</br>
<i>exude process sequence flow:</i>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMP68DRmrXQcBbViA0LFBjQJWQsNOxnESre9F5tpoLeTgjnxQGHqMWYenVBM7yWqT5CMqDEgglQXMp8jTkazQWXCKk6UyhyphenhyphenDBj-kdBRUkww6zLB759BQNd0908OeLpSa0Dd-hGhB0bjnkI/s1600/flow.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMP68DRmrXQcBbViA0LFBjQJWQsNOxnESre9F5tpoLeTgjnxQGHqMWYenVBM7yWqT5CMqDEgglQXMp8jTkazQWXCKk6UyhyphenhyphenDBj-kdBRUkww6zLB759BQNd0908OeLpSa0Dd-hGhB0bjnkI/s1600/flow.png" /></a></div>
<blockquote>How to use exude Library</blockquote>
<i>Environment and dependent jar file</i></br>
1.Minimum JDK 1.6 or higher</br>
2.Apache Tika jar (which is used to parse the files for the data extraction)</br>
</br></br>
<blockquote>Sample code</blockquote>
<i>Sample Text Data</i></br>
<pre style="background:#000;color:#fff"> String inputData = <span style="color:#6c3">"Kannada is a Southern Dravidian language, and according to Dravidian scholar Sanford Steever, its history can be conventionally divided into three periods; Old Kannada (halegannada) from 450–1200 A.D., Middle Kannada (Nadugannada) from 1200–1700 A.D., and Modern Kannada from 1700 to the present.[20] Kannada is influenced to an appreciable extent by Sanskrit. Influences of other languages such as Prakrit and Pali can also be found in Kannada language."</span>;
String output = ExudeData.getInstance().filterStoppings(inputData);
</pre>
<i>output</i></br></br>
<pre style="background:#002240;color:#fff">extent southern influenced divided according halegannada kannada language three <span style="color:#ff628c">450</span> found modern influences periods pali steever a <span style="color:#ff9d00">middle</span> d languages old nadugannada dravidian sanford history scholar appreciable <span style="color:#ff628c">1700</span> <span style="color:#ff628c">1200</span> conventionally sanskrit prakrit present <span style="color:#ff628c">20</span>
</pre>
<i>Sample File Data</i></br>
<pre style="background:#0c1021;color:#f8f8f8">String inputData = <span style="color:#61ce3c">"any file path"</span>;
String output = ExudeData.getInstance().filterStoppings(inputData);
System.out.println(<span style="color:#61ce3c">"output : "</span>+output);
</pre>
<i>Sample link Data</i></br>
<pre style="background:#0c1021;color:#f8f8f8">String inputData = <span style="color:#61ce3c">"https://en.wikipedia.org/wiki/Rama"</span>;
String output = ExudeData.getInstance().filterStoppings(inputData);
System.out.println(<span style="color:#61ce3c">"output : "</span>+output);
</pre>
<i>Get swear words from data/file/link</i></br>
<pre style="background:#0c1021;color:#f8f8f8">String inputData = <span style="color:#61ce3c">"enter text with bad words"</span>;
String output = ExudeData.getInstance().getSwearWords(inputData);
</pre>
Library source code on <a target="_blank" href="https://github.com/uttesh/exude">github</a>
<br /></div>utteshhttp://www.blogger.com/profile/03890216292485985349noreply@blogger.com0tag:blogger.com,1999:blog-2372689584609551068.post-63009146573492043592015-12-27T19:57:00.001+05:302015-12-27T19:57:36.561+05:30Elastic Search 2.x sample CRUD code<div dir="ltr" style="text-align: left;" trbidi="on">
<h2>What is ElasticSearch?</h2>
<p>
Elasticsearch is an open-source, restful, distributed, search engine built on top of apache-lucene, Lucene is arguably the most advanced, high-performance, and fully featured search engine library in existence today—both open source and proprietary.
</br>
Elasticsearch is also written in Java and uses Lucene internally for all of its indexing and searching, but it aims to make full-text search easy by hiding the complexities of Lucene behind a simple, coherent, RESTful API.
</p>
<h3>Basic Concept and terminologies:</h3>
<b>1.Near Realtime (NRT)</b>
Elasticsearch is a near real time search platform. What this means is there is a slight latency (normally one second) from the time you index a document until the time it becomes searchable.
<br/>
<b>2.Cluster</b>
A cluster is a collection of one or more nodes (servers) that together holds your entire data and provides federated indexing and search capabilities across all nodes.
default cluster name will be "elasticsearch".
<br/>
<b>3.Node</b>
A node is a single server that is part of your cluster, stores your data, and participates in the cluster’s indexing and search capabilities.
<br/>
<b>4.Index</b>
An index is a collection of documents that have somewhat similar characteristics i.e like database.
<br/>
<b>5.Type</b>
Within an index, you can define one or more types. A type is a logical category/partition of your index and defined for documents that have a set of common fields.
i.e. like table in relational database. a type
<br/>
<b>6.Document</b>
A document is a basic unit of information that can be indexed. For example
<br/><br/>
<p>
Below image will show how we can co-relate the relational database with elastic index which will make easy to understand the elastic terms and api.
<br/>
In Elasticsearch, a document belongs to a type, and those types live inside an index. You can draw some (rough) parallels to a traditional relational database:
<br/><br/>
Relational DB ⇒ Databases ⇒ Tables ⇒ Rows ⇒ Columns
Elasticsearch ⇒ Indices ⇒ Types ⇒ Documents ⇒ Fields
<br/><br/>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyXOt5yR1iiewJSldDwymizaQI2LAbWkDrV8FSBZchytXSIV3A8lFxfpQRN-lFflEpIH05IpvjtZv4syBDvtjsYIk_qxgAQfIfd9ixv5dT3E8QxLCGUH5o-OwWWpXeUQUYMOol0VzifgOU/s1600/rel-ela.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyXOt5yR1iiewJSldDwymizaQI2LAbWkDrV8FSBZchytXSIV3A8lFxfpQRN-lFflEpIH05IpvjtZv4syBDvtjsYIk_qxgAQfIfd9ixv5dT3E8QxLCGUH5o-OwWWpXeUQUYMOol0VzifgOU/s1600/rel-ela.png" /></a></div>
</p>
<b>Development:</b>
Maven library dependency:
<pre style="background:#0c1021;color:#f8f8f8"><span style="color:#fbde2d"><</span>dependency<span style="color:#fbde2d">></span>
<span style="color:#fbde2d"><</span>groupId<span style="color:#fbde2d">></span>org<span style="color:#fbde2d">.</span>elasticsearch<span style="color:#fbde2d"><</span><span style="color:#fbde2d">/</span>groupId<span style="color:#fbde2d">></span>
<span style="color:#fbde2d"><</span>artifactId<span style="color:#fbde2d">></span>elasticsearch<span style="color:#fbde2d"><</span><span style="color:#fbde2d">/</span>artifactId<span style="color:#fbde2d">></span>
<span style="color:#fbde2d"><</span>version<span style="color:#fbde2d">></span><span style="color:#d8fa3c">2.1</span><span style="color:#d8fa3c">.1</span><span style="color:#fbde2d"><</span><span style="color:#fbde2d">/</span>version<span style="color:#fbde2d">></span>
<span style="color:#fbde2d"><</span><span style="color:#fbde2d">/</span>dependency<span style="color:#fbde2d">></span>
</pre>
<br/>
<p>
<b>Client:</b> using java client we can performe operations on elastic search cluster/node.<br/>
1.Perform standard index, get, delete and search operations on an existing cluster<br/>
2.Perform administrative tasks on a running cluster<br/>
3.Start full nodes when you want to run Elasticsearch embedded in your own application or when you want to launch unit or integration tests<br/>
</p>
Two types of client to get the client connection with cluster to perform the operations.
</br>
1. Node Client.<br/>
2. TransportClient.<br/>
<b>Node Client:</b>
<span>Instantiating a node based client is the simplest way to get a Client that can execute operations against elasticsearch.</span>
<b>TransportClient:</b>
The TransportClient connects remotely to an Elasticsearch cluster using the transport module. It does not join the cluster, but simply gets one or more initial transport addresses and communicates with them.
sample elastic search crud sample code:
<i>Node Client:</i>
<pre style="background:#000;color:#f8f8f8"><span style="color:#99cf50">Node</span> node <span style="color:#e28964">=</span> <span style="color:#99cf50">NodeBuilder</span><span style="color:#e28964">.</span>nodeBuilder()<span style="color:#e28964">.</span>clusterName(<span style="color:#65b042">"yourclustername"</span>)<span style="color:#e28964">.</span>node();
<span style="color:#99cf50">Client</span> client <span style="color:#e28964">=</span> node<span style="color:#e28964">.</span>client();
</pre>
<i>TransportClient:</i>
<pre style="background:#000;color:#f8f8f8"><span style="color:#99cf50">Settings</span> settings <span style="color:#e28964">=</span> <span style="color:#99cf50">Settings</span><span style="color:#e28964">.</span>settingsBuilder()
.put(<span style="color:#99cf50">ElasticConstants</span><span style="color:#3387cc"><span style="color:#e28964">.</span>CLUSTER_NAME</span>, cluster)<span style="color:#e28964">.</span>build();
<span style="color:#99cf50">TransportClient</span> transportClient <span style="color:#e28964">=</span> <span style="color:#99cf50">TransportClient</span><span style="color:#e28964">.</span>builder()<span style="color:#e28964">.</span>settings(settings)<span style="color:#e28964">.</span>build().
addTransportAddress(<span style="color:#e28964">new</span> <span style="color:#99cf50">InetSocketTransportAddress</span>(<span style="color:#99cf50">InetAddress</span><span style="color:#e28964">.</span>getByName(host), port));
</pre>
<i>Creat Index:</i>
We can create the IndexRequest or using XContentBuilder we can populate the request to store in the index.
<pre style="background:#0c1021;color:#f8f8f8"> <span style="color:#fbde2d">XContentBuilder</span> jsonBuilder <span style="color:#fbde2d">=</span> <span style="color:#fbde2d">XContentFactory</span><span style="color:#fbde2d">.</span>jsonBuilder();
<span style="color:#fbde2d">Map<<span style="color:#fbde2d">String</span>, <span style="color:#fbde2d">Object</span>></span> data <span style="color:#fbde2d">=</span> <span style="color:#fbde2d">new</span> <span style="color:#fbde2d">HashMap<<span style="color:#fbde2d">String</span>, <span style="color:#fbde2d">Object</span>></span>();
data<span style="color:#fbde2d">.</span>put(<span style="color:#61ce3c">"FirstName"</span>, <span style="color:#61ce3c">"Uttesh"</span>);
data<span style="color:#fbde2d">.</span>put(<span style="color:#61ce3c">"LastName"</span>, <span style="color:#61ce3c">"Kumar T.H."</span>);
jsonBuilder<span style="color:#fbde2d">.</span>map(data);
</pre>
<pre style="background:#0c1021;color:#f8f8f8"><span style="color:#fbde2d">public</span> <span style="color:#fbde2d">IndexResponse</span> createIndex(<span style="color:#fbde2d">String</span> index, <span style="color:#fbde2d">String</span> type, <span style="color:#fbde2d">String</span> id, <span style="color:#fbde2d">XContentBuilder</span> jsonData) {
<span style="color:#fbde2d">IndexResponse</span> response <span style="color:#fbde2d">=</span> <span style="color:#d8fa3c">null</span>;
<span style="color:#fbde2d">try</span> {
response <span style="color:#fbde2d">=</span> <span style="color:#fbde2d">ElasticSearchUtil</span><span style="color:#fbde2d">.</span>getClient()<span style="color:#fbde2d">.</span>prepareIndex(index, type, id)
.setSource(jsonData)
.get();
<span style="color:#fbde2d">return</span> response;
} <span style="color:#fbde2d">catch</span> (<span style="color:#fbde2d">Exception</span> e) {
logger<span style="color:#fbde2d">.</span>error(<span style="color:#61ce3c">"createIndex"</span>, e);
}
<span style="color:#fbde2d">return</span> <span style="color:#d8fa3c">null</span>;
}
</pre>
<i>Find Document By Index:</i>
<pre style="background:#0c1021;color:#f8f8f8"><span style="color:#fbde2d">public</span> <span style="color:#fbde2d">void</span> findDocumentByIndex() {
<span style="color:#fbde2d">GetResponse</span> response <span style="color:#fbde2d">=</span> findDocumentByIndex(<span style="color:#61ce3c">"users"</span>, <span style="color:#61ce3c">"user"</span>, <span style="color:#61ce3c">"1"</span>);
<span style="color:#fbde2d">Map<<span style="color:#fbde2d">String</span>, <span style="color:#fbde2d">Object</span>></span> source <span style="color:#fbde2d">=</span> response<span style="color:#fbde2d">.</span>getSource();
<span style="color:#fbde2d">System</span><span style="color:#fbde2d">.</span>out<span style="color:#fbde2d">.</span>println(<span style="color:#61ce3c">"------------------------------"</span>);
<span style="color:#fbde2d">System</span><span style="color:#fbde2d">.</span>out<span style="color:#fbde2d">.</span>println(<span style="color:#61ce3c">"Index: "</span> <span style="color:#fbde2d">+</span> response<span style="color:#fbde2d">.</span>getIndex());
<span style="color:#fbde2d">System</span><span style="color:#fbde2d">.</span>out<span style="color:#fbde2d">.</span>println(<span style="color:#61ce3c">"Type: "</span> <span style="color:#fbde2d">+</span> response<span style="color:#fbde2d">.</span>getType());
<span style="color:#fbde2d">System</span><span style="color:#fbde2d">.</span>out<span style="color:#fbde2d">.</span>println(<span style="color:#61ce3c">"Id: "</span> <span style="color:#fbde2d">+</span> response<span style="color:#fbde2d">.</span>getId());
<span style="color:#fbde2d">System</span><span style="color:#fbde2d">.</span>out<span style="color:#fbde2d">.</span>println(<span style="color:#61ce3c">"Version: "</span> <span style="color:#fbde2d">+</span> response<span style="color:#fbde2d">.</span>getVersion());
<span style="color:#fbde2d">System</span><span style="color:#fbde2d">.</span>out<span style="color:#fbde2d">.</span>println(<span style="color:#61ce3c">"getFields: "</span> <span style="color:#fbde2d">+</span> response<span style="color:#fbde2d">.</span>getFields());
<span style="color:#fbde2d">System</span><span style="color:#fbde2d">.</span>out<span style="color:#fbde2d">.</span>println(source);
<span style="color:#fbde2d">System</span><span style="color:#fbde2d">.</span>out<span style="color:#fbde2d">.</span>println(<span style="color:#61ce3c">"------------------------------"</span>);
}
<span style="color:#fbde2d">public</span> <span style="color:#fbde2d">GetResponse</span> findDocumentByIndex(<span style="color:#fbde2d">String</span> index, <span style="color:#fbde2d">String</span> type, <span style="color:#fbde2d">String</span> id) {
<span style="color:#fbde2d">try</span> {
<span style="color:#fbde2d">GetResponse</span> getResponse <span style="color:#fbde2d">=</span> <span style="color:#fbde2d">ElasticSearchUtil</span><span style="color:#fbde2d">.</span>getClient()<span style="color:#fbde2d">.</span>prepareGet(index, type, id)<span style="color:#fbde2d">.</span>get();
<span style="color:#fbde2d">return</span> getResponse;
} <span style="color:#fbde2d">catch</span> (<span style="color:#fbde2d">Exception</span> e) {
logger<span style="color:#fbde2d">.</span>error(<span style="color:#61ce3c">""</span>, e);
}
<span style="color:#fbde2d">return</span> <span style="color:#d8fa3c">null</span>;
}
</pre>
</br>
<i>Find Document By Value</i>
<pre style="background:#0c1021;color:#f8f8f8"><span style="color:#fbde2d">public</span> <span style="color:#fbde2d">void</span> findDocumentByValue() {
<span style="color:#fbde2d">SearchResponse</span> response <span style="color:#fbde2d">=</span> findDocument(<span style="color:#61ce3c">"users"</span>, <span style="color:#61ce3c">"user"</span>, <span style="color:#61ce3c">"LastName"</span>, <span style="color:#61ce3c">"Kumar T.H."</span>);
<span style="color:#fbde2d">SearchHit</span>[] results <span style="color:#fbde2d">=</span> response<span style="color:#fbde2d">.</span>getHits()<span style="color:#fbde2d">.</span>getHits();
<span style="color:#fbde2d">System</span><span style="color:#fbde2d">.</span>out<span style="color:#fbde2d">.</span>println(<span style="color:#61ce3c">"Current results: "</span> <span style="color:#fbde2d">+</span> results<span style="color:#fbde2d">.</span>length);
<span style="color:#fbde2d">for</span> (<span style="color:#fbde2d">SearchHit</span> hit <span style="color:#fbde2d">:</span> results) {
<span style="color:#fbde2d">System</span><span style="color:#fbde2d">.</span>out<span style="color:#fbde2d">.</span>println(<span style="color:#61ce3c">"--------------HIT----------------"</span>);
<span style="color:#fbde2d">System</span><span style="color:#fbde2d">.</span>out<span style="color:#fbde2d">.</span>println(<span style="color:#61ce3c">"Index: "</span> <span style="color:#fbde2d">+</span> hit<span style="color:#fbde2d">.</span>getIndex());
<span style="color:#fbde2d">System</span><span style="color:#fbde2d">.</span>out<span style="color:#fbde2d">.</span>println(<span style="color:#61ce3c">"Type: "</span> <span style="color:#fbde2d">+</span> hit<span style="color:#fbde2d">.</span>getType());
<span style="color:#fbde2d">System</span><span style="color:#fbde2d">.</span>out<span style="color:#fbde2d">.</span>println(<span style="color:#61ce3c">"Id: "</span> <span style="color:#fbde2d">+</span> hit<span style="color:#fbde2d">.</span>getId());
<span style="color:#fbde2d">System</span><span style="color:#fbde2d">.</span>out<span style="color:#fbde2d">.</span>println(<span style="color:#61ce3c">"Version: "</span> <span style="color:#fbde2d">+</span> hit<span style="color:#fbde2d">.</span>getVersion());
<span style="color:#fbde2d">Map<<span style="color:#fbde2d">String</span>, <span style="color:#fbde2d">Object</span>></span> result <span style="color:#fbde2d">=</span> hit<span style="color:#fbde2d">.</span>getSource();
<span style="color:#fbde2d">System</span><span style="color:#fbde2d">.</span>out<span style="color:#fbde2d">.</span>println(result);
}
<span style="color:#fbde2d">Assert</span><span style="color:#fbde2d">.</span>assertSame(response<span style="color:#fbde2d">.</span>getHits()<span style="color:#fbde2d">.</span>totalHits() <span style="color:#fbde2d">></span> <span style="color:#d8fa3c">0</span>, <span style="color:#d8fa3c">true</span>);
}
<span style="color:#fbde2d">public</span> <span style="color:#fbde2d">SearchResponse</span> findDocument(<span style="color:#fbde2d">String</span> index, <span style="color:#fbde2d">String</span> type, <span style="color:#fbde2d">String</span> field, <span style="color:#fbde2d">String</span> value) {
<span style="color:#fbde2d">try</span> {
<span style="color:#fbde2d">QueryBuilder</span> queryBuilder <span style="color:#fbde2d">=</span> <span style="color:#fbde2d">new</span> <span style="color:#fbde2d">MatchQueryBuilder</span>(field, value);
<span style="color:#fbde2d">SearchResponse</span> response <span style="color:#fbde2d">=</span> <span style="color:#fbde2d">ElasticSearchUtil</span><span style="color:#fbde2d">.</span>getClient()<span style="color:#fbde2d">.</span>prepareSearch(index)
.setTypes(type)
.setSearchType(<span style="color:#fbde2d">SearchType</span><span style="color:#d8fa3c"><span style="color:#fbde2d">.</span>QUERY_AND_FETCH</span>)
.setQuery(queryBuilder)
.setFrom(<span style="color:#d8fa3c">0</span>)<span style="color:#fbde2d">.</span>setSize(<span style="color:#d8fa3c">60</span>)<span style="color:#fbde2d">.</span>setExplain(<span style="color:#d8fa3c">true</span>)
.execute()
.actionGet();
<span style="color:#fbde2d">SearchHit</span>[] results <span style="color:#fbde2d">=</span> response<span style="color:#fbde2d">.</span>getHits()<span style="color:#fbde2d">.</span>getHits();
<span style="color:#fbde2d">return</span> response;
} <span style="color:#fbde2d">catch</span> (<span style="color:#fbde2d">Exception</span> e) {
logger<span style="color:#fbde2d">.</span>error(<span style="color:#61ce3c">""</span>, e);
}
<span style="color:#fbde2d">return</span> <span style="color:#d8fa3c">null</span>;
}
</pre>
<i>Update Index</i>
<pre style="background:#0c1021;color:#f8f8f8"><span style="color:#fbde2d">public</span> <span style="color:#fbde2d">void</span> UpdateDocument() throws <span style="color:#fbde2d">IOException</span> {
<span style="color:#fbde2d">XContentBuilder</span> jsonBuilder <span style="color:#fbde2d">=</span> <span style="color:#fbde2d">XContentFactory</span><span style="color:#fbde2d">.</span>jsonBuilder();
<span style="color:#fbde2d">Map<<span style="color:#fbde2d">String</span>, <span style="color:#fbde2d">Object</span>></span> data <span style="color:#fbde2d">=</span> <span style="color:#fbde2d">new</span> <span style="color:#fbde2d">HashMap<<span style="color:#fbde2d">String</span>, <span style="color:#fbde2d">Object</span>></span>();
data<span style="color:#fbde2d">.</span>put(<span style="color:#61ce3c">"FirstName"</span>, <span style="color:#61ce3c">"Uttesh Kumar"</span>);
data<span style="color:#fbde2d">.</span>put(<span style="color:#61ce3c">"LastName"</span>, <span style="color:#61ce3c">"TEST"</span>);
jsonBuilder<span style="color:#fbde2d">.</span>map(data);
<span style="color:#fbde2d">UpdateResponse</span> updateResponse <span style="color:#fbde2d">=</span> updateIndex(<span style="color:#61ce3c">"users"</span>, <span style="color:#61ce3c">"user"</span>, <span style="color:#61ce3c">"1"</span>, jsonBuilder);
}
</pre>
<pre style="background:#0c1021;color:#f8f8f8"><span style="color:#fbde2d">public</span> <span style="color:#fbde2d">UpdateResponse</span> updateIndex(<span style="color:#fbde2d">String</span> index, <span style="color:#fbde2d">String</span> type, <span style="color:#fbde2d">String</span> id, <span style="color:#fbde2d">XContentBuilder</span> jsonData) {
<span style="color:#fbde2d">UpdateResponse</span> response <span style="color:#fbde2d">=</span> <span style="color:#d8fa3c">null</span>;
<span style="color:#fbde2d">try</span> {
<span style="color:#fbde2d">System</span><span style="color:#fbde2d">.</span>out<span style="color:#fbde2d">.</span>println(<span style="color:#61ce3c">"updateIndex "</span>);
response <span style="color:#fbde2d">=</span> <span style="color:#fbde2d">ElasticSearchUtil</span><span style="color:#fbde2d">.</span>getClient()<span style="color:#fbde2d">.</span>prepareUpdate(index, type, id)
.setDoc(jsonData)
.execute()<span style="color:#fbde2d">.</span>get();
<span style="color:#fbde2d">System</span><span style="color:#fbde2d">.</span>out<span style="color:#fbde2d">.</span>println(<span style="color:#61ce3c">"response "</span> <span style="color:#fbde2d">+</span> response);
<span style="color:#fbde2d">return</span> response;
} <span style="color:#fbde2d">catch</span> (<span style="color:#fbde2d">Exception</span> e) {
logger<span style="color:#fbde2d">.</span>error(<span style="color:#61ce3c">"UpdateIndex"</span>, e);
}
<span style="color:#fbde2d">return</span> <span style="color:#d8fa3c">null</span>;
}
</pre>
<i>Remove Index:</i>
<pre style="background:#0c1021;color:#f8f8f8"><span style="color:#fbde2d">public</span> <span style="color:#fbde2d">void</span> RemoveDocument() throws <span style="color:#fbde2d">IOException</span> {
<span style="color:#fbde2d">DeleteResponse</span> deleteResponse <span style="color:#fbde2d">=</span> elastiSearchService<span style="color:#fbde2d">.</span>removeDocument(<span style="color:#61ce3c">"users"</span>, <span style="color:#61ce3c">"user"</span>, <span style="color:#61ce3c">"1"</span>);
}
<span style="color:#fbde2d">public</span> <span style="color:#fbde2d">DeleteResponse</span> removeDocument(<span style="color:#fbde2d">String</span> index, <span style="color:#fbde2d">String</span> type, <span style="color:#fbde2d">String</span> id) {
<span style="color:#fbde2d">DeleteResponse</span> response <span style="color:#fbde2d">=</span> <span style="color:#d8fa3c">null</span>;
<span style="color:#fbde2d">try</span> {
response <span style="color:#fbde2d">=</span> <span style="color:#fbde2d">ElasticSearchUtil</span><span style="color:#fbde2d">.</span>getClient()<span style="color:#fbde2d">.</span>prepareDelete(index, type, id)<span style="color:#fbde2d">.</span>execute()<span style="color:#fbde2d">.</span>actionGet();
<span style="color:#fbde2d">return</span> response;
} <span style="color:#fbde2d">catch</span> (<span style="color:#fbde2d">Exception</span> e) {
logger<span style="color:#fbde2d">.</span>error(<span style="color:#61ce3c">"RemoveIndex"</span>, e);
}
<span style="color:#fbde2d">return</span> <span style="color:#d8fa3c">null</span>;
}
</pre>
Full sample code is available at guthub <a target="_blank" href="https://github.com/uttesh/elasticsearch">Download full code</a>
<br /></div>utteshhttp://www.blogger.com/profile/03890216292485985349noreply@blogger.com1tag:blogger.com,1999:blog-2372689584609551068.post-28656716201121389302015-05-11T15:04:00.002+05:302015-05-11T15:04:50.772+05:30ipc.Client: Retrying connect to server: localhost/127.0.0.1:9000. Already tried 0 time(s); retry policy is <div dir="ltr" style="text-align: left;" trbidi="on"><br />
15/05/08 01:26:12 INFO ipc.Client: Retrying connect to server: localhost/127.0.0.1:9000. Already tried 0 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1 SECONDS)<br />
...<br />
Bad connection to FS. command aborted. exception: Call to localhost/127.0.0.1:9000 failed on connection exception: java.net.ConnectException: Connection refused<br />
<br />
<br />
<b>solution : </b> run "bin/hadoop namenode -format" command<br />
</div>Anonymoushttp://www.blogger.com/profile/02258593205933843635noreply@blogger.com0tag:blogger.com,1999:blog-2372689584609551068.post-88462283475261882002015-05-11T14:56:00.000+05:302015-05-11T15:16:56.475+05:30Hadoop Set Up on Ubuntu Linux (Single-Node Cluster)<div dir="ltr" style="text-align: left;" trbidi="on">Running Hadoop on Ubuntu Linux (Single-Node Cluster)<br />
<br />
Hadoop is a framework written in Java, Incorporates features similar to those of the Google File System (GFS) and of the MapReduce computing paradigm. <br />
<br />
Hadoop’s HDFS is a highly fault-tolerant distributed file system and, like Hadoop in general, designed to be deployed on low-cost hardware. It provides high throughput access to application data and is suitable for applications that have large data sets.<br />
<br />
Simple Hadoop installation up and running so that you can play around with the software and learn more about it.<br />
<br />
For windows OS user to learn hadoop install the virtual box along with Ubuntu OS.<br />
<br />
Click here for the virtual box and Ubuntu set-up <a target="_blank" href="http://uttesh.blogspot.in/2015/05/install-ubuntu-linux-on-virtual-box.html">http://uttesh.blogspot.in/2015/05/install-ubuntu-linux-on-virtual-box.html</a><br />
<br />
<iframe width="560" height="315" src="https://www.youtube.com/embed/voAMq3SrDuc" frameborder="0" allowfullscreen></iframe><br />
<br />
After the virtual box with Ubuntu set-up is done, follow below for the hadoop set up.<br />
<br />
Step 1. Hadoop requires a working Java 1.5+ installation.<br />
Step 2. Adding a dedicated Hadoop system user.<br />
Step 3. Configuring SSH<br />
Step 4. Disabling IPv6<br />
Step 5. Hadoop Installation<br />
<br />
<b>Step 1. Hadoop requires a working Java 1.5+ installation:</b> <br />
<br />
run following command for sun JDK<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #c65d09; font-weight: bold">#</span> Update the <span style="color: #007020">source </span>list
<span style="color: #c65d09; font-weight: bold">$</span> sudo apt-get update
<span style="color: #c65d09; font-weight: bold">#</span> Install Sun Java 7 JDK
<span style="color: #c65d09; font-weight: bold">$</span> sudo apt-get install sun-java7-jdk
</pre></div>We can also install oracle jdk manually or running following commands<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #c65d09; font-weight: bold">$</span> sudo apt-add-repository ppa:webupd8team/java
<span style="color: #c65d09; font-weight: bold">$</span> sudo apt-get update
<span style="color: #c65d09; font-weight: bold">$</span> sudo apt-get install oracle-java7-installer
</pre></div>The full JDK which will be placed in /usr/lib/jvm/java-6-* (well, this directory is actually a symlink on Ubuntu).<br />
<br />
After installation, check whether JDK is correctly set up:<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #c65d09; font-weight: bold">uttesh@uttesh-VirtualBox:~$</span> java -version
<span style="color: #888888">java version "1.7.0_80"</span>
<span style="color: #888888">Java(TM) SE Runtime Environment (build 1.7.0_80-b15)</span>
<span style="color: #888888">Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)</span>
</pre></div><br />
<b>Step 2. Adding a dedicated Hadoop system user:</b> *this is not recommended, you can skip only it helps to separate the Hadoop installation from other software applications and user accounts running on the same machine.<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #c65d09; font-weight: bold">$</span> sudo addgroup hadoop
<span style="color: #c65d09; font-weight: bold">$</span> sudo adduser --ingroup hadoop hduser
</pre></div><br />
<b>Step 3. Configuring SSH</b><br />
<br />
Hadoop requires SSH access to manage its nodes,For single-node setup of Hadoop, we therefore need to configure SSH access to "localhost"<br />
<br />
a. Install SSH : ssh is pre-packaged with Ubuntu, but we need to install ssh first to start sshd server. Use the following command to install ssh and sshd.<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #c65d09; font-weight: bold">$</span> sudo apt-get install ssh
</pre></div><br />
<br />
Verify installation using following commands.<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #c65d09; font-weight: bold">$</span> which ssh
<span style="color: #c65d09; font-weight: bold">#</span><span style="color: #888888"># Should print '/usr/bin/ssh'</span>
<span style="color: #c65d09; font-weight: bold">$</span> which sshd
<span style="color: #c65d09; font-weight: bold">#</span><span style="color: #888888"># Should print '/usr/bin/sshd'</span>
</pre></div><br />
<br />
b. Check if you can ssh to the localhost without a password.<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #c65d09; font-weight: bold">$</span> ssh localhost
</pre></div><br />
Note that if you try ssh to the localhost without installing ssh first, an error message will be printed saying 'ssh: connect to host localhost port 22: Connection refused'. So be sure to install ssh first.<br />
<br />
c. If you cannot SSH to the localhost without a password create a ssh key pair using the following command.<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #c65d09; font-weight: bold">$</span> ssh-keygen -t dsa -P <span style="background-color: #fff0f0">''</span> -f ~/.ssh/id_dsa
</pre></div><br />
<br />
d. Now the key pair has been created, note that id_rsa is the private key and id_rsa.pub is the public key are in .ssh directory. We need to include the new public key to the list of authorized keys using the following command.<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #c65d09; font-weight: bold">$</span> cat ~/.ssh/id_dsa.pub &gt;&gt; ~/.ssh/authorized_keys
</pre></div><div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #c65d09; font-weight: bold">uttesh@uttesh-VirtualBox:~$</span> ssh-keygen -t rsa -P <span style="background-color: #fff0f0">""</span>
<span style="color: #888888">Generating public/private rsa key pair.</span>
<span style="color: #888888">Enter file in which to save the key (/home/uttesh/.ssh/id_rsa): </span>
<span style="color: #888888">Created directory '/home/uttesh/.ssh'.</span>
<span style="color: #888888">Your identification has been saved in /home/uttesh/.ssh/id_rsa.</span>
<span style="color: #888888">Your public key has been saved in /home/uttesh/.ssh/id_rsa.pub.</span>
<span style="color: #888888">The key fingerprint is:</span>
<span style="color: #888888">53:e9:c6:d8:0a:7f:3e:7b:b2:36:2d:6c:df:be:16:7c uttesh@uttesh-VirtualBox</span>
<span style="color: #888888">The key's randomart image is:</span>
<span style="color: #888888">+--[ RSA 2048]----+</span>
<span style="color: #888888">| |</span>
<span style="color: #888888">| . |</span>
<span style="color: #888888">| o |</span>
<span style="color: #888888">| * |</span>
<span style="color: #888888">| . S = . |</span>
<span style="color: #888888">| o + o E|</span>
<span style="color: #888888">| o... o |</span>
<span style="color: #888888">| oO o.. |</span>
<span style="color: #888888">| o+X.o+. |</span>
<span style="color: #888888">+-----------------+</span>
</pre></div>e. try connect to the localhost and check if you can ssh to the localhost without a password.<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #c65d09; font-weight: bold">$</span> ssh localhost
</pre></div><br />
If the SSH connect should fail, these general tips might help:<br />
<br />
Enable debugging with ssh -vvv localhost and investigate the error in detail.<br />
<br />
<b>Step 4. Disabling IPv6 :</b><br />
<br />
One problem with IPv6 on Ubuntu is that using 0.0.0.0 for the various networking-related Hadoop configuration options will result in Hadoop binding to the IPv6 addresses of my Ubuntu box. there’s no practical point in enabling IPv6 on a box when you are not connected to any IPv6 network. Hence, I simply disabled IPv6 on my Ubuntu machine. <br />
<br />
To disable IPv6 on Ubuntu 10.04 LTS, open /etc/sysctl.conf in the editor of your choice and add the following lines to the end of the file:<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #c65d09; font-weight: bold">#</span> disable ipv6
<span style="color: #888888">net.ipv6.conf.all.disable_ipv6 = 1</span>
<span style="color: #888888">net.ipv6.conf.default.disable_ipv6 = 1</span>
<span style="color: #888888">net.ipv6.conf.lo.disable_ipv6 = 1</span>
</pre></div>You have to reboot your machine in order to make the changes take effect.<br />
<br />
You can check whether IPv6 is enabled on your machine with the following command:<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #c65d09; font-weight: bold">$</span> cat /proc/sys/net/ipv6/conf/all/disable_ipv6
</pre></div><br />
A return value of 0 means IPv6 is enabled, a value of 1 means disabled.<br />
<br />
<br />
<b>Step 5. Hadoop Installation : </b><br />
<br />
1. Download the latest stable Hadoop release from this <a href="http://www.apache.org/dyn/closer.cgi/hadoop/common/">http://www.apache.org/dyn/closer.cgi/hadoop/common/</a>. hadoop-2.5.1.tar.gz<br />
<br />
2. Install Hadoop in /usr/local or any preferred directory. Decompress the downloaded file using the following command.<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #c65d09; font-weight: bold">$</span> tar -xf hadoop-2.5.1.tar.gz -C /usr/local/
</pre></div><br />
or right click on the file and click extract from UI.<br />
<br />
3. Add $HADOOP_PREFIX/bin directory to your PATH, to ensure Hadoop is available from the command line. <br />
<br />
Add the following lines to the end of the $HOME/.bashrc file of user. If you use a shell other than bash, you should of course update its appropriate configuration files instead of .bashrc.<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #888888">PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"</span>
<span style="color: #c65d09; font-weight: bold">#</span> Set Hadoop-related environment variables
<span style="color: #888888">export HADOOP_HOME=/usr/local/hadoop</span>
<span style="color: #c65d09; font-weight: bold">#</span> Set JAVA_HOME <span style="color: #333333">(</span>we will also configure JAVA_HOME directly <span style="color: #008800; font-weight: bold">for </span>Hadoop later on<span style="color: #333333">)</span>
<span style="color: #888888">export JAVA_HOME=/usr/lib/jvm/java-6-sun</span>
<span style="color: #c65d09; font-weight: bold">#</span> Some convenient aliases and functions <span style="color: #008800; font-weight: bold">for </span>running Hadoop-related commands
<span style="color: #888888">unalias fs &> /dev/null</span>
<span style="color: #888888">alias fs="hadoop fs"</span>
<span style="color: #888888">unalias hls &> /dev/null</span>
<span style="color: #888888">alias hls="fs -ls"</span>
<span style="color: #c65d09; font-weight: bold">#</span> If you have LZO compression enabled in your Hadoop cluster and
<span style="color: #c65d09; font-weight: bold">#</span> compress job outputs with LZOP <span style="color: #333333">(</span>not covered in this tutorial<span style="color: #333333">)</span>:
<span style="color: #c65d09; font-weight: bold">#</span> Conveniently inspect an LZOP compressed file from the <span style="color: #007020">command</span>
<span style="color: #c65d09; font-weight: bold">#</span><span style="color: #007020"> </span>line; run via:
<span style="color: #c65d09; font-weight: bold">#</span>
<span style="color: #c65d09; font-weight: bold">#</span> <span style="color: #996633">$ </span>lzohead /hdfs/path/to/lzop/compressed/file.lzo
<span style="color: #c65d09; font-weight: bold">#</span>
<span style="color: #c65d09; font-weight: bold">#</span> Requires installed <span style="background-color: #fff0f0">'lzop'</span> command.
<span style="color: #c65d09; font-weight: bold">#</span>
<span style="color: #888888">lzohead () {</span>
<span style="color: #888888"> hadoop fs -cat $1 | lzop -dc | head -1000 | less</span>
<span style="color: #888888">}</span>
<span style="color: #c65d09; font-weight: bold">#</span> Add Hadoop bin/ directory to PATH
<span style="color: #888888">export PATH=$PATH:$HADOOP_HOME/bin</span>
</pre></div><br />
<b>Standalone Mode</b><br />
Hadoop by default is configured to run as a single Java process, which runs in a non distributed mode. Standalone mode is usually useful in development phase since it is easy to test and debug. Also, Hadoop daemons are not started in this mode. Since Hadoop's default properties are set to standalone mode and there are no Hadoop daemons to run, there are no additional steps to carry out here.<br />
<br />
<b>Pseudo-Distributed Mode</b><br />
This mode simulates a small scale cluster, with Hadoop daemons running on a local machine. Each Hadoop daemon is run on a separate Java process. Pseudo-Distributed Mode is a special case of Fully distributed mode.<br />
<br />
To enable Pseudo-Distributed Mode, you should edit following two XML files. These XML files contain multiple property elements within a single configuration element. Property elements contain name and value elements.<br />
<br />
1. etc/hadoop/core-site.xml<br />
2. etc/hadoop/hdfs-site.xml<br />
<br />
Edit the core-site.xml and modify the following properties. fs.defaultFS property holds the locations of the NameNode.<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #007700"><configuration></span>
<span style="color: #007700"><property></span>
<span style="color: #007700"><name></span>fs.defaultFS<span style="color: #007700"></name></span>
<span style="color: #007700"><value></span>hdfs://localhost:9000<span style="color: #007700"></value></span>
<span style="color: #007700"></property></span>
<span style="color: #007700"></configuration></span>
</pre></div><br />
Edit the hdfs-site.xml and modify the following properties. dfs.replication property holds the number of times each HDFS block should be replicated.<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #007700"><configuration></span>
<span style="color: #007700"><property></span>
<span style="color: #007700"><name></span>dfs.replication<span style="color: #007700"></name></span>
<span style="color: #007700"><value></span>1<span style="color: #007700"></value></span>
<span style="color: #007700"></property></span>
<span style="color: #007700"></configuration></span>
</pre></div><br />
<b>Configuring the base HDFS directory :</b><br />
hadoop.tmp.dir property within core-site.xml file holds the location to the base HDFS directory. Note that this property configuration doesn't depend on the mode Hadoop runs on. The default value for hadoop.tmp.dir property is /tmp, and there is a risk that some linux distributions might discard the contents of the /tmp directory in the local file system on each reboot, and leads to data loss within the local file system, hence to be on the safer side, it makes sense to change the location of the base directory to a much reliable one.<br />
<br />
Carry out following steps to change the location of the base HDFS directory.<br />
<br />
1.Create a directory for Hadoop to store its data locally and change its permissions to be writable by any user.<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #c65d09; font-weight: bold">$</span> mkdir /var/lib/hadoop
<span style="color: #c65d09; font-weight: bold">$</span> chmod 777 /var/lib/hadoop
</pre></div><br />
<br />
2.Edit the core-site.xml and modify the following property.<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #007700"><configuration></span>
<span style="color: #007700"><property></span>
<span style="color: #007700"><name></span>hadoop.tmp.dir<span style="color: #007700"></name></span>
<span style="color: #007700"><value></span>/var/lib/hadoop<span style="color: #007700"></value></span>
<span style="color: #007700"></property></span>
<span style="color: #007700"></configuration></span>
</pre></div><br />
<br />
Formatting the HDFS filesystem<br />
<br />
We need to format the HDFS file system, before starting Hadoop cluster in Pseudo-Distributed Mode for the first time. Note that formatting the file system multiple times will result deleting the existing file system data.<br />
<br />
Execute the following command on command line to format the HDFS file system.<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #c65d09; font-weight: bold">$</span> hdfs namenode -format
</pre></div><br />
<br />
Starting NameNode daemon and DataNode daemon<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #c65d09; font-weight: bold">$</span> <span style="color: #996633">$HADOOP_HOME</span>/sbin/start-dfs.sh
</pre></div><br />
<br />
Now you can access the name node web interface at <a href="http://localhost:50070/">http://localhost:50070/</a>.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxVpHOut1hjYuwuqus8W0sbfzm5AWl7WccqY0A5y2XDhXiL60dbkO2U9Nbc1agjOvLnqASuh1Vj85wcm-Mngb8O23yIgFR8FTq-GkOapxD_qkjjau6kWKjJ8NLASG-mSGC9U5IXbeeOuVl/s1600/hadoop_data_node.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxVpHOut1hjYuwuqus8W0sbfzm5AWl7WccqY0A5y2XDhXiL60dbkO2U9Nbc1agjOvLnqASuh1Vj85wcm-Mngb8O23yIgFR8FTq-GkOapxD_qkjjau6kWKjJ8NLASG-mSGC9U5IXbeeOuVl/s320/hadoop_data_node.png" /></a><br />
<br />
<br />
<br />
<br />
<br />
</div>Anonymoushttp://www.blogger.com/profile/02258593205933843635noreply@blogger.com0tag:blogger.com,1999:blog-2372689584609551068.post-56999420788092487992015-05-09T00:44:00.000+05:302015-05-09T11:00:09.317+05:30Install Ubuntu Linux on Virtual Box<div dir="ltr" style="text-align: left;" trbidi="on"><br />
It is always good to have virtual box with our required OS installed, If u have windows box and want to learn hadoop, its good to have virtual box with ubuntu to learn.<br />
<br />
Prerequisites :<br />
<br />
1. Download and install Virtual box <a target="_blank" href="https://www.virtualbox.org/">https://www.virtualbox.org/</a>.<br />
2. Download Ubuntu ISO from <a target="_blank" href="http://www.ubuntu.com/download/desktop">http://www.ubuntu.com/download/desktop</a>.<br />
<br />
<br />
Installation of the virtual box is simple and easy. after installing the virtual box now we will install Ubuntu linux in VM.<br />
<br />
<iframe width="560" height="315" src="https://www.youtube.com/embed/voAMq3SrDuc" frameborder="0" allowfullscreen></iframe><br />
<br />
Create the VM instance for the ubuntu OS.<br />
<br />
Click on the "new" menu item from VM virtual box and it will pop-up the window as show below and choose the name for the VM alongwith system bit and OS Type.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizeKpUJQfpa7TCo9ZZjSSxcriS9V-QllXMBNFifFr-8uu-Nced4KeF60frf_QGuxG7JUkYcobMYmXhYC-X2YQ18htmyP6aZpFUdenVwIhJRvzdXMYUwUl8tMpLcJ4G_XGVlTxY9LhgP0NX/s1600/create_VM.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizeKpUJQfpa7TCo9ZZjSSxcriS9V-QllXMBNFifFr-8uu-Nced4KeF60frf_QGuxG7JUkYcobMYmXhYC-X2YQ18htmyP6aZpFUdenVwIhJRvzdXMYUwUl8tMpLcJ4G_XGVlTxY9LhgP0NX/s320/create_VM.png" /></a><br />
<br />
select the RAM for the system, its always good to have RAM more 1GB<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhalF67J5vCBPXOb9iXuHCSIWF29yD-txGphFtnne43QOWZSgAlbpMkZUWVxuYDfivupA9CMg_X7OffYbQNXUYVCEDtiOys_UKYTxHzP-eDlqlwOIJukN4yqqnvpafSH61F9ReV5oqWm67V/s1600/create_VM_2.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhalF67J5vCBPXOb9iXuHCSIWF29yD-txGphFtnne43QOWZSgAlbpMkZUWVxuYDfivupA9CMg_X7OffYbQNXUYVCEDtiOys_UKYTxHzP-eDlqlwOIJukN4yqqnvpafSH61F9ReV5oqWm67V/s320/create_VM_2.png" /></a><br />
<br />
select the hard drive<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgve0THdrH5EdrczYqXoWIN4TXugCkKTT2SxVIFQpwJbZKx-zpwdcw22oiShyZuGdvnrKS-YNq-yYycOxo5Y51JXu9IMJIum7ATOmGySiw5D2E6qvkoJgn-1JGSxpDEDUrKvLKq15zW4Vcp/s1600/create_VM_3.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgve0THdrH5EdrczYqXoWIN4TXugCkKTT2SxVIFQpwJbZKx-zpwdcw22oiShyZuGdvnrKS-YNq-yYycOxo5Y51JXu9IMJIum7ATOmGySiw5D2E6qvkoJgn-1JGSxpDEDUrKvLKq15zW4Vcp/s320/create_VM_3.png" /></a><br />
<br />
<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhY9tp9Uqwzh4oBHhC_dn6pnGGy6C45j3cslExb5EfLjLvZaewI0qEjjc4LViKLVg-pH8SqawEI189vsrYr0HCHqpbO80f0DM_GCl8qJCbVoivi-jYSj0gOBVR8seS28C6hFRxvUL8NOeK0/s1600/create_VM_4.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhY9tp9Uqwzh4oBHhC_dn6pnGGy6C45j3cslExb5EfLjLvZaewI0qEjjc4LViKLVg-pH8SqawEI189vsrYr0HCHqpbO80f0DM_GCl8qJCbVoivi-jYSj0gOBVR8seS28C6hFRxvUL8NOeK0/s320/create_VM_4.png" /></a><br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpjq9c1fcmKIbC8lLBzYydDW2gjCwC9CAoBxaGy458AVcaMJxBsxoj8RnRDIET2Tfzr9fu2GA9SavlTRepFH8gu90I7HEPBSrGi-Es8Fhm76Ly2n5GUUxELA43Ef6L-3fyX_C2AVQbo0sp/s1600/create_VM_5.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpjq9c1fcmKIbC8lLBzYydDW2gjCwC9CAoBxaGy458AVcaMJxBsxoj8RnRDIET2Tfzr9fu2GA9SavlTRepFH8gu90I7HEPBSrGi-Es8Fhm76Ly2n5GUUxELA43Ef6L-3fyX_C2AVQbo0sp/s320/create_VM_5.png" /></a><br />
<br />
select the Memory for the system, its always good to have Memory more 15GB.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeHCEvhzy64Iiwkdenw58O8yReKObxIUADKqPwvra7ffxWV0stiW-pdUewJt0yjY6wy6J50QgV2jf5GWWW4vFq3Q8q5KaPojGdtqB6kBpBgTGKf3x4VxwkL9-z94gp9vXEdLlLSfrav_zd/s1600/create_VM_6.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeHCEvhzy64Iiwkdenw58O8yReKObxIUADKqPwvra7ffxWV0stiW-pdUewJt0yjY6wy6J50QgV2jf5GWWW4vFq3Q8q5KaPojGdtqB6kBpBgTGKf3x4VxwkL9-z94gp9vXEdLlLSfrav_zd/s320/create_VM_6.png" /></a><br />
<br />
VM is created and now we need to install the Ubuntu linux on this VM.<br />
<br />
run the created VM or double click on the created VM instance.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOFknyVgHhhxyKs5RPLmtIY-vO5nEGvvKG4zS5L3Sb6oqniKJ5ZKFHVTpM66hwbdKuzCol4n6q_zH0SnUByqP43KMswRboEwT4YaaDpumHIHYhk6m7MBgTwW6XkVFWvm9GZDK9N29rQGoB/s1600/create_VM_7.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOFknyVgHhhxyKs5RPLmtIY-vO5nEGvvKG4zS5L3Sb6oqniKJ5ZKFHVTpM66hwbdKuzCol4n6q_zH0SnUByqP43KMswRboEwT4YaaDpumHIHYhk6m7MBgTwW6XkVFWvm9GZDK9N29rQGoB/s320/create_VM_7.png" /></a><br />
<br />
<br />
select the download ubuntu iso file.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6Np1e79dPBW9K2K9aB5I8mf2Q347KLWfZif0cwT6YKmWWrPaze8-ke-F5mLtRbSW6MfsGAeHfeUGLPFUvhoab4kqJ6U3N7WvgTwqYEP-1HkYUIpDuHux1JTCeoCYnDkvro539akRoCnHK/s1600/create_VM_9.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6Np1e79dPBW9K2K9aB5I8mf2Q347KLWfZif0cwT6YKmWWrPaze8-ke-F5mLtRbSW6MfsGAeHfeUGLPFUvhoab4kqJ6U3N7WvgTwqYEP-1HkYUIpDuHux1JTCeoCYnDkvro539akRoCnHK/s320/create_VM_9.png" /></a><br />
<br />
after some time, ubuntu installation window will load.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIb73f6RCSGXpL8AkgRe-ChFKpgg9mCEd-dPIQexy3UBV9uW-yR2o9bqRihJ6A3Bb76_c0j9YMURQNBKh2lEeKxXQa_e-UlE6GwmvbngS5JWcYcY4OnJXj23zTVQinh29C_6BzX7-qdIcf/s1600/create_VM_10.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIb73f6RCSGXpL8AkgRe-ChFKpgg9mCEd-dPIQexy3UBV9uW-yR2o9bqRihJ6A3Bb76_c0j9YMURQNBKh2lEeKxXQa_e-UlE6GwmvbngS5JWcYcY4OnJXj23zTVQinh29C_6BzX7-qdIcf/s320/create_VM_10.png" /></a><br />
<br />
click on the install button and follow the ubuntu installation process, it will take 10-15 min for the ubuntu installation.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiPoSZ0LgNOY4w3eAbKprGeySCqHGwbW8SQ7M5V_GhBG-DkCDClyfJKxCjlRrOqE7-MfK9PH5_q3CjvTjHzqxPQyb5DykXQvg3LKLAazOqCbyG2vF8r-eKJRaA0hTNHDDOzt_0zfv8xe6P/s1600/create_VM_11.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiPoSZ0LgNOY4w3eAbKprGeySCqHGwbW8SQ7M5V_GhBG-DkCDClyfJKxCjlRrOqE7-MfK9PH5_q3CjvTjHzqxPQyb5DykXQvg3LKLAazOqCbyG2vF8r-eKJRaA0hTNHDDOzt_0zfv8xe6P/s320/create_VM_11.png" /></a><br />
<br />
after the successful installation of the ubuntu, install the guess-addition for the full screen mode of the VM.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPdvoLsCIs5FIb0MJsd29Ia3icQCIYWBwbJuMOR__ejubInv9cd7zBKVqBKzF9ReW9jCbLCU0WBZBjvHqp1eHMUn0OK3JNICk-9NpaQ_lZmfmIqOllefAnkkjq3fCVjlAhQEyWfp0uRkc5/s1600/guest-addition.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPdvoLsCIs5FIb0MJsd29Ia3icQCIYWBwbJuMOR__ejubInv9cd7zBKVqBKzF9ReW9jCbLCU0WBZBjvHqp1eHMUn0OK3JNICk-9NpaQ_lZmfmIqOllefAnkkjq3fCVjlAhQEyWfp0uRkc5/s320/guest-addition.png" /></a><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>Anonymoushttp://www.blogger.com/profile/02258593205933843635noreply@blogger.com0tag:blogger.com,1999:blog-2372689584609551068.post-17743087695303191232015-04-28T18:09:00.000+05:302015-04-28T18:09:21.317+05:30Analyzing the application code by using the sonarqube ANT/MAVEN<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<a target="_blank" href="http://www.sonarqube.org/">SonarQube™</a> software (previously known as “Sonar”) is an open source project hosted at Codehaus. By using this we can analyze the source code, its very easy to configure and use.<br />
<br />
<br />
1. <a target="_blank" href="http://www.sonarsource.org/downloads/">Download</a> and unzip the SonarQube distribution ("C:\sonarqube" or "/etc/sonarqube")<br />
<br />
2. Start the SonarQube server: under bin folder run the executable file according to respective OS.<br />
<br />
sonarqube/bin/[OS]<br />
<br />
3.Browse the results at <a target="_blank" href="http://localhost:9000">http://localhost:9000</a><br />
<br />
we will use Embedded database for learning.<br />
<br />
under sonarqube/conf/sonar.properties will have the db base configuration, default it uses embeded db H2 which is in build in java.<br />
<br />
Application level ANT configuration :<br />
<br />
<br />
Download the sonar-ant-task jar file <a href="http://repository.codehaus.org/org/codehaus/sonar-plugins/sonar-ant-task/2.2/sonar-ant-task-2.2.jar">download</a><br />
<br />
copy the jar file to <ANT_HOME>/lib folder<br />
<br />
add following to existing build.xml file of the application.<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #007700"><taskdef</span> <span style="color: #0000CC">uri=</span><span style="background-color: #fff0f0">"antlib:org.sonar.ant"</span> <span style="color: #0000CC">resource=</span><span style="background-color: #fff0f0">"org/sonar/ant/antlib.xml"</span><span style="color: #007700">></span>
<span style="color: #007700"><classpath</span> <span style="color: #0000CC">path=</span><span style="background-color: #fff0f0">"path/to/sonar-ant-task-*.jar"</span> <span style="color: #007700">/></span>
<span style="color: #007700"></taskdef></span>
</pre></div><br />
if you don't want to modify the existing build.xml file then use below xml file and run "ant -f analyze-code.xml"<br />
<br />
<script src="https://gist.github.com/uttesh/53c68e50a2faee614c01.js"></script><br />
<br />
after the successful execution it will provide the url to access the result.<br />
<br />
<br />
for maven application it simple run the following command <br />
<br />
mvn clean install sonar:sonar<br />
<br />
<br />
sample result page :<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-Zh7IwYHVpExwNZux9q3C_BQvgtFGj1nNfE60Unzu7lEZ5a-PzwB3ZAlEetWQQ_pojPEIfyde22gWR1modvkS8-MByyD4iBpCr2uful6M8EWtU7MWsaIH1SwKnTJxxusR_TF6CbQh8FTL/s1600/result.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-Zh7IwYHVpExwNZux9q3C_BQvgtFGj1nNfE60Unzu7lEZ5a-PzwB3ZAlEetWQQ_pojPEIfyde22gWR1modvkS8-MByyD4iBpCr2uful6M8EWtU7MWsaIH1SwKnTJxxusR_TF6CbQh8FTL/s320/result.png" /></a> <br />
<br />
<br />
<br />
</div>Anonymoushttp://www.blogger.com/profile/02258593205933843635noreply@blogger.com0tag:blogger.com,1999:blog-2372689584609551068.post-57155697116684140712015-04-28T17:25:00.000+05:302015-04-28T17:32:33.527+05:30web service client JAXWS by maven<div dir="ltr" style="text-align: left;" trbidi="on">Generate web service client stub class by using the JAXWS maven plugin.<br />
<br />
"jaxws-maven-plugin" will generate the web service stub classes by using that we can implement client or test the web service.<br />
<br />
<br />
generated stub classes will stored under src folder and by using this service classes we can communicate with service and get the response.<br />
<br />
for free webservice for the learning and client implementation visit <a target="_blank" href="http://www.xmethods.com/">xmethod.com</a><br />
<br />
take any service and generate the client stub classes.<br />
<br />
<br />
add the WSDL URL in the pom.xml <br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #007700"><wsdlUrls></span>
<span style="color: #007700"><wsdlUrl></span>
enter the wsdl URL here
<span style="color: #007700"></wsdlUrl></span>
<span style="color: #007700"></wsdlUrls></span>
</pre></div><br />
<br />
full sample :<br />
<br />
<script src="https://gist.github.com/uttesh/a59dd0b31f44af23d201.js"></script><br />
<br />
</div>Anonymoushttp://www.blogger.com/profile/02258593205933843635noreply@blogger.com0tag:blogger.com,1999:blog-2372689584609551068.post-38851379412939933722015-04-14T23:21:00.000+05:302015-04-14T23:22:44.710+05:30JMETER load testing by code/ JMETER API implementation sample by java code<div dir="ltr" style="text-align: left;" trbidi="on">This tutorial attempts to explain the basic design, functionality and usage of the Jmeter, Jmeter is excellent tool used to perform load testing on the application, By using the jmeter GUI we can create the test samples for the request<br />
according to our requirement and execute the samples with load of number of users.<br />
As jmeter tool is fully developed by using JAVA, We can write the java code to do the same without using the GUI of the jmeter, Its not advisable to implement the java code for the load testing, its just a proof of concept to write the samples by java code using the jmeter libraries.<br />
Jmeter as very good documentation/APIs, After going through the jmeter source code and other reference resources, wrote the following sample code.<br />
<h4>Pre-prerequisites:</h4><hr/><ul><ol><a href="http://jmeter.apache.org/" target="_blank">JMETER </a></ol><ol><a href="http://java.com/" target="_blank">JAVA >= 1.6 </a></ol><ol><a href="" target="_blank">Eclipse or net beans editor </a></ol></ul><hr/>Prior to understand following code we must have basic knowledge of the how jmeter works.<br />
Initially we need load the jmeter properties which will be used by jmeter classes/libraries in later stage of code<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #888888">//JMeter Engine</span>
StandardJMeterEngine jmeter <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">new</span> StandardJMeterEngine<span style="color: #333333">();</span>
<span style="color: #888888">//JMeter initialization (properties, log levels, locale, etc)</span>
JMeterUtils<span style="color: #333333">.</span><span style="color: #0000CC">setJMeterHome</span><span style="color: #333333">(</span>jmeterHome<span style="color: #333333">.</span><span style="color: #0000CC">getPath</span><span style="color: #333333">());</span>
JMeterUtils<span style="color: #333333">.</span><span style="color: #0000CC">loadJMeterProperties</span><span style="color: #333333">(</span>jmeterProperties<span style="color: #333333">.</span><span style="color: #0000CC">getPath</span><span style="color: #333333">());</span>
JMeterUtils<span style="color: #333333">.</span><span style="color: #0000CC">initLogging</span><span style="color: #333333">();</span><span style="color: #888888">// you can comment this line out to see extra log messages of i.e. DEBUG level</span>
JMeterUtils<span style="color: #333333">.</span><span style="color: #0000CC">initLocale</span><span style="color: #333333">();</span>
</pre></div><h4>1. Create "Test Plan" Object and JOrphan HashTree</h4><div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #888888">//JMeter Test Plan, basically JOrphan HashTree</span>
HashTree testPlanTree <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">new</span> HashTree<span style="color: #333333">();</span>
</pre></div><div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #888888">// Test Plan</span>
TestPlan testPlan <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">new</span> TestPlan<span style="color: #333333">(</span><span style="background-color: #fff0f0">"Create JMeter Script From Java Code"</span><span style="color: #333333">);</span>
testPlan<span style="color: #333333">.</span><span style="color: #0000CC">setProperty</span><span style="color: #333333">(</span>TestElement<span style="color: #333333">.</span><span style="color: #0000CC">TEST_CLASS</span><span style="color: #333333">,</span> TestPlan<span style="color: #333333">.</span><span style="color: #0000CC">class</span><span style="color: #333333">.</span><span style="color: #0000CC">getName</span><span style="color: #333333">());</span>
testPlan<span style="color: #333333">.</span><span style="color: #0000CC">setProperty</span><span style="color: #333333">(</span>TestElement<span style="color: #333333">.</span><span style="color: #0000CC">GUI_CLASS</span><span style="color: #333333">,</span> TestPlanGui<span style="color: #333333">.</span><span style="color: #0000CC">class</span><span style="color: #333333">.</span><span style="color: #0000CC">getName</span><span style="color: #333333">());</span>
testPlan<span style="color: #333333">.</span><span style="color: #0000CC">setUserDefinedVariables</span><span style="color: #333333">((</span>Arguments<span style="color: #333333">)</span> <span style="color: #008800; font-weight: bold">new</span> ArgumentsPanel<span style="color: #333333">().</span><span style="color: #0000CC">createTestElement</span><span style="color: #333333">());</span>
</pre></div><h4>2. Samplers : Add "Http Sample" Object</h4>Samplers tell JMeter to send requests to a server and wait for a response. They are processed in the order they appear in the tree. Controllers can be used to modify the number of repetitions of a sampler<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #888888">// First HTTP Sampler - open uttesh.com</span>
HTTPSamplerProxy examplecomSampler <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">new</span> HTTPSamplerProxy<span style="color: #333333">();</span>
examplecomSampler<span style="color: #333333">.</span><span style="color: #0000CC">setDomain</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"uttesh.com"</span><span style="color: #333333">);</span>
examplecomSampler<span style="color: #333333">.</span><span style="color: #0000CC">setPort</span><span style="color: #333333">(</span><span style="color: #0000DD; font-weight: bold">80</span><span style="color: #333333">);</span>
examplecomSampler<span style="color: #333333">.</span><span style="color: #0000CC">setPath</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"/"</span><span style="color: #333333">);</span>
examplecomSampler<span style="color: #333333">.</span><span style="color: #0000CC">setMethod</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"GET"</span><span style="color: #333333">);</span>
examplecomSampler<span style="color: #333333">.</span><span style="color: #0000CC">setName</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"Open uttesh.com"</span><span style="color: #333333">);</span>
examplecomSampler<span style="color: #333333">.</span><span style="color: #0000CC">setProperty</span><span style="color: #333333">(</span>TestElement<span style="color: #333333">.</span><span style="color: #0000CC">TEST_CLASS</span><span style="color: #333333">,</span> HTTPSamplerProxy<span style="color: #333333">.</span><span style="color: #0000CC">class</span><span style="color: #333333">.</span><span style="color: #0000CC">getName</span><span style="color: #333333">());</span>
examplecomSampler<span style="color: #333333">.</span><span style="color: #0000CC">setProperty</span><span style="color: #333333">(</span>TestElement<span style="color: #333333">.</span><span style="color: #0000CC">GUI_CLASS</span><span style="color: #333333">,</span> HttpTestSampleGui<span style="color: #333333">.</span><span style="color: #0000CC">class</span><span style="color: #333333">.</span><span style="color: #0000CC">getName</span><span style="color: #333333">());</span>
</pre></div><h4>3.Loop Controller</h4>Loop Controller will execute the samples number times the loop iteration is declared.<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #888888">// Loop Controller</span>
LoopController loopController <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">new</span> LoopController<span style="color: #333333">();</span>
loopController<span style="color: #333333">.</span><span style="color: #0000CC">setLoops</span><span style="color: #333333">(</span><span style="color: #0000DD; font-weight: bold">1</span><span style="color: #333333">);</span>
loopController<span style="color: #333333">.</span><span style="color: #0000CC">setFirst</span><span style="color: #333333">(</span><span style="color: #008800; font-weight: bold">true</span><span style="color: #333333">);</span>
loopController<span style="color: #333333">.</span><span style="color: #0000CC">setProperty</span><span style="color: #333333">(</span>TestElement<span style="color: #333333">.</span><span style="color: #0000CC">TEST_CLASS</span><span style="color: #333333">,</span> LoopController<span style="color: #333333">.</span><span style="color: #0000CC">class</span><span style="color: #333333">.</span><span style="color: #0000CC">getName</span><span style="color: #333333">());</span>
loopController<span style="color: #333333">.</span><span style="color: #0000CC">setProperty</span><span style="color: #333333">(</span>TestElement<span style="color: #333333">.</span><span style="color: #0000CC">GUI_CLASS</span><span style="color: #333333">,</span> LoopControlPanel<span style="color: #333333">.</span><span style="color: #0000CC">class</span><span style="color: #333333">.</span><span style="color: #0000CC">getName</span><span style="color: #333333">());</span>
loopController<span style="color: #333333">.</span><span style="color: #0000CC">initialize</span><span style="color: #333333">();</span>
</pre></div><h4>4.Thread Group</h4>Thread group elements are the beginning points of any test plan. All controllers and samplers must be under a thread group. Other elements, e.g. Listeners, may be placed directly under the test plan, in which case they will apply to all the thread groups. As the name implies, the thread group element controls the number of threads JMeter will use to execute your test.<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #888888">// Thread Group</span>
ThreadGroup threadGroup <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">new</span> ThreadGroup<span style="color: #333333">();</span>
threadGroup<span style="color: #333333">.</span><span style="color: #0000CC">setName</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"Sample Thread Group"</span><span style="color: #333333">);</span>
threadGroup<span style="color: #333333">.</span><span style="color: #0000CC">setNumThreads</span><span style="color: #333333">(</span><span style="color: #0000DD; font-weight: bold">1</span><span style="color: #333333">);</span>
threadGroup<span style="color: #333333">.</span><span style="color: #0000CC">setRampUp</span><span style="color: #333333">(</span><span style="color: #0000DD; font-weight: bold">1</span><span style="color: #333333">);</span>
threadGroup<span style="color: #333333">.</span><span style="color: #0000CC">setSamplerController</span><span style="color: #333333">(</span>loopController<span style="color: #333333">);</span>
threadGroup<span style="color: #333333">.</span><span style="color: #0000CC">setProperty</span><span style="color: #333333">(</span>TestElement<span style="color: #333333">.</span><span style="color: #0000CC">TEST_CLASS</span><span style="color: #333333">,</span> ThreadGroup<span style="color: #333333">.</span><span style="color: #0000CC">class</span><span style="color: #333333">.</span><span style="color: #0000CC">getName</span><span style="color: #333333">());</span>
threadGroup<span style="color: #333333">.</span><span style="color: #0000CC">setProperty</span><span style="color: #333333">(</span>TestElement<span style="color: #333333">.</span><span style="color: #0000CC">GUI_CLASS</span><span style="color: #333333">,</span> ThreadGroupGui<span style="color: #333333">.</span><span style="color: #0000CC">class</span><span style="color: #333333">.</span><span style="color: #0000CC">getName</span><span style="color: #333333">());</span>
</pre></div><h4>5. Add sampler,controller..etc to test plan</h4><div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #888888">// Construct Test Plan from previously initialized elements</span>
testPlanTree<span style="color: #333333">.</span><span style="color: #0000CC">add</span><span style="color: #333333">(</span>testPlan<span style="color: #333333">);</span>
HashTree threadGroupHashTree <span style="color: #333333">=</span> testPlanTree<span style="color: #333333">.</span><span style="color: #0000CC">add</span><span style="color: #333333">(</span>testPlan<span style="color: #333333">,</span> threadGroup<span style="color: #333333">);</span>
threadGroupHashTree<span style="color: #333333">.</span><span style="color: #0000CC">add</span><span style="color: #333333">(</span>examplecomSampler<span style="color: #333333">);</span>
<span style="color: #888888">// save generated test plan to JMeter's .jmx file format</span>
SaveService<span style="color: #333333">.</span><span style="color: #0000CC">saveTree</span><span style="color: #333333">(</span>testPlanTree<span style="color: #333333">,</span> <span style="color: #008800; font-weight: bold">new</span> FileOutputStream<span style="color: #333333">(</span><span style="background-color: #fff0f0">"report\\jmeter_api_sample.jmx"</span><span style="color: #333333">));</span>
</pre></div>above code will generate the jmeter script which we wrote from the code.<br />
<h4>5. Add Summary and reports</h4><div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #888888">//add Summarizer output to get test progress in stdout like:</span>
<span style="color: #888888">// summary = 2 in 1.3s = 1.5/s Avg: 631 Min: 290 Max: 973 Err: 0 (0.00%)</span>
Summariser summer <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">null</span><span style="color: #333333">;</span>
String summariserName <span style="color: #333333">=</span> JMeterUtils<span style="color: #333333">.</span><span style="color: #0000CC">getPropDefault</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"summariser.name"</span><span style="color: #333333">,</span> <span style="background-color: #fff0f0">"summary"</span><span style="color: #333333">);</span>
<span style="color: #008800; font-weight: bold">if</span> <span style="color: #333333">(</span>summariserName<span style="color: #333333">.</span><span style="color: #0000CC">length</span><span style="color: #333333">()</span> <span style="color: #333333">></span> <span style="color: #0000DD; font-weight: bold">0</span><span style="color: #333333">)</span> <span style="color: #333333">{</span>
summer <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">new</span> Summariser<span style="color: #333333">(</span>summariserName<span style="color: #333333">);</span>
<span style="color: #333333">}</span>
<span style="color: #888888">// Store execution results into a .jtl file, we can save file as csv also</span>
String reportFile <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"report\\report.jtl"</span><span style="color: #333333">;</span>
String csvFile <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"report\\report.csv"</span><span style="color: #333333">;</span>
ResultCollector logger <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">new</span> ResultCollector<span style="color: #333333">(</span>summer<span style="color: #333333">);</span>
logger<span style="color: #333333">.</span><span style="color: #0000CC">setFilename</span><span style="color: #333333">(</span>reportFile<span style="color: #333333">);</span>
ResultCollector csvlogger <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">new</span> ResultCollector<span style="color: #333333">(</span>summer<span style="color: #333333">);</span>
csvlogger<span style="color: #333333">.</span><span style="color: #0000CC">setFilename</span><span style="color: #333333">(</span>csvFile<span style="color: #333333">);</span>
testPlanTree<span style="color: #333333">.</span><span style="color: #0000CC">add</span><span style="color: #333333">(</span>testPlanTree<span style="color: #333333">.</span><span style="color: #0000CC">getArray</span><span style="color: #333333">()[</span><span style="color: #0000DD; font-weight: bold">0</span><span style="color: #333333">],</span> logger<span style="color: #333333">);</span>
testPlanTree<span style="color: #333333">.</span><span style="color: #0000CC">add</span><span style="color: #333333">(</span>testPlanTree<span style="color: #333333">.</span><span style="color: #0000CC">getArray</span><span style="color: #333333">()[</span><span style="color: #0000DD; font-weight: bold">0</span><span style="color: #333333">],</span> csvlogger<span style="color: #333333">);</span>
</pre></div><h4>Finally Execute the test</h4><div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #888888">// Run Test Plan</span>
jmeter<span style="color: #333333">.</span><span style="color: #0000CC">configure</span><span style="color: #333333">(</span>testPlanTree<span style="color: #333333">);</span>
jmeter<span style="color: #333333">.</span><span style="color: #0000CC">run</span><span style="color: #333333">();</span>
System<span style="color: #333333">.</span><span style="color: #0000CC">out</span><span style="color: #333333">.</span><span style="color: #0000CC">println</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"Test completed. See "</span> <span style="color: #333333">+</span> jmeterHome <span style="color: #333333">+</span> slash <span style="color: #333333">+</span> <span style="background-color: #fff0f0">"report.jtl file for results"</span><span style="color: #333333">);</span>
System<span style="color: #333333">.</span><span style="color: #0000CC">out</span><span style="color: #333333">.</span><span style="color: #0000CC">println</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"JMeter .jmx script is available at "</span> <span style="color: #333333">+</span> jmeterHome <span style="color: #333333">+</span> slash <span style="color: #333333">+</span> <span style="background-color: #fff0f0">"jmeter_api_sample.jmx"</span><span style="color: #333333">);</span>
System<span style="color: #333333">.</span><span style="color: #0000CC">exit</span><span style="color: #333333">(</span><span style="color: #0000DD; font-weight: bold">0</span><span style="color: #333333">);</span>
</pre></div><br />
Full Source Code of the POC is available on the GitHub <a href="https://github.com/uttesh/JmeterAPISample" target="blank">click here</a><br />
Simple source :<br />
<script src="https://gist.github.com/uttesh/8ce5fde4ac5149b115f1.js"></script><br />
Generate JMX sample file by code and opened in jmeter UI.<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbKC20FvwfEpsf9q7EczYYXubkN0HotAa9oJhbSFisMSsyV1SzkiZZPniFy3if0Gob28cSCfcjOiks0Q1rgYtqU8ApVBLkJ1UhL1C3gOw_JmCXx_7xCa7eAmwtJoenzxMdPpRmQY4tPh4a/s1600/jmxsample.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbKC20FvwfEpsf9q7EczYYXubkN0HotAa9oJhbSFisMSsyV1SzkiZZPniFy3if0Gob28cSCfcjOiks0Q1rgYtqU8ApVBLkJ1UhL1C3gOw_JmCXx_7xCa7eAmwtJoenzxMdPpRmQY4tPh4a/s320/jmxsample.png" /></a><br />
Summary Report generated by code after test execution<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyuvaZXoiScqUSA7CndJ2dEjudtFRqtAbVsuHn74U5EjIE2xxXdHXvrv7umgU3flpJG0Cm3zwihyt2jR0oZlfaWM1hyphenhyphenSiV7VqQYVQd0kHl25NYpm92FnI2dReCVysCi6iGDryoDm7j7qun/s1600/summary+report.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyuvaZXoiScqUSA7CndJ2dEjudtFRqtAbVsuHn74U5EjIE2xxXdHXvrv7umgU3flpJG0Cm3zwihyt2jR0oZlfaWM1hyphenhyphenSiV7VqQYVQd0kHl25NYpm92FnI2dReCVysCi6iGDryoDm7j7qun/s320/summary+report.png" /></a><br />
</div>Anonymoushttp://www.blogger.com/profile/02258593205933843635noreply@blogger.com3tag:blogger.com,1999:blog-2372689584609551068.post-49630739079760847862015-04-08T23:49:00.001+05:302015-04-08T23:50:40.474+05:30get byte or memory size of array,list,collections in java<div dir="ltr" style="text-align: left;" trbidi="on">In java lot of time we will come across the scenerio where in which we need to find the how much memory used by given list. <br />
<br />
The ArrayList holds a pointer to a single Object array, which grows as the number of elements exceed the size of the array. The ArrayList's underlying Object array grows by about 50% whenever we run out of space. <br />
<br />
ArrayList also writes out the size of the underlying array, used to recreate an identical ArrayList to what was serialized.<br />
<br />
sample code to get the memory size the collection in bytes<br />
<br />
<script src="https://gist.github.com/uttesh/fae8385bfd56530e7921.js"></script><br />
<br />
</div>Anonymoushttp://www.blogger.com/profile/02258593205933843635noreply@blogger.com1tag:blogger.com,1999:blog-2372689584609551068.post-43854181377068582622015-03-30T13:47:00.000+05:302015-03-30T13:47:50.122+05:30Generate the bar code image by itext<div dir="ltr" style="text-align: left;" trbidi="on">We can generate a bar code image by using the itext jar.<br />
<br />
Itext jar : <a href="http://sourceforge.net/projects/itext/">http://sourceforge.net/projects/itext/</a><br />
<br />
Download jar : <a href="http://sourceforge.net/projects/itext/files/latest/download">http://sourceforge.net/projects/itext/files/latest/download</a><br />
<br />
<br />
sample code <br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">com.itextpdf.text.pdf.BarcodePDF417</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.awt.Color</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.awt.image.BufferedImage</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.io.ByteArrayOutputStream</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.io.FileOutputStream</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.io.IOException</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">javax.imageio.ImageIO</span><span style="color: #333333">;</span>
<span style="color: #888888">/**</span>
<span style="color: #888888"> *</span>
<span style="color: #888888"> * @author Uttesh Kumar T.H.</span>
<span style="color: #888888"> */</span>
<span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">class</span> <span style="color: #BB0066; font-weight: bold">GenerateBarCodeImage</span> <span style="color: #333333">{</span>
<span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">static</span> <span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">main</span><span style="color: #333333">(</span>String<span style="color: #333333">[]</span> args<span style="color: #333333">)</span> <span style="color: #008800; font-weight: bold">throws</span> IOException <span style="color: #333333">{</span>
BarcodePDF417 barcode <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">new</span> BarcodePDF417<span style="color: #333333">();</span>
barcode<span style="color: #333333">.</span><span style="color: #0000CC">setText</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"Bla bla"</span><span style="color: #333333">);</span>
java<span style="color: #333333">.</span><span style="color: #0000CC">awt</span><span style="color: #333333">.</span><span style="color: #0000CC">Image</span> img <span style="color: #333333">=</span> barcode<span style="color: #333333">.</span><span style="color: #0000CC">createAwtImage</span><span style="color: #333333">(</span>Color<span style="color: #333333">.</span><span style="color: #0000CC">BLACK</span><span style="color: #333333">,</span> Color<span style="color: #333333">.</span><span style="color: #0000CC">WHITE</span><span style="color: #333333">);</span>
BufferedImage outImage <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">new</span> BufferedImage<span style="color: #333333">(</span>img<span style="color: #333333">.</span><span style="color: #0000CC">getWidth</span><span style="color: #333333">(</span><span style="color: #008800; font-weight: bold">null</span><span style="color: #333333">),</span> img<span style="color: #333333">.</span><span style="color: #0000CC">getHeight</span><span style="color: #333333">(</span><span style="color: #008800; font-weight: bold">null</span><span style="color: #333333">),</span> BufferedImage<span style="color: #333333">.</span><span style="color: #0000CC">TYPE_INT_RGB</span><span style="color: #333333">);</span>
outImage<span style="color: #333333">.</span><span style="color: #0000CC">getGraphics</span><span style="color: #333333">().</span><span style="color: #0000CC">drawImage</span><span style="color: #333333">(</span>img<span style="color: #333333">,</span> <span style="color: #0000DD; font-weight: bold">0</span><span style="color: #333333">,</span> <span style="color: #0000DD; font-weight: bold">0</span><span style="color: #333333">,</span> <span style="color: #008800; font-weight: bold">null</span><span style="color: #333333">);</span>
ByteArrayOutputStream bytesOut <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">new</span> ByteArrayOutputStream<span style="color: #333333">();</span>
ImageIO<span style="color: #333333">.</span><span style="color: #0000CC">write</span><span style="color: #333333">(</span>outImage<span style="color: #333333">,</span> <span style="background-color: #fff0f0">"png"</span><span style="color: #333333">,</span> bytesOut<span style="color: #333333">);</span>
bytesOut<span style="color: #333333">.</span><span style="color: #0000CC">flush</span><span style="color: #333333">();</span>
<span style="color: #333399; font-weight: bold">byte</span><span style="color: #333333">[]</span> pngImageData <span style="color: #333333">=</span> bytesOut<span style="color: #333333">.</span><span style="color: #0000CC">toByteArray</span><span style="color: #333333">();</span>
FileOutputStream fos <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">new</span> FileOutputStream<span style="color: #333333">(</span><span style="background-color: #fff0f0">"barcode.png"</span><span style="color: #333333">);</span>
fos<span style="color: #333333">.</span><span style="color: #0000CC">write</span><span style="color: #333333">(</span>pngImageData<span style="color: #333333">);</span>
fos<span style="color: #333333">.</span><span style="color: #0000CC">flush</span><span style="color: #333333">();</span>
fos<span style="color: #333333">.</span><span style="color: #0000CC">close</span><span style="color: #333333">();</span>
<span style="color: #333333">}</span>
<span style="color: #333333">}</span>
</pre></div><br />
</div>Anonymoushttp://www.blogger.com/profile/02258593205933843635noreply@blogger.com0tag:blogger.com,1999:blog-2372689584609551068.post-75436780346001522652015-03-30T12:20:00.000+05:302015-03-30T12:20:40.416+05:30Regular expression to extract the src tag details from given image tag or html source text<div dir="ltr" style="text-align: left;" trbidi="on"><br />
By using the regular expression we can extract the any data from the given input, here we are trying to get the <i>src</i> attribute value from the given image tag or html text data.<br />
<br />
Image 'src' attribute extract Regx:<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #0000CC"><img[^>]*src</span><span style="color: #333333">=</span><span style="background-color: #fff0f0">[\\\"']([^\\\"^']*)</span>
</pre></div><br />
<br />
sample code:<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.util.regex.Matcher</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.util.regex.Pattern</span><span style="color: #333333">;</span>
<span style="color: #888888">/**</span>
<span style="color: #888888"> *</span>
<span style="color: #888888"> * @author Uttesh Kumar T.H.</span>
<span style="color: #888888"> */</span>
<span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">class</span> <span style="color: #BB0066; font-weight: bold">ImgTest</span> <span style="color: #333333">{</span>
<span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">static</span> <span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">main</span><span style="color: #333333">(</span>String<span style="color: #333333">[]</span> args<span style="color: #333333">)</span> <span style="color: #333333">{</span>
String s <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"<p><img src=\"38220.png\" alt=\"test\" title=\"test\" /> <img src=\"32222.png\" alt=\"test\" title=\"test\" /></p>"</span><span style="color: #333333">;</span>
Pattern p <span style="color: #333333">=</span> Pattern<span style="color: #333333">.</span><span style="color: #0000CC">compile</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"<img[^>]*src=[\\\"']([^\\\"^']*)"</span><span style="color: #333333">);</span>
Matcher m <span style="color: #333333">=</span> p<span style="color: #333333">.</span><span style="color: #0000CC">matcher</span><span style="color: #333333">(</span>s<span style="color: #333333">);</span>
<span style="color: #008800; font-weight: bold">while</span> <span style="color: #333333">(</span>m<span style="color: #333333">.</span><span style="color: #0000CC">find</span><span style="color: #333333">())</span> <span style="color: #333333">{</span>
String src <span style="color: #333333">=</span> m<span style="color: #333333">.</span><span style="color: #0000CC">group</span><span style="color: #333333">();</span>
<span style="color: #333399; font-weight: bold">int</span> startIndex <span style="color: #333333">=</span> src<span style="color: #333333">.</span><span style="color: #0000CC">indexOf</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"src="</span><span style="color: #333333">)</span> <span style="color: #333333">+</span> <span style="color: #0000DD; font-weight: bold">5</span><span style="color: #333333">;</span>
String srcTag <span style="color: #333333">=</span> src<span style="color: #333333">.</span><span style="color: #0000CC">substring</span><span style="color: #333333">(</span>startIndex<span style="color: #333333">,</span> src<span style="color: #333333">.</span><span style="color: #0000CC">length</span><span style="color: #333333">());</span>
System<span style="color: #333333">.</span><span style="color: #0000CC">out</span><span style="color: #333333">.</span><span style="color: #0000CC">println</span><span style="color: #333333">(</span>srcTag<span style="color: #333333">);</span>
<span style="color: #333333">}</span>
<span style="color: #333333">}</span>
<span style="color: #333333">}</span>
</pre></div><br />
<br />
</div>Anonymoushttp://www.blogger.com/profile/02258593205933843635noreply@blogger.com1tag:blogger.com,1999:blog-2372689584609551068.post-23201697823111818872015-03-30T11:41:00.001+05:302015-03-30T12:07:32.277+05:30Compare images are same by java<div dir="ltr" style="text-align: left;" trbidi="on">We can compare the given images are same or not by comparing the buffer data of the image.<br />
<br />
1. Compare the image sizes are same or not.<br />
2. Compare the binary data of two images are same or not.<br />
<br />
sample code :<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.awt.image.BufferedImage</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.awt.image.DataBuffer</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.io.File</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">javax.imageio.ImageIO</span><span style="color: #333333">;</span>
<span style="color: #888888">/**</span>
<span style="color: #888888"> *</span>
<span style="color: #888888"> * @author Uttesh Kumar T.H.</span>
<span style="color: #888888"> */</span>
<span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">class</span> <span style="color: #BB0066; font-weight: bold">compareimage</span> <span style="color: #333333">{</span>
<span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">static</span> <span style="color: #333399; font-weight: bold">boolean</span> <span style="color: #0066BB; font-weight: bold">compareImage</span><span style="color: #333333">(</span>File fileA<span style="color: #333333">,</span> File fileB<span style="color: #333333">)</span> <span style="color: #333333">{</span>
<span style="color: #008800; font-weight: bold">try</span> <span style="color: #333333">{</span>
<span style="color: #888888">// take buffer data from botm image files //</span>
BufferedImage biA <span style="color: #333333">=</span> ImageIO<span style="color: #333333">.</span><span style="color: #0000CC">read</span><span style="color: #333333">(</span>fileA<span style="color: #333333">);</span>
DataBuffer dbA <span style="color: #333333">=</span> biA<span style="color: #333333">.</span><span style="color: #0000CC">getData</span><span style="color: #333333">().</span><span style="color: #0000CC">getDataBuffer</span><span style="color: #333333">();</span>
<span style="color: #333399; font-weight: bold">int</span> sizeA <span style="color: #333333">=</span> dbA<span style="color: #333333">.</span><span style="color: #0000CC">getSize</span><span style="color: #333333">();</span>
BufferedImage biB <span style="color: #333333">=</span> ImageIO<span style="color: #333333">.</span><span style="color: #0000CC">read</span><span style="color: #333333">(</span>fileB<span style="color: #333333">);</span>
DataBuffer dbB <span style="color: #333333">=</span> biB<span style="color: #333333">.</span><span style="color: #0000CC">getData</span><span style="color: #333333">().</span><span style="color: #0000CC">getDataBuffer</span><span style="color: #333333">();</span>
<span style="color: #333399; font-weight: bold">int</span> sizeB <span style="color: #333333">=</span> dbB<span style="color: #333333">.</span><span style="color: #0000CC">getSize</span><span style="color: #333333">();</span>
<span style="color: #888888">// compare data-buffer objects //</span>
<span style="color: #008800; font-weight: bold">if</span> <span style="color: #333333">(</span>sizeA <span style="color: #333333">==</span> sizeB<span style="color: #333333">)</span> <span style="color: #333333">{</span>
<span style="color: #008800; font-weight: bold">for</span> <span style="color: #333333">(</span><span style="color: #333399; font-weight: bold">int</span> i <span style="color: #333333">=</span> <span style="color: #0000DD; font-weight: bold">0</span><span style="color: #333333">;</span> i <span style="color: #333333"><</span> sizeA<span style="color: #333333">;</span> i<span style="color: #333333">++)</span> <span style="color: #333333">{</span>
<span style="color: #008800; font-weight: bold">if</span> <span style="color: #333333">(</span>dbA<span style="color: #333333">.</span><span style="color: #0000CC">getElem</span><span style="color: #333333">(</span>i<span style="color: #333333">)</span> <span style="color: #333333">!=</span> dbB<span style="color: #333333">.</span><span style="color: #0000CC">getElem</span><span style="color: #333333">(</span>i<span style="color: #333333">))</span> <span style="color: #333333">{</span>
<span style="color: #008800; font-weight: bold">return</span> <span style="color: #008800; font-weight: bold">false</span><span style="color: #333333">;</span>
<span style="color: #333333">}</span>
<span style="color: #333333">}</span>
<span style="color: #008800; font-weight: bold">return</span> <span style="color: #008800; font-weight: bold">true</span><span style="color: #333333">;</span>
<span style="color: #333333">}</span> <span style="color: #008800; font-weight: bold">else</span> <span style="color: #333333">{</span>
<span style="color: #008800; font-weight: bold">return</span> <span style="color: #008800; font-weight: bold">false</span><span style="color: #333333">;</span>
<span style="color: #333333">}</span>
<span style="color: #333333">}</span> <span style="color: #008800; font-weight: bold">catch</span> <span style="color: #333333">(</span>Exception e<span style="color: #333333">)</span> <span style="color: #333333">{</span>
System<span style="color: #333333">.</span><span style="color: #0000CC">out</span><span style="color: #333333">.</span><span style="color: #0000CC">println</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"Failed to compare image files ..."</span><span style="color: #333333">);</span>
<span style="color: #008800; font-weight: bold">return</span> <span style="color: #008800; font-weight: bold">false</span><span style="color: #333333">;</span>
<span style="color: #333333">}</span>
<span style="color: #333333">}</span>
<span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">static</span> <span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">main</span><span style="color: #333333">(</span>String<span style="color: #333333">[]</span> args<span style="color: #333333">)</span> <span style="color: #333333">{</span>
File file1 <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">new</span> File<span style="color: #333333">(</span><span style="background-color: #fff0f0">"path to image1"</span><span style="color: #333333">);</span>
File file2 <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">new</span> File<span style="color: #333333">(</span><span style="background-color: #fff0f0">"path to image2"</span><span style="color: #333333">);</span>
System<span style="color: #333333">.</span><span style="color: #0000CC">out</span><span style="color: #333333">.</span><span style="color: #0000CC">println</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"result :"</span> <span style="color: #333333">+</span> compareImage<span style="color: #333333">(</span>file1<span style="color: #333333">,</span> file2<span style="color: #333333">));</span>
<span style="color: #333333">}</span>
<span style="color: #333333">}</span>
</pre></div><br />
</div>Anonymoushttp://www.blogger.com/profile/02258593205933843635noreply@blogger.com0tag:blogger.com,1999:blog-2372689584609551068.post-26716376617357910202015-03-28T11:37:00.000+05:302015-03-28T11:37:54.026+05:30Reverse elements in Array<div dir="ltr" style="text-align: left;" trbidi="on">Reverse all elements in array, traditional way how we use to do is get the array and iterate through the for loop and use swap logic to move to temporary array and get the result.<br />
<br />
But from > jdk 1.5 introduced reverse() in java.util.Collections which will reverse the order of the elements, all we have to do is to convert the array to arraylist by using Arrays.asList() and using collections.reverse() to reverse the order of the element.<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.util.Arrays</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.util.Collections</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.util.List</span><span style="color: #333333">;</span>
<span style="color: #888888">/**</span>
<span style="color: #888888"> *</span>
<span style="color: #888888"> * @author Uttesh Kumar T.H.</span>
<span style="color: #888888"> */</span>
<span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">class</span> <span style="color: #BB0066; font-weight: bold">ReverseArray</span> <span style="color: #333333">{</span>
<span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">static</span> <span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">main</span><span style="color: #333333">(</span>String<span style="color: #333333">[]</span> args<span style="color: #333333">)</span> <span style="color: #333333">{</span>
Integer<span style="color: #333333">[]</span> numbers <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">new</span> Integer<span style="color: #333333">[]{</span><span style="color: #0000DD; font-weight: bold">1</span><span style="color: #333333">,</span> <span style="color: #0000DD; font-weight: bold">2</span><span style="color: #333333">,</span> <span style="color: #0000DD; font-weight: bold">3</span><span style="color: #333333">,</span> <span style="color: #0000DD; font-weight: bold">4</span><span style="color: #333333">,</span> <span style="color: #0000DD; font-weight: bold">5</span><span style="color: #333333">,</span> <span style="color: #0000DD; font-weight: bold">6</span><span style="color: #333333">};</span>
List numberlist <span style="color: #333333">=</span> Arrays<span style="color: #333333">.</span><span style="color: #0000CC">asList</span><span style="color: #333333">(</span>numbers<span style="color: #333333">);</span>
Collections<span style="color: #333333">.</span><span style="color: #0000CC">reverse</span><span style="color: #333333">(</span>numberlist<span style="color: #333333">);</span>
<span style="color: #008800; font-weight: bold">for</span> <span style="color: #333333">(</span><span style="color: #333399; font-weight: bold">int</span> i <span style="color: #333333">=</span> <span style="color: #0000DD; font-weight: bold">0</span><span style="color: #333333">;</span> i <span style="color: #333333"><</span> numberlist<span style="color: #333333">.</span><span style="color: #0000CC">size</span><span style="color: #333333">();</span> i<span style="color: #333333">++)</span> <span style="color: #333333">{</span>
System<span style="color: #333333">.</span><span style="color: #0000CC">out</span><span style="color: #333333">.</span><span style="color: #0000CC">println</span><span style="color: #333333">(</span>numberlist<span style="color: #333333">.</span><span style="color: #0000CC">get</span><span style="color: #333333">(</span>i<span style="color: #333333">));</span>
<span style="color: #333333">}</span>
<span style="color: #888888">// logical way of doing , its always good to understand the logic </span>
<span style="color: #333399; font-weight: bold">int</span><span style="color: #333333">[]</span> _numbers <span style="color: #333333">=</span> <span style="color: #333333">{</span><span style="color: #0000DD; font-weight: bold">1</span><span style="color: #333333">,</span> <span style="color: #0000DD; font-weight: bold">2</span><span style="color: #333333">,</span> <span style="color: #0000DD; font-weight: bold">3</span><span style="color: #333333">,</span> <span style="color: #0000DD; font-weight: bold">4</span><span style="color: #333333">,</span> <span style="color: #0000DD; font-weight: bold">5</span><span style="color: #333333">,</span> <span style="color: #0000DD; font-weight: bold">6</span><span style="color: #333333">};</span>
<span style="color: #008800; font-weight: bold">for</span> <span style="color: #333333">(</span><span style="color: #333399; font-weight: bold">int</span> i <span style="color: #333333">=</span> <span style="color: #0000DD; font-weight: bold">0</span><span style="color: #333333">;</span> i <span style="color: #333333"><</span> _numbers<span style="color: #333333">.</span><span style="color: #0000CC">length</span> <span style="color: #333333">/</span> <span style="color: #0000DD; font-weight: bold">2</span><span style="color: #333333">;</span> i<span style="color: #333333">++)</span> <span style="color: #333333">{</span>
<span style="color: #333399; font-weight: bold">int</span> temp <span style="color: #333333">=</span> _numbers<span style="color: #333333">[</span>i<span style="color: #333333">];</span> <span style="color: #888888">// swap numbers </span>
_numbers<span style="color: #333333">[</span>i<span style="color: #333333">]</span> <span style="color: #333333">=</span> _numbers<span style="color: #333333">[</span>_numbers<span style="color: #333333">.</span><span style="color: #0000CC">length</span> <span style="color: #333333">-</span> <span style="color: #0000DD; font-weight: bold">1</span> <span style="color: #333333">-</span> i<span style="color: #333333">];</span>
_numbers<span style="color: #333333">[</span>_numbers<span style="color: #333333">.</span><span style="color: #0000CC">length</span> <span style="color: #333333">-</span> <span style="color: #0000DD; font-weight: bold">1</span> <span style="color: #333333">-</span> i<span style="color: #333333">]</span> <span style="color: #333333">=</span> temp<span style="color: #333333">;</span>
<span style="color: #333333">}</span>
System<span style="color: #333333">.</span><span style="color: #0000CC">out</span><span style="color: #333333">.</span><span style="color: #0000CC">println</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"reversed array : "</span> <span style="color: #333333">+</span> Arrays<span style="color: #333333">.</span><span style="color: #0000CC">toString</span><span style="color: #333333">(</span>_numbers<span style="color: #333333">));</span>
<span style="color: #333333">}</span>
<span style="color: #333333">}</span>
</pre></div><br />
<br />
</div>Anonymoushttp://www.blogger.com/profile/02258593205933843635noreply@blogger.com0tag:blogger.com,1999:blog-2372689584609551068.post-11682580677881389002015-03-28T10:28:00.000+05:302015-03-28T10:28:40.617+05:30find character uppercase/lowercase count from given text<div dir="ltr" style="text-align: left;" trbidi="on">Find the character upper/lower case occurrence count with simple single line code without iteration in java.<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #333399; font-weight: bold">int</span> counta <span style="color: #333333">=</span> text<span style="color: #333333">.</span><span style="color: #0000CC">split</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"(?=[a])"</span><span style="color: #333333">).</span><span style="color: #0000CC">length</span> <span style="color: #333333">-</span> <span style="color: #0000DD; font-weight: bold">1</span><span style="color: #333333">;</span>
</pre></div><br />
This simple code will find all the lowercase character 'a' from the given text, change the regx for the uppercase . ex 'A'.<br />
<br />
sample test code<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #888888">/**</span>
<span style="color: #888888"> *</span>
<span style="color: #888888"> * @author Uttesh Kumar T.H.</span>
<span style="color: #888888"> */</span>
<span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">class</span> <span style="color: #BB0066; font-weight: bold">Countchar</span> <span style="color: #333333">{</span>
<span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">static</span> <span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">main</span><span style="color: #333333">(</span>String<span style="color: #333333">[]</span> args<span style="color: #333333">)</span> <span style="color: #333333">{</span>
String text <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"asfasfzxph adsa wetw"</span><span style="color: #333333">;</span>
<span style="color: #333399; font-weight: bold">int</span> counta <span style="color: #333333">=</span> text<span style="color: #333333">.</span><span style="color: #0000CC">split</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"(?=[a])"</span><span style="color: #333333">).</span><span style="color: #0000CC">length</span> <span style="color: #333333">-</span> <span style="color: #0000DD; font-weight: bold">1</span><span style="color: #333333">;</span>
System<span style="color: #333333">.</span><span style="color: #0000CC">out</span><span style="color: #333333">.</span><span style="color: #0000CC">println</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"count a : "</span><span style="color: #333333">+</span>counta<span style="color: #333333">);</span>
<span style="color: #333333">}</span>
<span style="color: #333333">}</span>
</pre></div><br />
<br />
</div>Anonymoushttp://www.blogger.com/profile/02258593205933843635noreply@blogger.com0tag:blogger.com,1999:blog-2372689584609551068.post-68807281358488890412015-03-23T22:03:00.000+05:302015-03-23T22:03:21.593+05:30Get all files from parent/sub folders along with file size<div dir="ltr" style="text-align: left;" trbidi="on">In Java, you can use the File.length() method to get the file size in bytes and folder.listFiles() method to get all file/folders.<br />
<br />
sample code<br />
<br />
<script src="https://gist.github.com/uttesh/49adeecff6d440e93e23.js"></script><br />
</div>Anonymoushttp://www.blogger.com/profile/02258593205933843635noreply@blogger.com0tag:blogger.com,1999:blog-2372689584609551068.post-41597047238545186242015-03-19T18:27:00.000+05:302015-03-19T18:27:58.944+05:30Jfreechart servelt example<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<br />
Prerequisites <br />
<hr/><ul><li>JDK 1.5 and above</li>
<li>Jfreechart jar</li>
<li>mysql connector jar</li>
</ul><hr/>To generate charts we can use jfrecharts which is open source and free. In this example i will show how to generate the jfreechart dynamically for every 5 seconds getting data from the database.<br />
<br />
Full source code : <a target="_blank" href="https://github.com/uttesh/servletSamples/tree/master/jfreeChartServlet">github link</a><br />
<br />
sample : <a href="https://raw.githubusercontent.com/uttesh/servletSamples/master/jfreeChartServlet/sample.png" imageanchor="1" ><img border="0" src="https://raw.githubusercontent.com/uttesh/servletSamples/master/jfreeChartServlet/sample.png" /></a><br />
Create Simple servlet :<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.awt.BasicStroke</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.awt.Color</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.io.IOException</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.io.OutputStream</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.sql.*</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.sql.Connection</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.sql.DriverManager</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.sql.SQLException</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">java.util.ArrayList</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">javax.servlet.ServletException</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">javax.servlet.http.HttpServlet</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">javax.servlet.http.HttpServletRequest</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">javax.servlet.http.HttpServletResponse</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">org.jfree.chart.ChartFactory</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">org.jfree.chart.ChartRenderingInfo</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">org.jfree.chart.ChartUtilities</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">org.jfree.chart.JFreeChart</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">org.jfree.chart.entity.StandardEntityCollection</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">org.jfree.data.jdbc.JDBCPieDataset</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">class</span> <span style="color: #BB0066; font-weight: bold">JfreeChartServlet</span> <span style="color: #008800; font-weight: bold">extends</span> HttpServlet <span style="color: #333333">{</span>
<span style="color: #008800; font-weight: bold">private</span> <span style="color: #008800; font-weight: bold">static</span> Connection connection <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">null</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">protected</span> <span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">doGet</span><span style="color: #333333">(</span>HttpServletRequest request<span style="color: #333333">,</span> HttpServletResponse response<span style="color: #333333">)</span> <span style="color: #008800; font-weight: bold">throws</span> ServletException<span style="color: #333333">,</span> IOException <span style="color: #333333">{</span>
<span style="color: #008800; font-weight: bold">try</span> <span style="color: #333333">{</span>
JDBCPieDataset dataset <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">new</span> JDBCPieDataset<span style="color: #333333">(</span>getConnection<span style="color: #333333">());</span>
dataset<span style="color: #333333">.</span><span style="color: #0000CC">executeQuery</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"select * from result"</span><span style="color: #333333">);</span>
JFreeChart chart <span style="color: #333333">=</span> ChartFactory<span style="color: #333333">.</span><span style="color: #0000CC">createPieChart</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"Result Chart"</span><span style="color: #333333">,</span> dataset<span style="color: #333333">,</span> <span style="color: #008800; font-weight: bold">true</span><span style="color: #333333">,</span> <span style="color: #008800; font-weight: bold">true</span><span style="color: #333333">,</span> <span style="color: #008800; font-weight: bold">false</span><span style="color: #333333">);</span>
chart<span style="color: #333333">.</span><span style="color: #0000CC">setBorderPaint</span><span style="color: #333333">(</span>Color<span style="color: #333333">.</span><span style="color: #0000CC">black</span><span style="color: #333333">);</span>
chart<span style="color: #333333">.</span><span style="color: #0000CC">setBorderStroke</span><span style="color: #333333">(</span><span style="color: #008800; font-weight: bold">new</span> BasicStroke<span style="color: #333333">(</span><span style="color: #6600EE; font-weight: bold">4.0f</span><span style="color: #333333">));</span>
chart<span style="color: #333333">.</span><span style="color: #0000CC">setBorderVisible</span><span style="color: #333333">(</span><span style="color: #008800; font-weight: bold">true</span><span style="color: #333333">);</span>
<span style="color: #008800; font-weight: bold">if</span> <span style="color: #333333">(</span>chart <span style="color: #333333">!=</span> <span style="color: #008800; font-weight: bold">null</span><span style="color: #333333">)</span> <span style="color: #333333">{</span>
<span style="color: #333399; font-weight: bold">int</span> width <span style="color: #333333">=</span> <span style="color: #0000DD; font-weight: bold">500</span><span style="color: #333333">;</span>
<span style="color: #333399; font-weight: bold">int</span> height <span style="color: #333333">=</span> <span style="color: #0000DD; font-weight: bold">350</span><span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">final</span> ChartRenderingInfo info <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">new</span> ChartRenderingInfo<span style="color: #333333">(</span><span style="color: #008800; font-weight: bold">new</span> StandardEntityCollection<span style="color: #333333">());</span>
response<span style="color: #333333">.</span><span style="color: #0000CC">setContentType</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"image/png"</span><span style="color: #333333">);</span>
OutputStream out <span style="color: #333333">=</span> response<span style="color: #333333">.</span><span style="color: #0000CC">getOutputStream</span><span style="color: #333333">();</span>
ChartUtilities<span style="color: #333333">.</span><span style="color: #0000CC">writeChartAsPNG</span><span style="color: #333333">(</span>out<span style="color: #333333">,</span> chart<span style="color: #333333">,</span> width<span style="color: #333333">,</span> height<span style="color: #333333">,</span> info<span style="color: #333333">);</span>
<span style="color: #333333">}</span>
<span style="color: #333333">}</span> <span style="color: #008800; font-weight: bold">catch</span> <span style="color: #333333">(</span>SQLException e<span style="color: #333333">)</span> <span style="color: #333333">{</span>
e<span style="color: #333333">.</span><span style="color: #0000CC">printStackTrace</span><span style="color: #333333">();</span>
<span style="color: #333333">}</span>
<span style="color: #333333">}</span>
<span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">static</span> Connection <span style="color: #0066BB; font-weight: bold">getConnection</span><span style="color: #333333">()</span> <span style="color: #333333">{</span>
<span style="color: #008800; font-weight: bold">if</span> <span style="color: #333333">(</span>connection <span style="color: #333333">!=</span> <span style="color: #008800; font-weight: bold">null</span><span style="color: #333333">)</span>
<span style="color: #008800; font-weight: bold">return</span> connection<span style="color: #333333">;</span>
<span style="color: #008800; font-weight: bold">else</span> <span style="color: #333333">{</span>
<span style="color: #008800; font-weight: bold">try</span> <span style="color: #333333">{</span>
String driver <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"com.mysql.jdbc.Driver"</span><span style="color: #333333">;</span>
String url <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"jdbc:mysql://localhost:3306/test"</span><span style="color: #333333">;</span>
String user <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"root"</span><span style="color: #333333">;</span>
String password <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"******"</span><span style="color: #333333">;</span>
Class<span style="color: #333333">.</span><span style="color: #0000CC">forName</span><span style="color: #333333">(</span>driver<span style="color: #333333">);</span>
connection <span style="color: #333333">=</span> DriverManager<span style="color: #333333">.</span><span style="color: #0000CC">getConnection</span><span style="color: #333333">(</span>url<span style="color: #333333">,</span> user<span style="color: #333333">,</span> password<span style="color: #333333">);</span>
<span style="color: #333333">}</span> <span style="color: #008800; font-weight: bold">catch</span> <span style="color: #333333">(</span>ClassNotFoundException e<span style="color: #333333">)</span> <span style="color: #333333">{</span>
e<span style="color: #333333">.</span><span style="color: #0000CC">printStackTrace</span><span style="color: #333333">();</span>
<span style="color: #333333">}</span> <span style="color: #008800; font-weight: bold">catch</span> <span style="color: #333333">(</span>SQLException e<span style="color: #333333">)</span> <span style="color: #333333">{</span>
e<span style="color: #333333">.</span><span style="color: #0000CC">printStackTrace</span><span style="color: #333333">();</span>
<span style="color: #333333">}</span>
<span style="color: #008800; font-weight: bold">return</span> connection<span style="color: #333333">;</span>
<span style="color: #333333">}</span>
<span style="color: #333333">}</span>
<span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">static</span> ArrayList<span style="color: #333333"><</span>Result<span style="color: #333333">></span> <span style="color: #0066BB; font-weight: bold">getData</span><span style="color: #333333">()</span> <span style="color: #333333">{</span>
connection <span style="color: #333333">=</span> getConnection<span style="color: #333333">();</span>
ArrayList<span style="color: #333333"><</span>Result<span style="color: #333333">></span> resultList <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">new</span> ArrayList<span style="color: #333333"><</span>Result<span style="color: #333333">>();</span>
<span style="color: #008800; font-weight: bold">try</span> <span style="color: #333333">{</span>
Statement statement <span style="color: #333333">=</span> connection<span style="color: #333333">.</span><span style="color: #0000CC">createStatement</span><span style="color: #333333">();</span>
ResultSet rs <span style="color: #333333">=</span> statement<span style="color: #333333">.</span><span style="color: #0000CC">executeQuery</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"select * from result"</span><span style="color: #333333">);</span>
<span style="color: #008800; font-weight: bold">while</span><span style="color: #333333">(</span>rs<span style="color: #333333">.</span><span style="color: #0000CC">next</span><span style="color: #333333">())</span> <span style="color: #333333">{</span>
Result result<span style="color: #333333">=</span><span style="color: #008800; font-weight: bold">new</span> Result<span style="color: #333333">();</span>
result<span style="color: #333333">.</span><span style="color: #0000CC">setStatus</span><span style="color: #333333">(</span>rs<span style="color: #333333">.</span><span style="color: #0000CC">getString</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"status"</span><span style="color: #333333">));</span>
result<span style="color: #333333">.</span><span style="color: #0000CC">setCount</span><span style="color: #333333">(</span>rs<span style="color: #333333">.</span><span style="color: #0000CC">getInt</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"count"</span><span style="color: #333333">));</span>
resultList<span style="color: #333333">.</span><span style="color: #0000CC">add</span><span style="color: #333333">(</span>result<span style="color: #333333">);</span>
<span style="color: #333333">}</span>
<span style="color: #333333">}</span> <span style="color: #008800; font-weight: bold">catch</span> <span style="color: #333333">(</span>SQLException e<span style="color: #333333">)</span> <span style="color: #333333">{</span>
e<span style="color: #333333">.</span><span style="color: #0000CC">printStackTrace</span><span style="color: #333333">();</span>
<span style="color: #333333">}</span>
<span style="color: #008800; font-weight: bold">return</span> resultList<span style="color: #333333">;</span>
<span style="color: #333333">}</span>
<span style="color: #333333">}</span>
</pre></div><br />
<br />
jfreechartSample.jsp :<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #007700"><html></span>
<span style="color: #007700"><head></span>
<span style="color: #007700"><meta</span> <span style="color: #0000CC">http-equiv=</span><span style="background-color: #fff0f0">"Content-Type"</span> <span style="color: #0000CC">content=</span><span style="background-color: #fff0f0">"text/html; charset=ISO-8859-1"</span><span style="color: #007700">></span>
<span style="color: #007700"><title></span>Pie Chart Demo<span style="color: #007700"></title></span>
<span style="color: #007700"><script</span> <span style="color: #0000CC">language=</span><span style="background-color: #fff0f0">"Javascript"</span><span style="color: #007700">></span>
function refreshpage(){
document.forms.form1.submit();
}
<span style="color: #007700"></script></span>
<span style="color: #007700"></head></span>
<span style="color: #007700"><body></span>
<span style="color: #007700"><h1></span>Pie Chart<span style="color: #007700"></h1></span>
<span style="color: #008800; font-weight: bold"><%r</span>esponse<span style="color: #333333">.</span><span style="color: #0000CC">setIntHeader</span><span style="color: #333333">(</span><span style="background-color: #fff0f0">"Refresh"</span><span style="color: #333333">,</span><span style="color: #0000DD; font-weight: bold">5</span><span style="color: #333333">);</span><span style="color: #008800; font-weight: bold">%></span>
<span style="color: #007700"><form</span> <span style="color: #0000CC">id=</span><span style="background-color: #fff0f0">"form1"</span><span style="color: #007700">></span>
<span style="color: #007700"><img</span> <span style="color: #0000CC">src=</span><span style="background-color: #fff0f0">"chart"</span> <span style="color: #0000CC">width=</span><span style="background-color: #fff0f0">"600"</span> <span style="color: #0000CC">height=</span><span style="background-color: #fff0f0">"400"</span> <span style="color: #0000CC">border=</span><span style="background-color: #fff0f0">"0"</span><span style="color: #007700">/></span>
<span style="color: #888888"><!-- <input type="button" onclick="refreshpage()" value="Refresh"/>--></span>
<span style="color: #007700"></form></span>
<span style="color: #007700"></body></span>
<span style="color: #007700"></html></span>
</pre></div><br />
web.xml:<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #557799"><?xml version="1.0" encoding="UTF-8"?></span>
<span style="color: #007700"><web-app</span> <span style="color: #0000CC">version=</span><span style="background-color: #fff0f0">"2.5"</span>
<span style="color: #0000CC">xmlns=</span><span style="background-color: #fff0f0">"http://java.sun.com/xml/ns/javaee"</span>
<span style="color: #0000CC">xmlns:xsi=</span><span style="background-color: #fff0f0">"http://www.w3.org/2001/XMLSchema-instance"</span>
<span style="color: #0000CC">xsi:schemaLocation=</span><span style="background-color: #fff0f0">"http://java.sun.com/xml/ns/javaee </span>
<span style="background-color: #fff0f0"> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"</span><span style="color: #007700">></span>
<span style="color: #007700"><servlet></span>
<span style="color: #007700"><servlet-name></span>JfreeChartServlet<span style="color: #007700"></servlet-name></span>
<span style="color: #007700"><servlet-class></span>JfreeChartServlet<span style="color: #007700"></servlet-class></span>
<span style="color: #007700"></servlet></span>
<span style="color: #007700"><servlet-mapping></span>
<span style="color: #007700"><servlet-name></span>JfreeChartServlet<span style="color: #007700"></servlet-name></span>
<span style="color: #007700"><url-pattern></span>/chart<span style="color: #007700"></url-pattern></span>
<span style="color: #007700"></servlet-mapping></span>
<span style="color: #007700"><welcome-file-list></span>
<span style="color: #007700"><welcome-file></span>jfreechartSample.jsp<span style="color: #007700"></welcome-file></span>
<span style="color: #007700"></welcome-file-list></span>
<span style="color: #007700"></web-app></span>
</pre></div><br />
Database scripts: create the following table and insert the sample data.<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #008800; font-weight: bold">CREATE</span> <span style="color: #008800; font-weight: bold">TABLE</span> <span style="color: #333333">`</span><span style="color: #008800; font-weight: bold">result</span><span style="color: #333333">`</span> (
<span style="color: #333333">`</span>status<span style="color: #333333">`</span> <span style="color: #007020">varchar</span>(<span style="color: #0000DD; font-weight: bold">20</span>) <span style="color: #008800; font-weight: bold">DEFAULT</span> <span style="color: #008800; font-weight: bold">NULL</span>,
<span style="color: #333333">`</span><span style="color: #008800; font-weight: bold">count</span><span style="color: #333333">`</span> <span style="color: #007020">int</span>(<span style="color: #0000DD; font-weight: bold">11</span>) <span style="color: #008800; font-weight: bold">DEFAULT</span> <span style="color: #008800; font-weight: bold">NULL</span>
);
<span style="color: #008800; font-weight: bold">INSERT</span> <span style="color: #008800; font-weight: bold">INTO</span> <span style="color: #008800; font-weight: bold">result</span>(
status
,<span style="color: #008800; font-weight: bold">count</span>
) <span style="color: #008800; font-weight: bold">VALUES</span> (
<span style="background-color: #fff0f0">'PASSED'</span> <span style="color: #888888">-- status - IN varchar(20)</span>
,<span style="color: #0000DD; font-weight: bold">25</span> <span style="color: #888888">-- count - IN int(11)</span>
);
<span style="color: #008800; font-weight: bold">INSERT</span> <span style="color: #008800; font-weight: bold">INTO</span> <span style="color: #008800; font-weight: bold">result</span>(
status
,<span style="color: #008800; font-weight: bold">count</span>
) <span style="color: #008800; font-weight: bold">VALUES</span> (
<span style="background-color: #fff0f0">'FAILED'</span> <span style="color: #888888">-- status - IN varchar(20)</span>
,<span style="color: #0000DD; font-weight: bold">40</span> <span style="color: #888888">-- count - IN int(11)</span>
);
<span style="color: #008800; font-weight: bold">INSERT</span> <span style="color: #008800; font-weight: bold">INTO</span> <span style="color: #008800; font-weight: bold">result</span>(
status
,<span style="color: #008800; font-weight: bold">count</span>
) <span style="color: #008800; font-weight: bold">VALUES</span> (
<span style="background-color: #fff0f0">'SKIPPED'</span> <span style="color: #888888">-- status - IN varchar(20)</span>
,<span style="color: #0000DD; font-weight: bold">10</span> <span style="color: #888888">-- count - IN int(11)</span>
)
</pre></div><br />
</div>Anonymoushttp://www.blogger.com/profile/02258593205933843635noreply@blogger.com1tag:blogger.com,1999:blog-2372689584609551068.post-13153351064372045682015-03-03T08:34:00.000+05:302015-04-22T00:17:24.090+05:30Generate PDF report for selenium/testng test cases.<div dir="ltr" style="text-align: left;" trbidi="on">Use Open source pdfngreport plugin to generate the pdf report for the selenium/testng test cases execution.<br />
<br />
It's Opensource and in maven repository<br />
<br />
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #007700"><dependency></span>
<span style="color: #007700"><groupId></span>com.uttesh<span style="color: #007700"></groupId></span>
<span style="color: #007700"><artifactId></span>pdfngreport<span style="color: #007700"></artifactId></span>
<span style="color: #007700"><version></span>2.0.3<span style="color: #007700"></version></span>
<span style="color: #007700"></dependency></span>
</pre></div><br />
Official WebPage <a href="http://uttesh.github.io/pdfngreport/" target="_blank">http://uttesh.github.io/pdfngreport/</a><br />
<br />
Pdf report will have chart shows how many test cases passed/failed/skipped.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjG4RILWo-MORYtrG6KnnGtkhDs4MHPleOevvfzU43JqfW1ge27diU7_jcyB9hmoaEgEEvnzc79tPnvYCpTV-bNN-NMHG9s1IE3M3tTyEXWDjMh3v9dxKItX5cwKaLsRNzyHhl3AbunSFvx/s1600/slide2.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjG4RILWo-MORYtrG6KnnGtkhDs4MHPleOevvfzU43JqfW1ge27diU7_jcyB9hmoaEgEEvnzc79tPnvYCpTV-bNN-NMHG9s1IE3M3tTyEXWDjMh3v9dxKItX5cwKaLsRNzyHhl3AbunSFvx/s320/slide2.png" /></a><br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1RPIWOFxuiieNsxpFtAz1VugIfVcl1P-kSIp-a-IHeWP6y8EwbX8272yECQBXRKIAnY2lSTnBBvcOJtnjaKMTyz3hsfSkywdCa-ohQZWw_OHYjKRlwRhlGDOqzBgF-VQdTQLOExbFab_U/s1600/report_2.0.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1RPIWOFxuiieNsxpFtAz1VugIfVcl1P-kSIp-a-IHeWP6y8EwbX8272yECQBXRKIAnY2lSTnBBvcOJtnjaKMTyz3hsfSkywdCa-ohQZWw_OHYjKRlwRhlGDOqzBgF-VQdTQLOExbFab_U/s320/report_2.0.png" /></a><br />
<br />
Status table which shows full detail status of each test cases.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZpykLXbvb2NCx-fBtTKLU6nwughUn0sTAJNOsyOmXI0qlgHEO5mN3CnM5nQZSNbKlHuG4sL8luVbdWJr2OIRojDIVYkkjf1Ye3Qyk9-cUcwraLgAAfFAK5J2Wc-YU6I_d1JB4xqYLsPya/s1600/slide3.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZpykLXbvb2NCx-fBtTKLU6nwughUn0sTAJNOsyOmXI0qlgHEO5mN3CnM5nQZSNbKlHuG4sL8luVbdWJr2OIRojDIVYkkjf1Ye3Qyk9-cUcwraLgAAfFAK5J2Wc-YU6I_d1JB4xqYLsPya/s320/slide3.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOjb3wiKRMfeZnYsbAEPQ0ZnhOd98QsRX8fEQbWap8UNRGNas2l7V9MJVNpvPjqG_Pp1L9dNEenW-y8L_FLxSpg6yz2Bc-K4VM_exRqcJuQZT1Gtkp6ebaWbGgqiMbF9DT5feoBrRQHpFZ/s1600/slide4.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOjb3wiKRMfeZnYsbAEPQ0ZnhOd98QsRX8fEQbWap8UNRGNas2l7V9MJVNpvPjqG_Pp1L9dNEenW-y8L_FLxSpg6yz2Bc-K4VM_exRqcJuQZT1Gtkp6ebaWbGgqiMbF9DT5feoBrRQHpFZ/s320/slide4.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSy6abyq6dg_bazrUs_B4TaMaoVrKOxcCgFQ91uWN8JtxFLebKJvs3cJfASebUnTT523eOgqyVBVqaVlpUn_vDpj_e6fGsXUma8_RJLetGakVlGlClHTaz-yP0buST92O6Tmnj08X3ks1h/s1600/slide5.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSy6abyq6dg_bazrUs_B4TaMaoVrKOxcCgFQ91uWN8JtxFLebKJvs3cJfASebUnTT523eOgqyVBVqaVlpUn_vDpj_e6fGsXUma8_RJLetGakVlGlClHTaz-yP0buST92O6Tmnj08X3ks1h/s320/slide5.png" /></a><br />
<br />
Exception summary of failed test cases.<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj23chHKwGZtAv-_H4mCzz4RgKjL7nhW7UJR1-aWsGVvS_J6mNA8wwZe1IfWNo2c0lSEBxGoAE_gBQzwPTRED_qgn10Tl24hHA1Z059hWMm9MZ51180EhPD9in9v0khL61_7AaG0yEv1uw1/s1600/pdfngreport_5.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj23chHKwGZtAv-_H4mCzz4RgKjL7nhW7UJR1-aWsGVvS_J6mNA8wwZe1IfWNo2c0lSEBxGoAE_gBQzwPTRED_qgn10Tl24hHA1Z059hWMm9MZ51180EhPD9in9v0khL61_7AaG0yEv1uw1/s320/pdfngreport_5.png" /></a><br />
</div>Anonymoushttp://www.blogger.com/profile/02258593205933843635noreply@blogger.com0