rename getHostName -> getHostAddress since it should always be an IP now.

patch by jbellis; reviewed by Eric Evans for #94

git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@768442 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Ellis 2009-04-24 23:28:24 +00:00
parent f06a9da69a
commit 0bf69f8cce
11 changed files with 13 additions and 20 deletions

View File

@ -23,11 +23,9 @@ import java.math.BigInteger;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import org.apache.cassandra.config.CFMetaData;
import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.service.StorageService;
import org.apache.cassandra.utils.BasicUtilities;
@ -115,7 +113,7 @@ public class DBManager
StorageMetadata storageMetadata = null;
/* Read the system table to retrieve the storage ID and the generation */
SystemTable sysTable = SystemTable.openSystemTable(SystemTable.name_);
Row row = sysTable.get(FBUtilities.getHostName());
Row row = sysTable.get(FBUtilities.getHostAddress());
Random random = new Random();
if ( row == null )
@ -128,7 +126,7 @@ public class DBManager
int generation = 1;
String key = FBUtilities.getHostName();
String key = FBUtilities.getHostAddress();
row = new Row(key);
ColumnFamily cf = new ColumnFamily(SystemTable.cfName_, "Standard");
cf.addColumn(new Column(SystemTable.token_, token.toByteArray()));

View File

@ -275,7 +275,7 @@ public class RowMutation implements Serializable
DataOutputStream dos = new DataOutputStream(bos);
serializer().serialize(this, dos);
EndPoint local = StorageService.getLocalStorageEndPoint();
EndPoint from = (local != null) ? local : new EndPoint(FBUtilities.getHostName(), 7000);
EndPoint from = (local != null) ? local : new EndPoint(FBUtilities.getHostAddress(), 7000);
return new Message(from, StorageService.mutationStage_, verbHandlerName, bos.toByteArray());
}

View File

@ -23,14 +23,12 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.Serializable;
import java.util.*;
import javax.xml.bind.annotation.XmlElement;
import org.apache.cassandra.io.ICompactSerializer;
import org.apache.cassandra.net.EndPoint;
import org.apache.cassandra.net.Message;
import org.apache.cassandra.net.MessagingService;
import org.apache.cassandra.service.StorageService;
import org.apache.cassandra.utils.FBUtilities;
@ -66,7 +64,7 @@ public class RowMutationMessage implements Serializable
DataOutputStream dos = new DataOutputStream( bos );
RowMutationMessage.serializer().serialize(rowMutationMessage, dos);
EndPoint local = StorageService.getLocalStorageEndPoint();
EndPoint from = ( local != null ) ? local : new EndPoint(FBUtilities.getHostName(), 7000);
EndPoint from = ( local != null ) ? local : new EndPoint(FBUtilities.getHostAddress(), 7000);
Message message = new Message(from, StorageService.mutationStage_, verbHandlerName, new Object[]{bos.toByteArray()});
return message;
}

View File

@ -141,7 +141,7 @@ public class FailureDetector implements IFailureDetector, FailureDetectorMBean
try
{
/* If the endpoint in question is the local endpoint return true. */
String localHost = FBUtilities.getHostName();
String localHost = FBUtilities.getHostAddress();
if ( localHost.equals( ep.getHost() ) )
return true;
}

View File

@ -30,7 +30,6 @@ import java.util.Map;
import org.apache.cassandra.utils.FBUtilities;
import org.apache.cassandra.utils.LogUtil;
import org.apache.log4j.Logger;
import org.apache.cassandra.config.DatabaseDescriptor;
/**
* Author : Avinash Lakshman ( alakshman@facebook.com) & Prashant Malik ( pmalik@facebook.com )
@ -49,7 +48,7 @@ public class EndPoint implements Serializable, Comparable<EndPoint>
{
try
{
randomLocalEndPoint_ = new EndPoint(FBUtilities.getHostName(), EndPoint.randomPort_);
randomLocalEndPoint_ = new EndPoint(FBUtilities.getHostAddress(), EndPoint.randomPort_);
}
catch ( IOException ex )
{
@ -74,7 +73,7 @@ public class EndPoint implements Serializable, Comparable<EndPoint>
{
try
{
host_ = FBUtilities.getHostName();
host_ = FBUtilities.getHostAddress();
}
catch (UnknownHostException e)
{

View File

@ -20,9 +20,7 @@ package org.apache.cassandra.service;
import java.io.File;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.InetSocketAddress;
import java.net.InetAddress;
import org.apache.log4j.Logger;
import org.apache.thrift.protocol.TBinaryProtocol;
@ -69,7 +67,7 @@ public class CassandraDaemon
Cassandra.Processor processor = new Cassandra.Processor(peerStorageServer);
// Transport
TServerSocket tServerSocket = new TServerSocket(new InetSocketAddress(FBUtilities.getHostName(), listenPort));
TServerSocket tServerSocket = new TServerSocket(new InetSocketAddress(FBUtilities.getHostAddress(), listenPort));
// Protocol factory
TProtocolFactory tProtocolFactory = new TBinaryProtocol.Factory();

View File

@ -739,7 +739,7 @@ public class StressTest
System.err.println("**********Errors*************");
}
if ( jsap.messagePrinted() ) return null;
String hostName = FBUtilities.getHostName();
String hostName = FBUtilities.getHostAddress();
from_ = new EndPoint(hostName,10001);
MessagingService.getMessagingInstance().listen(from_, false);
}

View File

@ -65,7 +65,7 @@ public class KeyChecker
/* Sleep for proper discovery */
Thread.sleep(240000);
/* Create the file for the missing keys */
RandomAccessFile raf = new RandomAccessFile( "Missing-" + FBUtilities.getHostName() + ".dat", "rw");
RandomAccessFile raf = new RandomAccessFile( "Missing-" + FBUtilities.getHostAddress() + ".dat", "rw");
/* Start reading the file that contains the keys */
BufferedReader bufReader = new BufferedReader( new InputStreamReader( new FileInputStream(args[0]) ), KeyChecker.bufSize_ );

View File

@ -63,7 +63,7 @@ public class MembershipCleaner
DataOutputStream dos = new DataOutputStream(bos);
MembershipCleanerMessage.serializer().serialize(mcMessage, dos);
/* Construct the token update message to be sent */
Message mbrshipCleanerMessage = new Message( new EndPoint(FBUtilities.getHostName(), port_), "", StorageService.mbrshipCleanerVerbHandler_, new Object[]{bos.toByteArray()} );
Message mbrshipCleanerMessage = new Message( new EndPoint(FBUtilities.getHostAddress(), port_), "", StorageService.mbrshipCleanerVerbHandler_, new Object[]{bos.toByteArray()} );
BufferedReader bufReader = new BufferedReader( new InputStreamReader( new FileInputStream(file) ) );
String line = null;

View File

@ -61,7 +61,7 @@ public class TokenUpdater
DataOutputStream dos = new DataOutputStream(bos);
TokenInfoMessage.serializer().serialize(tiMessage, dos);
/* Construct the token update message to be sent */
Message tokenUpdateMessage = new Message( new EndPoint(FBUtilities.getHostName(), port_), "", StorageService.tokenVerbHandler_, new Object[]{bos.toByteArray()} );
Message tokenUpdateMessage = new Message( new EndPoint(FBUtilities.getHostAddress(), port_), "", StorageService.tokenVerbHandler_, new Object[]{bos.toByteArray()} );
BufferedReader bufReader = new BufferedReader( new InputStreamReader( new FileInputStream(file) ) );
String line = null;

View File

@ -148,7 +148,7 @@ public class FBUtilities
return localInetAddress_;
}
public static String getHostName() throws UnknownHostException
public static String getHostAddress() throws UnknownHostException
{
InetAddress inetAddr = getLocalAddress();
if (DatabaseDescriptor.getListenAddress() != null)