r/m redundant or unused code. patch by jbellis; reviewed by johano for #56

git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@762441 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Ellis 2009-04-06 17:56:01 +00:00
parent d1e78cbf84
commit 85c9bda653
9 changed files with 39 additions and 155 deletions

View File

@ -356,8 +356,8 @@ public class ColumnFamilyStore
*/
String getTempFileName( List<String> files)
{
int lowestIndex = 0 ;
int index = 0;
int lowestIndex;
int index;
Collections.sort(files, new FileNameComparator(FileNameComparator.Ascending));
if( files.size() <= 1)
@ -515,7 +515,7 @@ public class ColumnFamilyStore
{
SSTable ssTable = new SSTable(ssTableFile);
long start = System.currentTimeMillis();
DataInputBuffer bufIn = null;
DataInputBuffer bufIn;
bufIn = filter.next(key, cf, ssTable);
logger_.debug("DISK ssTable.next TIME: " + (System.currentTimeMillis() - start) + " ms.");
if (bufIn.getLength() == 0)
@ -746,7 +746,7 @@ public class ColumnFamilyStore
List<String> files = new ArrayList<String>(ssTables_);
try
{
int count = 0;
int count;
for(List<String> fileList : getCompactionBuckets(files, 50L*1024L*1024L))
{
Collections.sort( fileList , new FileNameComparator( FileNameComparator.Ascending));
@ -781,7 +781,7 @@ public class ColumnFamilyStore
}
}
void doMajorCompaction(long skip) throws IOException
void doMajorCompaction(long skip)
{
doMajorCompactionInternal( skip );
}
@ -796,7 +796,7 @@ public class ColumnFamilyStore
{
isCompacting_.set(true);
List<String> filesInternal = new ArrayList<String>(ssTables_);
List<String> files = null;
List<String> files;
try
{
if( skip > 0L )
@ -948,11 +948,11 @@ public class ColumnFamilyStore
* @throws IOException
*/
/* TODO: Take care of the comments later. */
void doCleanup(String file) throws IOException
void doCleanup(String file)
{
if(file == null )
return;
List<Range> myRanges = null;
List<Range> myRanges;
List<String> files = new ArrayList<String>();
files.add(file);
List<String> newFiles = new ArrayList<String>();
@ -1002,8 +1002,8 @@ public class ColumnFamilyStore
long totalBytesWritten = 0;
long totalkeysRead = 0;
long totalkeysWritten = 0;
String rangeFileLocation = null;
String mergedFileName = null;
String rangeFileLocation;
String mergedFileName;
try
{
// Calculate the expected compacted filesize
@ -1053,7 +1053,7 @@ public class ColumnFamilyStore
else
{
Collections.sort(lfs, new FileStructComparator());
ColumnFamily columnFamily = null;
ColumnFamily columnFamily;
bufOut.reset();
if(lfs.size() > 1)
{
@ -1295,7 +1295,7 @@ public class ColumnFamilyStore
else
{
Collections.sort(lfs, new FileStructComparator());
ColumnFamily columnFamily = null;
ColumnFamily columnFamily;
bufOut.reset();
if(lfs.size() > 1)
{

View File

@ -82,7 +82,7 @@ public class Memtable implements MemtableMBean, Comparable<Memtable>
/* Lock and Condition for notifying new clients about Memtable switches */
Lock lock_ = new ReentrantLock();
Memtable(String table, String cfName) throws IOException
Memtable(String table, String cfName)
{
if ( apartments_.get(cfName) == null )
{
@ -315,7 +315,7 @@ public class Memtable implements MemtableMBean, Comparable<Memtable>
* is not respected and a forceFlush() needs to be invoked to flush
* the contents to disk.
*/
void putOnRecovery(String key, ColumnFamily columnFamily) throws IOException
void putOnRecovery(String key, ColumnFamily columnFamily)
{
if(!key.equals(Memtable.flushKey_))
resolve(key, columnFamily);

View File

@ -101,12 +101,6 @@ class MinorCompactionManager implements IComponentShutdown
private EndPoint target_;
private List<String> fileList_;
FileCompactor2(ColumnFamilyStore columnFamilyStore, List<Range> ranges)
{
columnFamilyStore_ = columnFamilyStore;
ranges_ = ranges;
}
FileCompactor2(ColumnFamilyStore columnFamilyStore, List<Range> ranges, EndPoint target,List<String> fileList)
{
columnFamilyStore_ = columnFamilyStore;
@ -117,7 +111,7 @@ class MinorCompactionManager implements IComponentShutdown
public Boolean call()
{
boolean result = true;
boolean result;
logger_.debug("Started compaction ..."+columnFamilyStore_.columnFamily_);
result = columnFamilyStore_.doAntiCompaction(ranges_, target_,fileList_);
logger_.debug("Finished compaction ..."+columnFamilyStore_.columnFamily_);
@ -138,17 +132,9 @@ class MinorCompactionManager implements IComponentShutdown
public void run()
{
try
{
logger_.debug("Started Major compaction ..."+columnFamilyStore_.columnFamily_);
columnFamilyStore_.doMajorCompaction(skip_);
logger_.debug("Finished Major compaction ..."+columnFamilyStore_.columnFamily_);
}
catch (IOException e)
{
logger_.debug( LogUtil.throwableToString(e) );
}
return ;
logger_.debug("Started Major compaction ..."+columnFamilyStore_.columnFamily_);
columnFamilyStore_.doMajorCompaction(skip_);
logger_.debug("Finished Major compaction ..."+columnFamilyStore_.columnFamily_);
}
}

View File

@ -65,11 +65,6 @@ public class Table
{
/* Name of the column family */
public final static String cfName_ = "TableMetadata";
/*
* Name of one of the columns. The other columns are the individual
* column families in the system.
*/
public static final String cardinality_ = "PrimaryCardinality";
private static ICompactSerializer<TableMetadata> serializer_;
static
{
@ -173,11 +168,6 @@ public class Table
return cfTypeMap_.get(cfName);
}
void setColumnFamilyType(String cfName, String type)
{
cfTypeMap_.put(cfName, type);
}
Set<String> getColumnFamilies()
{
return cfIdMap_.keySet();
@ -208,13 +198,7 @@ public class Table
logger_.debug(LogUtil.throwableToString(ex));
}
}
public void reset() throws IOException
{
writer_.seek(0L);
apply();
}
public String toString()
{
StringBuilder sb = new StringBuilder("");
@ -380,19 +364,7 @@ public class Table
return fileNames;
}
private boolean isStreamContextForThisColumnFamily(StreamContextManager.StreamContext streamContext, String cf)
{
String[] peices = FBUtilities.strip(streamContext.getTargetFile(), "-");
return peices[1].equals(cf);
}
private String getColumnFamilyFromFile(String file)
{
String[] peices = FBUtilities.strip(file, "-");
return peices[1];
}
private void addStreamContext(String host, StreamContextManager.StreamContext streamContext, StreamContextManager.StreamStatus streamStatus)
{
logger_.debug("Adding stream context " + streamContext + " for " + host + " ...");
@ -401,7 +373,6 @@ public class Table
}
private static Logger logger_ = Logger.getLogger(Table.class);
public static final String newLine_ = System.getProperty("line.separator");
public static final String recycleBin_ = "RecycleColumnFamily";
public static final String hints_ = "HintsColumnFamily";
@ -467,11 +438,6 @@ public class Table
return cfType;
}
public void setColumnFamilyType(String cfName, String type)
{
tableMetadata_.setColumnFamilyType(cfName, type);
}
/*
* This method is called to obtain statistics about
* the table. It will return statistics about all
@ -562,7 +528,7 @@ public class Table
* do a complete compaction since we can figure out based on the ranges
* whether the files need to be split.
*/
public boolean forceCompaction(List<Range> ranges, EndPoint target, List<String> fileList) throws IOException
public boolean forceCompaction(List<Range> ranges, EndPoint target, List<String> fileList)
{
boolean result = true;
Set<String> columnFamilies = tableMetadata_.getColumnFamilies();
@ -585,7 +551,7 @@ public class Table
* This method is an ADMIN operation to force compaction
* of all SSTables on disk.
*/
public void forceCompaction() throws IOException
public void forceCompaction()
{
Set<String> columnFamilies = tableMetadata_.getColumnFamilies();
for ( String columnFamily : columnFamilies )

View File

@ -69,8 +69,8 @@ public class Range implements Comparable<Range>
}
private BigInteger left_;
private BigInteger right_;
private final BigInteger left_;
private final BigInteger right_;
public Range(BigInteger left, BigInteger right)
{

View File

@ -193,7 +193,7 @@ public class SSTable
public int compareTo(KeyPositionInfo kPosInfo)
{
int value = 0;
int value;
PartitionerType pType = StorageService.getPartitionerType();
switch( pType )
{
@ -513,7 +513,7 @@ public class SSTable
bufIn.readInt();
/* Number of keys in the block. */
int keys = bufIn.readInt();
String largestKeyInBlock = null;
String largestKeyInBlock;
for ( int i = 0; i < keys; ++i )
{
String keyInBlock = bufIn.readUTF();
@ -660,7 +660,7 @@ public class SSTable
return currentPosition;
}
private void afterAppend(String key, long position, long size) throws IOException
private void afterAppend(String key, long position, long size)
{
++indexKeysWritten_;
lastWrittenKey_ = key;
@ -673,7 +673,7 @@ public class SSTable
}
}
private void afterAppend(BigInteger hash, long position, long size) throws IOException
private void afterAppend(BigInteger hash, long position, long size)
{
++indexKeysWritten_;
String key = hash.toString();
@ -760,14 +760,6 @@ public class SSTable
dataWriter_.append(key, value);
afterAppend(key, currentPosition, value.length );
}
public void append(String key, BigInteger hash, byte[] value) throws IOException
{
long currentPosition = beforeAppend(hash);
/* Use as key - hash + ":" + key */
dataWriter_.append(hash + ":" + key, value);
afterAppend(hash, currentPosition, value.length);
}
private Coordinate getCoordinates(String key, IFileReader dataReader) throws IOException
{
@ -894,56 +886,6 @@ public class SSTable
List<String> columnNames = (values.length == 1) ? null : Arrays.asList(values[1]);
return next(key, columnFamilyName, columnNames, null);
}
long getSeekPosition(String key, long start)
{
Long seekStart = touchCache_.get(dataFile_ + ":" + key);
if( seekStart != null)
{
return seekStart;
}
return start;
}
/*
* Given a key we are interested in this method gets the
* closest index before the key on disk.
*
* param @ key - key we are interested in.
* return position of the closest index before the key
* on disk or -1 if this key is not on disk.
*/
private long getClosestIndexPositionToKeyOnDisk(String key)
{
long position = -1L;
List<KeyPositionInfo> indexInfo = indexMetadataMap_.get(dataFile_);
int size = indexInfo.size();
int index = Collections.binarySearch(indexInfo, new KeyPositionInfo(key));
if ( index < 0 )
{
/*
* We are here which means that the requested
* key is not an index.
*/
index = (++index)*(-1);
/* this means key is not present at all */
if ( index >= size )
return position;
/* a scan is in order. */
position = (index == 0) ? 0 : indexInfo.get(index - 1).position();
}
else
{
/*
* If we are here that means the key is in the index file
* and we can retrieve it w/o a scan. In reality we would
* like to have a retreive(key, fromPosition) but for now
* we use scan(start, start + 1) - a hack.
*/
position = indexInfo.get(index).position();
}
return position;
}
public void close() throws IOException
{

View File

@ -421,7 +421,7 @@ public class SequenceFile
{
Method getCleanerMethod = buffer.getClass().getMethod("cleaner", new Class[0]);
getCleanerMethod.setAccessible(true);
sun.misc.Cleaner cleaner = (sun.misc.Cleaner) getCleanerMethod.invoke(buffer, new Object[0]);
sun.misc.Cleaner cleaner = (sun.misc.Cleaner) getCleanerMethod.invoke(buffer);
cleaner.clean();
}
catch (Throwable e)

View File

@ -684,14 +684,7 @@ public class HttpRequestVerbHandler implements IVerbHandler
private String handleCompactMe()
{
Table table = Table.open(DatabaseDescriptor.getTables().get(0));
try
{
table.forceCompaction();
}
catch (IOException ex)
{
logger_.debug(LogUtil.throwableToString(ex));
}
table.forceCompaction();
return "Compacting ...";
}

View File

@ -138,8 +138,8 @@ public final class StorageService implements IEndPointStateChangeSubscriber, Sto
{
WEAK,
STRONG
};
}
private static StorageService instance_;
/* Used to lock the factory for creation of StorageService instance */
private static Lock createLock_ = new ReentrantLock();
@ -181,8 +181,8 @@ public final class StorageService implements IEndPointStateChangeSubscriber, Sto
{
HINT,
FULL
};
}
public static class BootstrapInitiateDoneVerbHandler implements IVerbHandler
{
private static Logger logger_ = Logger.getLogger( BootstrapInitiateDoneVerbHandler.class );
@ -302,7 +302,7 @@ public final class StorageService implements IEndPointStateChangeSubscriber, Sto
}
}
public StorageService() throws Throwable
public StorageService()
{
init();
uptime_ = System.currentTimeMillis();
@ -627,8 +627,7 @@ public final class StorageService implements IEndPointStateChangeSubscriber, Sto
Set<BigInteger> tokens = tokenToEndPointMap.keySet();
/* All the ranges for the tokens */
Range[] ranges = getAllRanges(tokens);
Map<Range, List<EndPoint>> oldRangeToEndPointMap = constructRangeToEndPointMap(ranges);
return oldRangeToEndPointMap;
return constructRangeToEndPointMap(ranges);
}
/**
@ -856,7 +855,7 @@ public final class StorageService implements IEndPointStateChangeSubscriber, Sto
private void doBootstrap(String nodes)
{
String[] allNodesAndFilter = nodes.split("-");
String nodesToLoad = null;
String nodesToLoad;
String filterSources = null;
if ( allNodesAndFilter.length == 2 )
@ -1032,10 +1031,9 @@ public final class StorageService implements IEndPointStateChangeSubscriber, Sto
List<BigInteger> tokens = new ArrayList<BigInteger>(tokenToEndPointMap.keySet());
Collections.sort(tokens);
int index = Collections.binarySearch(tokens, token);
EndPoint predecessor = (index == 0) ? tokenToEndPointMap.get(tokens
return (index == 0) ? tokenToEndPointMap.get(tokens
.get(tokens.size() - 1)) : tokenToEndPointMap.get(tokens
.get(--index));
return predecessor;
}
/*
@ -1049,10 +1047,9 @@ public final class StorageService implements IEndPointStateChangeSubscriber, Sto
List<BigInteger> tokens = new ArrayList<BigInteger>(tokenToEndPointMap.keySet());
Collections.sort(tokens);
int index = Collections.binarySearch(tokens, token);
EndPoint successor = (index == (tokens.size() - 1)) ? tokenToEndPointMap
return (index == (tokens.size() - 1)) ? tokenToEndPointMap
.get(tokens.get(0))
: tokenToEndPointMap.get(tokens.get(++index));
return successor;
}
/**