[ http://jira.jboss.com/jira/browse/JGRP-14?page=history ]
Bela Ban updated JGRP-14:
-------------------------
Fix Version: 2.2.8
> TCP protocol stack won't mergeview with initial hosts specified as IP
> addresses
> -------------------------------------------------------------------------------
>
> Key: JGRP-14
> URL: http://jira.jboss.com/jira/browse/JGRP-14
> Project: JGroups
> Type: Bug
> Versions: 2.2.8
> Environment: Linux and JGroups 2.2.7
> Reporter: Zac Hansen
> Assignee: Bela Ban
> Fix For: 2.2.8
>
>
> When I use a TCP protocol stack with TCPPING having initial members as ip
> addresses: initial_members=192.168.1.200[4000], no merges will occur when 2
> instances are started simultaneously. The same thing with
> initial_members=localhost[4000] merges fine when 2 instances are started
> simultaneously.
> The following code reproduces the problem when started with a command line
> parameter of 1, and works when run with a parameter of 0.
> belacode.java follows:
> --------------------------------
> import java.sql.*;
> import java.util.*;
> import java.util.regex.*;
> import java.net.*;
> import org.jgroups.*;
> import org.jgroups.stack.GossipServer;
> // Helper class for JGroups stuff
> class JGroupsManager {
> static String fillInProtocolString ( String protocol, Map vars )
> {
> String variableRegexString = "[$]([A-Z]+)";
> Pattern variablePattern;
> try {
> variablePattern = Pattern.compile ( variableRegexString );
> } catch ( Exception e ) {
> throw new RuntimeException ( "Couldn't compile into regex: " +
> variableRegexString );
> }
> Matcher matcher = variablePattern.matcher ( protocol );
> while ( matcher.find ( ) ) {
> String variable = matcher.group ( 1 );
> String variableLowerCase = variable.toLowerCase ( );
> // System.err.println ( "Found variable for interpolation: " +
> variable );
> if ( vars.get ( variableLowerCase ) == null ) {
> throw new RuntimeException ( "Couldn't find value for " +
> variableLowerCase + " in value map" );
> }
> protocol = protocol.replaceFirst ( "[$]" + variable, (String)
> vars.get ( variableLowerCase ) );
> }
> // System.err.println ( "Returning: " + protocol );
> return protocol;
> }
> static Channel createChannel ( String protocol )
> {
>
> Channel channel;
> try {
> channel = new JChannel ( protocol );
> } catch ( Exception e ) {
> System.err.println ( "##########");
> e.printStackTrace ( );
> throw new RuntimeException ( "Couldn't create channel with
> protocol: " + protocol );
> }
> System.err.println ( "Created channel with protocol: " + protocol );
> return channel;
> }
> }
> class belacode {
> static String localIpAddress_ = "";
> static String localHostname_ = "";
> static
> {
> try {
> java.net.InetAddress localMachine =
> java.net.InetAddress.getLocalHost();
> // put the text version of the address into localIpAddress_
> localIpAddress_ = localMachine.getHostAddress ( );
>
> localHostname_ = localMachine.getHostName ( );
> } catch ( java.net.UnknownHostException uhe ) {
> //handle exception
> } finally {
> // System.err.println ( "I think I'm running on: " +
> localIpAddress_ + " / " + localHostname_ );
> }
> }
>
>
> public static void main ( String [ ] args )
> {
>
> if ( args.length != 1 || (!args [ 0 ].equals ( "0" ) && !args [ 0
> ].equals ( "1" ) ) ) {
> System.err.println ( "Usage: java belacode [0/1]\n0 for localhost
> (works)\n1 for ip address (doesn't work)\n" );
> System.exit ( 1 );
> }
> int port = 20043;
> String host;
> try {
> host = InetAddress.getLocalHost ( ).getHostAddress ( );
> System.err.println ( host = InetAddress.getLocalHost (
> ).getHostAddress ( ) );
> } catch ( UnknownHostException e ) {
> throw new RuntimeException ( "Couldn't determine localhost. This
> shouldn't happen" );
> }
> if ( args [ 0 ].equals ( "0" ) ) {
> System.err.println ( "Setting localhost" );
> host = "localhost";
> }
>
> String prot = "TCP(start_port=" + port + "):TCPPING(initial_hosts=" +
> host + "[" + port +
> "];port_range=5;timeout=3000;num_initial_members=2):FD(timeout=3000;max_tries=4):MERGE2(min_interval=5000;max_interval=10000):VERIFY_SUSPECT(timeout=1500;down_thread=false;up_thread=false):pbcast.NAKACK(gc_lag=100):pbcast.STABLE(stability_delay=1000;desired_avg_gossip=20000;down_thread=false;up_thread=false;max_bytes=0):UNICAST(timeout=5000):pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;shun=true;print_local_addr=true)";
>
> System.err.println ( "Using protocol string:\n" + prot );
> Channel channel = JGroupsManager.createChannel ( prot );
>
> String groupName = "mygroup";
> try {
>
> System.err.println ( "Connecting with groupname: " + groupName );
> channel.connect ( groupName );
>
> } catch ( Exception e ) {
> System.err.println ( "Couldn't connect to group: " + groupName );
> }
>
>
> // new ChannelSenderThread ( channel, new Integer ( port ).toString ( )
> ).start ( );
>
> // let's look at the current view
> View view = channel.getView ( );
>
>
> while ( true ) {
>
> // let's block waiting for a message
> Object message;
> try {
> message = channel.receive ( 10000 );
> } catch ( ChannelNotConnectedException e ) {
> throw new RuntimeException ( "Tried to receive on a channel
> that wasn't connected" );
> } catch ( ChannelClosedException e ) {
> throw new RuntimeException ( "Tried to receive on a channel
> that was closed" );
> } catch ( TimeoutException e ) {
> System.err.println ( "Timed out on receive" );
> continue;
> }
> System.err.println ( "######### Received object: " + message );
> if ( message instanceof View ) {
> System.err.println ( "###\n###\n###\nGot a view with " +
> ((View)message).size ( ) + " element(s)" );
> for ( Iterator j = ((View)message).getMembers ( ).iterator ( );
> j.hasNext ( ); ) {
> System.err.println ( j.next ( ) );
> }
> if ( message instanceof MergeView ) {
> System.err.println ( "BTW, this view is a mergeview" );
> }
>
> } else if ( message instanceof Message ) {
> System.err.println ( "Got a message: " + message +
> (((Message)message).getObject ( ) ) );
> } else if ( message instanceof SuspectEvent ) {
> System.err.println ( "Got a Suspect Event: " + message );
> } else if ( message instanceof BlockEvent ) {
> System.err.println ( "Got a Block Event: " + message );
> } else if ( message instanceof GetStateEvent ) {
> System.err.println ( "Got a Get State Event: " + message );
> } else if ( message instanceof SetStateEvent ) {
> System.err.println ( "Got a Set State Event: " + message );
> }
> }
> }
>
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
JBoss-Development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-development