tag:blogger.com,1999:blog-46300291988090275812024-03-19T10:28:24.833+03:00Lost in Time!!!This weblog only liked a combination of technical articles and writings have been using to keep. Many of the articles published in this blog do not belong to me, articles resources, am showing you care to publish the latter part of the articles.Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.comBlogger216125tag:blogger.com,1999:blog-4630029198809027581.post-62458701471145375762013-10-30T14:46:00.002+02:002013-10-30T14:46:32.815+02:00Open Platform Trust Services (OpenPTS)<span style="font-family: 'MS PGothic';">Open Platform Trust Services is a proof-of-concept (PoC) and reference implementation of Platform Trust Services (PTS) which is defined by the Trusted Computing Group, </span><a href="https://www.trustedcomputinggroup.org/home" style="font-family: 'MS PGothic';">https://www.trustedcomputinggroup.org/home</a><span style="font-family: 'MS PGothic';">. The infrastructure working group in the TCG is defining an Integrity Management Infrastructure in which the Platform Trust Services (PTS) is a key new components which deals with the integrity information of a trusted platform. OpenPTS is a reference implementation of the PTS, and works with other trusted computing opensource components, BIOS, GRUB-IMA, Linux-IMA, TrouSerS.</span><br />
<span style="font-family: 'MS PGothic';"><br /></span>
<br />
<table class="tcg" style="font-family: 'MS PGothic';"><tbody>
<tr><th colspan="2"><href http:="" trusted_computing="" www.trustedcomputinggroup.org=""></href></th></tr>
<tr><td style="background-color: lightblue; font-family: sans-serif; font-weight: 700; padding: 0px;"><h3>
Applications<table align="RIGHT" class="tcg2"><tbody>
<tr><th>spec</th><th>info</th></tr>
<tr><td style="background-color: white; border: 0px; font-weight: 700; padding: 5px;"><a href="http://www.trustedcomputinggroup.org/resources/infrastructure_work_group_platform_trust_services_interface_specification_version_10" target="_top">PTS</a></td><td style="background-color: white; border: 0px; font-weight: 700; padding: 5px;"><a href="http://openpts.sourceforge.jp/" target="_top">OpenPTS</a></td></tr>
<tr><td style="border: 0px; font-weight: 700; padding: 5px;"></td><td style="background-color: white; border: 0px; font-weight: 700; padding: 5px;"><a href="http://sourceforge.net/projects/trousers/files/tpm-tools/tpm-tools-1.3.2.tar.gz/download" target="_top">tpm-tools</a></td></tr>
</tbody></table>
</h3>
<h2>
</h2>
</td></tr>
<tr><td style="background-color: lightblue; font-family: sans-serif; font-weight: 700; padding: 0px;"><h3>
Libraries<table align="RIGHT" class="tcg2"><tbody>
<tr><th>spec</th><th>info</th></tr>
<tr><td style="background-color: white; border: 0px; font-weight: 700; padding: 5px;"><a href="http://www.trustedcomputinggroup.org/developers/software_stack" target="_top">TSS</a></td><td style="background-color: white; border: 0px; font-weight: 700; padding: 5px;"><a href="http://trousers.sourceforge.net/" target="_top">TrouSerS</a></td></tr>
</tbody></table>
</h3>
</td></tr>
<tr><td style="background-color: lightblue; font-family: sans-serif; font-weight: 700; padding: 0px;"><h3>
Linux Kernel<table align="RIGHT" class="tcg2"><tbody>
<tr><th>spec</th><th>info</th></tr>
<tr><td style="border: 0px; font-weight: 700; padding: 5px;"></td><td style="background-color: white; border: 0px; font-weight: 700; padding: 5px;"><a href="http://linux-ima.sourceforge.net/#Integrity Measurement Architecture" target="_top">IMA</a>, <a href="http://linux-ima.sourceforge.net/#Linux Extended Verification Module" target="_top">EVM</a></td></tr>
<tr><td style="background-color: white; border: 0px; font-weight: 700; padding: 5px;"><a href="http://www.trustedcomputinggroup.org/files/resource_files/87BCE22B-1D09-3519-ADEBA772FBF02CBD/TCG_PCClientTPMSpecification_1-20_1-00_FINAL.pdf" target="_top">tpm-1.2</a></td><td style="background-color: white; border: 0px; font-weight: 700; padding: 5px;"><a href="http://tpmdd.sourceforge.net/" target="_top">TPM driver</a></td></tr>
</tbody></table>
</h3>
</td></tr>
<tr><td style="background-color: lightblue; font-family: sans-serif; font-weight: 700; padding: 0px;"><h3>
Boot<table align="RIGHT" class="tcg2"><tbody>
<tr><th>spec</th><th>info</th></tr>
<tr><td style="background-color: white; border: 0px; font-weight: 700; padding: 5px;"><a href="http://www.trustedcomputinggroup.org/resources/pc_client_work_group_specific_implementation_specification_for_conventional_bios_specification_version_12" target="_top">BIOS</a></td><td style="background-color: white; border: 0px; font-weight: 700; padding: 5px;"><a href="http://sourceforge.jp/projects/openpts/wiki/GRUB-IMA" target="_top">GRUB-IMA</a>, <a href="http://sourceforge.net/projects/tboot" target="_top">TBOOT</a></td></tr>
</tbody></table>
</h3>
</td></tr>
<tr><td style="background-color: lightblue; font-family: sans-serif; font-weight: 700; padding: 0px;"><h3>
Hardware<table align="RIGHT" class="tcg2"><tbody>
<tr><th>spec</th></tr>
<tr><td style="background-color: white; border: 0px; font-weight: 700; padding: 5px;"><a href="http://www.trustedcomputinggroup.org/developers/trusted_platform_module" target="_top">TPM</a></td></tr>
</tbody></table>
</h3>
</td></tr>
</tbody></table>
Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com346tag:blogger.com,1999:blog-4630029198809027581.post-56346125710062059302013-04-16T10:32:00.001+03:002013-04-16T10:32:28.620+03:002 ways to convert Java Map to String<br />
import java.io.UnsupportedEncodingException;<br />
import java.net.URLDecoder;<br />
import java.net.URLEncoder;<br />
import java.util.HashMap;<br />
import java.util.Map;<br />
<br />
public class MapUtil {<br />
public static String mapToString(Map<String, String> map) {<br />
StringBuilder stringBuilder = new StringBuilder();<br />
<br />
for (String key : map.keySet()) {<br />
if (stringBuilder.length() > 0) {<br />
stringBuilder.append("&");<br />
}<br />
String value = map.get(key);<br />
try {<br />
stringBuilder.append((key != null ? URLEncoder.encode(key, "UTF-8") : ""));<br />
stringBuilder.append("=");<br />
stringBuilder.append(value != null ? URLEncoder.encode(value, "UTF-8") : "");<br />
} catch (UnsupportedEncodingException e) {<br />
throw new RuntimeException("This method requires UTF-8 encoding support", e);<br />
}<br />
}<br />
<br />
return stringBuilder.toString();<br />
}<br />
<br />
public static Map<String, String> stringToMap(String input) {<br />
Map<String, String> map = new HashMap<String, String>();<br />
<br />
String[] nameValuePairs = input.split("&");<br />
for (String nameValuePair : nameValuePairs) {<br />
String[] nameValue = nameValuePair.split("=");<br />
try {<br />
map.put(URLDecoder.decode(nameValue[0], "UTF-8"), nameValue.length > 1 ? URLDecoder.decode(<br />
nameValue[1], "UTF-8") : "");<br />
} catch (UnsupportedEncodingException e) {<br />
throw new RuntimeException("This method requires UTF-8 encoding support", e);<br />
}<br />
}<br />
<br />
return map;<br />
}<br />
}<br />
<div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-21094246999887197482013-03-14T20:04:00.002+02:002013-03-14T20:04:11.057+02:00Setting up an android Device for Development<br />
<br />
<br />
INSTALL<br />
<br />
1、Create the file "51-android.rules" with text editor on ubuntu,like vi ,vim ,or gedit.<br />
<br />
2、Add lines below to file<br />
---------------------------------------- BEGIN ---------------------------------------------------------------<br />
<br />
<br class="Apple-interchange-newline" />#Acer<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0660", OWNER="zana"<br />
<br />
<br />
#ASUS<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="0b05", MODE="0660", OWNER="zana"<br />
<br />
<br />
#Dell<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="413c", MODE="0660", OWNER="zana"<br />
<br />
<br />
#Foxconn<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0660", OWNER="zana"<br />
<br />
<br />
#Fujitsu/Fujitsu Toshiba<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="04c5", MODE="0660", OWNER="zana"<br />
<br />
<br />
#Garmin-Asus<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="091e", MODE="0660", OWNER="zana"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
#Google<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", MODE="0660", OWNER="zana"<br />
<br />
<br />
#Hisense<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="109b", MODE="0660", OWNER="zana"<br />
<br />
#HTC<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0660", OWNER="zana"<br />
<br />
#Huawei<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0660", OWNER="zana"<br />
<br />
<br />
#K-Touch<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="24e3", MODE="0660", OWNER="zana"<br />
<br />
<br />
#KT Tech<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="2116", MODE="0660", OWNER="zana"<br />
<br />
<br />
#Kyocera<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="0482", MODE="0660", OWNER="zana"<br />
<br />
<br />
#Lenovo<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="2006", MODE="0660", OWNER="zana"<br />
<br />
<br />
#LG<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0660", OWNER="zana"<br />
<br />
<br />
#Motorola<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0660", OWNER="zana"<br />
<br />
<br />
#NEC<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="0409", MODE="0660", OWNER="zana"<br />
<br />
<br />
#Nook<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="2080", MODE="0660", OWNER="zana"<br />
<br />
<br />
#Nvidia<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="0955", MODE="0660", OWNER="zana"<br />
<br />
<br />
#OTGV<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="2257", MODE="0660", OWNER="zana"<br />
<br />
<br />
#Pantech<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="10a9", MODE="0660", OWNER="zana"<br />
<br />
<br />
#Pegatron<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="1d4d", MODE="0660", OWNER="zana"<br />
<br />
<br />
#Philips<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="0471", MODE="0660", OWNER="zana"<br />
<br />
<br />
#PMC-Sierra<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="04da", MODE="0660", OWNER="zana"<br />
<br />
<br />
#Qualcomm<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="05c6", MODE="0660", OWNER="zana"<br />
<br />
<br />
#SK Telesys<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="1f53", MODE="0660", OWNER="zana"<br />
<br />
<br />
#Samsung<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0660", OWNER="zana"<br />
<br />
<br />
#Sharp<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="04dd", MODE="0660", OWNER="zana"<br />
<br />
<br />
#Sony<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="054c", MODE="0660", OWNER="zana"<br />
<br />
<br />
#Sony Ericsson<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", MODE="0660", OWNER="zana"<br />
<br />
<br />
#Teleepoch<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="2340", MODE="0660", OWNER="zana"<br />
<br />
<br />
#Toshiba<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="0930", MODE="0660", OWNER="zana"<br />
<br />
<br />
#ZTE<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="19d2", MODE="0660", OWNER="zana"<br />
<br />
<br />
---------------------------------------- END--------------------------------------------------------------------<br />
<br />
2、Replace the name of the OWNER(eg.zana) with your username,which is used for logging into the Ubuntu System.Then,save it.<br />
<br />
3、Copy the file "51-android.rules" to "/etc/udev/rules.d/51-android.rules".To Achieve it,You should be sure that you have the root permission.<br />
<br />
4、Now open the console,and execute:<br />
sudo chmod a+r /etc/udev/rules.d/51-android.rules<br />
<br />
5、Then execute:<br />
sudo service udev restart<br />
<br />
6、When plugged in over USB, can verify that your device is connected by executing adb devices from your SDK platform-tools/ directory. If connected, you'll see the device name listed as a "device."<br />
<div>
<br /></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-73708566460096621532013-03-13T21:08:00.000+02:002013-03-13T21:08:19.744+02:00Object Orientated Programming<br />
<div style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px; margin-left: 10px; margin-right: 10px; text-align: center;">
OO programming suggests that you use the following principles during the design of a software. The following are not "Design Principles" but a repetition of a good OO design.</div>
<div class="section" style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div class="titlepage">
<h3 class="title" style="color: #333333; font-size: 20px; margin: 0px; padding: 0px 0px 10px; text-align: center;">
<a href="" name="chapter20s1s2a" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif;"></a> Encapsulation</h3>
</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
In general a general manipulation of an object's variables by other objects or classes is discouraged to ensure data encapsulation. A class should provide methods through which other objects could access variables. Java deletes objects which are not longer used (garbage collection).</div>
</div>
<div class="section" style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div class="titlepage">
<h3 class="title" style="color: #333333; font-size: 20px; margin: 0px; padding: 0px 0px 10px; text-align: center;">
<a href="" name="chapter20s1as2b" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif;"></a> Abstraction</h3>
</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
Java support the abstraction of data definition and concrete usage of this definition.</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
The concept is divided from the concrete which means you first define a class containing the variables and the behavior (methods) and afterwards you create the real objects which then all behave like the class defined it.</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
A class is the definition of the behavior and data. A class can not be directly be used.</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
A object in an instance of this class and is the real object which can be worked with.</div>
</div>
<div class="section" style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div class="titlepage">
<h3 class="title" style="color: #333333; font-size: 20px; margin: 0px; padding: 0px 0px 10px; text-align: center;">
<a href="" name="chapter20s1as2c" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif;"></a> Polymorphisms</h3>
</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
The ability of object variables to contain objects of different classes. If class X1 is a subclass of class X then a method which is defined with a parameter for an object X can also get called which an object X1.</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
If you define a supertype for a group of classes any subclass of that supertype can be substituted where the supertype is expected.</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
If you use an interface as a polymorphic type any object which implements this interface can be used as arguments.</div>
</div>
<div class="section" style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div class="titlepage">
<h3 class="title" style="color: #333333; font-size: 20px; margin: 0px; padding: 0px 0px 10px; text-align: center;">
<a href="" name="chapter20s1as2d" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif;"></a> Inheritance</h3>
</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
Inheritance allows that classes can be based on each other. If a class A inherits another class B this is called "class A extends class B".</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
For example you can define a base class which provides certain logging functionality and this class is extended by another class which adds email notification to the functionality.</div>
</div>
<div class="section" style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div class="titlepage">
<h3 class="title" style="color: #333333; font-size: 20px; margin: 0px; padding: 0px 0px 10px; text-align: center;">
<a href="" name="120_ooprincipless1s2a" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif;"></a> Delegation</h3>
</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
Delegation is then you hand over the responsibility for a particular task to anther class or method.</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
If you need to use functionality in another class but you do not want to change that functionality then use delegation instead of inheritance.</div>
</div>
<div class="section" style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div class="titlepage">
<h3 class="title" style="color: #333333; font-size: 20px; margin: 0px; padding: 0px 0px 10px; text-align: center;">
<a href="" name="120_ooprincipless1s2b" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif;"></a> Composition</h3>
</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
When you refer to a whole family of behavior then you use composition. Here you program against an interface and then any class which implements this interface can be used to be defined. In composition the composition class is still defined in the calling class.</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
When you use composition, the composing object owns the behaviors is uses and they stop existing as soon as the composing object does.</div>
</div>
<div class="section" style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div class="titlepage">
<h3 class="title" style="color: #333333; font-size: 20px; margin: 0px; padding: 0px 0px 10px; text-align: center;">
<a href="" name="120_ooprincipless1s2c" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif;"></a> Aggregation</h3>
</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
Aggregation allows you to use behavior from another class without limiting the lifetime of those behaviors.</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
Aggregation is when one class is used as part of another class but still exists outside of that class.</div>
</div>
<div class="section" style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div class="titlepage">
<h3 class="title" style="color: #333333; font-size: 20px; margin: 0px; padding: 0px 0px 10px; text-align: center;">
<a href="" name="120_ooprincipless1s2d" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif;"></a> Design by contract</h3>
</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
Programming by contract assumes both sides in a transaction understand what actions generate what behavior and will abide by that contact.</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
Methods usually return null or unchecked exceptions when errors occurs in programming by contract environment.</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
If you believe that a method should not get called in a certain way just throw an unchecked runtime exception. This can be really powerful. Instead of checking in your calling code for exceptions you just throw an exception in the called code. Therefore you can easier identify the place in the coding their an error occurs. This follows the "crash-early" principle, which tells that if an error occurs in your software you should crash immediately and not later in the program because then it is hard to find the error.</div>
</div>
<div class="section" style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div class="titlepage">
<h3 class="title" style="color: #333333; font-size: 20px; margin: 0px; padding: 0px 0px 10px; text-align: center;">
<a href="" name="120_ooprincipless1s2e" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif;"></a> Cohesion</h3>
</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
A system should have a high cohesion.</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
Cohesion is a measure of how strongly-related and focused the responsibilities of a single class are. In object-oriented programming, it is beneficial to assign responsibilities to classes in a way that keeps cohesion high.</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
Code readability and the likelihood of reuse is increased, while complexity is kept manageable, in a highly-cohesive system.</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
Therefore you should avoid classes which have several responsibilities, e.g. a Logger class should only be responsible for logging.</div>
</div>
<div class="section" style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div class="titlepage">
<h3 class="title" style="color: #333333; font-size: 20px; margin: 0px; padding: 0px 0px 10px; text-align: center;">
<a href="" name="120_ooprincipless1s2f" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif;"></a> The Principle of Least Knowledge</h3>
</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
<span class="emphasis"><em>Talk only to your immediate friends.</em></span></div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
Also known as Law of Demeter.</div>
</div>
<div class="section" style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<div class="titlepage">
<h3 class="title" style="color: #333333; font-size: 20px; margin: 0px; padding: 0px 0px 10px; text-align: center;">
<a href="" name="120_ooprincipless1s2g" style="color: #101010; font-family: Lato, arial, helvetica, sans-serif;"></a> The Open Closed Principle</h3>
</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
<span class="emphasis"><em>Software entities like classes, modules and functions should be open for extension but closed for modifications.</em></span></div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
This principles encourages developers to write code that can be easily extended with only minimal or no changes to existing code.</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
An example for a good application of this principles would be that a certain class calls internally an abstract class to conducted a certain behavior. At runtime this class is provided with an concrete implementation of this abstract class. This allows the developer later to implement another concrete calls of this abstract class without changing the code of the class which uses this abstract class.</div>
<div style="margin-left: 10px; margin-right: 10px; text-align: center;">
Another excellent example is the Eclipse Extension Point method. Eclipse Plugins or Eclipse based application can define extension points where other plugs-ins can later add functionality.</div>
</div>
Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com19tag:blogger.com,1999:blog-4630029198809027581.post-10869238087388458182013-03-13T12:29:00.000+02:002013-03-13T12:29:08.151+02:00Design Patterns in Java - Singleton<br />
<div style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px; margin-left: 10px; margin-right: 10px;">
A singleton in Java is a class for which only one instance can be created provides a global point of access this instance. The singleton pattern describe how this can be archived.</div>
<div style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px; margin-left: 10px; margin-right: 10px;">
Singletons are useful to provide a unique source of data or functionality to other Java Objects. For example you may use a singleton to access your data model from within your application or to define logger which the rest of the application can use.</div>
<div style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px; margin-left: 10px; margin-right: 10px;">
<br /></div>
<div style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px; margin-left: 10px; margin-right: 10px;">
</div>
<div class="section">
<div style="margin-left: 10px; margin-right: 10px;">
The possible implementation of Java depends on the version of Java you are using.</div>
<div style="margin-left: 10px; margin-right: 10px;">
As of Java 6 you can singletons with a single-element enum type. This way is currently the best way to implement a singleton in Java 1.6 or later according to that book ""Effective Java from Joshua Bloch.</div>
<div style="margin-left: 10px; margin-right: 10px;">
</div>
<pre class="programlisting" style="background-color: #ffffee; border-bottom-left-radius: 9px; border-bottom-right-radius: 9px; border-top-left-radius: 9px; border-top-right-radius: 9px; border: 1px solid rgb(187, 187, 187); font-family: 'Droid Sans Mono', Monaco, 'Bitstream Vera Sans Mono', 'Lucida Console', Terminal, monospace; font-size: 13px; line-height: 16px; margin: 10px; overflow: auto; padding: 1em; word-wrap: break-word;"><span class="hl-keyword" style="color: #7f0055; font-weight: bold;">package</span> mypackage;
<span class="hl-keyword" style="color: #7f0055; font-weight: bold;">public</span> enum MyEnumSingleton {
INSTANCE;
<em class="hl-comment" style="color: #008800;">// other useful methods here</em>
} </pre>
<div style="margin-left: 10px; margin-right: 10px;">
</div>
<div style="margin-left: 10px; margin-right: 10px;">
Before Java 1.6 a class which should be a singleton can be defined like the following.</div>
<div style="margin-left: 10px; margin-right: 10px;">
</div>
<pre class="programlisting" style="background-color: #ffffee; border-bottom-left-radius: 9px; border-bottom-right-radius: 9px; border-top-left-radius: 9px; border-top-right-radius: 9px; border: 1px solid rgb(187, 187, 187); font-family: 'Droid Sans Mono', Monaco, 'Bitstream Vera Sans Mono', 'Lucida Console', Terminal, monospace; font-size: 13px; line-height: 16px; margin: 10px; overflow: auto; padding: 1em; word-wrap: break-word;"><span class="hl-keyword" style="color: #7f0055; font-weight: bold;">public</span> <span class="hl-keyword" style="color: #7f0055; font-weight: bold;">class</span> Singleton {
<span class="hl-keyword" style="color: #7f0055; font-weight: bold;">private</span> <span class="hl-keyword" style="color: #7f0055; font-weight: bold;">static</span> Singleton uniqInstance;
<span class="hl-keyword" style="color: #7f0055; font-weight: bold;">private</span> Singleton() {
}
<span class="hl-keyword" style="color: #7f0055; font-weight: bold;">public</span> <span class="hl-keyword" style="color: #7f0055; font-weight: bold;">static</span> <span class="hl-keyword" style="color: #7f0055; font-weight: bold;">synchronized</span> Singleton getInstance() {
<span class="hl-keyword" style="color: #7f0055; font-weight: bold;">if</span> (uniqInstance == null) {
uniqInstance = <span class="hl-keyword" style="color: #7f0055; font-weight: bold;">new</span> Singleton();
}
<span class="hl-keyword" style="color: #7f0055; font-weight: bold;">return</span> uniqInstance;
}
<em class="hl-comment" style="color: #008800;">// other useful methods here</em>
} </pre>
</div>
<div class="section">
<div style="margin-left: 10px; margin-right: 10px;">
A static class with static method would result in the same functionality as a singleton. As singletons are define using an object orientated approach it is in general advised to work with singletons.</div>
<div style="margin-left: 10px; margin-right: 10px;">
Singleton violate the "One Class, one responsibility" principle as they are used to manage its one instance and the functionality of the class.</div>
<div style="margin-left: 10px; margin-right: 10px;">
A singleton cannot be subclassed as the constructor is declared private.</div>
<div style="margin-left: 10px; margin-right: 10px;">
If you are using multiple classloaders then several instances of the singleton can get created.</div>
</div>
<br />
Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-8413750643640139692013-03-13T12:27:00.001+02:002013-03-13T12:27:25.591+02:00Design Patterns in Java<br />
<div style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px; margin-left: 10px; margin-right: 10px;">
The terminology of "Design Pattern" in software developed is based on the GOF (Gang of Four) book "Design Patterns - Elements of Reusable Object-Oriented Software" from Erich Gamma, Richard Helm, Ralph Johnson und John Vlissides. Design Pattern are proven solutions approaches to specific problems. A design pattern is not framework and is not directly deployed via code.</div>
<div style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px; margin-left: 10px; margin-right: 10px;">
Design Pattern have two main usages:</div>
<div class="itemizedlist" style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<ul class="itemizedlist" type="disc">
<li class="listitem"><div style="margin-left: 10px; margin-right: 10px;">
Common language for developers: They provide developer a common language for certain problems. For example if a developer tells another developer that he is using a Singleton, the another developer (should) know exactly what this means.</div>
</li>
<li class="listitem"><div style="margin-left: 10px; margin-right: 10px;">
Capture best practices: Design patterns capture solutions which have been applied to certain problems. By learning these patterns and the problem they are trying to solve a unexperienced developer can learn a lot about software design.</div>
</li>
</ul>
</div>
<div style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px; margin-left: 10px; margin-right: 10px;">
</div>
<div style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px; margin-left: 10px; margin-right: 10px;">
Design pattern are based on the base principles of object orientated design.</div>
<div class="itemizedlist" style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<ul class="itemizedlist" type="disc">
<li class="listitem"><div style="margin-left: 10px; margin-right: 10px;">
Program to an interface not an implementation</div>
</li>
<li class="listitem"><div style="margin-left: 10px; margin-right: 10px;">
Favor object composition over inheritance</div>
</li>
</ul>
</div>
<div style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px; margin-left: 10px; margin-right: 10px;">
</div>
<div style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px; margin-left: 10px; margin-right: 10px;">
Design Patterns can be divided into:</div>
<div class="itemizedlist" style="background-color: white; font-family: Lato, arial, sans-serif; font-size: 16px; line-height: 24px;">
<ul class="itemizedlist" type="disc">
<li class="listitem"><div style="margin-left: 10px; margin-right: 10px;">
Creational Patterns</div>
</li>
<li class="listitem"><div style="margin-left: 10px; margin-right: 10px;">
Structural Patterns</div>
</li>
<li class="listitem"><div style="margin-left: 10px; margin-right: 10px;">
Behavioral Patterns</div>
</li>
</ul>
</div>
Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-27719481569563636472012-11-27T20:03:00.001+02:002012-11-27T20:03:37.012+02:00Ubuntu 12.04 – install sun jdk 6-7<br />
<div style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 19px; margin-bottom: 1.2em; padding: 0px;">
Ubuntu GNU/Linux 12.04 LTS (Precise Pangolin) released. I wanted to manually install the Sun JDK 6 and 7 on Ubuntu.</div>
<div style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 19px; margin-bottom: 1.2em; padding: 0px;">
<strong style="margin: 0px; padding: 0px;">Installing Sun JDK 6 on Ubuntu 12.04:</strong></div>
<ul style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 18px; margin: 1em 0px 1.4em 24px; padding: 0px;">
<li style="margin: 0px 0px 0.5em; padding: 0px;">Download the sun jdk 6 bin <a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u32-downloads-1594644.html" style="color: #026acb; margin: 0px; outline: none; padding: 0px; text-decoration: initial;" target="_blank" title="jdk 1.6.0_32">from here</a>.</li>
</ul>
<ul style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 18px; margin: 1em 0px 1.4em 24px; padding: 0px;">
<li style="margin: 0px 0px 0.5em; padding: 0px;">Make the bin file executeable:</li>
</ul>
<pre class="bash" style="background-color: white; color: #666666; line-height: 19px; padding: 0px;" title="code">chmod +x jdk-6u32-linux-x64.bin</pre>
<ul style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 18px; margin: 1em 0px 1.4em 24px; padding: 0px;">
<li style="margin: 0px 0px 0.5em; padding: 0px;">Extract the bin file:</li>
</ul>
<pre class="bash" style="background-color: white; color: #666666; line-height: 19px; padding: 0px;" title="code">./jdk-6u32-linux-x64.bin</pre>
<ul style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 18px; margin: 1em 0px 1.4em 24px; padding: 0px;">
<li style="margin: 0px 0px 0.5em; padding: 0px;">Move extracted folder to this location:</li>
</ul>
<pre class="bash" style="background-color: white; color: #666666; line-height: 19px; padding: 0px;" title="code">sudo mv jdk1.6.0_32 /usr/lib/jvm/</pre>
<ul style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 18px; margin: 1em 0px 1.4em 24px; padding: 0px;">
<li style="margin: 0px 0px 0.5em; padding: 0px;">Install new java source in system:</li>
</ul>
<pre class="bash" style="background-color: white; color: #666666; line-height: 19px; padding: 0px;" title="code">sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_32/bin/javac 1
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_32/bin/java 1
sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_32/bin/javaws 1</pre>
<ul style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 18px; margin: 1em 0px 1.4em 24px; padding: 0px;">
<li style="margin: 0px 0px 0.5em; padding: 0px;">Choose default java:</li>
</ul>
<pre class="bash" style="background-color: white; color: #666666; line-height: 19px; padding: 0px;" title="code">sudo update-alternatives --config javac
sudo update-alternatives --config java
sudo update-alternatives --config javaws</pre>
<ul style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 18px; margin: 1em 0px 1.4em 24px; padding: 0px;">
<li style="margin: 0px 0px 0.5em; padding: 0px;">java version test:</li>
</ul>
<pre class="bash" style="background-color: white; color: #666666; line-height: 19px; padding: 0px;" title="code">java -version</pre>
<ul style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 18px; margin: 1em 0px 1.4em 24px; padding: 0px;">
<li style="margin: 0px 0px 0.5em; padding: 0px;">Verify the symlinks all point to the new java location:</li>
</ul>
<pre class="bash" style="background-color: white; color: #666666; line-height: 19px; padding: 0px;" title="code">ls -la /etc/alternatives/java*</pre>
<ul style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 18px; margin: 1em 0px 1.4em 24px; padding: 0px;">
<li style="margin: 0px 0px 0.5em; padding: 0px;">Enable Java plugin for Mozilla Firefox (even for Chrome)</li>
</ul>
<pre style="background-color: white; color: #666666; line-height: 19px; padding: 0px;" title="code">#for 64-Bit jdk
sudo ln -s /usr/lib/jvm/jdk1.6.0_32/jre/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins
#for 32-Bit jdk
sudo ln -s /usr/lib/jvm/jdk1.6.0_32/jre/lib/i386/libnpjp2.so /usr/lib/mozilla/plugins</pre>
<div style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 19px; margin-bottom: 1.2em; padding: 0px;">
</div>
<div style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 19px; margin-bottom: 1.2em; padding: 0px;">
<strong style="margin: 0px; padding: 0px;">Installing Sun JDK 7 on Ubuntu 12.04:</strong></div>
<ul style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 18px; margin: 1em 0px 1.4em 24px; padding: 0px;">
<li style="margin: 0px 0px 0.5em; padding: 0px;">Download the sun jdk 7 tar file <a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u4-downloads-1591156.html" style="color: #026acb; margin: 0px; outline: none; padding: 0px; text-decoration: initial;" target="_blank" title="sun jdk 1.7.0_4">from here</a></li>
<li style="margin: 0px 0px 0.5em; padding: 0px;">Extract the tar file:</li>
</ul>
<pre style="background-color: white; color: #666666; line-height: 19px; padding: 0px;" title="code">tar -xvzf jdk-7u4-linux-x64.tar.gz</pre>
<ul style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 18px; margin: 1em 0px 1.4em 24px; padding: 0px;">
<li style="margin: 0px 0px 0.5em; padding: 0px;">Move extracted folder to this location:</li>
</ul>
<pre style="background-color: white; color: #666666; line-height: 19px; padding: 0px;" title="code">sudo mv jdk1.7.0_04 /usr/lib/jvm/</pre>
<ul style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 18px; margin: 1em 0px 1.4em 24px; padding: 0px;">
<li style="margin: 0px 0px 0.5em; padding: 0px;">Install new java source in system:</li>
</ul>
<pre style="background-color: white; color: #666666; line-height: 19px; padding: 0px;" title="code">sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_04/bin/javac 1
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_04/bin/java 1
sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.7.0_04/bin/javaws 1</pre>
<ul style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 18px; margin: 1em 0px 1.4em 24px; padding: 0px;">
<li style="margin: 0px 0px 0.5em; padding: 0px;">Choose default java:</li>
</ul>
<pre style="background-color: white; color: #666666; line-height: 19px; padding: 0px;" title="code">sudo update-alternatives --config javac
sudo update-alternatives --config java
sudo update-alternatives --config javaws</pre>
<ul style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 18px; margin: 1em 0px 1.4em 24px; padding: 0px;">
<li style="margin: 0px 0px 0.5em; padding: 0px;">java version test:</li>
</ul>
<pre style="background-color: white; color: #666666; line-height: 19px; padding: 0px;" title="code">java -version</pre>
<ul style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 18px; margin: 1em 0px 1.4em 24px; padding: 0px;">
<li style="margin: 0px 0px 0.5em; padding: 0px;">Verify the symlinks all point to the new java location:</li>
</ul>
<pre class="bash" style="background-color: white; color: #666666; line-height: 19px; padding: 0px;" title="code">ls -la /etc/alternatives/java*</pre>
<ul style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 18px; margin: 1em 0px 1.4em 24px; padding: 0px;">
<li style="margin: 0px 0px 0.5em; padding: 0px;">Enable Java plugin for Mozilla Firefox (even for Chrome)</li>
</ul>
<pre style="background-color: white; color: #666666; line-height: 19px; padding: 0px;" title="code">#for 64-Bit jdk
sudo ln -s /usr/lib/jvm/jdk1.7.0_04/jre/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins
#for 32-Bit jdk
sudo ln -s /usr/lib/jvm/jdk1.7.0_04/jre/lib/i386/libnpjp2.so /usr/lib/mozilla/plugins</pre>
<div style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 19px; margin-bottom: 1.2em; padding: 0px;">
</div>
<div style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 19px; margin-bottom: 1.2em; padding: 0px;">
<strong style="margin: 0px; padding: 0px;">Update: </strong>I have added Java Web Start configuration (Thanks Jack).</div>
<div style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 19px; margin-bottom: 1.2em; padding: 0px;">
<strong style="margin: 0px; padding: 0px;">Update: </strong>I have added Java Plugin configuration for Mozilla Firefox even for Chrome (Thanks <cite style="margin: 0px; padding: 0px;">shetty</cite>).</div>
<div style="background-color: white; color: #666666; font-family: 'Lucida Grande', Arial, 'Lucida Sans Unicode', sans-serif; font-size: 13px; line-height: 19px; margin-bottom: 1.2em; padding: 0px;">
<strong style="margin: 0px; padding: 0px;">Update: </strong>JAVA_HOME configuration: Some tools require JAVA_HOME variable. You can set JAVA_HOME in Ubuntu so simple: Edit the file <strong style="margin: 0px; padding: 0px;"><em style="margin: 0px; padding: 0px;">.bashrc</em></strong> under your home directory and add the following lines: (if .bashrc is hidden click in Nautilus Menu View > Show Hidden Files)</div>
<pre style="background-color: white; color: #666666; line-height: 19px; padding: 0px;" title="code">export JAVA_HOME=/path/your/jdk
export PATH=$JAVA_HOME/bin:$PATH</pre>
Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-49076717634140485112012-11-16T21:06:00.001+02:002012-11-16T21:06:24.455+02:00Upgrade subversion from 1.6 to 1.7 on ubuntu 12.04<br />
<div style="background-color: #e7e9eb; border: 0px; color: #434343; font-family: Arial, Verdana, sans-serif; font-size: 12px; line-height: 24px; outline: 0px; padding: 0px 0px 10px; text-align: left; vertical-align: baseline;">
execute the following commands:</div>
<div style="background-color: #e7e9eb; border: 0px; color: #434343; font-family: Arial, Verdana, sans-serif; font-size: 12px; line-height: 24px; outline: 0px; padding: 0px 0px 10px; text-align: left; vertical-align: baseline;">
<code style="background-color: transparent; border: 0px; font-family: 'Courier New', monospace; margin: 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;"><br />echo "deb http://opensource.wandisco.com/ubuntu lucid svn17" | sudo tee /etc/apt/sources.list.d/svn.list<br />sudo wget -q http://opensource.wandisco.com/wandisco-debian.gpg -O- | sudo apt-key add -<br />sudo apt-get update<br />sudo apt-get dist-upgrade</code></div>
Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-13477608317776657712012-10-16T18:16:00.001+03:002012-10-16T18:16:50.617+03:00grep --exclude/--include syntax (do not grep through certain files)<br />
<pre class="lang-sh prettyprint" style="background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; line-height: 18px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">grep </span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">-</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Ir</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">--</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">exclude</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="str" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;">"*\.svn*"</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="str" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;">"pattern"</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">*</span></code></pre>
Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-70528135031988113302012-10-12T21:37:00.001+03:002012-10-19T16:05:50.691+03:00Linux : search and replace string in a directory recursively<span style="background-color: white;">find /home/zana/folder -type f -exec sed -i 's/oldstring/newstring/g' {} \;</span><br />
<span style="background-color: white;"><br /></span>
<span style="background-color: white;"></span><br />
<pre class="alt2" style="background-color: #f4f4f4; border: 1px inset; font-size: 13px; height: 50px; overflow: auto; padding: 6px; width: 640px;"><span style="background-color: white;">find . -type f -print0 | xargs -0 sed -i 's/Application/whatever/g'</span></pre>
Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-328377522311835772012-09-27T20:19:00.000+03:002012-09-27T20:19:07.170+03:00find and replace a file by another file recursively in all subdirectoriesfind . -type f -name "image.png" -printf "%h\n" | xargs -i cp /home/zana/DEVELOPMENT/LIB/DIR/Images/image.png "{}"'/'Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-40073614111536354472012-08-09T17:36:00.003+03:002012-08-09T17:36:53.973+03:00How to remove MySQL completely with config and library files on ubuntu 12.04<br />
<span class="Apple-style-span" style="border-collapse: collapse; color: #333333; font-family: 'Ubuntu Beta', UbuntuBeta, Ubuntu, 'Bitstream Vera Sans', 'DejaVu Sans', Tahoma, sans-serif; font-size: 14px; line-height: 17px;"></span><br />
<pre style="background-color: #e0e0e0; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: 'Ubuntu Mono', 'Ubuntu Beta Mono A', Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 14px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; max-height: 600px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; vertical-align: baseline; width: auto;"><code style="background-color: #e0e0e0; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: 'Ubuntu Mono', 'Ubuntu Beta Mono A', Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">sudo apt-get remove mysql-server mysql-client mysql-common
sudo apt-get purge mysql-server mysql-client mysql-common
sudo apt-get autoremove</code></pre>
<pre style="background-color: #e0e0e0; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: 'Ubuntu Mono', 'Ubuntu Beta Mono A', Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 14px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; max-height: 600px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; vertical-align: baseline; width: auto;"><code style="background-color: #e0e0e0; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: 'Ubuntu Mono', 'Ubuntu Beta Mono A', Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"><span class="Apple-style-span" style="color: #333333; font-family: 'Ubuntu Beta', UbuntuBeta, Ubuntu, 'Bitstream Vera Sans', 'DejaVu Sans', Tahoma, sans-serif; white-space: normal;"><pre style="background-color: #e0e0e0; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: 'Ubuntu Mono', 'Ubuntu Beta Mono A', Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 14px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; max-height: 600px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; vertical-align: baseline; width: auto;"><code style="background-color: #e0e0e0; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: 'Ubuntu Mono', 'Ubuntu Beta Mono A', Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">shell>> locate mysql</code></pre>
</span></code></pre>Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-87652087263101928542012-06-13T22:19:00.000+03:002012-06-13T22:19:02.896+03:00The sky's the limit.<span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 20px;"></span><br />
<div class="Column-i1" style="padding-left: 15px; padding-top: 20px;">
<div style="margin-bottom: 4px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">
At Intel, we're unlocking the potential of the cloud. We envision a world where data and services are shared securely—confidently—from person to person across multiple clouds. Where shared resources and cloud infrastructure can be redeployed and reallocated on the fly. Where clouds are client aware, so people who access the cloud have a great experience no matter what device they're using. Intel<span class="super" style="font-size: 10px; vertical-align: 4px;">®</span>Architecture is ideal for the cloud, whether at the system, storage or network level.<br /><br />The sky really is the limit. Here's how we're making it happen.</div>
</div>
<div class="Column-i2" style="margin-left: 110px; margin-top: 80px;">
<div class="Column-i3" style="float: left; font-size: 16px; padding-left: 45px; padding-right: 45px; text-align: center;">
<a class="local" hidefocus="true" href="http://www.intelcloudbuilders.com/cloud-usage-models/#First" style="color: #333333; outline-color: initial; outline-style: none; outline-width: initial; text-decoration: none;">Trusted compute pools<br /> <img alt="" border="0" height="9" src="http://www.intelcloudbuilders.com/cloud-usage-models/images/blackDownArrow.png" width="18" /><br /><img alt="" border="0" height="156" src="http://www.intelcloudbuilders.com/cloud-usage-models/images/smallCircleStack.png" style="margin-top: 14px;" width="120" /></a></div>
<div class="Column-i4" style="background-attachment: scroll; background-clip: initial; background-color: transparent; background-image: url(http://www.intelcloudbuilders.com/cloud-usage-models/images/vertLine.png); background-origin: initial; background-position: 0px 70px; background-repeat: no-repeat no-repeat; float: left; font-size: 16px; padding-left: 45px; padding-right: 45px; text-align: center;">
<a class="local" hidefocus="true" href="http://www.intelcloudbuilders.com/cloud-usage-models/#Second" style="color: #333333; outline-color: initial; outline-style: none; outline-width: initial; text-decoration: none;">Unified networking<br /> <img alt="" border="0" height="9" src="http://www.intelcloudbuilders.com/cloud-usage-models/images/blackDownArrow.png" width="18" /><br /><img alt="" border="0" height="224" src="http://www.intelcloudbuilders.com/cloud-usage-models/images/smallSquareStack.png" style="margin-top: 14px;" width="118" /></a></div>
<div class="Column-i5" style="background-attachment: scroll; background-clip: initial; background-color: transparent; background-image: url(http://www.intelcloudbuilders.com/cloud-usage-models/images/vertLine.png); background-origin: initial; background-position: 0px 70px; background-repeat: no-repeat no-repeat; float: left; font-size: 16px; padding-left: 45px; padding-right: 45px; text-align: center;">
<a class="local" hidefocus="true" href="http://www.intelcloudbuilders.com/cloud-usage-models/#Third" style="color: #333333; outline-color: initial; outline-style: none; outline-width: initial; text-decoration: none;">Power management<br /><img alt="" border="0" height="9" src="http://www.intelcloudbuilders.com/cloud-usage-models/images/blackDownArrow.png" width="18" /><br /><img alt="" border="0" height="226" src="http://www.intelcloudbuilders.com/cloud-usage-models/images/smallTriStack.png" style="margin-top: 14px;" width="129" /></a></div>
<div class="Column-i5" style="background-attachment: scroll; background-clip: initial; background-color: transparent; background-image: url(http://www.intelcloudbuilders.com/cloud-usage-models/images/vertLine.png); background-origin: initial; background-position: 0px 70px; background-repeat: no-repeat no-repeat; float: left; font-size: 16px; padding-left: 45px; padding-right: 45px; text-align: center;">
source : <span class="Apple-style-span" style="font-size: small;"><a href="http://www.intelcloudbuilders.com/cloud-usage-models/#Third">http://www.intelcloudbuilders.com/cloud-usage-models/#Third</a></span></div>
</div>Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-69748107068655042372012-06-13T22:09:00.001+03:002012-06-13T22:09:53.192+03:00Intel® Cloud Builders Guide: Data Center Infrastructure and Energy Management with 3D visualization with Visual Data CenterBuilt on the Intel® Xeon® Processor E5-2600 Product Family<a href="http://www.intelcloudbuilders.com/index.php?option=com_productsearch&view=lightbox&proid=107&ie=UTF-8&oe=UTF-8&q=prettyphoto&showlink=1&Itemid=181#.T9jlfH2vzKc.blogger">Intel® Cloud Builders Guide: Data Center Infrastructure and Energy Management with 3D visualization with Visual Data CenterBuilt on the Intel® Xeon® Processor E5-2600 Product Family</a>Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-50044502346225370652012-06-13T22:06:00.001+03:002012-06-13T22:06:01.259+03:00Intel® Cloud Builders Guide: Apache* Hadoop*<a href="http://www.intelcloudbuilders.com/index.php?option=com_productsearch&view=lightbox&proid=113&ie=UTF-8&oe=UTF-8&q=prettyphoto&showlink=1&Itemid=181#.T9jki36Lmns.blogger">Intel® Cloud Builders Guide: Apache* Hadoop*</a>Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-6090112009265669472012-03-28T11:46:00.001+03:002012-03-28T11:46:10.802+03:00Set ulimit parameters on ubuntu<span class="Apple-style-span" style="background-color: #f6f6f6; color: #494a4b; font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 12px; line-height: 18px;"></span><br />
<h1 class="entry-title" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; clear: none; color: #4378ae; font-family: Arial, Helvetica, sans-serif; font-size: 28px; line-height: 26px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 2px; padding-left: 0px; padding-right: 0px; padding-top: 8px; text-transform: none; vertical-align: baseline;">
Set ulimit parameters on ubuntu</h1>
<div class="entry-meta" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #787878; font-size: 11px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
<span class="meta-prep meta-prep-author" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 11px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">By </span><span class="author vcard" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 11px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"><a ca_clicked="0" class="url fn n" href="http://posidev.com/blog/author/ivanov/" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #787878; font-size: 11px; font-style: italic; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none; vertical-align: baseline;" title="View all posts by ivanov">ivanov</a></span><span class="meta-sep meta-sep-entry-date" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 11px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"> | </span><span class="meta-prep meta-prep-entry-date" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 11px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">Published: </span><span class="entry-date" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 11px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"><abbr class="published" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-color: rgb(51, 51, 51); border-bottom-style: dotted; border-bottom-width: 1px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; cursor: help; font-size: 11px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;" title="2009-06-04T09:34:10+0000">June 4, 2009</abbr></span></div>
<div class="entry-content" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
<div id="content_div-7" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
<div class="handbook_link_add_7" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
<a ca_clicked="0" href="http://posidev.com/blog/2009/06/04/set-ulimit-parameters-on-ubuntu/#" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #2772b3; font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none; vertical-align: baseline;">Add to pdf</a></div>
<div id="result" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
</div>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
By default the number of open files pro user in Ubuntu 8.04 is 1024. In my case this number was too small so I have to increase it.This is done with the <strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">ulimit </strong>command:</div>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
<strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">$ulimit -a # see all the kernel parameters<br />$ulimit -n #see the number of open files<br />$ulimit -n 9000 # set the number open files to 9000</strong></div>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
The problem with this way is that the<strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"> ulimit </strong>parameter is only set currently for this command terminla and user.If you open a new tab and type again <strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">ulimit -a</strong> you will see that the number of open files is <strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">1024</strong>.This means that after a reboot you’ll need to set the parameter again.</div>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
<strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">First</strong>, in order to set this options automatically you have to edit the<strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">etc/security/limits.conf</strong> file.</div>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
<strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">$sudo gedit /etc/security/limits.conf #open the file in gedit</strong></div>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
The <strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">#</strong> means that this part is commented.The <strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">wildcard *</strong> means for all users.We need to set the <strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">nofile</strong> option meaning maximum number of open files.If you want to change the number of files of <strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">user</strong>, you should add this line in the <strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">limits.conf</strong>:</div>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
<strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">user soft nofile 9000</strong></div>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
<strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">user hard nofile 65000</strong></div>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
If you want to set the <strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">nofile </strong>only for <strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">superuser </strong>you just write <strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">root </strong>instead of <strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">user</strong>.</div>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
<strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">root soft nofile 9000</strong></div>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
<strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">root hard nofile 65000</strong></div>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
<strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">Second </strong>you have to add a line in the <strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">/etc/pam.d/common-session </strong>file:</div>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
<strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">$ sudo gedit /etc/pam.d/common-session #open the file in gedit</strong></div>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
Then add the line:</div>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
<strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">session required pam_limits.so</strong></div>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
Now after rebooting you can see in the terminal with <strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">ulimit -a</strong> the change.</div>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
The option with <strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">wildcard *</strong>didn’t work for me , because I used <strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">root </strong>accout to run my programms and wildcard option doesn’t affect the <strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">superuser.</strong></div>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
<strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">Remark: </strong>Using the same steps you should be able to set and change other parameters ( core file size, max user processes, stack size ….) from the ulimit options.<strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"></strong></div>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
<strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">References:</strong></div>
<ul style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; list-style-image: initial; list-style-position: inside; list-style-type: square; margin-bottom: 18px; margin-left: 1.5em; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
<li style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"><strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"><a ca_clicked="0" href="http://knol.google.com/k/fred-grott/open-file-limits-settings-on-ubuntu/166jfml0mowlh/3" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #2772b3; font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none; vertical-align: baseline;" target="_blank">Open File Limits Settings on Ubuntu</a></strong></li>
<li style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"><strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"><a ca_clicked="0" href="https://bugs.launchpad.net/ubuntu/+source/pam/+bug/65244" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #2772b3; font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none; vertical-align: baseline;" target="_blank">ulimits not set according to /etc/security/limits.conf for root – update documentation</a></strong></li>
<li style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"><strong style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"><a ca_clicked="0" href="http://www.extremetech.com/article2/0,2845,2114123,00.asp" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #2772b3; font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none; vertical-align: baseline;" target="_blank">Hacking Ubuntu to Improve Performance</a></strong></li>
<li></li>
</ul>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; margin-bottom: 18px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">
</div>
</div>
</div>Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-17366910996014864932012-03-17T11:40:00.002+02:002012-03-17T11:40:25.670+02:00Android Connect to FTP server example<span class="Apple-style-span" style="background-color: #cccccc; color: white; font-family: Arial, Helvetica, sans-serif; font-size: 12px;"></span><br />
<h2 style="clear: both; font-size: 2em; height: 24px; line-height: normal; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 15px; padding-top: 10px;">
<a href="http://androiddev.orkitra.com/?p=28" style="color: #62a4ba; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;">Connect to FTP server example</a></h2>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
This is the android coding example showing how to connect to FTP server and some basic file operations such as downloading, uploading, deleting, renaming file, and creating new directory.</div>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
<span id="more-28" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"></span>You must import the following <a class="kLink" href="http://androiddev.orkitra.com/?p=28#" id="KonaLink0" style="background-attachment: initial !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; border-bottom-color: transparent !important; border-bottom-style: none !important; border-bottom-width: 0px !important; border-left-color: transparent !important; border-left-style: none !important; border-left-width: 0px !important; border-right-color: transparent !important; border-right-style: none !important; border-right-width: 0px !important; border-top-color: transparent !important; border-top-style: none !important; border-top-width: 0px !important; bottom: 0px; color: #0099ff; cursor: pointer; display: inline !important; font-family: inherit !important; font-size: inherit !important; font-variant: normal; left: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: none; outline-width: initial; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; right: 0px; text-decoration: underline !important; text-transform: none !important; top: 0px;"><span style="color: rgb(109, 208, 247) !important; font-family: inherit !important; font-size: inherit !important; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: static;"><span class="kLink" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: none; background-origin: initial; border-bottom-color: initial; border-bottom-style: solid; border-bottom-width: 1px; border-left-color: initial !important; border-left-style: none !important; border-left-width: 0px !important; border-right-color: initial !important; border-right-style: none !important; border-right-width: 0px !important; border-top-color: initial !important; border-top-style: none !important; border-top-width: 0px !important; color: rgb(109, 208, 247) !important; display: inline !important; float: none !important; font-family: inherit !important; font-size: inherit !important; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; width: auto !important;">FTP </span><span class="kLink" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: none; background-origin: initial; border-bottom-color: initial; border-bottom-style: solid; border-bottom-width: 1px; border-left-color: initial !important; border-left-style: none !important; border-left-width: 0px !important; border-right-color: initial !important; border-right-style: none !important; border-right-width: 0px !important; border-top-color: initial !important; border-top-style: none !important; border-top-width: 0px !important; color: rgb(109, 208, 247) !important; display: inline !important; float: none !important; font-family: inherit !important; font-size: inherit !important; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; width: auto !important;">client</span></span></a> library, <a href="http://androiddev.orkitra.com/?p=139" style="color: #0099ff; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;" title="Download FTPClient Library">download it here</a>:</div>
<blockquote style="border-left-color: rgb(119, 255, 119); border-left-style: solid; border-left-width: 2px; color: #77ff77; font-style: normal; margin-bottom: 0px; margin-left: 2px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 10px; padding-right: 0px; padding-top: 0px;">
<pre style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">import org.apache.commons.net.ftp.*;</pre>
</blockquote>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
<br /></div>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
Now, declare a public FTP client object.</div>
<blockquote style="border-left-color: rgb(119, 255, 119); border-left-style: solid; border-left-width: 2px; color: #77ff77; font-style: normal; margin-bottom: 0px; margin-left: 2px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 10px; padding-right: 0px; padding-top: 0px;">
<pre style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">public FTPClient mFTPClient = null;</pre>
</blockquote>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
<br /></div>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
Method to connect to FTP server:</div>
<blockquote style="border-left-color: rgb(119, 255, 119); border-left-style: solid; border-left-width: 2px; color: #77ff77; font-style: normal; margin-bottom: 0px; margin-left: 2px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 10px; padding-right: 0px; padding-top: 0px;">
<pre style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">public boolean ftpConnect(String host, String username,
String password, int port)
{
try {
mFTPClient = new FTPClient();
// connecting to the host
mFTPClient.connect(host, port);
// now check the reply code, if positive mean connection success
if (FTPReply.isPositiveCompletion(mFTPClient.getReplyCode())) {
// login using username & password
boolean status = mFTPClient.login(username, password);
/* Set File Transfer Mode
*
* To avoid corruption issue you must specified a correct
* transfer mode, such as ASCII_FILE_TYPE, BINARY_FILE_TYPE,
* EBCDIC_FILE_TYPE .etc. Here, I use BINARY_FILE_TYPE
* for transferring text, image, and compressed files.
*/
mFTPClient.setFileType(FTP.BINARY_FILE_TYPE);
mFTPClient.enterLocalPassiveMode();
return status;
}
} catch(Exception e) {
Log.d(TAG, "Error: could not connect to host " + host );
}
return false;
}</pre>
</blockquote>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
<br /></div>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
Method to disconnect from FTP server:</div>
<blockquote style="border-left-color: rgb(119, 255, 119); border-left-style: solid; border-left-width: 2px; color: #77ff77; font-style: normal; margin-bottom: 0px; margin-left: 2px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 10px; padding-right: 0px; padding-top: 0px;">
<pre style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">public boolean ftpDisconnect()
{
try {
mFTPClient.logout();
mFTPClient.disconnect();
return true;
} catch (Exception e) {
Log.d(TAG, "Error occurred while disconnecting from ftp server.");
}
return false;
}</pre>
</blockquote>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
<br /></div>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
Method to get current working directory:</div>
<blockquote style="border-left-color: rgb(119, 255, 119); border-left-style: solid; border-left-width: 2px; color: #77ff77; font-style: normal; margin-bottom: 0px; margin-left: 2px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 10px; padding-right: 0px; padding-top: 0px;">
<pre style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">public String ftpGetCurrentWorkingDirectory()
{
try {
String workingDir = mFTPClient.printWorkingDirectory();
return workingDir;
} catch(Exception e) {
Log.d(TAG, "Error: could not get current working directory.");
}
return null;
}</pre>
</blockquote>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
<br /></div>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
Method to change working directory:</div>
<blockquote style="border-left-color: rgb(119, 255, 119); border-left-style: solid; border-left-width: 2px; color: #77ff77; font-style: normal; margin-bottom: 0px; margin-left: 2px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 10px; padding-right: 0px; padding-top: 0px;">
<pre style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">public boolean ftpChangeDirectory(String directory_path)
{
try {
mFTPClient.changeWorkingDirectory(directory_path);
} catch(Exception e) {
Log.d(TAG, "Error: could not change directory to " + directory_path);
}
return false;
}</pre>
</blockquote>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
<br /></div>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
Method to list all files in a directory:</div>
<blockquote style="border-left-color: rgb(119, 255, 119); border-left-style: solid; border-left-width: 2px; color: #77ff77; font-style: normal; margin-bottom: 0px; margin-left: 2px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 10px; padding-right: 0px; padding-top: 0px;">
<pre style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">public void ftpPrintFilesList(String dir_path)
{
try {
FTPFile[] ftpFiles = mFTPClient.listFiles(dir_path);
int length = ftpFiles.length;
for (int i = 0; i < length; i++) {
String name = ftpFiles[i].getName();
boolean isFile = ftpFiles[i].isFile();
if (isFile) {
Log.i(TAG, "File : " + name);
}
else {
Log.i(TAG, "Directory : " + name);
}
}
} catch(Exception e) {
e.printStackTrace();
}
}</pre>
</blockquote>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
<br /></div>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
Method to create new directory:</div>
<blockquote style="border-left-color: rgb(119, 255, 119); border-left-style: solid; border-left-width: 2px; color: #77ff77; font-style: normal; margin-bottom: 0px; margin-left: 2px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 10px; padding-right: 0px; padding-top: 0px;">
<pre style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">public boolean ftpMakeDirectory(String new_dir_path)
{
try {
boolean status = mFTPClient.makeDirectory(new_dir_path);
return status;
} catch(Exception e) {
Log.d(TAG, "Error: could not create new directory named " + new_dir_path);
}
return false;
}</pre>
</blockquote>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
<br /></div>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
Method to delete/remove a directory:</div>
<blockquote style="border-left-color: rgb(119, 255, 119); border-left-style: solid; border-left-width: 2px; color: #77ff77; font-style: normal; margin-bottom: 0px; margin-left: 2px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 10px; padding-right: 0px; padding-top: 0px;">
<pre style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">public boolean ftpRemoveDirectory(String dir_path)
{
try {
boolean status = mFTPClient.removeDirectory(dir_path);
return status;
} catch(Exception e) {
Log.d(TAG, "Error: could not remove directory named " + dir_path);
}
return false;
}</pre>
</blockquote>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
<br /></div>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
Method to delete a file:</div>
<blockquote style="border-left-color: rgb(119, 255, 119); border-left-style: solid; border-left-width: 2px; color: #77ff77; font-style: normal; margin-bottom: 0px; margin-left: 2px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 10px; padding-right: 0px; padding-top: 0px;">
<pre style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">public boolean ftpRemoveFile(String filePath)
{
try {
boolean status = mFTPClient.deleteFile(filePath);
return status;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}</pre>
</blockquote>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
<br /></div>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
Method to rename a file:</div>
<blockquote style="border-left-color: rgb(119, 255, 119); border-left-style: solid; border-left-width: 2px; color: #77ff77; font-style: normal; margin-bottom: 0px; margin-left: 2px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 10px; padding-right: 0px; padding-top: 0px;">
<pre style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">public boolean ftpRenameFile(String from, String to)
{
try {
boolean status = mFTPClient.rename(from, to);
return status;
} catch (Exception e) {
Log.d(TAG, "Could not rename file: " + from + " to: " + to);
}
return false;
}</pre>
</blockquote>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
<br /></div>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
Method to download a file from FTP server:</div>
<blockquote style="border-left-color: rgb(119, 255, 119); border-left-style: solid; border-left-width: 2px; color: #77ff77; font-style: normal; margin-bottom: 0px; margin-left: 2px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 10px; padding-right: 0px; padding-top: 0px;">
<pre style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">/**
* mFTPClient: FTP client connection object (see FTP connection example)
* srcFilePath: path to the source file in FTP server
* desFilePath: path to the destination file to be saved in sdcard
*/
public boolean ftpDownload(String srcFilePath, String desFilePath)
{
boolean status = false;
try {
FileOutputStream desFileStream = new FileOutputStream(desFilePath);;
status = mFTPClient.retrieveFile(srcFilePath, desFileStream);
desFileStream.close();
return status;
} catch (Exception e) {
Log.d(TAG, "download failed");
}
return status;
}</pre>
</blockquote>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
<br /></div>
<div style="line-height: 1.3em; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 0px;">
Method to upload a file to FTP server:</div>
<blockquote style="border-left-color: rgb(119, 255, 119); border-left-style: solid; border-left-width: 2px; color: #77ff77; font-style: normal; margin-bottom: 0px; margin-left: 2px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 10px; padding-right: 0px; padding-top: 0px;">
<pre style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">/**
* mFTPClient: FTP client connection object (see FTP connection example)
* srcFilePath: source file path in sdcard
* desFileName: file name to be stored in FTP server
* desDirectory: directory path where the file should be upload to
*/
public boolean ftpUpload(String srcFilePath, String desFileName,
String desDirectory)
{
boolean status = false;
try {
FileInputStream srcFileStream = new FileInputStream(srcFilePath);
// change working directory to the destination directory
if (ftpChangeDirectory(desDirectory)) {
status = mFTPClient.storeFile(desFileName, srcFileStream);
}
srcFileStream.close();
return status;
} catch (Exception e) {
Log.d(TAG, "upload failed");
}
return status;
}</pre>
</blockquote>
<div class="details" style="border-top-color: rgb(102, 164, 189); border-top-style: solid; border-top-width: 1px; clear: both; font-size: 0.9em; height: 20px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 40px; padding-bottom: 0px; padding-left: 0px; padding-right: 20px; padding-top: 5px;">
</div>Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com25tag:blogger.com,1999:blog-4630029198809027581.post-66294742655358660982012-02-24T23:15:00.002+02:002012-02-24T23:15:16.936+02:00Dynamic Web Service Client<span class="Apple-style-span" style="font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; line-height: 20px;">In Apache Axis2, the are several ways to write a client for a web service. One approach would be to use WSDL2Java, the code generation tool provided with Axis2 generate a stub for the web service and use that stub to consume the web service. Other option is to write a dynamic client. This is how you can write a dynamic client for a web service.<br /><br />We will you expose a simple POJO as a web service.</span><br />
<div class="dp-highlighter" style="background-color: #e7e5dc; color: #cccccc; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; margin-bottom: 18px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 18px !important; overflow-x: auto; overflow-y: auto; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 1px !important; width: 792px;">
<div class="bar" style="padding-bottom: 0px; padding-left: 45px; padding-right: 0px; padding-top: 0px;">
<div class="tools" style="background-color: #f8f8f8; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; color: silver; font: normal normal normal 9px/normal Verdana, Geneva, Arial, Helvetica, sans-serif; padding-bottom: 10px; padding-left: 10px; padding-right: 8px; padding-top: 3px;">
<a href="http://www.nandana.org/2008/11/how-to-write-dynamic-client-for-web.html#" style="background-attachment: initial; background-clip: initial; background-color: inherit; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #a0a0a0; font-size: 9px; margin-bottom: 0px; margin-left: 0px; margin-right: 10px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;">view plain</a><a href="http://www.nandana.org/2008/11/how-to-write-dynamic-client-for-web.html#" style="background-attachment: initial; background-clip: initial; background-color: inherit; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #a0a0a0; font-size: 9px; margin-bottom: 0px; margin-left: 0px; margin-right: 10px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;">print</a><a href="http://www.nandana.org/2008/11/how-to-write-dynamic-client-for-web.html#" style="background-attachment: initial; background-clip: initial; background-color: inherit; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #a0a0a0; font-size: 9px; margin-bottom: 0px; margin-left: 0px; margin-right: 10px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;">?</a></div>
</div>
<ol class="dp-j" start="1" style="background-color: white; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; list-style-image: initial; list-style-position: initial; list-style-type: decimal; margin-bottom: 1px !important; margin-left: 45px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">package</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> org.wso2.training; </span></span></li>
<li class="" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> </span></li>
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">public</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> </span><span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">class</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> CalculatorService { </span></span></li>
<li class="" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> </span></li>
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> <span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">public</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> </span><span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">int</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> add (</span><span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">int</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> a, </span><span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">int</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> b) { </span></span></li>
<li class="" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> <span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">return</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> a + b; </span></span></li>
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> } </span></li>
<li class="" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> </span></li>
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> <span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">public</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> </span><span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">int</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> multiply(</span><span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">int</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> a, </span><span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">int</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> b) { </span></span></li>
<li class="" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> <span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">return</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> a * b; </span></span></li>
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> } </span></li>
<li class="" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> </span></li>
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">} </span></li>
</ol>
</div>
Exposing this as a web service is a matter of 2 lines of code ...<div class="dp-highlighter" style="background-color: #e7e5dc; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; margin-bottom: 18px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 18px !important; overflow-x: auto; overflow-y: auto; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 1px !important; width: 792px;">
<div class="bar" style="padding-bottom: 0px; padding-left: 45px; padding-right: 0px; padding-top: 0px;">
<div class="tools" style="background-color: #f8f8f8; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; color: silver; font: normal normal normal 9px/normal Verdana, Geneva, Arial, Helvetica, sans-serif; padding-bottom: 10px; padding-left: 10px; padding-right: 8px; padding-top: 3px;">
<a href="http://www.nandana.org/2008/11/how-to-write-dynamic-client-for-web.html#" style="background-attachment: initial; background-clip: initial; background-color: inherit; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #a0a0a0; font-size: 9px; margin-bottom: 0px; margin-left: 0px; margin-right: 10px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;">view plain</a><a href="http://www.nandana.org/2008/11/how-to-write-dynamic-client-for-web.html#" style="background-attachment: initial; background-clip: initial; background-color: inherit; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #a0a0a0; font-size: 9px; margin-bottom: 0px; margin-left: 0px; margin-right: 10px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;">print</a><a href="http://www.nandana.org/2008/11/how-to-write-dynamic-client-for-web.html#" style="background-attachment: initial; background-clip: initial; background-color: inherit; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #a0a0a0; font-size: 9px; margin-bottom: 0px; margin-left: 0px; margin-right: 10px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;">?</a></div>
</div>
<ol class="dp-j" start="1" style="background-color: white; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; list-style-image: initial; list-style-position: initial; list-style-type: decimal; margin-bottom: 1px !important; margin-left: 45px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">AxisServer axisServer = </span><span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">new</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> AxisServer(); </span></span></li>
<li class="" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">axisServer.deployService(CalculatorService.<span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">class</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">.getName()); </span></span></li>
</ol>
</div>
Now, the WSDL for this web service will be available at<br /><div class="dp-highlighter" style="background-color: #e7e5dc; color: #cccccc; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; margin-bottom: 18px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 18px !important; overflow-x: auto; overflow-y: auto; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 1px !important; width: 792px;">
<div class="bar" style="padding-bottom: 0px; padding-left: 45px; padding-right: 0px; padding-top: 0px;">
<div class="tools" style="background-color: #f8f8f8; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; color: silver; font: normal normal normal 9px/normal Verdana, Geneva, Arial, Helvetica, sans-serif; padding-bottom: 10px; padding-left: 10px; padding-right: 8px; padding-top: 3px;">
<a href="http://www.nandana.org/2008/11/how-to-write-dynamic-client-for-web.html#" style="background-attachment: initial; background-clip: initial; background-color: inherit; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #a0a0a0; font-size: 9px; margin-bottom: 0px; margin-left: 0px; margin-right: 10px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;">view plain</a><a href="http://www.nandana.org/2008/11/how-to-write-dynamic-client-for-web.html#" style="background-attachment: initial; background-clip: initial; background-color: inherit; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #a0a0a0; font-size: 9px; margin-bottom: 0px; margin-left: 0px; margin-right: 10px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;">print</a><a href="http://www.nandana.org/2008/11/how-to-write-dynamic-client-for-web.html#" style="background-attachment: initial; background-clip: initial; background-color: inherit; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #a0a0a0; font-size: 9px; margin-bottom: 0px; margin-left: 0px; margin-right: 10px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;">?</a></div>
</div>
<ol class="dp-xml" start="1" style="background-color: white; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; list-style-image: initial; list-style-position: initial; list-style-type: decimal; margin-bottom: 1px !important; margin-left: 45px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">http://localhost:6060/axis2/services/CalculatorService?wsdl </span></span></li>
</ol>
</div>
Now let's see how we can write a dynamic client for this web service<div class="dp-highlighter" style="background-color: #e7e5dc; color: #cccccc; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; margin-bottom: 18px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 18px !important; overflow-x: auto; overflow-y: auto; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 1px !important; width: 792px;">
<div class="bar" style="padding-bottom: 0px; padding-left: 45px; padding-right: 0px; padding-top: 0px;">
<div class="tools" style="background-color: #f8f8f8; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; color: silver; font: normal normal normal 9px/normal Verdana, Geneva, Arial, Helvetica, sans-serif; padding-bottom: 10px; padding-left: 10px; padding-right: 8px; padding-top: 3px;">
<a href="http://www.nandana.org/2008/11/how-to-write-dynamic-client-for-web.html#" style="background-attachment: initial; background-clip: initial; background-color: inherit; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #a0a0a0; font-size: 9px; margin-bottom: 0px; margin-left: 0px; margin-right: 10px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;">view plain</a><a href="http://www.nandana.org/2008/11/how-to-write-dynamic-client-for-web.html#" style="background-attachment: initial; background-clip: initial; background-color: inherit; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #a0a0a0; font-size: 9px; margin-bottom: 0px; margin-left: 0px; margin-right: 10px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;">print</a><a href="http://www.nandana.org/2008/11/how-to-write-dynamic-client-for-web.html#" style="background-attachment: initial; background-clip: initial; background-color: inherit; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #a0a0a0; font-size: 9px; margin-bottom: 0px; margin-left: 0px; margin-right: 10px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;">?</a></div>
</div>
<ol class="dp-j" start="1" style="background-color: white; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; list-style-image: initial; list-style-position: initial; list-style-type: decimal; margin-bottom: 1px !important; margin-left: 45px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> </span><span class="comment" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #008200; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">//Create a service client for given WSDL service by passing the following four parameters</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> </span></span></li>
<li class="" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> <span class="comment" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #008200; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">//ConfigurationContext - we keep it as null</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> </span></span></li>
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> <span class="comment" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #008200; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">//wsdlURL - The URL of the WSDL document to read</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> </span></span></li>
<li class="" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> <span class="comment" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #008200; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">//wsdlServiceName The QName of the WSDL service in the WSDL document </span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> </span></span></li>
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> <span class="comment" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #008200; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">//portName The name of the WSDL 1.1 port to create a client for. </span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> </span></span></li>
<li class="" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> </span></li>
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> RPCServiceClient dynamicClient = <span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">new</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> RPCServiceClient(</span><span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">null</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">, </span><span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">new</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> URL( </span></span></li>
<li class="" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> <span class="string" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">"http://localhost:6060/axis2/services/CalculatorService?wsdl"</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">), </span><span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">new</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> QName( </span></span></li>
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> <span class="string" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">"http://training.wso2.org"</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">, </span><span class="string" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">"CalculatorService"</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">), </span></span></li>
<li class="" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> <span class="string" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">"CalculatorServiceHttpSoap12Endpoint"</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">); </span></span></li>
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> </span></li>
<li class="" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> <span class="comment" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #008200; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">// We provide the parameters as an object array and return types as an class array</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> </span></span></li>
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> Object[] returnArray = dynamicClient.invokeBlocking(<span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">new</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> QName(</span><span class="string" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">"http://training.wso2.org"</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">,</span><span class="string" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">"add"</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">), </span></span></li>
<li class="" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> <span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">new</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> Object[] { </span><span class="number" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #c00000; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">1</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">, </span><span class="number" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #c00000; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">2</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> }, </span><span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">new</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> Class[] { Integer.</span><span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">class</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> }); </span></span></li>
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> </span></li>
<li class="" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> System.out.println(<span class="string" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">"1 + 2 = "</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> + returnArray[</span><span class="number" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #c00000; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">0</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">]); </span></span></li>
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> </span></li>
<li class="" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> returnArray = dynamicClient.invokeBlocking(<span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">new</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> QName(</span><span class="string" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">"http://training.wso2.org"</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">,</span><span class="string" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">"multiply"</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">), </span></span></li>
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> <span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">new</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> Object[] { </span><span class="number" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #c00000; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">1</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">, </span><span class="number" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #c00000; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">2</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> }, </span><span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">new</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> Class[] { Integer.</span><span class="keyword" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #006699; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">class</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> }); </span></span></li>
<li class="" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> </span></li>
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> System.out.println(<span class="string" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: blue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">"1 X 2 = "</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> + returnArray[</span><span class="number" style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: #c00000; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">0</span><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">]); </span></span></li>
<li class="" style="background-attachment: initial; background-clip: initial; background-color: #f8f8f8; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: #5c5c5c; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> </span></li>
<li class="alt" style="background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-style: none; border-color: initial; border-left-color: rgb(108, 226, 108); border-left-style: solid; border-left-width: 3px; border-right-style: none; border-top-style: none; border-width: initial; color: inherit; line-height: 14px; list-style-image: initial; list-style-position: outside !important; list-style-type: decimal-leading-zero; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; padding-bottom: 0px !important; padding-left: 10px !important; padding-right: 3px !important; padding-top: 0px !important;"><span style="background-color: inherit; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">. </span></li>
</ol>
</div>Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-29390263320597503752011-12-21T13:40:00.003+02:002011-12-21T13:40:37.415+02:00Checkout a specific revision from subversion from command line<span class="Apple-style-span" style="background-color: white; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 18px;"></span><br />
<pre style="background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; margin-bottom: 10px; max-height: 600px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; vertical-align: baseline; width: auto;"><code style="background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">svn checkout svn://somepath@1234 working-directory</code></pre>
<pre style="background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; margin-bottom: 10px; max-height: 600px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; vertical-align: baseline; width: auto;"><code style="background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">or</code></pre>
<span class="Apple-style-span" style="background-color: white; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 18px;"><pre style="background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; margin-bottom: 10px; max-height: 600px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; vertical-align: baseline; width: auto;"><code style="background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">svn checkout url://repository/path@1234
</code></pre>
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; clear: both; font-size: 14px; margin-bottom: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline; word-wrap: break-word;">
or</div>
<pre style="background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; margin-bottom: 10px; max-height: 600px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; vertical-align: baseline; width: auto;"><code style="background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">svn checkout -r 1234 url://repository/path</code></pre>
</span>Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-22503942118038013532011-12-09T03:50:00.001+02:002011-12-09T03:51:25.144+02:00UTF8 encode decode<span class="Apple-style-span" style="font-family: Arial;"></span><br />
<pre><code><span style="color: #3f7f5f;">/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/</span>
<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/org.apache.harmony.nio_char.tests.java.nio.charset.htm" style="color: #003399; text-decoration: none;">package org.apache.harmony.nio_char.tests.java.nio.charset;</a>
import <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/dalvik/annotation/TestTargetClass.java.htm" style="color: #003399; text-decoration: none;"><b>dalvik.annotation.TestTargetClass</b></a>;
import <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/dalvik/annotation/TestTargets.java.htm" style="color: #003399; text-decoration: none;"><b>dalvik.annotation.TestTargets</b></a>;
import <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/dalvik/annotation/TestTargetNew.java.htm" style="color: #003399; text-decoration: none;"><b>dalvik.annotation.TestTargetNew</b></a>;
import <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/dalvik/annotation/TestLevel.java.htm" style="color: #003399; text-decoration: none;"><b>dalvik.annotation.TestLevel</b></a>;
import <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/io/IOException.java.htm" style="color: #003399; text-decoration: none;"><b>java.io.IOException</b></a>;
import <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/BufferOverflowException.java.htm" style="color: #003399; text-decoration: none;"><b>java.nio.BufferOverflowException</b></a>;
import <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/ByteBuffer.java.htm" style="color: #003399; text-decoration: none;"><b>java.nio.ByteBuffer</b></a>;
import <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/CharBuffer.java.htm" style="color: #003399; text-decoration: none;"><b>java.nio.CharBuffer</b></a>;
import <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/Charset.java.htm" style="color: #003399; text-decoration: none;"><b>java.nio.charset.Charset</b></a>;
import <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/CharsetDecoder.java.htm" style="color: #003399; text-decoration: none;"><b>java.nio.charset.CharsetDecoder</b></a>;
import <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/CharsetEncoder.java.htm" style="color: #003399; text-decoration: none;"><b>java.nio.charset.CharsetEncoder</b></a>;
import <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/CoderMalfunctionError.java.htm" style="color: #003399; text-decoration: none;"><b>java.nio.charset.CoderMalfunctionError</b></a>;
import <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/CoderResult.java.htm" style="color: #003399; text-decoration: none;"><b>java.nio.charset.CoderResult</b></a>;
import <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/junit/framework/TestCase.java.htm" style="color: #003399; text-decoration: none;"><b>junit.framework.TestCase</b></a>;
<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/dalvik/annotation/TestTargetClass.java.htm" style="color: #003399; text-decoration: none;"><b>@TestTargetClass(CharsetEncoder.class)</b></a>
<span style="color: #7f0055;"><b>public</b></span> <span style="color: #7f0055;"><b>class</b></span> CharsetEncoderTest <span style="color: #7f0055;"><b>extends</b></span> <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/junit/framework/TestCase.java.htm" style="color: #003399; text-decoration: none;"><b>TestCase</b></a> {
<span style="color: #3f7f5f;">/**
<a href="" name="testConstructorLjavaniocharsetCharsetFF" style="color: #003399; text-decoration: none;"></a> * @tests java.nio.charset.CharsetEncoder.CharsetEncoder(
* java.nio.charset.Charset, float, float)
*/</span>
<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/dalvik/annotation/TestTargets.java.htm" style="color: #003399; text-decoration: none;"><b>@TestTargets({@TestTargetNew(level=TestLevel.PARTIAL_COMPLETE,notes="Checks IllegalArgumentException",method="CharsetEncoder",args={java.nio.charset.Charset.class,float.class,float.class}),@TestTargetNew(level=TestLevel.PARTIAL_COMPLETE,notes="Checks IllegalArgumentException",method="CharsetEncoder",args={java.nio.charset.Charset.class,float.class,float.class,byte[].class})})</b></a>
<span style="color: #7f0055;"><b>public</b></span> <span style="color: #7f0055;"><b>void</b></span> test_ConstructorLjava_nio_charset_CharsetFF() {
<span style="color: #3f7f5f;">// Regression for HARMONY-141</span>
<span style="color: #7f0055;"><b>try</b></span> {
<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/Charset.java.htm" style="color: #003399; text-decoration: none;"><b>Charset</b></a> cs = Charset.forName(<span style="color: #2a00ff;">"UTF-8"</span>);
<span style="color: #7f0055;"><b>new</b></span> MockCharsetEncoderForHarmony141(cs, <span style="color: #990000;"><b>1.1f</b></span>, <span style="color: #990000;"><b>1</b></span>);
fail(<span style="color: #2a00ff;">"Assert 0: Should throw IllegalArgumentException."</span>);
} <span style="color: #7f0055;"><b>catch</b></span> (<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/lang/IllegalArgumentException.java.htm" style="color: #003399; text-decoration: none;"><b>IllegalArgumentException</b></a> e) {
<span style="color: #3f7f5f;">// expected</span>
}
<span style="color: #7f0055;"><b>try</b></span> {
<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/Charset.java.htm" style="color: #003399; text-decoration: none;"><b>Charset</b></a> cs = Charset.forName(<span style="color: #2a00ff;">"ISO8859-1"</span>);
<span style="color: #7f0055;"><b>new</b></span> MockCharsetEncoderForHarmony141(cs, <span style="color: #990000;"><b>1.1f</b></span>, <span style="color: #990000;"><b>1</b></span>,
<span style="color: #7f0055;"><b>new</b></span> <span style="color: #7f0055;"><b>byte</b></span>[] { <span style="color: #990000;"><b>0x1a</b></span> });
fail(<span style="color: #2a00ff;">"Assert 1: Should throw IllegalArgumentException."</span>);
} <span style="color: #7f0055;"><b>catch</b></span> (<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/lang/IllegalArgumentException.java.htm" style="color: #003399; text-decoration: none;"><b>IllegalArgumentException</b></a> e) {
<span style="color: #3f7f5f;">// expected</span>
}
}
<span style="color: #3f7f5f;">/**
* @tests java.nio.charset.CharsetEncoder.CharsetEncoder(
* java.nio.charset.Charset, float, float)
*/</span>
<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/dalvik/annotation/TestTargetNew.java.htm" style="color: #003399; text-decoration: none;"><b>@TestTargetNew(level=TestLevel.PARTIAL_COMPLETE,notes="",method="CharsetEncoder",args={java.nio.charset.Charset.class,float.class,float.class})</b></a>
<span style="color: #7f0055;"><b>public</b></span> <span style="color: #7f0055;"><b>void</b></span> test_ConstructorLjava_nio_charset_CharsetNull() {
<span style="color: #3f7f5f;">// Regression for HARMONY-491</span>
<a href="" name="testConstructorLjavaniocharsetCharsetNull" style="color: #003399; text-decoration: none;"></a> <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/CharsetEncoder.java.htm" style="color: #003399; text-decoration: none;"><b>CharsetEncoder</b></a> ech = <span style="color: #7f0055;"><b>new</b></span> MockCharsetEncoderForHarmony491(null,
<span style="color: #990000;"><b>1</b></span>, <span style="color: #990000;"><b>1</b></span>);
assertNull(ech.charset());
}
<span style="color: #3f7f5f;">/**
* Helper for constructor tests
*/</span>
<span style="color: #7f0055;"><b>public</b></span> <span style="color: #7f0055;"><b>static</b></span> <span style="color: #7f0055;"><b>class</b></span> MockCharsetEncoderForHarmony141 extends
<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/CharsetEncoder.java.htm" style="color: #003399; text-decoration: none;"><b>CharsetEncoder</b></a> {
<span style="color: #7f0055;"><b>protected</b></span> MockCharsetEncoderForHarmony141(<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/Charset.java.htm" style="color: #003399; text-decoration: none;"><b>Charset</b></a> cs,
<a href="" name="MockCharsetEncoderForHarmony141" style="color: #003399; text-decoration: none;"></a> <span style="color: #7f0055;"><b>float</b></span> averageBytesPerChar, <span style="color: #7f0055;"><b>float</b></span> maxBytesPerChar) {
<span style="color: #7f0055;"><b>super</b></span> (cs, averageBytesPerChar, maxBytesPerChar);
}
<span style="color: #7f0055;"><b>public</b></span> MockCharsetEncoderForHarmony141(<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/Charset.java.htm" style="color: #003399; text-decoration: none;"><b>Charset</b></a> cs,
<span style="color: #7f0055;"><b>float</b></span> averageBytesPerChar, <span style="color: #7f0055;"><b>float</b></span> maxBytesPerChar,
<span style="color: #7f0055;"><b>byte</b></span>[] replacement) {
<a href="" name="MockCharsetEncoderForHarmony141Charsetfloatfloat" style="color: #003399; text-decoration: none;"></a> <span style="color: #7f0055;"><b>super</b></span> (cs, averageBytesPerChar, maxBytesPerChar, replacement);
}
<span style="color: #7f0055;"><b>protected</b></span> <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/CoderResult.java.htm" style="color: #003399; text-decoration: none;"><b>CoderResult</b></a> encodeLoop(<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/CharBuffer.java.htm" style="color: #003399; text-decoration: none;"><b>CharBuffer</b></a> in, <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/ByteBuffer.java.htm" style="color: #003399; text-decoration: none;"><b>ByteBuffer</b></a> out) {
<span style="color: #7f0055;"><b>return</b></span> null;
<a href="" name="MockCharsetEncoderForHarmony141Charsetfloatfloatbyte" style="color: #003399; text-decoration: none;"></a> }
}
<span style="color: #7f0055;"><b>public</b></span> <span style="color: #7f0055;"><b>static</b></span> <span style="color: #7f0055;"><b>class</b></span> MockCharsetEncoderForHarmony491 extends
<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/CharsetEncoder.java.htm" style="color: #003399; text-decoration: none;"><b>CharsetEncoder</b></a> {
<a href="" name="encodeLoopCharBufferByteBuffer" style="color: #003399; text-decoration: none;"></a> <span style="color: #7f0055;"><b>public</b></span> MockCharsetEncoderForHarmony491(<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/Charset.java.htm" style="color: #003399; text-decoration: none;"><b>Charset</b></a> arg0,
<span style="color: #7f0055;"><b>float</b></span> arg1, <span style="color: #7f0055;"><b>float</b></span> arg2) {
<span style="color: #7f0055;"><b>super</b></span> (arg0, arg1, arg2);
}
<a href="" name="MockCharsetEncoderForHarmony491" style="color: #003399; text-decoration: none;"></a> <span style="color: #7f0055;"><b>protected</b></span> <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/CoderResult.java.htm" style="color: #003399; text-decoration: none;"><b>CoderResult</b></a> encodeLoop(<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/CharBuffer.java.htm" style="color: #003399; text-decoration: none;"><b>CharBuffer</b></a> arg0,
<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/ByteBuffer.java.htm" style="color: #003399; text-decoration: none;"><b>ByteBuffer</b></a> arg1) {
<span style="color: #7f0055;"><b>return</b></span> null;
<a href="" name="MockCharsetEncoderForHarmony491Charsetfloatfloat" style="color: #003399; text-decoration: none;"></a> }
<span style="color: #7f0055;"><b>public</b></span> <span style="color: #7f0055;"><b>boolean</b></span> isLegalReplacement(<span style="color: #7f0055;"><b>byte</b></span>[] arg0) {
<span style="color: #7f0055;"><b>return</b></span> <span style="color: #990000;"><b>true</b></span>;
}
<a href="" name="encodeLoopCharBufferByteBuffer" style="color: #003399; text-decoration: none;"></a> }
<span style="color: #3f7f5f;">/*
* Test malfunction encode(CharBuffer)
*/</span>
<a href="" name="isLegalReplacementbyte" style="color: #003399; text-decoration: none;"></a> <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/dalvik/annotation/TestTargetNew.java.htm" style="color: #003399; text-decoration: none;"><b>@TestTargetNew(level=TestLevel.PARTIAL,notes="Regression test checks CoderMalfunctionError",method="encode",args={java.nio.CharBuffer.class})</b></a>
<span style="color: #7f0055;"><b>public</b></span> <span style="color: #7f0055;"><b>void</b></span> test_EncodeLjava_nio_CharBuffer() <span style="color: #7f0055;"><b>throws</b></span> Exception {
MockMalfunctionCharset cs = <span style="color: #7f0055;"><b>new</b></span> MockMalfunctionCharset(<span style="color: #2a00ff;">"mock"</span>,
null);
<span style="color: #7f0055;"><b>try</b></span> {
cs.encode(CharBuffer.wrap(<span style="color: #2a00ff;">"AB"</span>));
fail(<span style="color: #2a00ff;">"should throw CoderMalfunctionError"</span>);
} <span style="color: #7f0055;"><b>catch</b></span> (<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/CoderMalfunctionError.java.htm" style="color: #003399; text-decoration: none;"><b>CoderMalfunctionError</b></a> e) {
<a href="" name="testEncodeLjavanioCharBuffer" style="color: #003399; text-decoration: none;"></a> <span style="color: #3f7f5f;">// expected</span>
}
}
<span style="color: #3f7f5f;">/*
* Mock charset class with malfunction decode & encode.
*/</span>
<span style="color: #7f0055;"><b>static</b></span> <span style="color: #7f0055;"><b>final</b></span> <span style="color: #7f0055;"><b>class</b></span> MockMalfunctionCharset <span style="color: #7f0055;"><b>extends</b></span> <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/Charset.java.htm" style="color: #003399; text-decoration: none;"><b>Charset</b></a> {
<span style="color: #7f0055;"><b>public</b></span> MockMalfunctionCharset(<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/lang/String.java.htm" style="color: #003399; text-decoration: none;"><b>String</b></a> canonicalName,
<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/lang/String.java.htm" style="color: #003399; text-decoration: none;"><b>String</b></a>[] aliases) {
<span style="color: #7f0055;"><b>super</b></span> (canonicalName, aliases);
}
<span style="color: #7f0055;"><b>public</b></span> <span style="color: #7f0055;"><b>boolean</b></span> contains(<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/Charset.java.htm" style="color: #003399; text-decoration: none;"><b>Charset</b></a> cs) {
<a href="" name="MockMalfunctionCharset" style="color: #003399; text-decoration: none;"></a> <span style="color: #7f0055;"><b>return</b></span> <span style="color: #990000;"><b>false</b></span>;
}
<a href="" name="MockMalfunctionCharsetStringString" style="color: #003399; text-decoration: none;"></a>
<span style="color: #7f0055;"><b>public</b></span> <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/CharsetDecoder.java.htm" style="color: #003399; text-decoration: none;"><b>CharsetDecoder</b></a> newDecoder() {
<span style="color: #7f0055;"><b>return</b></span> Charset.forName(<span style="color: #2a00ff;">"UTF-8"</span>).newDecoder();
}
<a href="" name="containsCharset" style="color: #003399; text-decoration: none;"></a> <span style="color: #7f0055;"><b>public</b></span> <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/CharsetEncoder.java.htm" style="color: #003399; text-decoration: none;"><b>CharsetEncoder</b></a> newEncoder() {
<span style="color: #7f0055;"><b>return</b></span> <span style="color: #7f0055;"><b>new</b></span> MockMalfunctionEncoder(<span style="color: #7f0055;"><b>this</b></span> );
}
}
<a href="" name="newDecoder" style="color: #003399; text-decoration: none;"></a>
<span style="color: #3f7f5f;">/*
* Mock encoder. encodeLoop always throws unexpected exception.
*/</span>
<a href="" name="newEncoder" style="color: #003399; text-decoration: none;"></a> <span style="color: #7f0055;"><b>static</b></span> <span style="color: #7f0055;"><b>class</b></span> MockMalfunctionEncoder extends
<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/CharsetEncoder.java.htm" style="color: #003399; text-decoration: none;"><b>java.nio.charset.CharsetEncoder</b></a> {
<span style="color: #7f0055;"><b>public</b></span> MockMalfunctionEncoder(<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/Charset.java.htm" style="color: #003399; text-decoration: none;"><b>Charset</b></a> cs) {
<span style="color: #7f0055;"><b>super</b></span> (cs, <span style="color: #990000;"><b>1</b></span>, <span style="color: #990000;"><b>3</b></span>, <span style="color: #7f0055;"><b>new</b></span> <span style="color: #7f0055;"><b>byte</b></span>[] { (<span style="color: #7f0055;"><b>byte</b></span>) <span style="color: #990000;">'?'</span> });
}
<span style="color: #7f0055;"><b>protected</b></span> <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/CoderResult.java.htm" style="color: #003399; text-decoration: none;"><b>CoderResult</b></a> encodeLoop(<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/CharBuffer.java.htm" style="color: #003399; text-decoration: none;"><b>CharBuffer</b></a> in, <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/ByteBuffer.java.htm" style="color: #003399; text-decoration: none;"><b>ByteBuffer</b></a> out) {
<a href="" name="MockMalfunctionEncoder" style="color: #003399; text-decoration: none;"></a> throw <span style="color: #7f0055;"><b>new</b></span> <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/BufferOverflowException.java.htm" style="color: #003399; text-decoration: none;"><b>BufferOverflowException</b></a>();
}
}
<a href="" name="MockMalfunctionEncoderCharset" style="color: #003399; text-decoration: none;"></a>
<span style="color: #3f7f5f;">/*
* Test reserve bytes encode(CharBuffer,ByteBuffer,boolean)
*/</span>
<a href="" name="encodeLoopCharBufferByteBuffer" style="color: #003399; text-decoration: none;"></a> <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/dalvik/annotation/TestTargetNew.java.htm" style="color: #003399; text-decoration: none;"><b>@TestTargetNew(level=TestLevel.PARTIAL,notes="Functional test.",method="encode",args={java.nio.CharBuffer.class,java.nio.ByteBuffer.class,boolean.class})</b></a>
<span style="color: #7f0055;"><b>public</b></span> <span style="color: #7f0055;"><b>void</b></span> test_EncodeLjava_nio_CharBufferLjava_nio_ByteBufferB() {
<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/CharsetEncoder.java.htm" style="color: #003399; text-decoration: none;"><b>CharsetEncoder</b></a> encoder = Charset.forName(<span style="color: #2a00ff;">"utf-8"</span>).newEncoder();
<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/CharBuffer.java.htm" style="color: #003399; text-decoration: none;"><b>CharBuffer</b></a> in1 = CharBuffer.wrap(<span style="color: #2a00ff;">"\ud800"</span>);
<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/CharBuffer.java.htm" style="color: #003399; text-decoration: none;"><b>CharBuffer</b></a> in2 = CharBuffer.wrap(<span style="color: #2a00ff;">"\udc00"</span>);
<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/ByteBuffer.java.htm" style="color: #003399; text-decoration: none;"><b>ByteBuffer</b></a> out = ByteBuffer.allocate(<span style="color: #990000;"><b>4</b></span>);
encoder.reset();
<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/nio/charset/CoderResult.java.htm" style="color: #003399; text-decoration: none;"><b>CoderResult</b></a> result = encoder.encode(in1, out, <span style="color: #990000;"><b>false</b></span>);
<a href="" name="testEncodeLjavanioCharBufferLjavanioByteBufferB" style="color: #003399; text-decoration: none;"></a> assertEquals(<span style="color: #990000;"><b>4</b></span>, out.remaining());
assertTrue(result.isUnderflow());
result = encoder.encode(in2, out, <span style="color: #990000;"><b>true</b></span>);
assertEquals(<span style="color: #990000;"><b>4</b></span>, out.remaining());
assertTrue(result.isMalformed());
}
<span style="color: #3f7f5f;">/**
* @tests {<span style="color: #7f9fbf;"><b>@link</b></span> java.nio.charset.Charset#encode(java.nio.CharBuffer)
*/</span>
<span style="color: #7f0055;"><b>public</b></span> <span style="color: #7f0055;"><b>void</b></span> testUtf8Encoding() <span style="color: #7f0055;"><b>throws</b></span> IOException {
<span style="color: #7f0055;"><b>byte</b></span>[] orig = <span style="color: #7f0055;"><b>new</b></span> <span style="color: #7f0055;"><b>byte</b></span>[] { (<span style="color: #7f0055;"><b>byte</b></span>) <span style="color: #990000;"><b>0xed</b></span>, (<span style="color: #7f0055;"><b>byte</b></span>) <span style="color: #990000;"><b>0xa0</b></span>,
(<span style="color: #7f0055;"><b>byte</b></span>) <span style="color: #990000;"><b>0x80</b></span> };
<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/lang/String.java.htm" style="color: #003399; text-decoration: none;"><b>String</b></a> s = <span style="color: #7f0055;"><b>new</b></span> <a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/lang/String.java.htm" style="color: #003399; text-decoration: underline;"><b>String</b></a>(orig, <span style="color: #2a00ff;">"UTF-8"</span>);
assertEquals(<span style="color: #990000;"><b>1</b></span>, s.length());
assertEquals(<span style="color: #990000;"><b>55296</b></span>, s.charAt(<span style="color: #990000;"><b>0</b></span>));
Charset.forName(<span style="color: #2a00ff;">"UTF-8"</span>).encode(CharBuffer.wrap(s));
<a href="" name="testUtf8Encoding" style="color: #003399; text-decoration: none;"></a> <span style="color: #3f7f5f;">// ByteBuffer buf = <result></span>
<span style="color: #3f7f5f;">// for (byte o : orig) {</span>
<span style="color: #3f7f5f;">// byte b = 0;</span>
<span style="color: #3f7f5f;">// buf.get(b);</span>
<span style="color: #3f7f5f;">// assertEquals(o, b);</span>
<span style="color: #3f7f5f;">// }</span>
}
}</code></pre>
<pre><code>
</code></pre>
<pre><code>
</code></pre>
<a href="http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/org/apache/harmony/nio_char/tests/java/nio/charset/CharsetEncoderTest.java.htm">http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/org/apache/harmony/nio_char/tests/java/nio/charset/CharsetEncoderTest.java.htm</a><br />
<br /><span class="Apple-style-span" style="font-family: Arial;"></span><br />
<pre><code>source : </code></pre>Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-26591149650972795892011-11-20T21:14:00.001+02:002011-11-20T21:15:06.106+02:00creating header and footer for a existing pdf with iText<br />
import java.awt.Color;<br />
import java.io.FileOutputStream;<br />
<br />
import com.itextpdf.text.Anchor;<br />
import com.itextpdf.text.BaseColor;<br />
import com.itextpdf.text.Chunk;<br />
import com.itextpdf.text.Document;<br />
import com.itextpdf.text.Font;<br />
import com.itextpdf.text.FontFactory;<br />
import com.itextpdf.text.Paragraph;<br />
import com.itextpdf.text.Phrase;<br />
import com.itextpdf.text.pdf.PdfContentByte;<br />
import com.itextpdf.text.pdf.PdfImportedPage;<br />
import com.itextpdf.text.pdf.PdfPTable;<br />
import com.itextpdf.text.pdf.PdfReader;<br />
import com.itextpdf.text.pdf.PdfWriter;<br />
<br />
public class PDF {<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>/**<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * @param args<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> */<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public static void main(String[] args) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Document document = new Document();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>try {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>PdfWriter writer = PdfWriter.getInstance(document,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>new FileOutputStream("/home/zana/Desktop/v59-10.pdf"));<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>document.open();<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>PdfContentByte cb = writer.getDirectContent();<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// Load existing PDF<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>PdfReader reader = new PdfReader(new PdfReader(<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>"/home/zana/Desktop/v59-9.pdf"));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>PdfImportedPage page = writer.getImportedPage(reader, 1);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// Copy first page of existing PDF into output PDF<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>document.newPage();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>cb.addTemplate(page, 0, 0);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// Add your new data / text here<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// for example...<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Font font = new Font();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>font.setColor(BaseColor.BLUE);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>font.setStyle(Font.UNDERLINE);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Paragraph paragraph = new Paragraph();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>paragraph.setLeading(0, 25);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>paragraph.setAlignment(Paragraph.ALIGN_LEFT);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>paragraph.setAlignment(Paragraph.ALIGN_BASELINE);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Chunk chunk = new Chunk("http://www.geek-tutorials.com", font)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>.setAnchor("http://www.geek-tutorials.com");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>paragraph.add(chunk);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>document.add(paragraph);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>document.close();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} catch (Exception e) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>e.printStackTrace();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
}<br />Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-24011922238184688552011-11-15T10:53:00.001+02:002011-11-15T10:55:09.301+02:00Turkish company builds 65-inch Android 'tablet' with Honeycomb, 1080p support (video)<div class="separator" style="clear: both; text-align: center;">
<object width="320" height="266" class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://1.gvt0.com/vi/0X1NyZRX_Tk/0.jpg"><param name="movie" value="http://www.youtube.com/v/0X1NyZRX_Tk&fs=1&source=uds" />
<param name="bgcolor" value="#FFFFFF" />
<embed width="320" height="266" src="http://www.youtube.com/v/0X1NyZRX_Tk&fs=1&source=uds" type="application/x-shockwave-flash"></embed></object></div>
<br />
<br />
<span class="Apple-style-span" style="background-color: white; color: #444444; font-family: georgia; font-size: 14px; line-height: 19px;">Want <a href="http://www.engadget.com/tag/Honeycomb/" style="color: #00bdf6; outline-color: initial; outline-style: none; outline-width: initial; text-decoration: none;">Honeycomb</a> on your TV? You can <a href="http://www.engadget.com/2011/10/28/google-tv-take-2-arrives-next-week-with-honeycomb-android-marke/" style="color: #00bdf6; outline-color: initial; outline-style: none; outline-width: initial; text-decoration: none;">take your chances</a> with a <a href="http://www.engadget.com/tag/GoogleTV/" style="color: #00bdf6; outline-color: initial; outline-style: none; outline-width: initial; text-decoration: none;">Google TV</a>-enabled set <a href="http://www.engadget.com/2010/10/29/sony-internet-tv-with-google-tv-review/" style="color: #00bdf6; outline-color: initial; outline-style: none; outline-width: initial; text-decoration: none;">from Sony</a>, or you can get the full Android experience by adding a connected tablet to your HD mix -- if Istanbul-based Ardic gets its solution out the door, at least. The Turkish company's prototype uses a 10-inch Android Honeycomb-based tablet to power a 65-inch LCD with 1080p support for basic gestures, like pinch and zoom. The display currently has two touch sensors, but a version with four sensors is on the way, which will bring multi-touch support. The tablet is powered by an NVIDIA Tegra 2 SoC, and includes 1GB of RAM, 16GB of flash memory, dual cameras, HDMI, USB, microSD and 3G and WiFi connectivity. A dock enables instant connectivity with the OEM TV, including HDMI for video and audio, and USB for touch input (a wireless version is in the works as well).<br /><br />The devs customized Android to support 1080p output, and it appears to work quite seamlessly, as you'll see in the embedded video. And this isn't simply another goofy demo or proof of concept -- the Turkish company is in talks with education and enterprise customers and hopes to bring this setup to production as a more power- and cost-efficient smart board alternative. The company eventually hopes to offer displays in a variety of sizes, that will all be powered by a pocketable device, such as a smartphone, but watch in wonder as the 65-inch proto we have today struts its stuff in the video after the break.</span><br />
<span class="Apple-style-span" style="background-color: white; color: #444444; font-family: georgia; font-size: 14px; line-height: 19px;">source : </span><a href="http://www.engadget.com/2011/11/14/turkish-company-builds-65-inch-android-tablet-with-honeycomb/">http://www.engadget.com/2011/11/14/turkish-company-builds-65-inch-android-tablet-with-honeycomb/</a>Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-67174461794618649002011-11-11T06:46:00.001+02:002011-11-11T06:47:41.255+02:00Default MYSQL Engine for MYSQL Cluster<br />
<div class="vote">
<a class="vote-up-off" href="" title="This question shows research effort; it is useful and clear (click again to undo)"></a>
<span class="vote-count-post">4</span>
<a class="vote-down-off" href="" title="This question does not show any research effort; it is unclear or not useful (click again to undo)">down vote</a>
<a class="star-off" href="http://stackoverflow.com/questions/4764974/change-mysql-default-engine-to-innodb#" title="This is a favorite question (click again to undo)">favorite</a>
<div class="favoritecount">
<b>1</b></div>
<script>
</script>
<a class="fb-share" href="" id="fb-share-4764974" title="share link to this question on Facebook">share [fb]</a>
<a class="twitter-share" href="" id="twitter-share-4764974" title="share link to this question on Twitter">share [tw]</a>
</div>
<div>
<div class="post-text">
I am using mac and I installed mysql using homebrew. <br />
<pre class="lang-sql prettyprint"><code><span class="pln">brew install mysql</span></code></pre>
pretty standard installation.<br />
<pre class="lang-sql prettyprint"><code><span class="pln">mysql</span><span class="pun">></span><span class="pln"> show engines</span><span class="pun">;</span><span class="pln">
</span><span class="pun">+</span><span class="com">------------+---------+------------------------------------------------------------+--------------+------+------------+</span><span class="pln">
</span><span class="pun">|</span><span class="pln"> Engine </span><span class="pun">|</span><span class="pln"> Support </span><span class="pun">|</span><span class="pln"> Comment </span><span class="pun">|</span><span class="pln"> Transactions </span><span class="pun">|</span><span class="pln"> XA </span><span class="pun">|</span><span class="pln"> Savepoints </span><span class="pun">|</span><span class="pln">
</span><span class="pun">+</span><span class="com">------------+---------+------------------------------------------------------------+--------------+------+------------+</span><span class="pln">
</span><span class="pun">|</span><span class="pln"> MRG_MYISAM </span><span class="pun">|</span><span class="pln"> YES </span><span class="pun">|</span><span class="pln"> Collection </span><span class="kwd">of</span><span class="pln"> identical MyISAM tables </span><span class="pun">|</span><span class="pln"> NO </span><span class="pun">|</span><span class="pln"> NO </span><span class="pun">|</span><span class="pln"> NO </span><span class="pun">|</span><span class="pln">
</span><span class="pun">|</span><span class="pln"> CSV </span><span class="pun">|</span><span class="pln"> YES </span><span class="pun">|</span><span class="pln"> CSV storage engine </span><span class="pun">|</span><span class="pln"> NO </span><span class="pun">|</span><span class="pln"> NO </span><span class="pun">|</span><span class="pln"> NO </span><span class="pun">|</span><span class="pln">
</span><span class="pun">|</span><span class="pln"> MyISAM </span><span class="pun">|</span><span class="pln"> </span><span class="kwd">DEFAULT</span><span class="pln"> </span><span class="pun">|</span><span class="pln"> </span><span class="kwd">Default</span><span class="pln"> engine </span><span class="kwd">as</span><span class="pln"> </span><span class="kwd">of</span><span class="pln"> MySQL </span><span class="lit">3.23</span><span class="pln"> </span><span class="kwd">with</span><span class="pln"> great performance </span><span class="pun">|</span><span class="pln"> NO </span><span class="pun">|</span><span class="pln"> NO </span><span class="pun">|</span><span class="pln"> NO </span><span class="pun">|</span><span class="pln">
</span><span class="pun">|</span><span class="pln"> InnoDB </span><span class="pun">|</span><span class="pln"> YES </span><span class="pun">|</span><span class="pln"> Supports transactions</span><span class="pun">,</span><span class="pln"> row-level locking</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">and</span><span class="pln"> </span><span class="kwd">foreign</span><span class="pln"> keys </span><span class="pun">|</span><span class="pln"> YES </span><span class="pun">|</span><span class="pln"> YES </span><span class="pun">|</span><span class="pln"> YES </span><span class="pun">|</span><span class="pln">
</span><span class="pun">|</span><span class="pln"> MEMORY </span><span class="pun">|</span><span class="pln"> YES </span><span class="pun">|</span><span class="pln"> Hash based</span><span class="pun">,</span><span class="pln"> stored </span><span class="kwd">in</span><span class="pln"> memory</span><span class="pun">,</span><span class="pln"> useful </span><span class="kwd">for</span><span class="pln"> temporary tables </span><span class="pun">|</span><span class="pln"> NO </span><span class="pun">|</span><span class="pln"> NO </span><span class="pun">|</span><span class="pln"> NO </span><span class="pun">|</span><span class="pln">
</span><span class="pun">+</span><span class="com">------------+---------+------------------------------------------------------------+--------------+------+------------+</span><span class="pln">
</span></code></pre>
I would like innodb to be the default storage engine. What do I need to do?<br />
<br />
<br />
<br />
<div class="post-text">
Under <code>[mysqld]</code> section in your ini file, add:<br />
<pre class="lang-sql prettyprint"><code><span class="pln">default-storage-engine </span><span class="pun">=</span><span class="pln"> innodb</span></code></pre>
It is usually <code>/etc/my.cnf</code>, but not sure about Mac.<br />
From the <a href="http://dev.mysql.com/doc/refman/5.1/en/option-files.html" rel="nofollow">docs</a>:<br />
<blockquote>
On Unix, Linux and Mac OS X, MySQL programs read startup options
from the following files, in the specified order (top items are used
first).<br />
<pre class="lang-sql prettyprint"><code><span class="kwd">File</span><span class="pln"> Name Purpose
</span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">my</span><span class="pun">.</span><span class="pln">cnf Global options</span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">mysql</span><span class="pun">/</span><span class="pln">my</span><span class="pun">.</span><span class="pln">cnf Global options </span><span class="pun">(</span><span class="kwd">as</span><span class="pln"> </span><span class="kwd">of</span><span class="pln"> MySQL </span><span class="lit">5.1.15</span><span class="pun">)</span><span class="pln">
SYSCONFDIR</span><span class="pun">/</span><span class="pln">my</span><span class="pun">.</span><span class="pln">cnf Global options</span><span class="pun">$</span><span class="pln">MYSQL_HOME</span><span class="pun">/</span><span class="pln">my</span><span class="pun">.</span><span class="pln">cnf Server-specific options
defaults-extra-file The </span><span class="kwd">file</span><span class="pln"> specified </span><span class="kwd">with</span><span class="pln"> </span><span class="com">--defaults-extra-file=path, if any</span><span class="pln">
</span><span class="pun">~/.</span><span class="pln">my</span><span class="pun">.</span><span class="pln">cnf User-specific options</span></code></pre>
</blockquote>
The last one is never used by the daemon.<br />
<br />
<br />
<br />
<br />
http://linuxgazette.net/168/nielsen.html<br />
<br /></div>
</div>
</div>Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-33127791319676927542011-11-11T05:49:00.001+02:002011-11-11T05:49:15.795+02:00MYSQL User ADD<br />
<pre>#
# Connect to the local database server as user root
# You will be prompted for a password.
#
mysql -h localhost -u root -p
#
# Now we see the 'mysql>' prompt and we can run
# the following to create a new database for Paul.
#
mysql> create database pauldb;
Query OK, 1 row affected (0.00 sec)
#
# Now we create the user paul and give him full
# permissions on the new database
mysql> grant CREATE,INSERT,DELETE,UPDATE,SELECT on pauldb.* to paul@localhost;
Query OK, 0 rows affected (0.00 sec)
#
# Next we set a password for this new user
#
mysql> set password for paul = password('mysecretpassword');
Query OK, 0 rows affected (0.00 sec)
#
# Cleanup and ext
mysql> flush privileges;
mysql> exit;
</pre>Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0tag:blogger.com,1999:blog-4630029198809027581.post-25573208477956652022011-11-11T04:18:00.001+02:002011-11-11T04:21:01.275+02:00MYSQL Cluster On Ubuntu<span class="Apple-style-span" style="background-color: white; font-family: Verdana, Geneva, sans-serif; font-size: 12px; line-height: 18px;"></span><br />
<div style="margin-bottom: 1.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;">
This article will take you through setting up MySql cluster. As we will be using mysql-cluster tar package, this guide should work with most distros, including fedora, ubuntu. I am testing cluster on centos.</div>
<div style="margin-bottom: 1.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;">
For this you need 3 servers, two of which will work as storage cluster & one as management server.<br />cluster1 192.168.1.2<br />cluster2 192.168.1.3<br />cluster3 192.168.1.1 – management server</div>
<div style="margin-bottom: 1.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;">
<a href="http://www.mysql.com/downloads/cluster/" style="color: #006699;" target="_blank">Download mysql-cluster</a><br />(here we are using mysql-cluster-gpl-7.1.9a-linux-i686-glibc23.tar.gz as latest one available while this post was written.)</div>
<div style="margin-bottom: 1.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;">
<strong style="font-style: inherit; font-weight: bold;">Install MySQL on the first two servers ON CLUSTER1 & CLUSTER2</strong></div>
<div class="wp_syntax" style="background-color: #f9f9f9; border-bottom-color: silver; border-bottom-style: solid; border-bottom-width: 1px; border-left-color: silver; border-left-style: solid; border-left-width: 1px; border-right-color: silver; border-right-style: solid; border-right-width: 1px; border-top-color: silver; border-top-style: solid; border-top-width: 1px; color: #110000; margin-bottom: 1.5em; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: hidden; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 580px;">
<div class="code" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 2px; padding-left: 4px; padding-right: 4px; padding-top: 2px; vertical-align: top;">
<pre class="bash" style="clear: none; float: none; font-family: monospace; font-size: 12px; line-height: 1.333; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; white-space: pre; width: auto;"><span style="color: #666666; font-style: italic;">#Create Mysql user</span>
groupadd mysql
useradd <span style="color: #660033;">-g</span> mysql mysql
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: black; font-weight: bold;">/</span>usr<span style="color: black; font-weight: bold;">/</span>local<span style="color: black; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf <span style="color: black; font-weight: bold;">/</span>downloads<span style="color: black; font-weight: bold;">/</span>mysql-cluster-gpl-7.1.9a-linux-i686-glibc23.tar.gz
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> mysql-cluster-gpl-7.1.9a-linux-i686-glibc23 mysql
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: black; font-weight: bold;">/</span>usr<span style="color: black; font-weight: bold;">/</span>local<span style="color: black; font-weight: bold;">/</span>mysql
scripts<span style="color: black; font-weight: bold;">/</span>mysql_install_db <span style="color: #660033;">--user</span>=mysql
<span style="color: #666666; font-style: italic;">#change permission</span>
<span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> root .
<span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> mysql data
<span style="color: #c20cb9; font-weight: bold;">chgrp</span> <span style="color: #660033;">-R</span> mysql .
<span style="color: #666666; font-style: italic;">#init script</span>
<span style="color: #c20cb9; font-weight: bold;">cp</span> support-files<span style="color: black; font-weight: bold;">/</span>mysql.server <span style="color: black; font-weight: bold;">/</span>etc<span style="color: black; font-weight: bold;">/</span>rc.d<span style="color: black; font-weight: bold;">/</span>init.d<span style="color: black; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: black; font-weight: bold;">/</span>etc<span style="color: black; font-weight: bold;">/</span>rc.d<span style="color: black; font-weight: bold;">/</span>init.d<span style="color: black; font-weight: bold;">/</span>mysql.server
chkconfig <span style="color: #660033;">--add</span> mysql.server</pre>
</div>
</div>
<div style="margin-bottom: 1.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;">
<strong style="font-style: inherit; font-weight: bold;">Install and configure the management server ON CLUSTER3</strong></div>
<div class="wp_syntax" style="background-color: #f9f9f9; border-bottom-color: silver; border-bottom-style: solid; border-bottom-width: 1px; border-left-color: silver; border-left-style: solid; border-left-width: 1px; border-right-color: silver; border-right-style: solid; border-right-width: 1px; border-top-color: silver; border-top-style: solid; border-top-width: 1px; color: #110000; margin-bottom: 1.5em; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: hidden; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 580px;">
<div class="code" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 2px; padding-left: 4px; padding-right: 4px; padding-top: 2px; vertical-align: top;">
<pre class="bash" style="clear: none; float: none; font-family: monospace; font-size: 12px; line-height: 1.333; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; white-space: pre; width: auto;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: black; font-weight: bold;">/</span>usr<span style="color: black; font-weight: bold;">/</span>src
<span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf <span style="color: black; font-weight: bold;">/</span>downloads<span style="color: black; font-weight: bold;">/</span>mysql-cluster-gpl-7.1.9a-linux-i686-glibc23.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> mysql-cluster-gpl-7.1.9a-linux-i686-glibc23<span style="color: black; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> bin<span style="color: black; font-weight: bold;">/</span>ndb_mgm .
<span style="color: #c20cb9; font-weight: bold;">mv</span> bin<span style="color: black; font-weight: bold;">/</span>ndb_mgmd .
<span style="color: #c20cb9; font-weight: bold;">chmod</span> +x ndb_mg<span style="color: black; font-weight: bold;">*</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> ndb_mg<span style="color: black; font-weight: bold;">*</span> <span style="color: black; font-weight: bold;">/</span>usr<span style="color: black; font-weight: bold;">/</span>bin<span style="color: black; font-weight: bold;">/</span>
<span style="color: #7a0874; font-weight: bold;">cd</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: black; font-weight: bold;">/</span>usr<span style="color: black; font-weight: bold;">/</span>src<span style="color: black; font-weight: bold;">/</span>mysql-cluster-gpl-7.1.9a-linux-i686-glibc23<span style="color: black; font-weight: bold;">/</span></pre>
</div>
</div>
<div style="margin-bottom: 1.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;">
<strong style="font-style: inherit; font-weight: bold;">You now need to set up the config file ON CLUSTER3</strong></div>
<div class="wp_syntax" style="background-color: #f9f9f9; border-bottom-color: silver; border-bottom-style: solid; border-bottom-width: 1px; border-left-color: silver; border-left-style: solid; border-left-width: 1px; border-right-color: silver; border-right-style: solid; border-right-width: 1px; border-top-color: silver; border-top-style: solid; border-top-width: 1px; color: #110000; margin-bottom: 1.5em; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: hidden; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 580px;">
<div class="code" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 2px; padding-left: 4px; padding-right: 4px; padding-top: 2px; vertical-align: top;">
<pre class="bash" style="clear: none; float: none; font-family: monospace; font-size: 12px; line-height: 1.333; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; white-space: pre; width: auto;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: black; font-weight: bold;">/</span>var<span style="color: black; font-weight: bold;">/</span>lib<span style="color: black; font-weight: bold;">/</span>mysql-cluster
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: black; font-weight: bold;">/</span>var<span style="color: black; font-weight: bold;">/</span>lib<span style="color: black; font-weight: bold;">/</span>mysql-cluster
<span style="color: #c20cb9; font-weight: bold;">vi</span> config.ini
<span style="color: #7a0874; font-weight: bold;">[</span>NDBD DEFAULT<span style="color: #7a0874; font-weight: bold;">]</span>
<span style="color: #007800;">NoOfReplicas</span>=<span style="color: black;">2</span>
<span style="color: #7a0874; font-weight: bold;">[</span>MYSQLD DEFAULT<span style="color: #7a0874; font-weight: bold;">]</span>
<span style="color: #7a0874; font-weight: bold;">[</span>NDB_MGMD DEFAULT<span style="color: #7a0874; font-weight: bold;">]</span>
<span style="color: #7a0874; font-weight: bold;">[</span>TCP DEFAULT<span style="color: #7a0874; font-weight: bold;">]</span>
<span style="color: #666666; font-style: italic;"># Managment Server</span>
<span style="color: #7a0874; font-weight: bold;">[</span>NDB_MGMD<span style="color: #7a0874; font-weight: bold;">]</span>
<span style="color: #007800;">HostName</span>=192.168.1.1 <span style="color: #666666; font-style: italic;"># the IP of THIS SERVER</span>
<span style="color: #666666; font-style: italic;"># Storage Engines</span>
<span style="color: #7a0874; font-weight: bold;">[</span>NDBD<span style="color: #7a0874; font-weight: bold;">]</span>
<span style="color: #007800;">HostName</span>=192.168.1.2 <span style="color: #666666; font-style: italic;"># the IP of the FIRST SERVER</span>
<span style="color: #007800;">DataDir</span>= <span style="color: black; font-weight: bold;">/</span>var<span style="color: black; font-weight: bold;">/</span>lib<span style="color: black; font-weight: bold;">/</span>mysql-cluster
<span style="color: #7a0874; font-weight: bold;">[</span>NDBD<span style="color: #7a0874; font-weight: bold;">]</span>
<span style="color: #007800;">HostName</span>=192.168.1.3 <span style="color: #666666; font-style: italic;"># the IP of the SECOND SERVER</span>
<span style="color: #007800;">DataDir</span>=<span style="color: black; font-weight: bold;">/</span>var<span style="color: black; font-weight: bold;">/</span>lib<span style="color: black; font-weight: bold;">/</span>mysql-cluster
<span style="color: #666666; font-style: italic;"># 2 MySQL Clients</span>
<span style="color: #7a0874; font-weight: bold;">[</span>MYSQLD<span style="color: #7a0874; font-weight: bold;">]</span>
<span style="color: #7a0874; font-weight: bold;">[</span>MYSQLD<span style="color: #7a0874; font-weight: bold;">]</span></pre>
</div>
</div>
<div style="margin-bottom: 1.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;">
<code style="font-style: inherit; margin-bottom: 1.5em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">mkdir -p /usr/local/mysql/mysql-cluster</code></div>
<ins style="border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; display: inline-table; height: 15px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: relative; text-decoration: underline; visibility: visible; width: 468px;"><ins id="aswift_1_anchor" style="border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; display: block; height: 15px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: relative; text-decoration: underline; visibility: visible; width: 468px;"><iframe allowtransparency="true" frameborder="0" height="15" hspace="0" id="aswift_1" marginheight="0" marginwidth="0" name="aswift_1" scrolling="no" style="left: 0px; position: absolute; top: 0px;" vspace="0" width="468"></iframe></ins></ins><div style="margin-bottom: 1.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;">
</div>
<div style="margin-bottom: 1.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;">
Now, start the managment server:<br /><code style="font-style: inherit; margin-bottom: 1.5em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">ndb_mgmd</code></div>
<div style="margin-bottom: 1.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;">
<strong style="font-style: inherit; font-weight: bold;">Configure the storage/SQL servers and start mysql ON CLUSTER1 & CLUSTER2</strong></div>
<div class="wp_syntax" style="background-color: #f9f9f9; border-bottom-color: silver; border-bottom-style: solid; border-bottom-width: 1px; border-left-color: silver; border-left-style: solid; border-left-width: 1px; border-right-color: silver; border-right-style: solid; border-right-width: 1px; border-top-color: silver; border-top-style: solid; border-top-width: 1px; color: #110000; margin-bottom: 1.5em; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: hidden; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 580px;">
<div class="code" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 2px; padding-left: 4px; padding-right: 4px; padding-top: 2px; vertical-align: top;">
<pre class="bash" style="clear: none; float: none; font-family: monospace; font-size: 12px; line-height: 1.333; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; white-space: pre; width: auto;"><span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: black; font-weight: bold;">/</span>etc<span style="color: black; font-weight: bold;">/</span>my.cnf
<span style="color: #7a0874; font-weight: bold;">[</span>mysqld<span style="color: #7a0874; font-weight: bold;">]</span>
ndbcluster
ndb-connectstring=192.168.1.1 <span style="color: #666666; font-style: italic;"># the IP of the MANAGMENT (THIRD) SERVER</span>
<span style="color: #7a0874; font-weight: bold;">[</span>mysql_cluster<span style="color: #7a0874; font-weight: bold;">]</span>
ndb-connectstring=192.168.1.1 <span style="color: #666666; font-style: italic;"># the IP of the MANAGMENT (THIRD) SERVER</span>
<span style="color: #666666; font-style: italic;">#Now, we make the data directory and start the storage engine:</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: black; font-weight: bold;">/</span>var<span style="color: black; font-weight: bold;">/</span>lib<span style="color: black; font-weight: bold;">/</span>mysql-cluster
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: black; font-weight: bold;">/</span>var<span style="color: black; font-weight: bold;">/</span>lib<span style="color: black; font-weight: bold;">/</span>mysql-cluster
<span style="color: black; font-weight: bold;">/</span>usr<span style="color: black; font-weight: bold;">/</span>local<span style="color: black; font-weight: bold;">/</span>mysql<span style="color: black; font-weight: bold;">/</span>bin<span style="color: black; font-weight: bold;">/</span>ndbd <span style="color: #660033;">--initial</span>
<span style="color: black; font-weight: bold;">/</span>etc<span style="color: black; font-weight: bold;">/</span>rc.d<span style="color: black; font-weight: bold;">/</span>init.d<span style="color: black; font-weight: bold;">/</span>mysql.server start</pre>
</div>
</div>
<div style="margin-bottom: 1.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;">
<strong style="font-style: inherit; font-weight: bold;">Check if its working ON CLUSTER3</strong> using ndb_mgm</div>
<div class="wp_syntax" style="background-color: #f9f9f9; border-bottom-color: silver; border-bottom-style: solid; border-bottom-width: 1px; border-left-color: silver; border-left-style: solid; border-left-width: 1px; border-right-color: silver; border-right-style: solid; border-right-width: 1px; border-top-color: silver; border-top-style: solid; border-top-width: 1px; color: #110000; margin-bottom: 1.5em; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: hidden; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 580px;">
<div class="code" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 2px; padding-left: 4px; padding-right: 4px; padding-top: 2px; vertical-align: top;">
<pre class="bash" style="clear: none; float: none; font-family: monospace; font-size: 12px; line-height: 1.333; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; white-space: pre; width: auto;"><span style="color: #7a0874; font-weight: bold;">[</span>root<span style="color: black; font-weight: bold;">@</span>c3 mysql-cluster<span style="color: #7a0874; font-weight: bold;">]</span><span style="color: #666666; font-style: italic;"># ndb_mgm</span>
<span style="color: #660033;">--</span> NDB Cluster <span style="color: #660033;">--</span> Management Client <span style="color: #660033;">--</span>
ndb_mgm<span style="color: black; font-weight: bold;">></span> show
Connected to Management Server at: localhost:<span style="color: black;">1186</span>
Cluster Configuration
<span style="color: #660033;">---------------------</span>
<span style="color: #7a0874; font-weight: bold;">[</span>ndbd<span style="color: #7a0874; font-weight: bold;">(</span>NDB<span style="color: #7a0874; font-weight: bold;">)</span><span style="color: #7a0874; font-weight: bold;">]</span> <span style="color: black;">2</span> node<span style="color: #7a0874; font-weight: bold;">(</span>s<span style="color: #7a0874; font-weight: bold;">)</span>
<span style="color: #007800;">id</span>=<span style="color: black;">2</span> <span style="color: black; font-weight: bold;">@</span>192.168.1.2 <span style="color: #7a0874; font-weight: bold;">(</span>mysql-5.1.51 ndb-7.1.9, Nodegroup: <span style="color: black;">0</span>, Master<span style="color: #7a0874; font-weight: bold;">)</span>
<span style="color: #007800;">id</span>=<span style="color: black;">3</span> <span style="color: black; font-weight: bold;">@</span>192.168.1.3 <span style="color: #7a0874; font-weight: bold;">(</span>mysql-5.1.51 ndb-7.1.9, Nodegroup: <span style="color: black;">0</span><span style="color: #7a0874; font-weight: bold;">)</span>
<span style="color: #7a0874; font-weight: bold;">[</span>ndb_mgmd<span style="color: #7a0874; font-weight: bold;">(</span>MGM<span style="color: #7a0874; font-weight: bold;">)</span><span style="color: #7a0874; font-weight: bold;">]</span> <span style="color: black;">1</span> node<span style="color: #7a0874; font-weight: bold;">(</span>s<span style="color: #7a0874; font-weight: bold;">)</span>
<span style="color: #007800;">id</span>=<span style="color: black;">1</span> <span style="color: black; font-weight: bold;">@</span>192.168.1.1 <span style="color: #7a0874; font-weight: bold;">(</span>mysql-5.1.51 ndb-7.1.9<span style="color: #7a0874; font-weight: bold;">)</span>
<span style="color: #7a0874; font-weight: bold;">[</span>mysqld<span style="color: #7a0874; font-weight: bold;">(</span>API<span style="color: #7a0874; font-weight: bold;">)</span><span style="color: #7a0874; font-weight: bold;">]</span> <span style="color: black;">2</span> node<span style="color: #7a0874; font-weight: bold;">(</span>s<span style="color: #7a0874; font-weight: bold;">)</span>
<span style="color: #007800;">id</span>=<span style="color: black;">4</span> <span style="color: black; font-weight: bold;">@</span>192.168.1.2 <span style="color: #7a0874; font-weight: bold;">(</span>mysql-5.1.51 ndb-7.1.9<span style="color: #7a0874; font-weight: bold;">)</span>
<span style="color: #007800;">id</span>=<span style="color: black;">5</span> <span style="color: black; font-weight: bold;">@</span>192.168.1.3 <span style="color: #7a0874; font-weight: bold;">(</span>mysql-5.1.51 ndb-7.1.9<span style="color: #7a0874; font-weight: bold;">)</span></pre>
</div>
</div>
<div style="margin-bottom: 1.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;">
<strong style="font-style: inherit; font-weight: bold;">Stop Cluster</strong><br />To stop cluster run <strong style="font-style: inherit; font-weight: bold;">shutdown</strong> command in <strong style="font-style: inherit; font-weight: bold;">ndb_mgm</strong> Console<br />On storage clusters <code style="font-style: inherit; margin-bottom: 1.5em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">/etc/init.d/mysql.server stop</code></div>
<div style="margin-bottom: 1.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;">
<strong style="font-style: inherit; font-weight: bold;">Start Cluster</strong><br />Management Server -Cluster3<br /><code style="font-style: inherit; margin-bottom: 1.5em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">ndb_mgmd -f /var/lib/mysql-cluster/config.ini</code></div>
<div style="margin-bottom: 1.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;">
Storage Clusters -Cluster1 & Cluster2<br /><code style="font-style: inherit; margin-bottom: 1.5em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">/usr/local/mysql/bin/ndbd<br />/etc/init.d/mysql.server start</code></div>
<div style="margin-bottom: 1.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;">
While creating tables make sure ENGINE=NDBCLUSTER</div>
<div style="margin-bottom: 1.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;">
---------------------------------------------------------------------------------------------------------------</div>
<div style="background-color: white; color: #333333; line-height: 16px; margin-bottom: 8px; margin-left: 15px; margin-right: 0px; margin-top: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">
<div id="header" style="background-attachment: initial; background-clip: initial; background-color: initial; background-origin: initial; background-position: 0% 0%; display: block; font-size: 14px; height: 115px; width: 780px;">
<a href="http://www.lod.com/" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: blue; text-decoration: none;"><img alt="UNIX and Linux Internet Consulting by LOD.com" border="0" height="90" src="http://www.lod.com/images/dot.gif" style="display: block;" title="MySQL Cluster HowTo by LOD.com" width="740" /></a></div>
<table border="0" cellpadding="0" cellspacing="0" style="font-size: 14px; width: 740px;"><tbody>
<tr><td height="20" width="220"><a href="http://www.lod.com/" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: blue; text-decoration: none;"><img alt="" border="0" height="20" src="http://www.lod.com/images/header2.jpg" width="220" /></a></td><td halign="left" valign="top" width="500"><span style="font-family: arial; font-size: xx-small;"><a href="http://www.lod.com/unix-consulting.html" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: blue; text-decoration: none;">Unix Consulting</a> / <a href="http://www.lod.com/cisco-consulting.html" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: blue; text-decoration: none;">Cisco Consulting</a> / <a href="http://www.lod.com/linux-consulting.html" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: blue; text-decoration: none;">Linux Consulting</a> / <a href="http://www.lod.com/mysql-consulting.html" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: blue; text-decoration: none;">MySQL Consulting</a> / <a href="http://www.lod.com/sun-solaris.html" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: blue; text-decoration: none;">Solaris Consulting</a></span></td></tr>
</tbody></table>
<br /><div id="threecolwrap" style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; display: block; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 780px;">
<div class="clear" style="clear: both; display: block; font-size: 14px;">
</div>
<div id="leftcol">
<div id="centercol" style="width: 750px;">
<div class="padding">
<br /><big style="font-size: 14px;"><big>MySQL Cluster Server Setup</big><br />Version 1.0 - 2/11/2005<br /><br /><span style="font-family: arial;"><a href="http://www.lod.com/" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: blue; text-decoration: none;"><small>LOD Communications, Inc.<br />(800) 959-6641<br />http://www.lod.com</small></a></span><br />Introduction</big><span class="Apple-style-span" style="font-size: 14px;">MySQL Cluser Server is a fault-tolerant, redundant, scalable database architecture built on the open-source MySQL application, and capable of delivering 99.999% reliability. In this paper we describe the process we used to setup, configure, and test a three-node mySQL cluster server in a test environment.</span><br /><br /><big style="font-size: 14px;"><small><big>Schematic<small><br /><br /><img alt="" src="http://www.lod.com/whitepapers/mysql-cluster-1.jpg" style="height: 446px; width: 631px;" /><br /><br /><big>Hardware<small><br />We used four Sun Ultra Enterprise servers in our test environment, but the process for setting up a mySQL cluster server on other UNIX- or Linux-based platforms is very similar, and this setup guide should be applicable with little or no modification.<br /><br />Our four machines each fall into one of three roles:<br /><br />1. storage nodes (<span style="font-weight: bold;">mysql-ndb-1</span> and <span style="font-weight: bold;">mysql-ndb-2</span>)<br />2. API node (<span style="font-weight: bold;">mysql-api-1</span>)<br />3. management server and management console (<span style="font-weight: bold;">mgmt<span style="font-weight: bold;"></span></span>)</small></big></small></big><br />Note that the storage nodes are also API nodes, but the API node is not a storage node. The API node is a full member of the cluster, but it does not store any cluster data, and its state (whether it is up or down) does not affect the integrity or availablility of the data on the storage nodes. It can be thought of as a "client" of the cluster. Applications such as web servers live on the API nodes and communicate with the mySQL server process running locally, on the API node itself, which takes care of fetching data from the storage nodes. The storage nodes are API nodes as well, and technically additional applications could be installed there and communicate with the cluster via the mySQL server processes running on them, but for management and performance reasons this probably should be considered a sub-optimal configuration in a production environment.<br /><br /><big>Software<small><br />Sun Solaris 8 operating system<br />mysql-max-4.1.9</small></big></small></big><big style="font-size: 14px;"><small><br />We used the precompiled binary distribution of mySQL server for Sun SPARC Solaris 8. Obviously, for implementation on other platforms, the appropriate binary distribution should be used. In all cases, the "max" mySQL distribution is required. The mySQL 4.1 download page can be found <a href="http://dev.mysql.com/downloads/mysql/4.1.html" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: blue; text-decoration: none;">here</a>.<br /><br /><big>Procedure</big></small></big><br /><span style="color: red; font-size: 14px;">Step 1</span><span class="Apple-style-span" style="font-size: 14px;">. On both storage nodes, </span><big style="font-size: 14px;"><small><big><small><big><small><span style="font-weight: bold;">mysql-ndb-1</span> (192.168.0.33) and <span style="font-weight: bold;">mysql-ndb-2</span> (192.168.0.34)<span style="font-weight: bold;">, </span></small></big></small></big></small></big><big style="font-size: 14px;"><small><big><small><big><small>obtain and install mySQL server:</small></big></small></big></small></big><br /><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;">mysql-ndb-1</span><span style="font-family: monospace;"># <span style="font-weight: bold;">groupadd mysql</span><br /><span style="font-weight: bold;"></span></span><span style="font-family: monospace;">mysql-ndb-1</span><span style="font-family: monospace;">#<span style="font-weight: bold;"> useradd -g mysql mysql</span></span><span style="font-family: monospace;">mysql-ndb-1#</span><span style="font-family: monospace;"> <span style="font-weight: bold;">cd /usr/local</span></span><span style="font-family: monospace; font-weight: bold;"><span style="font-weight: bold;"></span></span><span style="font-family: monospace;">mysql-ndb-1</span><span style="font-family: monospace;">#</span><span style="font-family: monospace; font-weight: bold;"> wget http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-max-4.1.9-sun-solaris2.8-sparc.tar.gz/from/http://mysql.he.net/</span><br style="font-family: monospace;" /><span style="font-family: monospace;">mysql-ndb-1</span><span style="font-family: monospace;">#</span><span style="font-family: monospace;"> <span style="font-weight: bold;">gzip -dc </span></span><span style="font-family: monospace; font-weight: bold;">mysql-max-4.1.9-sun-solaris2.8-sparc.tar.gz | tar xvf -</span><br style="font-family: monospace;" /><span style="font-family: monospace;">mysql-ndb-1</span><span style="font-family: monospace;">#</span><span style="font-family: monospace;"> <span style="font-weight: bold;">ln -s </span></span><span style="font-family: monospace; font-weight: bold;">mysql-max-4.1.9-sun-solaris2.8-sparc</span><span style="font-family: monospace;"><span style="font-weight: bold;"> mysql</span><br /><span style="font-weight: bold;"></span></span><span style="font-family: monospace;"></span><span style="font-family: monospace;">mysql-ndb-1</span><span style="font-family: monospace;">#</span><span style="font-family: monospace;"> <span style="font-weight: bold;">cd mysql</span></span><br /><span style="font-family: monospace;">mysql-ndb-1</span><span style="font-family: monospace;"># <span style="font-weight: bold;">scripts/mysql_install_db --user=mysql</span><br />mysql-ndb-1#<span style="font-weight: bold;"> chown -R root .</span><br />mysql-ndb-1# <span style="font-weight: bold;">chown -R mysql data</span><br />mysql-ndb-1# <span style="font-weight: bold;">chgrp -R mysql .</span></span><span style="font-family: monospace;">mysql-ndb-1# <span style="font-weight: bold;">cp support-files/mysql.server /etc/init.d/</span></span><span style="font-family: monospace; font-weight: bold;">mysql.server</span><span style="font-family: monospace;"><br /></span><span style="font-family: monospace;">mysql-ndb-2</span><span style="font-family: monospace;"># <span style="font-weight: bold;">groupadd mysql</span><br /><span style="font-weight: bold;"></span></span><span style="font-family: monospace;">mysql-ndb-2</span><span style="font-family: monospace;">#<span style="font-weight: bold;"> useradd -g mysql mysql</span></span><span style="font-family: monospace;">mysql-ndb-2#</span><span style="font-family: monospace;"> <span style="font-weight: bold;">cd /usr/local</span></span><span style="font-family: monospace; font-weight: bold;"><span style="font-weight: bold;"></span></span><span style="font-family: monospace;">mysql-ndb-2</span><span style="font-family: monospace;">#</span><span style="font-family: monospace; font-weight: bold;"> wget http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-max-4.1.9-sun-solaris2.8-sparc.tar.gz/from/http://mysql.he.net/</span><br style="font-family: monospace;" /><span style="font-family: monospace;">mysql-ndb-2</span><span style="font-family: monospace;">#</span><span style="font-family: monospace;"> <span style="font-weight: bold;">gzip -dc </span></span><span style="font-family: monospace; font-weight: bold;">mysql-max-4.1.9-sun-solaris2.8-sparc.tar.gz | tar xvf -</span><br style="font-family: monospace;" /><span style="font-family: monospace;">mysql-ndb-2</span><span style="font-family: monospace;">#</span><span style="font-family: monospace;"> <span style="font-weight: bold;">ln -s </span></span><span style="font-family: monospace; font-weight: bold;">mysql-max-4.1.9-sun-solaris2.8-sparc</span><span style="font-family: monospace;"><span style="font-weight: bold;"> mysql</span><br /><span style="font-weight: bold;"></span></span><span style="font-family: monospace;"></span><span style="font-family: monospace;">mysql-ndb-2</span><span style="font-family: monospace;">#</span><span style="font-family: monospace;"> <span style="font-weight: bold;">cd mysql</span></span><br /><span style="font-family: monospace;">mysql-ndb-2</span><span style="font-family: monospace;"># <span style="font-weight: bold;">scripts/mysql_install_db --user=mysql</span><br />mysql-ndb-2#<span style="font-weight: bold;"> chown -R root .</span><br />mysql-ndb-2# <span style="font-weight: bold;">chown -R mysql data</span><br />mysql-ndb-2# <span style="font-weight: bold;">chgrp -R mysql .</span></span><span style="font-family: monospace;">mysql-ndb-2# <span style="font-weight: bold;">cp support-files/mysql.server /etc/init.d/</span></span><span style="font-family: monospace; font-weight: bold;">mysql.server</span><span style="font-family: monospace; font-weight: bold;"></span></div>
<br /><span class="Apple-style-span" style="font-size: 14px;"> Do not start the mysql servers yet.</span><br /><big style="font-size: 14px;"><small><br /><span style="color: red;">Step 2</span>. Setup the management server and management console on host <span style="font-weight: bold;">mgmt</span> (192.168.0.32). This requires only two executables be extracted form the mysql distribution. The rest can be deleted.<br /></small></big><div style="font-family: monospace; font-size: 14px; margin-left: 40px;">
mgmt# <span style="font-family: monospace; font-weight: bold;">gzip -dc mysql-max-4.1.9-sun-solaris2.8-sparc.tar.gz</span><span style="font-family: monospace;"><span style="font-weight: bold;"> | tar xvf -</span><br />mgmt# <span style="font-weight: bold;">cp mysql-max-4.1.9-sun-solaris2.8-sparc/bin/ndb_mgm /usr/bin</span><br />mgmt# <span style="font-weight: bold;">cp mysql-max-4.1.9-sun-solaris2.8-sparc/bin/ndb_mgmd /usr/bin</span><br />mgmt#<span style="font-weight: bold;"> rm -r mysql-max-4.1.9-sun-solaris2.8-sparc</span><br />mgmt# <span style="font-weight: bold;">mkdir /var/lib/mysql-cluster</span><br />mgmt# <span style="font-weight: bold;">cd /var/lib/mysql-cluster</span><br />mgmt# <span style="font-weight: bold;">vi config.ini</span></span></div>
<big style="font-size: 14px;"><small><br /> The file <span style="font-weight: bold;">config.ini</span> contains configuration information for the cluster:<br /></small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;">[NDBD DEFAULT]<br />NoOfReplicas=2<br />[MYSQLD DEFAULT]<br />[NDB_MGMD DEFAULT]<br />[TCP DEFAULT]<br /># Management Server<br />[NDB_MGMD]<br />HostName=192.168.0.32 # IP address of this server<br /># Storage Nodes<br />[NDBD]<br />HostName=192.168.0.33 # IP address of storage-node-1<br />DataDir= /var/lib/mysql-cluster<br />[NDBD]<br />HostName=192.168.0.34 # IP address of storage-node-2<br />DataDir=/var/lib/mysql-cluster<br /># Setup node IDs for mySQL API-servers (clients of the cluster)<br />[MYSQLD]<br />[MYSQLD]<br />[MYSQLD]<br />[MYSQLD]</span></div>
<big style="font-size: 14px;"><small><br /> Start the management server and verify that it is running:<br /></small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;">mgmt#</span><span style="font-family: monospace;"> <span style="font-weight: bold;">ndb_mgmd</span><br />mgmt# <span style="font-weight: bold;">ps -ef | grep [n]db</span></span></div>
<big style="font-size: 14px;"><small><br /><span style="color: red;">Step 3</span>. On <span style="font-weight: bold;">both</span> storage nodes, </small></big><big style="font-size: 14px;"><small><big><small><big><small><span style="font-weight: bold;">mysql-ndb-1</span> (192.168.0.33) and <span style="font-weight: bold;">mysql-ndb-2</span> (192.168.0.34)<span style="font-weight: bold;"></span></small></big></small></big></small></big><big style="font-size: 14px;"><small>, configure the mySQL servers:</small></big><big style="font-size: 14px;"><small><br /></small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />mysql-ndb-1# <span style="font-weight: bold;">vi /etc/my.cnf</span></span><span style="font-family: monospace;">mysql-ndb-2# <span style="font-weight: bold;">vi /etc/my.cnf</span></span><br /><span style="font-family: monospace;"><span style="font-weight: bold;"></span></span></div>
<big style="font-size: 14px;"><small> This is the configuration file (/etc/my.cnf) for the mysql server on both storage nodes:</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />[mysqld]<br />ndbcluster<br />ndb-connectstring='host=192.168.0.32' # IP address of the management server<br />[mysql_cluster]<br />ndb-connectstring='host=192.168.0.32' # IP address of the management server<br /></span></div>
<big style="font-size: 14px;"><small> On <span style="font-weight: bold;">both</span> storage nodes, start the NDB storage engine and mysql server and verify that they are running:<br /></small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;">mysql-ndb-1# <span style="font-weight: bold;">mkdir /var/lib/mysql-cluster</span><br />mysql-ndb-1# <span style="font-weight: bold;">cd /var/lib/mysql-cluster</span><br />mysql-ndb-1# <span style="font-weight: bold;">/usr/local/mysql/bin/ndbd --initial</span>mysql-ndb-1#<span style="font-weight: bold;"> /etc/init.d/mysql.server start</span><br />mysql-ndb-1# <span style="font-weight: bold;">ps -ef | grep [n]dbd</span></span><br style="font-family: monospace;" /><span style="font-family: monospace;">mysql-ndb-1# <span style="font-weight: bold;">ps -ef | grep [m]ysqld</span></span><br /><br /><span style="font-family: monospace;">mysql-ndb-2# <span style="font-weight: bold;">mkdir /var/lib/mysql-cluster</span><br />mysql-ndb-2# <span style="font-weight: bold;">cd /var/lib/mysql-cluster</span><br />mysql-ndb-2# <span style="font-weight: bold;">/usr/local/mysql/bin/ndbd --initial</span>mysql-ndb-2#<span style="font-weight: bold;"> /etc/init.d/mysql.server start</span><br />mysql-ndb-2# <span style="font-weight: bold;">ps -ef | grep [n]dbd</span></span><br style="font-family: monospace;" /><span style="font-family: monospace;">mysql-ndb-2# <span style="font-weight: bold;">ps -ef | grep [m]ysqld</span></span></div>
<big style="font-size: 14px;"><small><br /> If the mysql server did not startup properly, check the logfile in /usr/local/mysql/data/${HOSTNAME}.err and correct the problem.<br /><br /><span style="color: red;">Step 4</span>. Start the management console on the management server machine (<span style="font-weight: bold;">mgmt</span>) and query the status of the cluster:</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />mgmt# <span style="font-weight: bold;">ndb_mgm</span><br />-- NDB Cluster -- Management Client --<br />ndb_mgm> <span style="font-weight: bold;">show</span><br />Connected to Management Server at: localhost:1186<br />Cluster Configuration<br />---------------------<br />[ndbd(NDB)] 2 node(s)<br />id=2 @192.168.0.33 (Version: 4.1.9, starting, Nodegroup: 0, Master)<br />id=3 @192.168.0.34 (Version: 4.1.9, starting, Nodegroup: 0)<br /><br />[ndb_mgmd(MGM)] 1 node(s)<br />id=1 @192.168.0.32 (Version: 4.1.9)<br /><br />[mysqld(API)] 4 node(s)<br />id=4 (not connected, accepting connect from any host)<br />id=5 (not connected, accepting connect from any host)<br />id=6 (not connected, accepting connect from any host)<br />id=7 (not connected, accepting connect from any host)<br /><br /></span></div>
<big style="font-size: 14px;"><small><span style="color: red;">Step 5</span>. Create a test database, populate a table using the NDBCLUSTER engine, and verify correct operation:<br /></small></big><span class="Apple-style-span" style="font-size: 14px;"> On both storage node</span><span style="font-family: mon; font-size: 14px;"><span style="font-weight: bold;">s mysql-ndb-1</span> and <span style="font-weight: bold;">mysql-ndb-2</span> create the test database</span><span style="font-family: monospace; font-size: 14px;"><span style="font-weight: bold;"></span></span><big style="font-size: 14px;"><small>:</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br /></span><span style="font-family: monospace;">mysql-ndb-1# <span style="font-weight: bold;">mysql -u root</span><br />Welcome to the MySQL monitor. Commands end with ; or \g.<br />Your MySQL connection id is 1 to server version: 4.1.9-max<br /><br />Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<br /><br />mysql> <span style="font-weight: bold;">create database foo;</span><br />Query OK, 1 row affected (0.09 sec)</span><br /><br /><br /><br /><span style="font-family: monospace;">mysql-ndb-2# </span><span style="font-family: monospace;"><span style="font-weight: bold;">mysql -u root</span><br />Welcome to the MySQL monitor. Commands end with ; or \g.<br />Your MySQL connection id is 6 to server version: 4.1.9-max<br /><br />Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<br /><br />mysql> <span style="font-weight: bold;">create database foo;</span><br />Query OK, 1 row affected (0.13 sec)<span style="font-weight: bold;"><br /></span></span></div>
<big style="font-size: 14px;"><small> Back on storage node <span style="font-weight: bold;">mysql-ndb-1</span>, populate the database with a table containing some simple data:</small></big><div style="font-size: 14px; margin-left: 40px;">
<big><span style="font-family: monospace;"><br /></span><small></small></big><span style="font-family: monospace;">mysql-ndb-1# <span style="font-weight: bold;">mysql -u root</span><br />Welcome to the MySQL monitor. Commands end with ; or \g.<br />Your MySQL connection id is 1 to server version: 4.1.9-max<br /><br />Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<br /><br />mysql> <span style="font-weight: bold;">create database foo;</span><br />Query OK, 1 row affected (0.09 sec)<br /><br />mysql> <span style="font-weight: bold;">use foo;</span><br />Database changed<br />mysql> <span style="font-weight: bold;">create table test1 (i int) engine=ndbcluster;</span><br />Query OK, 0 rows affected (0.94 sec)<br /><br />mysql> <span style="font-weight: bold;">insert into test1 () values (1);</span><br />Query OK, 1 row affected (0.02 sec)<br /><br />mysql> <span style="font-weight: bold;">select * from test1;</span><br />+------+<br />| i |<br />+------+<br />| 1 |<br />+------+<br />1 row in set (0.01 sec)<br /></span></div>
<big style="font-size: 14px;"><small> Now go to storage node <span style="font-weight: bold;">mysql-ndb-2</span> and verify that the data is accessible:</small></big><big style="font-size: 14px;"><small><br /></small></big><div style="font-size: 14px; margin-left: 40px;">
<big><small><span style="font-family: monospace;"><br />mysql-ndb-2# <span style="font-weight: bold;">mysql -u root</span><br />Welcome to the MySQL monitor. Commands end with ; or \g.<br />Your MySQL connection id is 7 to server version: 4.1.9-max<br /><br />Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<br /><br />mysql> <span style="font-weight: bold;">use foo;</span><br />Reading table information for completion of table and column names<br />You can turn off this feature to get a quicker startup with -A<br /><br />Database changed<br />mysql> <span style="font-weight: bold;">select * from test1;</span><br />+------+<br />| i |<br />+------+<br />| 1 |<br />+------+<br />1 row in set (0.00 sec)</span></small></big></div>
<big style="font-size: 14px;"><small> This is a good sign, but note that it does not actually <span style="font-style: italic;">prove</span> that the data is being replicated. The storage node (</small></big><big style="font-size: 14px;"><small><span style="font-weight: bold;">mysql-ndb-2</span>) is also a cluster API node, and this test merely shows that it is able to retrieve data from the cluster. It demonstrates nothing with re</small></big><span class="Apple-style-span" style="font-size: 14px;">spect to the underlying storage mechanism in the cluster. This can be more clearly demonstrated with the following test.</span><br /><br /><span class="Apple-style-span" style="font-size: 14px;"> Kill off the NDB engine process (ndbd) on one of the storage nodes (</span><span style="font-size: 14px; font-weight: bold;">mysql-ndb-2</span><span class="Apple-style-span" style="font-size: 14px;">) in order to simulate failure of the storage engine:</span><br /><br /><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;">mysql-ndb-2# <span style="font-weight: bold;">ps -ef | grep [n]db</span><br /> root 3035 3034 0 17:28:41 ? 0:23 /usr/local/mysql/bin/ndbd --initial<br /> root 3034 1 0 17:28:41 ? 0:00 /usr/local/mysql/bin/ndbd --initial</span><span style="font-family: monospace;">mysql-ndb-2</span><span style="font-family: monospace;"># <span style="font-weight: bold;">kill -TERM 3034 3035</span><br /><span style="font-weight: bold;"></span></span><span style="font-family: monospace;">mysql-ndb-2</span><span style="font-family: monospace;"># <span style="font-weight: bold;">ps -ef | grep [n]db</span><br /></span></div>
<big style="font-size: 14px;"><small> The management server will recognize that the storage engine on mysql-ndb-2 (192.168.0.34) has failed, but his API connection is still active:</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />ndb_mgm> <span style="font-weight: bold;">show</span><br />Cluster Configuration<br />---------------------<br />[ndbd(NDB)] 2 node(s)<br />id=2 @192.168.0.33 (Version: 4.1.9, Nodegroup: 0)<br /><span style="color: #009900;">id=3 (not connected, accepting connect from 192.168.0.34)</span><br /><br />[ndb_mgmd(MGM)] 1 node(s)<br />id=1 @192.168.0.32 (Version: 4.1.9)<br /><br />[mysqld(API)] 4 node(s)<br />id=4 @192.168.0.33 (Version: 4.1.9)<br /><span style="color: #009900;">id=5 @192.168.0.34 (Version: 4.1.9)</span><br />id=6 (not connected, accepting connect from any host)<br />id=7 (not connected, accepting connect from any host)<br /></span></div>
<big style="font-size: 14px;"><small> On the first storage node (<span style="font-weight: bold;">mysql-ndb-1</span>) populate another new table with some test data:</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />mysql-ndb-1# <span style="font-weight: bold;">mysql -u root</span><br />Welcome to the MySQL monitor. Commands end with ; or \g.<br />Your MySQL connection id is 4 to server version: 4.1.9-max<br /><br />Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<br /><br />mysql> <span style="font-weight: bold;">use foo;</span><br />Reading table information for completion of table and column names<br />You can turn off this feature to get a quicker startup with -A<br /><br />Database changed<br />mysql> <span style="font-weight: bold;">create table test2 (i int) engine=ndbcluster;</span><br />Query OK, 0 rows affected (1.00 sec)<br /><br />mysql> <span style="font-weight: bold;">insert into test2 () values (2);</span><br />Query OK, 1 row affected (0.01 sec)<br /><br />mysql> <span style="font-weight: bold;">select * from test2;</span><br />+------+<br />| i |<br />+------+<br />| 2 |<br />+------+<br />1 row in set (0.01 sec)<br /></span></div>
<big style="font-size: 14px;"><small> Back on the second storage node (<span style="font-weight: bold;">mysql-ndb-2</span>) perform the same select command:</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />mysql-ndb-2# <span style="font-weight: bold;">mysql -u root</span><br />Welcome to the MySQL monitor. Commands end with ; or \g.<br />Your MySQL connection id is 9 to server version: 4.1.9-max<br /><br />Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<br /><br />mysql> <span style="font-weight: bold;">use foo;</span><br />Reading table information for completion of table and column names<br />You can turn off this feature to get a quicker startup with -A<br /><br />Database changed<br />mysql> <span style="font-weight: bold;">select * from test2</span>;<br />+------+<br />| i |<br />+------+<br />| 2 |<br />+------+<br />1 row in set (0.01 sec)<br /></span></div>
<big style="font-size: 14px;"><small> The storage engine and the API server are two separate, distinct processes that are not inherently dependent on one another. Once the ndbd storage engine process is restarted on the second storage node, the data is replicated, as the following test demonstrates.<br /><br /> First, restart the storage engine process on </small></big><big style="font-size: 14px;"><small><span style="font-weight: bold;">mysql-ndb-2</span>:</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />mysql-ndb-2# <span style="font-weight: bold;">/usr/local/mysql/bin/ndbd</span><br /></span></div>
<big style="font-size: 14px;"><small> Next, shutdown the storage engine on </small></big><big style="font-size: 14px;"><small><span style="font-weight: bold;">mysql-ndb-1</span> either using the management console or command line kill:</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />mgmt# <span style="font-weight: bold;">ndb_mgm</span><br />ndb_mgm> <span style="font-weight: bold;">show</span><br />Cluster Configuration<br />---------------------<br />[ndbd(NDB)] 2 node(s)<br />id=2 @192.168.0.33 (Version: 4.1.9, Nodegroup: 0, Master)<br />id=3 @192.168.0.34 (Version: 4.1.9, Nodegroup: 0)<br /><br />[ndb_mgmd(MGM)] 1 node(s)<br />id=1 @192.168.0.32 (Version: 4.1.9)<br /><br />[mysqld(API)] 4 node(s)<br />id=4 @192.168.0.33 (Version: 4.1.9)<br />id=5 @192.168.0.34 (Version: 4.1.9)<br />id=6 (not connected, accepting connect from any host)<br />id=7 (not connected, accepting connect from any host)<br /><br />ndb_mgm> <span style="font-weight: bold;">2 stop</span><br />Node 2 has shutdown.<br /></span></div>
<big style="font-size: 14px;"><small> Now, to determine if the SQL data was replicated when the storage engine on <span style="font-weight: bold;">mysql-ndb-2</span> was restarted, try the query on either (or both) hosts:</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />mysql-ndb-1# <span style="font-weight: bold;">mysql -u root</span><br />Welcome to the MySQL monitor. Commands end with ; or \g.<br />Your MySQL connection id is 5 to server version: 4.1.9-max<br /><br />Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<br /><br />mysql> <span style="font-weight: bold;">use foo;</span><br />Reading table information for completion of table and column names<br />You can turn off this feature to get a quicker startup with -A<br /><br />Database changed<br />mysql> <span style="font-weight: bold;">select * from test2;</span><br />+------+<br />| i |<br />+------+<br />| 2 |<br />+------+<br />1 row in set (0.01 sec)<br /><br /><br /><br /><br />mysql-ndb-2# <span style="font-weight: bold;">mysql -u root</span><br style="font-weight: bold;" />Welcome to the MySQL monitor. Commands end with ; or \g.<br />Your MySQL connection id is 10 to server version: 4.1.9-max<br /><br />Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<br /><br />mysql> <span style="font-weight: bold;">use foo;</span><br />Reading table information for completion of table and column names<br />You can turn off this feature to get a quicker startup with -A<br /><br />Database changed<br />mysql> <span style="font-weight: bold;">select * from test2;</span><br />+------+<br />| i |<br />+------+<br />| 2 |<br />+------+<br />1 row in set (0.01 sec)<br /></span></div>
<big style="font-size: 14px;"><small> This shows that the data is being replicated on both storage nodes. Restart the storage engine on <span style="font-weight: bold;">mysql-ndb-1</span>:</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />mysql-ndb-1# <span style="font-weight: bold;">/usr/local/mysql/bin/ndbd</span></span></div>
<big style="font-size: 14px;"><small><br /><br /><span style="color: red;">Step 6</span>. Next, we add a cluster API node. This node is a full member of the cluster, but does not run the NDB storage engine. Data is not replicated on this node, and it functions essentially as a "client" of the cluster server. Typically, we would install applications that require access to the mySQL data (web servers, etc) on this machine. The applications talk to the mySQL server on localhost, which then handles the underlying communication with the cluster in order to fetch the requested data.<br /><br /> First, install the mysql server on the API node <span style="font-weight: bold;">mysql-api-1</span> (192.168.0.35):</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br /></span><span style="font-family: monospace;">mysql-api-1</span><span style="font-family: monospace;"># <span style="font-weight: bold;">groupadd mysql</span><br /><span style="font-weight: bold;"></span></span><span style="font-family: monospace;">mysql-api-1</span><span style="font-family: monospace;">#<span style="font-weight: bold;"> useradd -g mysql mysql</span></span><span style="font-family: monospace;">mysql-api-1#</span><span style="font-family: monospace;"> <span style="font-weight: bold;">cd /usr/local</span></span><span style="font-family: monospace; font-weight: bold;"><span style="font-weight: bold;"></span></span><span style="font-family: monospace;">mysql-api-1</span><span style="font-family: monospace;">#</span><span style="font-family: monospace; font-weight: bold;"> wget http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-max-4.1.9-sun-solaris2.8-sparc.tar.gz/from/http://mysql.he.net/</span><br style="font-family: monospace;" /><span style="font-family: monospace;">mysql-api-1</span><span style="font-family: monospace;">#</span><span style="font-family: monospace;"> <span style="font-weight: bold;">gzip -dc </span></span><span style="font-family: monospace; font-weight: bold;">mysql-max-4.1.9-sun-solaris2.8-sparc.tar.gz | tar xvf -</span><br style="font-family: monospace;" /><span style="font-family: monospace;">mysql-api-1</span><span style="font-family: monospace;">#</span><span style="font-family: monospace;"> <span style="font-weight: bold;">ln -s </span></span><span style="font-family: monospace; font-weight: bold;">mysql-max-4.1.9-sun-solaris2.8-sparc</span><span style="font-family: monospace;"><span style="font-weight: bold;"> mysql</span><br /><span style="font-weight: bold;"></span></span><span style="font-family: monospace;"></span><span style="font-family: monospace;">mysql-api-1</span><span style="font-family: monospace;">#</span><span style="font-family: monospace;"> <span style="font-weight: bold;">cd mysql</span></span><br /><span style="font-family: monospace;">mysql-api-1</span><span style="font-family: monospace;"># <span style="font-weight: bold;">scripts/mysql_install_db --user=mysql</span><br />mysql-api-1#<span style="font-weight: bold;"> chown -R root .</span><br />mysql-api-1# <span style="font-weight: bold;">chown -R mysql data</span><br />mysql-api-1# <span style="font-weight: bold;">chgrp -R mysql .</span></span><span style="font-family: monospace;">mysql-api-1# <span style="font-weight: bold;">cp support-files/mysql.server /etc/init.d/</span></span><span style="font-family: monospace; font-weight: bold;">mysql.server</span><span style="font-family: monospace; font-weight: bold;"></span><span style="font-family: monospace;"><br /></span></div>
<big style="font-size: 14px;"><small> Install a simple /etc/my.cnf file:</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />[mysqld]<br />ndbcluster<br />ndb-connectstring='host=192.168.0.32' # IP address of the management server<br />[mysql_cluster]<br />ndb-connectstring='host=192.168.0.32' # </span><span style="font-family: monospace;">IP address of the management server<br /></span></div>
<big style="font-size: 14px;"><small> Now start the mySQL server:</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />mysql-api-1# <span style="font-weight: bold;">/etc/init.d/mysql.server start<br /></span></span></div>
<big style="font-size: 14px;"><small> Perform some test queries on the database tables we created earlier:</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />mysql-api-1# <span style="font-weight: bold;">mysql -u root</span><br />Welcome to the MySQL monitor. Commands end with ; or \g.<br />Your MySQL connection id is 1 to server version: 4.1.9-max<br /><br />Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<br /><br />mysql> <span style="font-weight: bold;">create database foo;</span><br />Query OK, 1 row affected (0.11 sec)<br /><br />mysql> <span style="font-weight: bold;">use foo;</span><br />Reading table information for completion of table and column names<br />You can turn off this feature to get a quicker startup with -A<br /><br />Database changed<br />mysql> <span style="font-weight: bold;">select * from test1;</span><br />+------+<br />| i |<br />+------+<br />| 1 |<br />+------+<br />1 row in set (0.01 sec)<br /><br />mysql> <span style="font-weight: bold;">select * from test2;</span><br />+------+<br />| i |<br />+------+<br />| 2 |<br />+------+<br />1 row in set (0.01 sec)<br /></span></div>
<big style="font-size: 14px;"><small> At this point you can check the cluster status on the management console and verify that the API node is now connected:</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />ndb_mgm> <span style="font-weight: bold;">show</span><br />Cluster Configuration<br />---------------------<br />[ndbd(NDB)] 2 node(s)<br />id=2 @192.168.0.33 (Version: 4.1.9, Nodegroup: 0)<br />id=3 @192.168.0.34 (Version: 4.1.9, Nodegroup: 0, Master)<br /><br />[ndb_mgmd(MGM)] 1 node(s)<br />id=1 @192.168.0.32 (Version: 4.1.9)<br /><br />[mysqld(API)] 4 node(s)<br />id=4 (Version: 4.1.9)<br />id=5 (Version: 4.1.9)<br /><span style="color: #009900;">id=6 @192.168.0.35 (Version: 4.1.9)</span><br />id=7 (not connected, accepting connect from any host)</span><span style="color: red;"><br /></span></div>
<span style="color: red; font-size: 14px;"><span style="color: black;"> Our configuration now resembles the diagram at the top of the page.<br /></span>Step 7<span style="color: black;">. </span></span><span class="Apple-style-span" style="font-size: 14px;">Finally, we should verify the fault-tolerance of the cluster when servicing queries from the API node.</span><br /><br /><span class="Apple-style-span" style="font-size: 14px;"> With the cluster up and operating corrrectly, use the API node to create a new table and insert some test data:</span><br /><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />mysql-api-1# <span style="font-weight: bold;">mysql -u root</span><br />Welcome to the MySQL monitor. Commands end with ; or \g.<br />Your MySQL connection id is 258519 to server version: 4.1.9-max<br /><br />Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<br /><br />mysql> <span style="font-weight: bold;">use foo;</span><br />Reading table information for completion of table and column names<br />You can turn off this feature to get a quicker startup with -A<br /><br />Database changed<br />mysql> <span style="font-weight: bold;">create table test3 (i int) engine=ndbcluster;</span><br />Query OK, 0 rows affected (0.81 sec)<br /><br />mysql> <span style="font-weight: bold;">quit</span><br />Bye</span><br /></div>
<big style="font-size: 14px;"><small> Now, insert some random data into the table, either by hand or you can use a quick script to do it:</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />#!/bin/sh<br />for i in 1 2 3 4 5 6 7 8 9 10<br />do<br /> random=`perl -e "print int(rand(100));"`<br /> echo "use foo; insert into test3 () values ($random);" | mysql -u root<br />done<br /></span></div>
<big style="font-size: 14px;"><small> Try a test query on the API node:</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />mysql-api-1# <span style="font-weight: bold;">mysql -u root</span><br />Welcome to the MySQL monitor. Commands end with ; or \g.<br />Your MySQL connection id is 258551 to server version: 4.1.9-max<br /><br />Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<br /><br />mysql> <span style="font-weight: bold;">use foo;</span><br />Reading table information for completion of table and column names<br />You can turn off this feature to get a quicker startup with -A<br /><br />Database changed<br />mysql> <span style="font-weight: bold;">select * from test3;</span><br />+------+<br />| i |<br />+------+<br />| 92 |<br />| 20 |<br />| 18 |<br />| 84 |<br />| 49 |<br />| 22 |<br />| 54 |<br />| 91 |<br />| 79 |<br />| 52 |<br />+------+<br />10 rows in set (0.02 sec)<br /></span></div>
<big style="font-size: 14px;"><small> Looks good. Now, disconnect the network cable from the first storage node so that it falls out of the cluster. Within a few seconds, the management console will recognize that it has disappeared:</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />ndb_mgm> <span style="font-weight: bold;">show</span><br />Cluster Configuration<br />---------------------<br />[ndbd(NDB)] 2 node(s)<br /><span style="color: #009900;">id=2 (not connected, accepting connect from 192.168.0.33)</span><br />id=3 @192.168.0.34 (Version: 4.1.9, Nodegroup: 0)<br /><br />[ndb_mgmd(MGM)] 1 node(s)<br />id=1 @192.168.0.32 (Version: 4.1.9)<br /><br />[mysqld(API)] 4 node(s)<br /><span style="color: #009900;">id=4 (not connected, accepting connect from any host)</span><br />id=5 (Version: 4.1.9)<br />id=6 @192.168.0.35 (Version: 4.1.9)<br />id=7 (not connected, accepting connect from any host)<br /></span></div>
<big style="font-size: 14px;"><small> Is the cluster data still available to the API node?</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />mysql-api-1# <span style="font-weight: bold;">mysql -u root</span><br />Welcome to the MySQL monitor. Commands end with ; or \g.<br />Your MySQL connection id is 258552 to server version: 4.1.9-max<br /><br />Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<br /><br />mysql> <span style="font-weight: bold;">use foo;</span><br />Reading table information for completion of table and column names<br />You can turn off this feature to get a quicker startup with -A<br /><br />Database changed<br />mysql> <span style="font-weight: bold;">select * from test3;</span><br />+------+<br />| i |<br />+------+<br />| 54 |<br />| 91 |<br />| 79 |<br />| 52 |<br />| 92 |<br />| 20 |<br />| 18 |<br />| 84 |<br />| 49 |<br />| 22 |<br />+------+<br />10 rows in set (0.02 sec)<br /></span></div>
<big style="font-size: 14px;"><small> Now, plug the disconnected storage node back into the network. It will attempt to rejoin the cluster, but probably will be shutdown by the management server, and something similar to the following will appear in the error log (<span style="font-weight: bold;">/var/lib/mysql-cluster/mdb_2_error.log</span>):</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />Date/Time: Saturday 12 February 2005 - 12:46:21<br />Type of error: error<br />Message: Arbitrator shutdown<br />Fault ID: 2305<br />Problem data: Arbitrator decided to shutdown this node<br />Object of reference: QMGR (Line: 3796) 0x0000000a<br />ProgramName: /usr/local/mysql/bin/ndbd<br />ProcessID: 1185<br />TraceFile: /var/lib/mysql-cluster/ndb_2_trace.log.3<br />***EOM***</span></div>
<div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br /></span></div>
<big style="font-size: 14px;"><small> Restart the ndb storage engine process on that node and verify that it rejoins the cluster properly:</small></big><div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;"><br />mysql-ndb-1# <span style="font-weight: bold;">/usr/local/mysql/bin/ndbd</span><br /><br /><br />ndb_mgm> <span style="font-weight: bold;">show</span><br />Cluster Configuration<br />---------------------<br />[ndbd(NDB)] 2 node(s)<br />id=2 @192.168.0.33 (Version: 4.1.9, Nodegroup: 0)<br />id=3 @192.168.0.34 (Version: 4.1.9, Nodegroup: 0, Master)<br /><br />[ndb_mgmd(MGM)] 1 node(s)<br />id=1 @192.168.0.32 (Version: 4.1.9)<br /><br />[mysqld(API)] 4 node(s)<br />id=4 (Version: 4.1.9)<br />id=5 (Version: 4.1.9)<br />id=6 @192.168.0.35 (Version: 4.1.9)<br />id=7 (not connected, accepting connect from any host)<br /></span></div>
<big style="font-size: 14px;"><small><br /><big>Miscellaneous<small><br /></small></big></small></big><ul style="font-size: 14px;">
<li>Remember that in order for SQL data to be stored (replicated) on the cluster, database tables must be created specifying<span style="font-weight: bold;">engine=NDBCLUSTER</span> (as shown the in the examples above). It is possible to use this mechanism to specify different storage engines for different tables within the same database, depending on individual performance and reliability requirements. Non-critical database tables need not be stored on the cluster.</li>
<li>It is possible to make NDBCLUSTER the default storage engine by adding a line to the <span style="font-weight: bold;">/etc/my.cnf</span> configuration file:</li>
</ul>
<div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;">[mysqld]<br />default-table-type=NDBCLUSTER<br /></span></div>
<ul style="font-size: 14px;">
<li>Occasionally, after abnormal cluster node termination (for example, a system crash) we see "hung" connections, and upon restart the failed node is unable to join the cluster. In this case, the session should be manually cleared on the management console using the command, "<span style="font-weight: bold;">purge stale sessions</span>":</li>
</ul>
<div style="font-size: 14px; margin-left: 40px;">
<span style="font-family: monospace;">ndb_mgm> <span style="font-weight: bold;">purge stale sessions</span><br />Purged sessions with node id's: 3<br />ndb_mgm> </span></div>
<big style="font-size: 14px;"><small><br /><br /><br /><br />Please direct questions, comments, and suggestions regarding this document to <span style="font-weight: bold;">consult@lod.com</span><br /><br /></small></big><div style="margin-bottom: 12px; margin-top: 2px;">
<span class="Apple-style-span" style="font-size: 12px;"><br /></span></div>
</div>
</div>
</div>
</div>
</div>
<span class="Apple-style-span" style="background-color: white; font-family: Verdana, Geneva, sans-serif; font-size: 12px; line-height: 18px;"><div style="margin-bottom: 1.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;">
---------------------------------------------------------------------------------------------------------------</div>
</span><span class="Apple-style-span" style="background-color: white; color: #333333; font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 19px;"><div class="post-794 post type-post status-publish format-standard hentry category-linux tag-ec2 tag-howto tag-mysql" id="post-794" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: justify;">
<h2 style="color: #333333; font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 1.6em; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 30px; text-decoration: none;">
EC2, MySQL Cluster, and You!</h2>
<div class="entry" style="line-height: 1.4em;">
<div style="font-size: 1.05em;">
The past week I’ve been pounding my head bloody going round and round with setting up a MySQL Cluster in EC2. First trying it with Ubuntu, then Fedora 6, and then finally I learned to trust the fine folks at Canonical and believe in that their distro was tight and damn is it ever tight. The beauty of using Ubuntu is that everything you need is installed by default and there is no mucking trying to get the right packages, dependencies, or source. Yes, this is probably not the optimal way of going about this but I need a workable solution and fast and while there are a whole pile of rpms ready to roll the nightmare of getting simple things like perl dependencies satisfied in Fedora were enough to send me screaming out of the cloud.</div>
<div style="font-size: 1.05em;">
Anyways, I have a wicked basic cluster running using the following process:</div>
<div style="font-size: 1.05em;">
On the Management Node I’m using this config.ini which is sort of cribbed together (/var/lib/mysql-cluster/config.ini)</div>
<pre><code style="font: normal normal normal 1.1em/normal 'Courier New', Courier, Fixed;"># Options affecting ndbd processes on all data nodes:
[NDBD DEFAULT]
NoOfReplicas=2 # Number of replicas
DataMemory=256M # How much memory to allocate for data storage
IndexMemory=256M # How much memory to allocate for index storage
# For DataMemory and IndexMemory, we have used the
# default values. Since the "world" database takes up
# only about 500KB, this should be more than enough for
# this example Cluster setup.
# TCP/IP options:
[TCP DEFAULT]
portnumber=2202 # This the default; however, you can use any
# port that is free for all the hosts in cluster
# Note: It is recommended beginning with MySQL 5.0 that
# you do not specify the portnumber at all and simply allow
# the default value to be used instead
# Management process options:
[NDB_MGMD]
hostname=mgmn # Hostname or IP address of MGM node
datadir=/var/lib/mysql-cluster # Directory for MGM node log files
# Options for data node "A":
[NDBD]
# (one [NDBD] section per data node)
hostname=ndbda # Hostname or IP address
datadir=/mnt/mysql/data # Directory for this data node's data files
# Options for data node "B":
[NDBD]
hostname=ndbdb # Hostname or IP address
datadir=/mnt/mysql/data # Directory for this data node's data files
# SQL node options:
[MYSQLD]
hostname=sqln # Hostname or IP address
# (additional mysqld connections can be
# specified for this node for various
# purposes such as running ndb_restore)</code></pre>
<div style="font-size: 1.05em;">
Now, in the end I moved this into /mnt (cp -ar /var/lib/mysql-cluster) so that I didn’t have the threat of running out of disk space on the primary partition.</div>
<div style="font-size: 1.05em;">
On the SQL Node in mysql.cnf (/etc/mysql/my.cnf) I have nothing more than this:</div>
<pre><code style="font: normal normal normal 1.1em/normal 'Courier New', Courier, Fixed;"># Options for mysqld process:
[MYSQLD]
ndbcluster # run NDB storage engine
ndb-connectstring=mgmn # location of management server
log=/var/lib/mysql/mysql.log</code></pre>
<div style="font-size: 1.05em;">
I am experimenting with adding settings back in but I’m not too sure if they belong in the config.ini on the management node or in here. My gut tell me management node. Anyhow, with this I copied the contents of /var/lib/mysql into /mnt (cp -ar again) and renamed the old directory and created a symbolic link pointing to the new location. Kludgey, yes, but I am still learning my way around MySQL and its various settings. Likely, I will figure which config file gets the data directory settings and I’ll make the appropriate changes. And yes, you read that right I do have logging turned on because I am the kind of guy who needs to know.</div>
<div style="font-size: 1.05em;">
On the Data Node in my.cnf (/etc/mysql/my.cnf) this plain vanilla setup:</div>
<pre><code style="font: normal normal normal 1.1em/normal 'Courier New', Courier, Fixed;"># Options for ndbd process:
[MYSQL_CLUSTER]
ndb-connectstring=mgmn # location of management server</code></pre>
<div style="font-size: 1.05em;">
Now to tie all this boxes together I ended up using a host file, recommended by <a href="http://blog.dbadojo.com/2007/08/mysql-51-ndb-cluster-on-ec2.html" style="color: #0066cc; text-decoration: none;" title="MySQL 5.1 NDB Cluster on EC2 configuration files">Paul Moen</a> and my boss and with an endorsement like that I just had to run with it! On all of the nodes in /etc/hosts I dropped the internal IP addresses of each box in the cloud (nslookup domU-12-34-56-78-9A-B1.z-2.compute-1.internal):</div>
<pre><code style="font: normal normal normal 1.1em/normal 'Courier New', Courier, Fixed;"># Mysql Cluster data node
10.1.2.3 ndbda
10.4.5.6 ndbdb
# Mysql Cluster mgm node
10.7.8.9 mgmn
# MySQL Cluster sql node
10.10.11.12 sqln</code></pre>
<div style="font-size: 1.05em;">
Starting everything up begins with the management cluster:</div>
<pre><code style="font: normal normal normal 1.1em/normal 'Courier New', Courier, Fixed;">ndb_mgmd -f /mnt/mysql-cluster/config.ini</code></pre>
<div style="font-size: 1.05em;">
Then the data nodes:</div>
<pre><code style="font: normal normal normal 1.1em/normal 'Courier New', Courier, Fixed;">ndbd --initial</code></pre>
<div style="font-size: 1.05em;">
Note, you only need to do the inital part if it is the first time the node is coming up if you are restarting a cluster you can skip it.</div>
<div style="font-size: 1.05em;">
Lastly, the SQL node:</div>
<pre><code style="font: normal normal normal 1.1em/normal 'Courier New', Courier, Fixed;">/etc/init.d/mysql start</code></pre>
<div style="font-size: 1.05em;">
On the management node you can issue a SHOW to figure out if your bacon is frying:</div>
<pre><code style="font: normal normal normal 1.1em/normal 'Courier New', Courier, Fixed;">root@mgmn:~# ndb_mgm -e show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @10.1.2.3 (Version: 5.0.38, Nodegroup: 0, Master)
id=3 @10.4.5.6 (Version: 5.0.38, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @10.7.8.9 (Version: 5.0.38)
[mysqld(API)] 1 node(s)
id=4 @10.10.11.12 (Version: 5.0.38)
</code></pre>
<div style="font-size: 1.05em;">
Now, what about backups? Well, I am in the process of experimenting with issuing <em>ndb_mgm -e “START BACKUP”</em> on the cluster manager and that will dump a backup to each of the data nodes. Ideally, I would like to issue periodic backups to each individual node in a staggered fashion and have those gziped and sent up to S3. What I need to figure out is if I can issue a backup command for individual nodes like START BACKUP Node_2 or something there abouts. If that is the case I could then grow the data nodes out to the maximum four and take snapshots every 15 minutes which could give us decent coverage if our whole section of the cloud decided to pop.</div>
<div style="font-size: 1.05em;">
If you have any questions, criticisms, or gripes feel free to slap me with them as I feel like I am still missing a huge chunk of the picture with all of this. <img alt=":-D" class="wp-smiley" src="http://elwoodicious.com/wp-includes/images/smilies/icon_biggrin.gif" style="border-bottom-color: rgb(153, 153, 153); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(153, 153, 153); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(153, 153, 153); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(153, 153, 153); border-top-style: solid; border-top-width: 1px; max-width: 100%; padding-bottom: 9px; padding-left: 9px; padding-right: 9px; padding-top: 9px;" /></div>
<div style="font-size: 1.05em;">
Tags: <a href="http://elwoodicious.com/tag/ec2/" rel="tag" style="color: #0066cc; text-decoration: none;">EC2</a>, <a href="http://elwoodicious.com/tag/howto/" rel="tag" style="color: #0066cc; text-decoration: none;">HowTo</a>, <a href="http://elwoodicious.com/tag/mysql/" rel="tag" style="color: #0066cc; text-decoration: none;">MySQL</a></div>
<div class="postmetadata alt" style="border-left-color: rgb(221, 221, 221); border-left-style: solid; border-left-width: 1px; clear: both; color: #777777; font-size: 1.05em; margin-bottom: 30px; margin-top: 30px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;">
<small style="color: #777777; font-family: Arial, Helvetica, sans-serif; font-size: 0.9em; line-height: 1.5em;">This entry was posted on Friday, August 17th, 2007 at 2:26 pm and is filed under <a href="http://elwoodicious.com/category/linux/" rel="category tag" style="color: #0066cc; text-decoration: none;" title="View all posts in Linux">Linux</a>. You can follow any responses to this entry through the <a href="http://elwoodicious.com/2007/08/17/ec2-mysql-cluster-and-you/feed/" style="color: #0066cc; text-decoration: none;">RSS 2.0</a> feed. Both comments and pings are currently closed.</small></div>
<div>
<small style="color: #777777; font-family: Arial, Helvetica, sans-serif; font-size: 0.9em; line-height: 1.5em;"><br /></small></div>
</div>
</div>
</span>Anonymoushttp://www.blogger.com/profile/00331908591430085897noreply@blogger.com0