mirror of https://github.com/apache/cassandra
cleanup. patch by jbellis
git-svn-id: https://svn.apache.org/repos/asf/cassandra/trunk@1003831 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1e47c83d25
commit
e239146914
|
|
@ -22,27 +22,22 @@ import java.nio.ByteBuffer;
|
|||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.google.common.collect.*;
|
||||
|
||||
import org.apache.avro.util.Utf8;
|
||||
import org.apache.cassandra.config.avro.CfDef;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
|
||||
import org.apache.avro.util.Utf8;
|
||||
import org.apache.cassandra.config.avro.ColumnDef;
|
||||
import org.apache.cassandra.db.marshal.TimeUUIDType;
|
||||
import org.apache.cassandra.db.marshal.UTF8Type;
|
||||
import org.apache.cassandra.io.SerDeUtils;
|
||||
import org.apache.cassandra.db.ColumnFamilyType;
|
||||
import org.apache.cassandra.db.ClockType;
|
||||
import org.apache.cassandra.db.*;
|
||||
import org.apache.cassandra.db.clock.AbstractReconciler;
|
||||
import org.apache.cassandra.db.clock.TimestampReconciler;
|
||||
import org.apache.cassandra.db.HintedHandOffManager;
|
||||
import org.apache.cassandra.db.SystemTable;
|
||||
import org.apache.cassandra.db.Table;
|
||||
import org.apache.cassandra.db.marshal.AbstractType;
|
||||
import org.apache.cassandra.db.marshal.BytesType;
|
||||
import org.apache.cassandra.db.marshal.TimeUUIDType;
|
||||
import org.apache.cassandra.db.marshal.UTF8Type;
|
||||
import org.apache.cassandra.db.migration.Migration;
|
||||
import org.apache.cassandra.io.SerDeUtils;
|
||||
import org.apache.cassandra.utils.FBUtilities;
|
||||
import org.apache.cassandra.utils.Pair;
|
||||
|
||||
|
|
@ -91,18 +86,10 @@ public final class CFMetaData
|
|||
Collections.<byte[], ColumnDefinition>emptyMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An immutable mapping of (ksname,cfname) to id.
|
||||
*/
|
||||
public static final Map<Pair<String, String>, Integer> getCfToIdMap()
|
||||
{
|
||||
return Collections.unmodifiableMap(cfIdMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The (ksname,cfname) pair for the given id, or null if it has been dropped.
|
||||
*/
|
||||
public static final Pair<String,String> getCF(Integer cfId)
|
||||
public static Pair<String,String> getCF(Integer cfId)
|
||||
{
|
||||
return cfIdMap.inverse().get(cfId);
|
||||
}
|
||||
|
|
@ -110,13 +97,13 @@ public final class CFMetaData
|
|||
/**
|
||||
* @return The id for the given (ksname,cfname) pair, or null if it has been dropped.
|
||||
*/
|
||||
public static final Integer getId(String table, String cfName)
|
||||
public static Integer getId(String table, String cfName)
|
||||
{
|
||||
return cfIdMap.get(new Pair<String, String>(table, cfName));
|
||||
}
|
||||
|
||||
// this gets called after initialization to make sure that id generation happens properly.
|
||||
public static final void fixMaxId()
|
||||
public static void fixMaxId()
|
||||
{
|
||||
// never set it to less than 1000. this ensures that we have enough system CFids for future use.
|
||||
idGen.set(cfIdMap.size() == 0 ? MIN_CF_ID : Math.max(Collections.max(cfIdMap.values()) + 1, MIN_CF_ID));
|
||||
|
|
@ -310,16 +297,6 @@ public final class CFMetaData
|
|||
cfIdMap.remove(new Pair<String, String>(cfm.tableName, cfm.cfName));
|
||||
}
|
||||
|
||||
// a quick and dirty pretty printer for describing the column family...
|
||||
//TODO: Make it prettier, use it in the CLI
|
||||
public String pretty()
|
||||
{
|
||||
return tableName + "." + cfName + "\n"
|
||||
+ "Column Family Type: " + cfType + "\n"
|
||||
+ "Column Family Clock Type: " + clockType + "\n"
|
||||
+ "Columns Sorted By: " + comparator + "\n";
|
||||
}
|
||||
|
||||
public org.apache.cassandra.config.avro.CfDef deflate()
|
||||
{
|
||||
org.apache.cassandra.config.avro.CfDef cf = new org.apache.cassandra.config.avro.CfDef();
|
||||
|
|
@ -465,7 +442,7 @@ public final class CFMetaData
|
|||
public CFMetaData apply(org.apache.cassandra.avro.CfDef cf_def) throws ConfigurationException
|
||||
{
|
||||
// validate.
|
||||
if (cf_def.id != cfId)
|
||||
if (!cf_def.id.equals(cfId))
|
||||
throw new ConfigurationException(String.format("ids do not match. %d, %d", cf_def.id, cfId));
|
||||
if (!cf_def.keyspace.toString().equals(tableName))
|
||||
throw new ConfigurationException(String.format("keyspaces do not match. %s, %s", cf_def.keyspace, tableName));
|
||||
|
|
@ -499,7 +476,7 @@ public final class CFMetaData
|
|||
cf_def.key_cache_size,
|
||||
cf_def.read_repair_chance,
|
||||
cf_def.gc_grace_seconds,
|
||||
DatabaseDescriptor.getComparator(cf_def.default_validation_class == null ? (String)null : cf_def.default_validation_class.toString()),
|
||||
DatabaseDescriptor.getComparator(cf_def.default_validation_class == null ? null : cf_def.default_validation_class.toString()),
|
||||
cf_def.min_compaction_threshold,
|
||||
cf_def.max_compaction_threshold,
|
||||
cfId,
|
||||
|
|
@ -682,4 +659,27 @@ public final class CFMetaData
|
|||
//Defaults are valid.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "CFMetaData{" +
|
||||
"gcGraceSeconds=" + gcGraceSeconds +
|
||||
", comparator=" + comparator +
|
||||
", subcolumnComparator=" + subcolumnComparator +
|
||||
", comment='" + comment + '\'' +
|
||||
", rowCacheSize=" + rowCacheSize +
|
||||
", keyCacheSize=" + keyCacheSize +
|
||||
", readRepairChance=" + readRepairChance +
|
||||
", preloadRowCache=" + preloadRowCache +
|
||||
", cfId=" + cfId +
|
||||
", tableName='" + tableName + '\'' +
|
||||
", cfName='" + cfName + '\'' +
|
||||
", cfType=" + cfType +
|
||||
", defaultValidator=" + defaultValidator +
|
||||
", minCompactionThreshold=" + minCompactionThreshold +
|
||||
", maxCompactionThreshold=" + maxCompactionThreshold +
|
||||
", column_metadata=" + FBUtilities.toString(column_metadata) +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,4 +143,15 @@ public class ColumnDefinition {
|
|||
|
||||
return Collections.unmodifiableMap(cds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "ColumnDefinition{" +
|
||||
"name=" + FBUtilities.bytesToHex(name) +
|
||||
", validator=" + validator +
|
||||
", index_type=" + index_type +
|
||||
", index_name='" + index_name + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,15 +86,8 @@ public class CassandraServer implements Cassandra.Iface
|
|||
*/
|
||||
private final IRequestScheduler requestScheduler;
|
||||
|
||||
/*
|
||||
* Handle to the storage service to interact with the other machines in the
|
||||
* cluster.
|
||||
*/
|
||||
private final StorageService storageService;
|
||||
|
||||
public CassandraServer()
|
||||
{
|
||||
storageService = StorageService.instance;
|
||||
requestScheduler = DatabaseDescriptor.getRequestScheduler();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -684,4 +684,16 @@ public class FBUtilities
|
|||
set.add(column);
|
||||
return set;
|
||||
}
|
||||
|
||||
public static String toString(Map<?,?> map)
|
||||
{
|
||||
// wtf, why isn't something like this in guava or commons collections?
|
||||
StringBuilder sb = new StringBuilder("{");
|
||||
for (Map.Entry<?,?> entry : map.entrySet())
|
||||
{
|
||||
sb.append(entry.getKey()).append(": ").append(entry.getValue()).append(", ");
|
||||
}
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue