import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegExp_SandBox {

//Pattern to escape
final static String SCRIPT_PATTERN = “<\\s*script\\s*([^>]*)\\s*>|<\\s*/\\s*script([^>]*)\\s*>”;
//Compile pattern
static Pattern scriptPattern = Pattern.compile(SCRIPT_PATTERN, Pattern.CASE_INSENSITIVE);

/**
* @param args
*/
public static void main(String[] args) {

//Source string
String css = “Hello world <p>Not replaced</p> <script id=’youfool’ name=\”youfool\”>Test this</script> <strong>this is strong</strong>”;
System.out.println( css + “\n———————————————” );

//replace all matches
css = matchAndReplace(css, scriptPattern, “*”);
System.out.println( css + “\n———————————————” );
}

public static String matchAndReplace(CharSequence message, final Pattern pattern, final String replace)
{
Matcher matcher = pattern.matcher(message);
StringBuffer buffer = new StringBuffer();
while (matcher.find())
{
matcher.appendReplacement(buffer, replace);
}
matcher.appendTail(buffer);
return buffer.toString();
}
}

360 Vista Image of Venice lagoon by motor boat .


Sometimes you will have multiple ip bound to your server’s network adapters. And, by default multicast will be enabled on all the interfaces except for the loop back. This will create troubles while handling applications that are depending multicasting for their working. We need to enable multicasting on only one network interface. I put this in my blog because I found out the solution for clustering problems after a while of research ;)

Steps you need to follow to disable multicast on multihomed servers :

[root@web bin]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:30:48:5B:54:9A
inet addr:10.5.108.84 Bcast:10.5.108.127 Mask:255.255.255.192
inet6 addr: fe80::230:48ff:fe5b:549a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:32349735 errors:0 dropped:0 overruns:0 frame:0
TX packets:27410647 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1607667954 (1.4 GiB) TX bytes:4270795211 (3.9 GiB)
Interrupt:17


eth1 Link encap:Ethernet HWaddr 00:30:48:5B:54:9B
inet addr:75.126.68.198 Bcast:xx.xx.xx.xx Mask:255.255.255.240
inet6 addr: fe80::230:48ff:fe5b:549b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:442117208 errors:0 dropped:0 overruns:0 frame:0
TX packets:471331869 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1831922661 (1.7 GiB) TX bytes:3006291822 (2.7 GiB)
Interrupt:18

eth1:0 Link encap:Ethernet HWaddr 00:30:48:5B:54:9B
inet addr:xx.xx.xx.xx Bcast:xx.xx.xx.xx Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:18

eth1:1 Link encap:Ethernet HWaddr 00:30:48:5B:54:9B
inet addr:75.126.48.157 Bcast:75.126.48.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:18

eth1:2 Link encap:Ethernet HWaddr 00:30:48:5B:54:9B
inet addr:xx.xx.xx.xx Bcast:xx.xx.xx.xx Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:18

eth1:3 Link encap:Ethernet HWaddr 00:30:48:5B:54:9B
inet addr:xx.xx.xx.xx Bcast:xx.xx.xx.xx Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:18

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:2994064 errors:0 dropped:0 overruns:0 frame:0
TX packets:2994064 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2632223784 (2.4 GiB) TX bytes:2632223784 (2.4 GiB)

You can disable multicast on multiple interfaces by the following command :

[root@web bin]# ifconfig eth1 -multicast

Then the ifconfig will look like :

http://www.yolinux.com/TUTORIALS/LinuxTutorialNetworking.html

http://www.penguin-soft.com/penguin/man/8/ifconfig.html

Welcome to http://chozhiyath.wordpress.com/ For a long time it was in my mind to start blogging. Many are taking blogging seriously while a few find it one among their hobbies. Either way, blogs are really great for “con·vey·ance.

Events

November 2009
S M T W T F S
« Jul    
1234567
891011121314
15161718192021
22232425262728
2930  

del.icio.us

Moments in memory

mylogo

More Photos