mirror of https://github.com/apache/cassandra
switch to IP everywhere. patch by jbellis; reviewed by Eric Evans for #94
git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@768441 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ef293c1a6a
commit
f06a9da69a
|
|
@ -20,6 +20,7 @@ package org.apache.cassandra.gms;
|
|||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.net.InetAddress;
|
||||
|
||||
import org.apache.cassandra.concurrent.SingleThreadedStage;
|
||||
import org.apache.cassandra.concurrent.StageManager;
|
||||
|
|
@ -895,7 +896,8 @@ public class Gossiper implements IFailureDetectionEventListener, IEndPointStateC
|
|||
Set<String> seedHosts = DatabaseDescriptor.getSeeds();
|
||||
for( String seedHost : seedHosts )
|
||||
{
|
||||
EndPoint seed = new EndPoint(seedHost, DatabaseDescriptor.getControlPort());
|
||||
EndPoint seed = new EndPoint(InetAddress.getByName(seedHost).getHostAddress(),
|
||||
DatabaseDescriptor.getControlPort());
|
||||
if ( seed.equals(localEndPoint) )
|
||||
continue;
|
||||
seeds_.add(seed);
|
||||
|
|
|
|||
|
|
@ -39,18 +39,6 @@ public class CompactEndPointSerializationHelper
|
|||
return EndPoint.fromBytes(bytes);
|
||||
}
|
||||
|
||||
private static byte[] getIPAddress(String host) throws UnknownHostException
|
||||
{
|
||||
InetAddress ia = InetAddress.getByName(host);
|
||||
return ia.getAddress();
|
||||
}
|
||||
|
||||
private static String getHostName(byte[] ipAddr) throws UnknownHostException
|
||||
{
|
||||
InetAddress ia = InetAddress.getByAddress(ipAddr);
|
||||
return ia.getCanonicalHostName();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Throwable
|
||||
{
|
||||
EndPoint ep = new EndPoint(7000);
|
||||
|
|
|
|||
|
|
@ -62,16 +62,9 @@ public class EndPoint implements Serializable, Comparable<EndPoint>
|
|||
|
||||
private transient InetSocketAddress ia_;
|
||||
|
||||
/* Ctor for JAXB. DO NOT DELETE */
|
||||
private EndPoint()
|
||||
{
|
||||
}
|
||||
|
||||
public EndPoint(String host, int port)
|
||||
{
|
||||
/*
|
||||
* Attempts to resolve the host, but does not fail if it cannot.
|
||||
*/
|
||||
assert host.matches("\\d+\\.\\d+\\.\\d+\\.\\d+") : host;
|
||||
host_ = host;
|
||||
port_ = port;
|
||||
}
|
||||
|
|
@ -166,7 +159,7 @@ public class EndPoint implements Serializable, Comparable<EndPoint>
|
|||
String host = hostNames_.get(charBuffer);
|
||||
if (host == null)
|
||||
{
|
||||
host = InetAddress.getByAddress(buffer.array()).getHostName();
|
||||
host = InetAddress.getByAddress(buffer.array()).getHostAddress();
|
||||
hostNames_.put(charBuffer, host);
|
||||
}
|
||||
int port = (int) MessagingService.byteArrayToShort(portBytes);
|
||||
|
|
|
|||
|
|
@ -512,7 +512,7 @@ public class TcpConnection extends SelectionKeyHandler implements Comparable
|
|||
if (remoteEp_ == null)
|
||||
{
|
||||
int port = ( pH.isListening_ ) ? DatabaseDescriptor.getStoragePort() : EndPoint.randomPort_;
|
||||
remoteEp_ = new EndPoint( socketChannel_.socket().getInetAddress().getHostName(), port );
|
||||
remoteEp_ = new EndPoint( socketChannel_.socket().getInetAddress().getHostAddress(), port );
|
||||
// put connection into pool if possible
|
||||
pool_ = MessagingService.getConnectionPool(localEp_, remoteEp_);
|
||||
pool_.addToPool(TcpConnection.this);
|
||||
|
|
|
|||
|
|
@ -150,11 +150,12 @@ public class FBUtilities
|
|||
|
||||
public static String getHostName() throws UnknownHostException
|
||||
{
|
||||
InetAddress inetAddr = getLocalAddress();
|
||||
if (DatabaseDescriptor.getListenAddress() != null)
|
||||
{
|
||||
return DatabaseDescriptor.getListenAddress();
|
||||
inetAddr = InetAddress.getByName(DatabaseDescriptor.getListenAddress());
|
||||
}
|
||||
return getLocalAddress().getCanonicalHostName();
|
||||
return inetAddr.getHostAddress();
|
||||
}
|
||||
|
||||
public static boolean isHostLocalHost(InetAddress host)
|
||||
|
|
|
|||
Loading…
Reference in New Issue