HBASE-9961 [WINDOWS] Multicast should bind to local address

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1542425 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Enis Soztutar 2013-11-15 22:52:25 +00:00
parent 16b799dae5
commit 18e018b3d9
2 changed files with 26 additions and 14 deletions

View File

@ -20,6 +20,18 @@
package org.apache.hadoop.hbase.client;
import java.io.Closeable;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@ -40,18 +52,6 @@ import org.jboss.netty.channel.socket.DatagramChannelFactory;
import org.jboss.netty.channel.socket.oio.OioDatagramChannelFactory;
import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder;
import java.io.Closeable;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* A class that receives the cluster status, and provide it as a set of service to the client.
@ -185,6 +185,7 @@ class ClusterStatusListener implements Closeable {
public MulticastListener() {
}
@Override
public void connect(Configuration conf) throws IOException {
// Can't be NiO with Netty today => not implemented in Netty.
DatagramChannelFactory f = new OioDatagramChannelFactory(service);
@ -196,9 +197,12 @@ class ClusterStatusListener implements Closeable {
String mcAddress = conf.get(HConstants.STATUS_MULTICAST_ADDRESS,
HConstants.DEFAULT_STATUS_MULTICAST_ADDRESS);
String bindAddress = conf.get(HConstants.STATUS_MULTICAST_BIND_ADDRESS,
HConstants.DEFAULT_STATUS_MULTICAST_BIND_ADDRESS);
int port = conf.getInt(HConstants.STATUS_MULTICAST_PORT,
HConstants.DEFAULT_STATUS_MULTICAST_PORT);
channel = (DatagramChannel) b.bind(new InetSocketAddress(mcAddress, port));
channel = (DatagramChannel) b.bind(new InetSocketAddress(bindAddress, port));
channel.getConfig().setReuseAddress(true);

View File

@ -298,7 +298,7 @@ public final class HConstants {
* The directory from which co-processor/custom filter jars can be loaded
* dynamically by the region servers. This value can be overridden by the
* hbase.dynamic.jars.dir config.
*/
*/
public static final String LIB_DIR = "lib";
/** Used to construct the name of the compaction directory during compaction */
@ -931,6 +931,14 @@ public final class HConstants {
public static final String STATUS_MULTICAST_ADDRESS = "hbase.status.multicast.address.ip";
public static final String DEFAULT_STATUS_MULTICAST_ADDRESS = "226.1.1.3";
/**
* The address to use for binding the local socket for receiving multicast. Defaults to
* 0.0.0.0.
* @see https://issues.apache.org/jira/browse/HBASE-9961
*/
public static final String STATUS_MULTICAST_BIND_ADDRESS = "hbase.status.multicast.bind.address.ip";
public static final String DEFAULT_STATUS_MULTICAST_BIND_ADDRESS = "0.0.0.0";
/**
* The port to use for the multicast messages.
*/