cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [04/26] cassandra git commit: Thrift removal
Date Tue, 13 Dec 2016 09:27:28 GMT
http://git-wip-us.apache.org/repos/asf/cassandra/blob/4881d9c3/src/java/org/apache/cassandra/thrift/ThriftConversion.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/ThriftConversion.java b/src/java/org/apache/cassandra/thrift/ThriftConversion.java
deleted file mode 100644
index 0c5c4be..0000000
--- a/src/java/org/apache/cassandra/thrift/ThriftConversion.java
+++ /dev/null
@@ -1,726 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cassandra.thrift;
-
-import java.util.*;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Strings;
-import com.google.common.collect.Maps;
-
-import org.apache.cassandra.config.*;
-import org.apache.cassandra.cql3.ColumnIdentifier;
-import org.apache.cassandra.cql3.Operator;
-import org.apache.cassandra.cql3.statements.IndexTarget;
-import org.apache.cassandra.db.CompactTables;
-import org.apache.cassandra.db.LegacyLayout;
-import org.apache.cassandra.db.WriteType;
-import org.apache.cassandra.db.compaction.AbstractCompactionStrategy;
-import org.apache.cassandra.db.filter.RowFilter;
-import org.apache.cassandra.db.marshal.*;
-import org.apache.cassandra.exceptions.*;
-import org.apache.cassandra.index.TargetParser;
-import org.apache.cassandra.io.compress.ICompressor;
-import org.apache.cassandra.locator.AbstractReplicationStrategy;
-import org.apache.cassandra.locator.LocalStrategy;
-import org.apache.cassandra.schema.*;
-import org.apache.cassandra.serializers.MarshalException;
-import org.apache.cassandra.utils.ByteBufferUtil;
-import org.apache.cassandra.utils.Pair;
-import org.apache.cassandra.utils.UUIDGen;
-
-/**
- * Static utility methods to convert internal structure to and from thrift ones.
- */
-public class ThriftConversion
-{
-    public static org.apache.cassandra.db.ConsistencyLevel fromThrift(ConsistencyLevel cl)
-    {
-        switch (cl)
-        {
-            case ANY: return org.apache.cassandra.db.ConsistencyLevel.ANY;
-            case ONE: return org.apache.cassandra.db.ConsistencyLevel.ONE;
-            case TWO: return org.apache.cassandra.db.ConsistencyLevel.TWO;
-            case THREE: return org.apache.cassandra.db.ConsistencyLevel.THREE;
-            case QUORUM: return org.apache.cassandra.db.ConsistencyLevel.QUORUM;
-            case ALL: return org.apache.cassandra.db.ConsistencyLevel.ALL;
-            case LOCAL_QUORUM: return org.apache.cassandra.db.ConsistencyLevel.LOCAL_QUORUM;
-            case EACH_QUORUM: return org.apache.cassandra.db.ConsistencyLevel.EACH_QUORUM;
-            case SERIAL: return org.apache.cassandra.db.ConsistencyLevel.SERIAL;
-            case LOCAL_SERIAL: return org.apache.cassandra.db.ConsistencyLevel.LOCAL_SERIAL;
-            case LOCAL_ONE: return org.apache.cassandra.db.ConsistencyLevel.LOCAL_ONE;
-        }
-        throw new AssertionError();
-    }
-
-    public static ConsistencyLevel toThrift(org.apache.cassandra.db.ConsistencyLevel cl)
-    {
-        switch (cl)
-        {
-            case ANY: return ConsistencyLevel.ANY;
-            case ONE: return ConsistencyLevel.ONE;
-            case TWO: return ConsistencyLevel.TWO;
-            case THREE: return ConsistencyLevel.THREE;
-            case QUORUM: return ConsistencyLevel.QUORUM;
-            case ALL: return ConsistencyLevel.ALL;
-            case LOCAL_QUORUM: return ConsistencyLevel.LOCAL_QUORUM;
-            case EACH_QUORUM: return ConsistencyLevel.EACH_QUORUM;
-            case SERIAL: return ConsistencyLevel.SERIAL;
-            case LOCAL_SERIAL: return ConsistencyLevel.LOCAL_SERIAL;
-            case LOCAL_ONE: return ConsistencyLevel.LOCAL_ONE;
-        }
-        throw new AssertionError();
-    }
-
-    // We never return, but returning a RuntimeException allows to write "throw rethrow(e)" without java complaining
-    // for methods that have a return value.
-    public static RuntimeException rethrow(RequestExecutionException e) throws UnavailableException, TimedOutException
-    {
-        if (e instanceof RequestFailureException)
-            throw toThrift((RequestFailureException)e);
-        else if (e instanceof RequestTimeoutException)
-            throw toThrift((RequestTimeoutException)e);
-        else
-            throw new UnavailableException();
-    }
-
-    public static InvalidRequestException toThrift(RequestValidationException e)
-    {
-        return new InvalidRequestException(e.getMessage());
-    }
-
-    public static UnavailableException toThrift(org.apache.cassandra.exceptions.UnavailableException e)
-    {
-        return new UnavailableException();
-    }
-
-    public static AuthenticationException toThrift(org.apache.cassandra.exceptions.AuthenticationException e)
-    {
-        return new AuthenticationException(e.getMessage());
-    }
-
-    public static TimedOutException toThrift(RequestTimeoutException e)
-    {
-        TimedOutException toe = new TimedOutException();
-        if (e instanceof WriteTimeoutException)
-        {
-            WriteTimeoutException wte = (WriteTimeoutException)e;
-            toe.setAcknowledged_by(wte.received);
-            if (wte.writeType == WriteType.BATCH_LOG)
-                toe.setAcknowledged_by_batchlog(false);
-            else if (wte.writeType == WriteType.BATCH)
-                toe.setAcknowledged_by_batchlog(true);
-            else if (wte.writeType == WriteType.CAS)
-                toe.setPaxos_in_progress(true);
-        }
-        return toe;
-    }
-
-    // Thrift does not support RequestFailureExceptions, so we translate them into timeouts
-    public static TimedOutException toThrift(RequestFailureException e)
-    {
-        return new TimedOutException();
-    }
-
-    public static RowFilter rowFilterFromThrift(CFMetaData metadata, List<IndexExpression> exprs)
-    {
-        if (exprs == null || exprs.isEmpty())
-            return RowFilter.NONE;
-
-        RowFilter converted = RowFilter.forThrift(exprs.size());
-        for (IndexExpression expr : exprs)
-            converted.addThriftExpression(metadata, expr.column_name, Operator.valueOf(expr.op.name()), expr.value);
-        return converted;
-    }
-
-    public static KeyspaceMetadata fromThrift(KsDef ksd, CFMetaData... cfDefs) throws ConfigurationException
-    {
-        Class<? extends AbstractReplicationStrategy> cls = AbstractReplicationStrategy.getClass(ksd.strategy_class);
-        if (cls.equals(LocalStrategy.class))
-            throw new ConfigurationException("Unable to use given strategy class: LocalStrategy is reserved for internal use.");
-
-        Map<String, String> replicationMap = new HashMap<>();
-        if (ksd.strategy_options != null)
-            replicationMap.putAll(ksd.strategy_options);
-        replicationMap.put(ReplicationParams.CLASS, cls.getName());
-
-        return KeyspaceMetadata.create(ksd.name, KeyspaceParams.create(ksd.durable_writes, replicationMap), Tables.of(cfDefs));
-    }
-
-    public static KsDef toThrift(KeyspaceMetadata ksm)
-    {
-        List<CfDef> cfDefs = new ArrayList<>();
-        for (CFMetaData cfm : ksm.tables) // do not include views
-            if (cfm.isThriftCompatible()) // Don't expose CF that cannot be correctly handle by thrift; see CASSANDRA-4377 for further details
-                cfDefs.add(toThrift(cfm));
-
-        KsDef ksdef = new KsDef(ksm.name, ksm.params.replication.klass.getName(), cfDefs);
-        ksdef.setStrategy_options(ksm.params.replication.options);
-        ksdef.setDurable_writes(ksm.params.durableWrites);
-
-        return ksdef;
-    }
-
-    public static CFMetaData fromThrift(CfDef cf_def)
-    throws org.apache.cassandra.exceptions.InvalidRequestException, ConfigurationException
-    {
-        // This is a creation: the table is dense if it doesn't define any column_metadata
-        boolean isDense = cf_def.column_metadata == null || cf_def.column_metadata.isEmpty();
-        return internalFromThrift(cf_def, true, Collections.<ColumnDefinition>emptyList(), isDense);
-    }
-
-    public static CFMetaData fromThriftForUpdate(CfDef cf_def, CFMetaData toUpdate)
-    throws org.apache.cassandra.exceptions.InvalidRequestException, ConfigurationException
-    {
-        return internalFromThrift(cf_def, false, toUpdate.allColumns(), toUpdate.isDense());
-    }
-
-    private static boolean isSuper(String thriftColumnType)
-    throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        switch (thriftColumnType.toLowerCase(Locale.ENGLISH))
-        {
-            case "standard": return false;
-            case "super": return true;
-            default: throw new org.apache.cassandra.exceptions.InvalidRequestException("Invalid column type " + thriftColumnType);
-        }
-    }
-
-    /**
-     * Convert a thrift CfDef.
-     * <p>,
-     * This is used both for creation and update of CF.
-     *
-     * @param cf_def the thrift CfDef to convert.
-     * @param isCreation whether that is a new table creation or not.
-     * @param previousCQLMetadata if it is not a table creation, the previous
-     * definitions of the tables (which we use to preserve the CQL metadata).
-     * If it is a table creation, this will be empty.
-     * @param isDense whether the table is dense or not.
-     *
-     * @return the converted table definition.
-     */
-    private static CFMetaData internalFromThrift(CfDef cf_def,
-                                                 boolean isCreation,
-                                                 Collection<ColumnDefinition> previousCQLMetadata,
-                                                 boolean isDense)
-    throws org.apache.cassandra.exceptions.InvalidRequestException, ConfigurationException
-    {
-        applyImplicitDefaults(cf_def);
-
-        try
-        {
-            boolean isSuper = isSuper(cf_def.column_type);
-            AbstractType<?> rawComparator = TypeParser.parse(cf_def.comparator_type);
-            AbstractType<?> subComparator = isSuper
-                                          ? cf_def.subcomparator_type == null ? BytesType.instance : TypeParser.parse(cf_def.subcomparator_type)
-                                          : null;
-
-            AbstractType<?> keyValidator = cf_def.isSetKey_validation_class() ? TypeParser.parse(cf_def.key_validation_class) : BytesType.instance;
-            AbstractType<?> defaultValidator = TypeParser.parse(cf_def.default_validation_class);
-
-            // Convert the definitions from the input CfDef
-            List<ColumnDefinition> defs = fromThrift(cf_def.keyspace, cf_def.name, rawComparator, subComparator, cf_def.column_metadata);
-
-            // Add the keyAlias if there is one, since that's a CQL metadata that thrift can actually change (for
-            // historical reasons)
-            boolean hasKeyAlias = cf_def.isSetKey_alias() && keyValidator != null && !(keyValidator instanceof CompositeType);
-            if (hasKeyAlias)
-                defs.add(ColumnDefinition.partitionKeyDef(cf_def.keyspace, cf_def.name, UTF8Type.instance.getString(cf_def.key_alias), keyValidator, 0));
-
-            // Now add any CQL metadata that we want to copy, skipping the keyAlias if there was one
-            for (ColumnDefinition def : previousCQLMetadata)
-            {
-                // isPartOfCellName basically means 'is not just a CQL metadata'
-                if (def.isPartOfCellName(false, isSuper))
-                    continue;
-
-                if (def.kind == ColumnDefinition.Kind.PARTITION_KEY && hasKeyAlias)
-                    continue;
-
-                defs.add(def);
-            }
-
-            UUID cfId = Schema.instance.getId(cf_def.keyspace, cf_def.name);
-            if (cfId == null)
-                cfId = UUIDGen.getTimeUUID();
-
-            boolean isCompound = !isSuper && (rawComparator instanceof CompositeType);
-            boolean isCounter = defaultValidator instanceof CounterColumnType;
-
-            // If it's a thrift table creation, adds the default CQL metadata for the new table
-            if (isCreation)
-            {
-                addDefaultCQLMetadata(defs,
-                                      cf_def.keyspace,
-                                      cf_def.name,
-                                      hasKeyAlias ? null : keyValidator,
-                                      rawComparator,
-                                      subComparator,
-                                      defaultValidator);
-            }
-
-            // We do not allow Thrift views, so we always set it to false
-            boolean isView = false;
-
-            CFMetaData newCFMD = CFMetaData.create(cf_def.keyspace,
-                                                   cf_def.name,
-                                                   cfId,
-                                                   isDense,
-                                                   isCompound,
-                                                   isSuper,
-                                                   isCounter,
-                                                   isView,
-                                                   defs,
-                                                   DatabaseDescriptor.getPartitioner());
-
-            // Convert any secondary indexes defined in the thrift column_metadata
-            newCFMD.indexes(indexDefsFromThrift(newCFMD,
-                                                cf_def.keyspace,
-                                                cf_def.name,
-                                                rawComparator,
-                                                subComparator,
-                                                cf_def.column_metadata));
-
-            if (cf_def.isSetGc_grace_seconds())
-                newCFMD.gcGraceSeconds(cf_def.gc_grace_seconds);
-
-            newCFMD.compaction(compactionParamsFromThrift(cf_def));
-
-            if (cf_def.isSetBloom_filter_fp_chance())
-                newCFMD.bloomFilterFpChance(cf_def.bloom_filter_fp_chance);
-            if (cf_def.isSetMemtable_flush_period_in_ms())
-                newCFMD.memtableFlushPeriod(cf_def.memtable_flush_period_in_ms);
-            if (cf_def.isSetCaching() || cf_def.isSetCells_per_row_to_cache())
-                newCFMD.caching(cachingFromThrift(cf_def.caching, cf_def.cells_per_row_to_cache));
-            if (cf_def.isSetRead_repair_chance())
-                newCFMD.readRepairChance(cf_def.read_repair_chance);
-            if (cf_def.isSetDefault_time_to_live())
-                newCFMD.defaultTimeToLive(cf_def.default_time_to_live);
-            if (cf_def.isSetDclocal_read_repair_chance())
-                newCFMD.dcLocalReadRepairChance(cf_def.dclocal_read_repair_chance);
-            if (cf_def.isSetMin_index_interval())
-                newCFMD.minIndexInterval(cf_def.min_index_interval);
-            if (cf_def.isSetMax_index_interval())
-                newCFMD.maxIndexInterval(cf_def.max_index_interval);
-            if (cf_def.isSetSpeculative_retry())
-                newCFMD.speculativeRetry(SpeculativeRetryParam.fromString(cf_def.speculative_retry));
-            if (cf_def.isSetTriggers())
-                newCFMD.triggers(triggerDefinitionsFromThrift(cf_def.triggers));
-            if (cf_def.isSetComment())
-                newCFMD.comment(cf_def.comment);
-            if (cf_def.isSetCompression_options())
-                newCFMD.compression(compressionParametersFromThrift(cf_def.compression_options));
-
-            return newCFMD;
-        }
-        catch (SyntaxException | MarshalException e)
-        {
-            throw new ConfigurationException(e.getMessage());
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    private static CompactionParams compactionParamsFromThrift(CfDef cf_def)
-    {
-        Class<? extends AbstractCompactionStrategy> klass =
-            CFMetaData.createCompactionStrategy(cf_def.compaction_strategy);
-        Map<String, String> options = new HashMap<>(cf_def.compaction_strategy_options);
-
-        int minThreshold = cf_def.min_compaction_threshold;
-        int maxThreshold = cf_def.max_compaction_threshold;
-
-        if (CompactionParams.supportsThresholdParams(klass))
-        {
-            options.putIfAbsent(CompactionParams.Option.MIN_THRESHOLD.toString(), Integer.toString(minThreshold));
-            options.putIfAbsent(CompactionParams.Option.MAX_THRESHOLD.toString(), Integer.toString(maxThreshold));
-        }
-
-        return CompactionParams.create(klass, options);
-    }
-
-    private static CompressionParams compressionParametersFromThrift(Map<String, String> compression_options)
-    {
-        CompressionParams compressionParameter = CompressionParams.fromMap(compression_options);
-        compressionParameter.validate();
-        return compressionParameter;
-    }
-
-    private static void addDefaultCQLMetadata(Collection<ColumnDefinition> defs,
-                                              String ks,
-                                              String cf,
-                                              AbstractType<?> keyValidator,
-                                              AbstractType<?> comparator,
-                                              AbstractType<?> subComparator,
-                                              AbstractType<?> defaultValidator)
-    {
-        CompactTables.DefaultNames names = CompactTables.defaultNameGenerator(defs);
-        if (keyValidator != null)
-        {
-            if (keyValidator instanceof CompositeType)
-            {
-                List<AbstractType<?>> subTypes = ((CompositeType)keyValidator).types;
-                for (int i = 0; i < subTypes.size(); i++)
-                    defs.add(ColumnDefinition.partitionKeyDef(ks, cf, names.defaultPartitionKeyName(), subTypes.get(i), i));
-            }
-            else
-            {
-                defs.add(ColumnDefinition.partitionKeyDef(ks, cf, names.defaultPartitionKeyName(), keyValidator, 0));
-            }
-        }
-
-        if (subComparator != null)
-        {
-            // SuperColumn tables: we use a special map to hold dynamic values within a given super column
-            defs.add(ColumnDefinition.clusteringDef(ks, cf, names.defaultClusteringName(), comparator, 0));
-            defs.add(ColumnDefinition.regularDef(ks, cf, CompactTables.SUPER_COLUMN_MAP_COLUMN_STR, MapType.getInstance(subComparator, defaultValidator, true)));
-        }
-        else
-        {
-            List<AbstractType<?>> subTypes = comparator instanceof CompositeType
-                                           ? ((CompositeType)comparator).types
-                                           : Collections.<AbstractType<?>>singletonList(comparator);
-
-            for (int i = 0; i < subTypes.size(); i++)
-                defs.add(ColumnDefinition.clusteringDef(ks, cf, names.defaultClusteringName(), subTypes.get(i), i));
-
-            defs.add(ColumnDefinition.regularDef(ks, cf, names.defaultCompactValueName(), defaultValidator));
-        }
-    }
-
-    /* applies implicit defaults to cf definition. useful in updates */
-    @SuppressWarnings("deprecation")
-    private static void applyImplicitDefaults(org.apache.cassandra.thrift.CfDef cf_def)
-    {
-        if (!cf_def.isSetComment())
-            cf_def.setComment("");
-        if (!cf_def.isSetMin_compaction_threshold())
-            cf_def.setMin_compaction_threshold(CompactionParams.DEFAULT_MIN_THRESHOLD);
-        if (!cf_def.isSetMax_compaction_threshold())
-            cf_def.setMax_compaction_threshold(CompactionParams.DEFAULT_MAX_THRESHOLD);
-        if (!cf_def.isSetCompaction_strategy())
-            cf_def.setCompaction_strategy(CompactionParams.DEFAULT.klass().getSimpleName());
-        if (!cf_def.isSetCompaction_strategy_options())
-            cf_def.setCompaction_strategy_options(Collections.emptyMap());
-        if (!cf_def.isSetCompression_options())
-            cf_def.setCompression_options(Collections.singletonMap(CompressionParams.SSTABLE_COMPRESSION, CompressionParams.DEFAULT.klass().getCanonicalName()));
-        if (!cf_def.isSetDefault_time_to_live())
-            cf_def.setDefault_time_to_live(TableParams.DEFAULT_DEFAULT_TIME_TO_LIVE);
-        if (!cf_def.isSetDclocal_read_repair_chance())
-            cf_def.setDclocal_read_repair_chance(TableParams.DEFAULT_DCLOCAL_READ_REPAIR_CHANCE);
-
-        // if index_interval was set, use that for the min_index_interval default
-        if (!cf_def.isSetMin_index_interval())
-        {
-            if (cf_def.isSetIndex_interval())
-                cf_def.setMin_index_interval(cf_def.getIndex_interval());
-            else
-                cf_def.setMin_index_interval(TableParams.DEFAULT_MIN_INDEX_INTERVAL);
-        }
-
-        if (!cf_def.isSetMax_index_interval())
-        {
-            // ensure the max is at least as large as the min
-            cf_def.setMax_index_interval(Math.max(cf_def.min_index_interval, TableParams.DEFAULT_MAX_INDEX_INTERVAL));
-        }
-    }
-
-    public static CfDef toThrift(CFMetaData cfm)
-    {
-        CfDef def = new CfDef(cfm.ksName, cfm.cfName);
-        def.setColumn_type(cfm.isSuper() ? "Super" : "Standard");
-
-        if (cfm.isSuper())
-        {
-            def.setComparator_type(cfm.comparator.subtype(0).toString());
-            def.setSubcomparator_type(cfm.thriftColumnNameType().toString());
-        }
-        else
-        {
-            def.setComparator_type(LegacyLayout.makeLegacyComparator(cfm).toString());
-        }
-
-        def.setComment(cfm.params.comment);
-        def.setRead_repair_chance(cfm.params.readRepairChance);
-        def.setDclocal_read_repair_chance(cfm.params.dcLocalReadRepairChance);
-        def.setGc_grace_seconds(cfm.params.gcGraceSeconds);
-        def.setDefault_validation_class(cfm.makeLegacyDefaultValidator().toString());
-        def.setKey_validation_class(cfm.getKeyValidator().toString());
-        def.setMin_compaction_threshold(cfm.params.compaction.minCompactionThreshold());
-        def.setMax_compaction_threshold(cfm.params.compaction.maxCompactionThreshold());
-        // We only return the alias if only one is set since thrift don't know about multiple key aliases
-        if (cfm.partitionKeyColumns().size() == 1)
-            def.setKey_alias(cfm.partitionKeyColumns().get(0).name.bytes);
-        def.setColumn_metadata(columnDefinitionsToThrift(cfm, cfm.allColumns()));
-        def.setCompaction_strategy(cfm.params.compaction.klass().getName());
-        def.setCompaction_strategy_options(cfm.params.compaction.options());
-        def.setCompression_options(compressionParametersToThrift(cfm.params.compression));
-        def.setBloom_filter_fp_chance(cfm.params.bloomFilterFpChance);
-        def.setMin_index_interval(cfm.params.minIndexInterval);
-        def.setMax_index_interval(cfm.params.maxIndexInterval);
-        def.setMemtable_flush_period_in_ms(cfm.params.memtableFlushPeriodInMs);
-        def.setCaching(toThrift(cfm.params.caching));
-        def.setCells_per_row_to_cache(toThriftCellsPerRow(cfm.params.caching));
-        def.setDefault_time_to_live(cfm.params.defaultTimeToLive);
-        def.setSpeculative_retry(cfm.params.speculativeRetry.toString());
-        def.setTriggers(triggerDefinitionsToThrift(cfm.getTriggers()));
-
-        return def;
-    }
-
-    public static ColumnDefinition fromThrift(String ksName,
-                                              String cfName,
-                                              AbstractType<?> thriftComparator,
-                                              AbstractType<?> thriftSubcomparator,
-                                              ColumnDef thriftColumnDef)
-    throws SyntaxException, ConfigurationException
-    {
-        boolean isSuper = thriftSubcomparator != null;
-        // For super columns, the componentIndex is 1 because the ColumnDefinition applies to the column component.
-        AbstractType<?> comparator = thriftSubcomparator == null ? thriftComparator : thriftSubcomparator;
-        try
-        {
-            comparator.validate(thriftColumnDef.name);
-        }
-        catch (MarshalException e)
-        {
-            throw new ConfigurationException(String.format("Column name %s is not valid for comparator %s", ByteBufferUtil.bytesToHex(thriftColumnDef.name), comparator));
-        }
-
-        // In our generic layout, we store thrift defined columns as static, but this doesn't work for super columns so we
-        // use a regular definition (and "dynamic" columns are handled in a map).
-        ColumnDefinition.Kind kind = isSuper ? ColumnDefinition.Kind.REGULAR : ColumnDefinition.Kind.STATIC;
-        return new ColumnDefinition(ksName,
-                                    cfName,
-                                    ColumnIdentifier.getInterned(ByteBufferUtil.clone(thriftColumnDef.name), comparator),
-                                    TypeParser.parse(thriftColumnDef.validation_class),
-                                    ColumnDefinition.NO_POSITION,
-                                    kind);
-    }
-
-    private static List<ColumnDefinition> fromThrift(String ksName,
-                                                     String cfName,
-                                                     AbstractType<?> thriftComparator,
-                                                     AbstractType<?> thriftSubcomparator,
-                                                     List<ColumnDef> thriftDefs)
-    throws SyntaxException, ConfigurationException
-    {
-        if (thriftDefs == null)
-            return new ArrayList<>();
-
-        List<ColumnDefinition> defs = new ArrayList<>(thriftDefs.size());
-        for (ColumnDef thriftColumnDef : thriftDefs)
-            defs.add(fromThrift(ksName, cfName, thriftComparator, thriftSubcomparator, thriftColumnDef));
-
-        return defs;
-    }
-
-    private static Indexes indexDefsFromThrift(CFMetaData cfm,
-                                               String ksName,
-                                               String cfName,
-                                               AbstractType<?> thriftComparator,
-                                               AbstractType<?> thriftSubComparator,
-                                               List<ColumnDef> thriftDefs)
-    {
-        if (thriftDefs == null)
-            return Indexes.none();
-
-        Set<String> indexNames = new HashSet<>();
-        Indexes.Builder indexes = Indexes.builder();
-        for (ColumnDef def : thriftDefs)
-        {
-            if (def.isSetIndex_type())
-            {
-                ColumnDefinition column = fromThrift(ksName, cfName, thriftComparator, thriftSubComparator, def);
-
-                String indexName = def.getIndex_name();
-                // add a generated index name if none was supplied
-                if (Strings.isNullOrEmpty(indexName))
-                    indexName = Indexes.getAvailableIndexName(ksName, cfName, column.name.toString());
-
-                if (indexNames.contains(indexName))
-                    throw new ConfigurationException("Duplicate index name " + indexName);
-
-                indexNames.add(indexName);
-
-                Map<String, String> indexOptions = def.getIndex_options();
-                if (indexOptions != null && indexOptions.containsKey(IndexTarget.TARGET_OPTION_NAME))
-                        throw new ConfigurationException("Reserved index option 'target' cannot be used");
-
-                IndexMetadata.Kind kind = IndexMetadata.Kind.valueOf(def.index_type.name());
-
-                indexes.add(IndexMetadata.fromLegacyMetadata(cfm, column, indexName, kind, indexOptions));
-            }
-        }
-        return indexes.build();
-    }
-
-    @VisibleForTesting
-    public static ColumnDef toThrift(CFMetaData cfMetaData, ColumnDefinition column)
-    {
-        ColumnDef cd = new ColumnDef();
-
-        cd.setName(ByteBufferUtil.clone(column.name.bytes));
-        cd.setValidation_class(column.type.toString());
-
-        // we include the index in the ColumnDef iff its targets are compatible with
-        // pre-3.0 indexes AND it is the only index defined on the given column, that is:
-        //   * it is the only index on the column (i.e. with this column as its target)
-        //   * it has only a single target, which matches the pattern for pre-3.0 indexes
-        //     i.e. keys/values/entries/full, with exactly 1 argument that matches the
-        //     column name OR a simple column name (for indexes on non-collection columns)
-        // n.b. it's a guess that using a pre-compiled regex and checking the group is
-        // cheaper than compiling a new regex for each column, but as this isn't on
-        // any hot path this hasn't been verified yet.
-        IndexMetadata matchedIndex = null;
-        for (IndexMetadata index : cfMetaData.getIndexes())
-        {
-            Pair<ColumnDefinition, IndexTarget.Type> target  = TargetParser.parse(cfMetaData, index);
-            if (target.left.equals(column))
-            {
-                // we already found an index for this column, we've no option but to
-                // ignore both of them (and any others we've yet to find)
-                if (matchedIndex != null)
-                    return cd;
-
-                matchedIndex = index;
-            }
-        }
-
-        if (matchedIndex != null)
-        {
-            cd.setIndex_type(org.apache.cassandra.thrift.IndexType.valueOf(matchedIndex.kind.name()));
-            cd.setIndex_name(matchedIndex.name);
-            Map<String, String> filteredOptions = Maps.filterKeys(matchedIndex.options,
-                                                                  s -> !IndexTarget.TARGET_OPTION_NAME.equals(s));
-            cd.setIndex_options(filteredOptions.isEmpty()
-                                ? null
-                                : Maps.newHashMap(filteredOptions));
-        }
-
-        return cd;
-    }
-
-    private static List<ColumnDef> columnDefinitionsToThrift(CFMetaData metadata, Collection<ColumnDefinition> columns)
-    {
-        List<ColumnDef> thriftDefs = new ArrayList<>(columns.size());
-        for (ColumnDefinition def : columns)
-            if (def.isPartOfCellName(metadata.isCQLTable(), metadata.isSuper()))
-                thriftDefs.add(ThriftConversion.toThrift(metadata, def));
-        return thriftDefs;
-    }
-
-    private static Triggers triggerDefinitionsFromThrift(List<TriggerDef> thriftDefs)
-    {
-        Triggers.Builder triggers = Triggers.builder();
-        for (TriggerDef thriftDef : thriftDefs)
-            triggers.add(new TriggerMetadata(thriftDef.getName(), thriftDef.getOptions().get(TriggerMetadata.CLASS)));
-        return triggers.build();
-    }
-
-    private static List<TriggerDef> triggerDefinitionsToThrift(Triggers triggers)
-    {
-        List<TriggerDef> thriftDefs = new ArrayList<>();
-        for (TriggerMetadata def : triggers)
-        {
-            TriggerDef td = new TriggerDef();
-            td.setName(def.name);
-            td.setOptions(Collections.singletonMap(TriggerMetadata.CLASS, def.classOption));
-            thriftDefs.add(td);
-        }
-        return thriftDefs;
-    }
-
-    @SuppressWarnings("deprecation")
-    public static Map<String, String> compressionParametersToThrift(CompressionParams parameters)
-    {
-        if (!parameters.isEnabled())
-            return Collections.emptyMap();
-
-        Map<String, String> options = new HashMap<>(parameters.getOtherOptions());
-        Class<? extends ICompressor> klass = parameters.getSstableCompressor().getClass();
-        options.put(CompressionParams.SSTABLE_COMPRESSION, klass.getName());
-        options.put(CompressionParams.CHUNK_LENGTH_KB, parameters.chunkLengthInKB());
-        return options;
-    }
-
-    private static String toThrift(CachingParams caching)
-    {
-        if (caching.cacheRows() && caching.cacheKeys())
-            return "ALL";
-
-        if (caching.cacheRows())
-            return "ROWS_ONLY";
-
-        if (caching.cacheKeys())
-            return "KEYS_ONLY";
-
-        return "NONE";
-    }
-
-    private static CachingParams cachingFromTrhfit(String caching)
-    {
-        switch (caching.toUpperCase(Locale.ENGLISH))
-        {
-            case "ALL":
-                return CachingParams.CACHE_EVERYTHING;
-            case "ROWS_ONLY":
-                return new CachingParams(false, Integer.MAX_VALUE);
-            case "KEYS_ONLY":
-                return CachingParams.CACHE_KEYS;
-            case "NONE":
-                return CachingParams.CACHE_NOTHING;
-            default:
-                throw new ConfigurationException(String.format("Invalid value %s for caching parameter", caching));
-        }
-    }
-
-    private static String toThriftCellsPerRow(CachingParams caching)
-    {
-        return caching.cacheAllRows()
-             ? "ALL"
-             : String.valueOf(caching.rowsPerPartitionToCache());
-    }
-
-    private static int fromThriftCellsPerRow(String value)
-    {
-        return "ALL".equals(value)
-             ? Integer.MAX_VALUE
-             : Integer.parseInt(value);
-    }
-
-    public static CachingParams cachingFromThrift(String caching, String cellsPerRow)
-    {
-        boolean cacheKeys = true;
-        int rowsPerPartitionToCache = 0;
-
-        // if we get a caching string from thrift it is legacy, "ALL", "KEYS_ONLY" etc
-        if (caching != null)
-        {
-            CachingParams parsed = cachingFromTrhfit(caching);
-            cacheKeys = parsed.cacheKeys();
-            rowsPerPartitionToCache = parsed.rowsPerPartitionToCache();
-        }
-
-        // if we get cells_per_row from thrift, it is either "ALL" or "<number of cells to cache>".
-        if (cellsPerRow != null && rowsPerPartitionToCache > 0)
-            rowsPerPartitionToCache = fromThriftCellsPerRow(cellsPerRow);
-
-        return new CachingParams(cacheKeys, rowsPerPartitionToCache);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4881d9c3/src/java/org/apache/cassandra/thrift/ThriftResultsMerger.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/ThriftResultsMerger.java b/src/java/org/apache/cassandra/thrift/ThriftResultsMerger.java
deleted file mode 100644
index a14409e..0000000
--- a/src/java/org/apache/cassandra/thrift/ThriftResultsMerger.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cassandra.thrift;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.apache.cassandra.db.transform.Transformation;
-import org.apache.cassandra.utils.AbstractIterator;
-import com.google.common.collect.Iterators;
-import com.google.common.collect.PeekingIterator;
-
-import org.apache.cassandra.config.CFMetaData;
-import org.apache.cassandra.config.ColumnDefinition;
-import org.apache.cassandra.db.*;
-import org.apache.cassandra.db.rows.*;
-import org.apache.cassandra.db.marshal.AbstractType;
-import org.apache.cassandra.db.marshal.MapType;
-import org.apache.cassandra.db.partitions.*;
-
-/**
- * Given an iterator on a partition of a compact table, this return an iterator that merges the
- * static row columns with the other results.
- *
- * Compact tables stores thrift column_metadata as static columns (see CompactTables for
- * details). When reading for thrift however, we want to merge those static values with other
- * results because:
- *   1) on thrift, all "columns" are sorted together, whether or not they are declared
- *      column_metadata.
- *   2) it's possible that a table add a value for a "dynamic" column, and later that column
- *      is statically defined. Merging "static" and "dynamic" columns make sure we don't miss
- *      a value prior to the column declaration.
- *
- * For example, if a thrift table declare 2 columns "c1" and "c5" and the results from a query
- * is:
- *    Partition: static: { c1: 3, c5: 4 }
- *                 "a" : { value : 2 }
- *                 "c3": { value : 8 }
- *                 "c7": { value : 1 }
- * then this class transform it into:
- *    Partition:   "a" : { value : 2 }
- *                 "c1": { value : 3 }
- *                 "c3": { value : 8 }
- *                 "c5": { value : 4 }
- *                 "c7": { value : 1 }
- */
-public class ThriftResultsMerger extends Transformation<UnfilteredRowIterator>
-{
-    private final int nowInSec;
-
-    private ThriftResultsMerger(int nowInSec)
-    {
-        this.nowInSec = nowInSec;
-    }
-
-    public static UnfilteredPartitionIterator maybeWrap(UnfilteredPartitionIterator iterator, CFMetaData metadata, int nowInSec)
-    {
-        if (!metadata.isStaticCompactTable() && !metadata.isSuper())
-            return iterator;
-
-        return Transformation.apply(iterator, new ThriftResultsMerger(nowInSec));
-    }
-
-    public static UnfilteredRowIterator maybeWrap(UnfilteredRowIterator iterator, int nowInSec)
-    {
-        if (!iterator.metadata().isStaticCompactTable() && !iterator.metadata().isSuper())
-            return iterator;
-
-        return iterator.metadata().isSuper()
-             ? Transformation.apply(iterator, new SuperColumnsPartitionMerger(iterator, nowInSec))
-             : new PartitionMerger(iterator, nowInSec);
-    }
-
-    @Override
-    public UnfilteredRowIterator applyToPartition(UnfilteredRowIterator iter)
-    {
-        return iter.metadata().isSuper()
-             ? Transformation.apply(iter, new SuperColumnsPartitionMerger(iter, nowInSec))
-             : new PartitionMerger(iter, nowInSec);
-    }
-
-    private static class PartitionMerger extends WrappingUnfilteredRowIterator
-    {
-        private final int nowInSec;
-
-        // We initialize lazily to avoid having this iterator fetch the wrapped iterator before it's actually asked for it.
-        private boolean isInit;
-
-        private Iterator<Cell> staticCells;
-
-        private final Row.Builder builder;
-        private Row nextToMerge;
-        private Unfiltered nextFromWrapped;
-
-        private PartitionMerger(UnfilteredRowIterator results, int nowInSec)
-        {
-            super(results);
-            assert results.metadata().isStaticCompactTable();
-            this.nowInSec = nowInSec;
-            this.builder = BTreeRow.sortedBuilder();
-        }
-
-        private void init()
-        {
-            assert !isInit;
-            Row staticRow = super.staticRow();
-            assert !staticRow.hasComplex();
-
-            staticCells = staticRow.cells().iterator();
-            updateNextToMerge();
-            isInit = true;
-        }
-
-        @Override
-        public Row staticRow()
-        {
-            return Rows.EMPTY_STATIC_ROW;
-        }
-
-        @Override
-        public boolean hasNext()
-        {
-            if (!isInit)
-                init();
-
-            return nextFromWrapped != null || nextToMerge != null || super.hasNext();
-        }
-
-        @Override
-        public Unfiltered next()
-        {
-            if (!isInit)
-                init();
-
-            if (nextFromWrapped == null && super.hasNext())
-                nextFromWrapped = super.next();
-
-            if (nextFromWrapped == null)
-            {
-                if (nextToMerge == null)
-                    throw new NoSuchElementException();
-
-                return consumeNextToMerge();
-            }
-
-            if (nextToMerge == null)
-                return consumeNextWrapped();
-
-            int cmp = metadata().comparator.compare(nextToMerge, nextFromWrapped);
-            if (cmp < 0)
-                return consumeNextToMerge();
-            if (cmp > 0)
-                return consumeNextWrapped();
-
-            // Same row, so merge them
-            assert nextFromWrapped instanceof Row;
-            return Rows.merge((Row)consumeNextWrapped(), consumeNextToMerge(), nowInSec);
-        }
-
-        private Unfiltered consumeNextWrapped()
-        {
-            Unfiltered toReturn = nextFromWrapped;
-            nextFromWrapped = null;
-            return toReturn;
-        }
-
-        private Row consumeNextToMerge()
-        {
-            Row toReturn = nextToMerge;
-            updateNextToMerge();
-            return toReturn;
-        }
-
-        private void updateNextToMerge()
-        {
-            if (!staticCells.hasNext())
-            {
-                // Nothing more to merge.
-                nextToMerge = null;
-                return;
-            }
-
-            Cell cell = staticCells.next();
-
-            // Given a static cell, the equivalent row uses the column name as clustering and the value as unique cell value.
-            builder.newRow(Clustering.make(cell.column().name.bytes));
-            builder.addCell(new BufferCell(metadata().compactValueColumn(), cell.timestamp(), cell.ttl(), cell.localDeletionTime(), cell.value(), cell.path()));
-            nextToMerge = builder.build();
-        }
-    }
-
-    private static class SuperColumnsPartitionMerger extends Transformation
-    {
-        private final int nowInSec;
-        private final Row.Builder builder;
-        private final ColumnDefinition superColumnMapColumn;
-        private final AbstractType<?> columnComparator;
-
-        private SuperColumnsPartitionMerger(UnfilteredRowIterator applyTo, int nowInSec)
-        {
-            assert applyTo.metadata().isSuper();
-            this.nowInSec = nowInSec;
-
-            this.superColumnMapColumn = applyTo.metadata().compactValueColumn();
-            assert superColumnMapColumn != null && superColumnMapColumn.type instanceof MapType;
-
-            this.builder = BTreeRow.sortedBuilder();
-            this.columnComparator = ((MapType)superColumnMapColumn.type).nameComparator();
-        }
-
-        @Override
-        public Row applyToRow(Row row)
-        {
-            PeekingIterator<Cell> staticCells = Iterators.peekingIterator(simpleCellsIterator(row));
-            if (!staticCells.hasNext())
-                return row;
-
-            builder.newRow(row.clustering());
-
-            ComplexColumnData complexData = row.getComplexColumnData(superColumnMapColumn);
-            
-            PeekingIterator<Cell> dynamicCells;
-            if (complexData == null)
-            {
-                dynamicCells = Iterators.peekingIterator(Collections.<Cell>emptyIterator());
-            }
-            else
-            {
-                dynamicCells = Iterators.peekingIterator(complexData.iterator());
-                builder.addComplexDeletion(superColumnMapColumn, complexData.complexDeletion());
-            }
-
-            while (staticCells.hasNext() && dynamicCells.hasNext())
-            {
-                Cell staticCell = staticCells.peek();
-                Cell dynamicCell = dynamicCells.peek();
-                int cmp = columnComparator.compare(staticCell.column().name.bytes, dynamicCell.path().get(0));
-                if (cmp < 0)
-                    builder.addCell(makeDynamicCell(staticCells.next()));
-                else if (cmp > 0)
-                    builder.addCell(dynamicCells.next());
-                else
-                    builder.addCell(Cells.reconcile(makeDynamicCell(staticCells.next()), dynamicCells.next(), nowInSec));
-            }
-
-            while (staticCells.hasNext())
-                builder.addCell(makeDynamicCell(staticCells.next()));
-            while (dynamicCells.hasNext())
-                builder.addCell(dynamicCells.next());
-
-            return builder.build();
-        }
-
-        private Cell makeDynamicCell(Cell staticCell)
-        {
-            return new BufferCell(superColumnMapColumn, staticCell.timestamp(), staticCell.ttl(), staticCell.localDeletionTime(), staticCell.value(), CellPath.create(staticCell.column().name.bytes));
-        }
-
-        private Iterator<Cell> simpleCellsIterator(Row row)
-        {
-            final Iterator<Cell> cells = row.cells().iterator();
-            return new AbstractIterator<Cell>()
-            {
-                protected Cell computeNext()
-                {
-                    if (cells.hasNext())
-                    {
-                        Cell cell = cells.next();
-                        if (cell.column().isSimple())
-                            return cell;
-                    }
-                    return endOfData();
-                }
-            };
-        }
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4881d9c3/src/java/org/apache/cassandra/thrift/ThriftServer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/ThriftServer.java b/src/java/org/apache/cassandra/thrift/ThriftServer.java
deleted file mode 100644
index 4aa5736..0000000
--- a/src/java/org/apache/cassandra/thrift/ThriftServer.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cassandra.thrift;
-
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.cassandra.service.CassandraDaemon;
-import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.thrift.TProcessor;
-import org.apache.thrift.protocol.TBinaryProtocol;
-import org.apache.thrift.server.TServer;
-import org.apache.thrift.transport.TFramedTransport;
-import org.apache.thrift.transport.TTransportFactory;
-
-public class ThriftServer implements CassandraDaemon.Server
-{
-    private static final Logger logger = LoggerFactory.getLogger(ThriftServer.class);
-
-    protected final InetAddress address;
-    protected final int port;
-    protected final int backlog;
-    private volatile ThriftServerThread server;
-
-    public ThriftServer(InetAddress address, int port, int backlog)
-    {
-        this.address = address;
-        this.port = port;
-        this.backlog = backlog;
-    }
-
-    public void start()
-    {
-        if (server == null)
-        {
-            CassandraServer iface = getCassandraServer();
-            server = new ThriftServerThread(address, port, backlog, getProcessor(iface), getTransportFactory());
-            server.start();
-        }
-    }
-
-    public synchronized void stop()
-    {
-        if (server != null)
-        {
-            server.stopServer();
-            try
-            {
-                server.join();
-            }
-            catch (InterruptedException e)
-            {
-                logger.error("Interrupted while waiting thrift server to stop", e);
-            }
-            server = null;
-        }
-    }
-
-    public boolean isRunning()
-    {
-        return server != null;
-    }
-
-    /*
-     * These methods are intended to be overridden to provide custom implementations.
-     */
-    protected CassandraServer getCassandraServer()
-    {
-        return new CassandraServer();
-    }
-
-    protected TProcessor getProcessor(CassandraServer server)
-    {
-        return new Cassandra.Processor<Cassandra.Iface>(server);
-    }
-
-    protected TTransportFactory getTransportFactory()
-    {
-        int tFramedTransportSize = DatabaseDescriptor.getThriftFramedTransportSize();
-        return new TFramedTransport.Factory(tFramedTransportSize);
-    }
-
-    /**
-     * Simple class to run the thrift connection accepting code in separate
-     * thread of control.
-     */
-    private static class ThriftServerThread extends Thread
-    {
-        private final TServer serverEngine;
-
-        public ThriftServerThread(InetAddress listenAddr,
-                                  int listenPort,
-                                  int listenBacklog,
-                                  TProcessor processor,
-                                  TTransportFactory transportFactory)
-        {
-            // now we start listening for clients
-            logger.info("Binding thrift service to {}:{}", listenAddr, listenPort);
-
-            TServerFactory.Args args = new TServerFactory.Args();
-            args.tProtocolFactory = new TBinaryProtocol.Factory(true, true);
-            args.addr = new InetSocketAddress(listenAddr, listenPort);
-            args.listenBacklog = listenBacklog;
-            args.processor = processor;
-            args.keepAlive = DatabaseDescriptor.getRpcKeepAlive();
-            args.sendBufferSize = DatabaseDescriptor.getRpcSendBufferSize();
-            args.recvBufferSize = DatabaseDescriptor.getRpcRecvBufferSize();
-            args.inTransportFactory = transportFactory;
-            args.outTransportFactory = transportFactory;
-            serverEngine = new TServerCustomFactory(DatabaseDescriptor.getRpcServerType()).buildTServer(args);
-        }
-
-        public void run()
-        {
-            logger.info("Listening for thrift clients...");
-            serverEngine.serve();
-        }
-
-        public void stopServer()
-        {
-            logger.info("Stop listening to thrift clients");
-            serverEngine.stop();
-        }
-    }
-
-    public static final class ThriftServerType
-    {
-        public final static String SYNC = "sync";
-        public final static String ASYNC = "async";
-        public final static String HSHA = "hsha";
-    }
-}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4881d9c3/src/java/org/apache/cassandra/thrift/ThriftSessionManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/ThriftSessionManager.java b/src/java/org/apache/cassandra/thrift/ThriftSessionManager.java
deleted file mode 100644
index 7d22507..0000000
--- a/src/java/org/apache/cassandra/thrift/ThriftSessionManager.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cassandra.thrift;
-
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Encapsulates the current client state (session).
- *
- * We rely on the Thrift server to tell us what socket it is
- * executing a request for via setCurrentSocket, after which currentSession can do its job anywhere.
- */
-public class ThriftSessionManager
-{
-    private static final Logger logger = LoggerFactory.getLogger(ThriftSessionManager.class);
-    public final static ThriftSessionManager instance = new ThriftSessionManager();
-
-    private final ThreadLocal<SocketAddress> remoteSocket = new ThreadLocal<>();
-    private final ConcurrentHashMap<SocketAddress, ThriftClientState> activeSocketSessions = new ConcurrentHashMap<>();
-
-    /**
-     * @param socket the address on which the current thread will work on requests for until further notice
-     */
-    public void setCurrentSocket(SocketAddress socket)
-    {
-        remoteSocket.set(socket);
-    }
-
-    /**
-     * @return the current session for the most recently given socket on this thread
-     */
-    public ThriftClientState currentSession()
-    {
-        SocketAddress socket = remoteSocket.get();
-        assert socket != null;
-
-        ThriftClientState cState = activeSocketSessions.get(socket);
-        if (cState == null)
-        {
-            //guarantee atomicity
-            ThriftClientState newState = new ThriftClientState((InetSocketAddress)socket);
-            cState = activeSocketSessions.putIfAbsent(socket, newState);
-            if (cState == null)
-                cState = newState;
-        }
-        return cState;
-    }
-
-    /**
-     * The connection associated with @param socket is permanently finished.
-     */
-    public void connectionComplete(SocketAddress socket)
-    {
-        assert socket != null;
-        activeSocketSessions.remove(socket);
-        if (logger.isTraceEnabled())
-            logger.trace("ClientState removed for socket addr {}", socket);
-    }
-    
-    public int getConnectedClients()
-    {
-        return activeSocketSessions.size();
-    }
-}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4881d9c3/src/java/org/apache/cassandra/thrift/ThriftValidation.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/ThriftValidation.java b/src/java/org/apache/cassandra/thrift/ThriftValidation.java
deleted file mode 100644
index 36a9755..0000000
--- a/src/java/org/apache/cassandra/thrift/ThriftValidation.java
+++ /dev/null
@@ -1,671 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cassandra.thrift;
-
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.cassandra.config.CFMetaData;
-import org.apache.cassandra.config.ColumnDefinition;
-import org.apache.cassandra.config.Schema;
-import org.apache.cassandra.config.SchemaConstants;
-import org.apache.cassandra.cql3.Attributes;
-import org.apache.cassandra.cql3.Operator;
-import org.apache.cassandra.db.*;
-import org.apache.cassandra.db.marshal.AbstractType;
-import org.apache.cassandra.dht.IPartitioner;
-import org.apache.cassandra.dht.Token;
-import org.apache.cassandra.index.Index;
-import org.apache.cassandra.index.SecondaryIndexManager;
-import org.apache.cassandra.serializers.MarshalException;
-import org.apache.cassandra.utils.ByteBufferUtil;
-import org.apache.cassandra.utils.FBUtilities;
-
-/**
- * This has a lot of building blocks for CassandraServer to call to make sure it has valid input
- * -- ensuring column names conform to the declared comparator, for instance.
- *
- * The methods here mostly try to do just one part of the validation so they can be combined
- * for different needs -- supercolumns vs regular, range slices vs named, batch vs single-column.
- * (ValidateColumnPath is the main exception in that it includes keyspace and CF validation.)
- */
-public class ThriftValidation
-{
-    private static final Logger logger = LoggerFactory.getLogger(ThriftValidation.class);
-
-    public static void validateKey(CFMetaData metadata, ByteBuffer key) throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        if (key == null || key.remaining() == 0)
-        {
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("Key may not be empty");
-        }
-
-        // check that key can be handled by FBUtilities.writeShortByteArray
-        if (key.remaining() > FBUtilities.MAX_UNSIGNED_SHORT)
-        {
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("Key length of " + key.remaining() +
-                                                                              " is longer than maximum of " +
-                                                                              FBUtilities.MAX_UNSIGNED_SHORT);
-        }
-
-        try
-        {
-            metadata.getKeyValidator().validate(key);
-        }
-        catch (MarshalException e)
-        {
-            throw new org.apache.cassandra.exceptions.InvalidRequestException(e.getMessage());
-        }
-    }
-
-    public static void validateKeyspace(String keyspaceName) throws KeyspaceNotDefinedException
-    {
-        if (!Schema.instance.getKeyspaces().contains(keyspaceName))
-        {
-            throw new KeyspaceNotDefinedException("Keyspace " + keyspaceName + " does not exist");
-        }
-    }
-
-    public static CFMetaData validateColumnFamily(String keyspaceName, String cfName, boolean isCommutativeOp) throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        CFMetaData metadata = validateColumnFamily(keyspaceName, cfName);
-
-        if (isCommutativeOp)
-        {
-            if (!metadata.isCounter())
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("invalid operation for non commutative table " + cfName);
-        }
-        else
-        {
-            if (metadata.isCounter())
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("invalid operation for commutative table " + cfName);
-        }
-        return metadata;
-    }
-
-    // To be used when the operation should be authorized whether this is a counter CF or not
-    public static CFMetaData validateColumnFamily(String keyspaceName, String cfName) throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        validateKeyspace(keyspaceName);
-        if (cfName.isEmpty())
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("non-empty table is required");
-
-        CFMetaData metadata = Schema.instance.getCFMetaData(keyspaceName, cfName);
-        if (metadata == null)
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("unconfigured table " + cfName);
-
-        return metadata;
-    }
-
-    /**
-     * validates all parts of the path to the column, including the column name
-     */
-    public static void validateColumnPath(CFMetaData metadata, ColumnPath column_path) throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        if (!metadata.isSuper())
-        {
-            if (column_path.super_column != null)
-            {
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("supercolumn parameter is invalid for standard CF " + metadata.cfName);
-            }
-            if (column_path.column == null)
-            {
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("column parameter is not optional for standard CF " + metadata.cfName);
-            }
-        }
-        else
-        {
-            if (column_path.super_column == null)
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("supercolumn parameter is not optional for super CF " + metadata.cfName);
-        }
-        if (column_path.column != null)
-        {
-            validateColumnNames(metadata, column_path.super_column, Arrays.asList(column_path.column));
-        }
-        if (column_path.super_column != null)
-        {
-            validateColumnNames(metadata, (ByteBuffer)null, Arrays.asList(column_path.super_column));
-        }
-    }
-
-    public static void validateColumnParent(CFMetaData metadata, ColumnParent column_parent) throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        if (!metadata.isSuper())
-        {
-            if (column_parent.super_column != null)
-            {
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("table alone is required for standard CF " + metadata.cfName);
-            }
-        }
-
-        if (column_parent.super_column != null)
-        {
-            validateColumnNames(metadata, (ByteBuffer)null, Arrays.asList(column_parent.super_column));
-        }
-    }
-
-    // column_path_or_parent is a ColumnPath for remove, where the "column" is optional even for a standard CF
-    static void validateColumnPathOrParent(CFMetaData metadata, ColumnPath column_path_or_parent) throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        if (metadata.isSuper())
-        {
-            if (column_path_or_parent.super_column == null && column_path_or_parent.column != null)
-            {
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("A column cannot be specified without specifying a super column for removal on super CF "
-                                                                          + metadata.cfName);
-            }
-        }
-        else
-        {
-            if (column_path_or_parent.super_column != null)
-            {
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("supercolumn may not be specified for standard CF " + metadata.cfName);
-            }
-        }
-        if (column_path_or_parent.column != null)
-        {
-            validateColumnNames(metadata, column_path_or_parent.super_column, Arrays.asList(column_path_or_parent.column));
-        }
-        if (column_path_or_parent.super_column != null)
-        {
-            validateColumnNames(metadata, (ByteBuffer)null, Arrays.asList(column_path_or_parent.super_column));
-        }
-    }
-
-    private static AbstractType<?> getThriftColumnNameComparator(CFMetaData metadata, ByteBuffer superColumnName)
-    {
-        if (!metadata.isSuper())
-            return LegacyLayout.makeLegacyComparator(metadata);
-
-        if (superColumnName == null)
-        {
-            // comparator for super column name
-            return metadata.comparator.subtype(0);
-        }
-        else
-        {
-            // comparator for sub columns
-            return metadata.thriftColumnNameType();
-        }
-    }
-
-    /**
-     * Validates the column names but not the parent path or data
-     */
-    private static void validateColumnNames(CFMetaData metadata, ByteBuffer superColumnName, Iterable<ByteBuffer> column_names)
-    throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        int maxNameLength = LegacyLayout.MAX_CELL_NAME_LENGTH;
-
-        if (superColumnName != null)
-        {
-            if (superColumnName.remaining() > maxNameLength)
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("supercolumn name length must not be greater than " + maxNameLength);
-            if (superColumnName.remaining() == 0)
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("supercolumn name must not be empty");
-            if (!metadata.isSuper())
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("supercolumn specified to table " + metadata.cfName + " containing normal columns");
-        }
-        AbstractType<?> comparator = getThriftColumnNameComparator(metadata, superColumnName);
-        boolean isCQL3Table = !metadata.isThriftCompatible();
-        for (ByteBuffer name : column_names)
-        {
-            if (name.remaining() > maxNameLength)
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("column name length must not be greater than " + maxNameLength);
-            if (name.remaining() == 0)
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("column name must not be empty");
-            try
-            {
-                comparator.validate(name);
-            }
-            catch (MarshalException e)
-            {
-                throw new org.apache.cassandra.exceptions.InvalidRequestException(e.getMessage());
-            }
-
-            if (isCQL3Table)
-            {
-                try
-                {
-                    LegacyLayout.LegacyCellName cname = LegacyLayout.decodeCellName(metadata, name);
-                    assert cname.clustering.size() == metadata.comparator.size();
-
-                    // CQL3 table don't support having only part of their composite column names set
-                    for (int i = 0; i < cname.clustering.size(); i++)
-                    {
-                        if (cname.clustering.get(i) == null)
-                            throw new org.apache.cassandra.exceptions.InvalidRequestException(String.format("Not enough components (found %d but %d expected) for column name since %s is a CQL3 table",
-                                                                                                            i, metadata.comparator.size() + 1, metadata.cfName));
-                    }
-
-                    // On top of that, if we have a collection component, the (CQL3) column must be a collection
-                    if (cname.column != null && cname.collectionElement != null && !cname.column.type.isCollection())
-                        throw new org.apache.cassandra.exceptions.InvalidRequestException(String.format("Invalid collection component, %s is not a collection", cname.column.name));
-                }
-                catch (IllegalArgumentException | UnknownColumnException e)
-                {
-                    throw new org.apache.cassandra.exceptions.InvalidRequestException(String.format("Error validating cell name for CQL3 table %s: %s", metadata.cfName, e.getMessage()));
-                }
-            }
-        }
-    }
-
-    public static void validateColumnNames(CFMetaData metadata, ColumnParent column_parent, Iterable<ByteBuffer> column_names) throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        validateColumnNames(metadata, column_parent.super_column, column_names);
-    }
-
-    public static void validateRange(CFMetaData metadata, ColumnParent column_parent, SliceRange range) throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        if (range.count < 0)
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("get_slice requires non-negative count");
-
-        int maxNameLength = LegacyLayout.MAX_CELL_NAME_LENGTH;
-        if (range.start.remaining() > maxNameLength)
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("range start length cannot be larger than " + maxNameLength);
-        if (range.finish.remaining() > maxNameLength)
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("range finish length cannot be larger than " + maxNameLength);
-
-        AbstractType<?> comparator = getThriftColumnNameComparator(metadata, column_parent.super_column);
-        try
-        {
-            comparator.validate(range.start);
-            comparator.validate(range.finish);
-        }
-        catch (MarshalException e)
-        {
-            throw new org.apache.cassandra.exceptions.InvalidRequestException(e.getMessage());
-        }
-
-        Comparator<ByteBuffer> orderedComparator = range.isReversed() ? comparator.reverseComparator : comparator;
-        if (range.start.remaining() > 0
-            && range.finish.remaining() > 0
-            && orderedComparator.compare(range.start, range.finish) > 0)
-        {
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("range finish must come after start in the order of traversal");
-        }
-    }
-
-    public static void validateColumnOrSuperColumn(CFMetaData metadata, ColumnOrSuperColumn cosc)
-            throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        boolean isCommutative = metadata.isCounter();
-
-        int nulls = 0;
-        if (cosc.column == null) nulls++;
-        if (cosc.super_column == null) nulls++;
-        if (cosc.counter_column == null) nulls++;
-        if (cosc.counter_super_column == null) nulls++;
-
-        if (nulls != 3)
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("ColumnOrSuperColumn must have one (and only one) of column, super_column, counter and counter_super_column");
-
-        if (cosc.column != null)
-        {
-            if (isCommutative)
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("invalid operation for commutative table " + metadata.cfName);
-
-            validateTtl(cosc.column);
-            validateColumnPath(metadata, new ColumnPath(metadata.cfName).setSuper_column((ByteBuffer)null).setColumn(cosc.column.name));
-            validateColumnData(metadata, null, cosc.column);
-        }
-
-        if (cosc.super_column != null)
-        {
-            if (isCommutative)
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("invalid operation for commutative table " + metadata.cfName);
-
-            for (Column c : cosc.super_column.columns)
-            {
-                validateColumnPath(metadata, new ColumnPath(metadata.cfName).setSuper_column(cosc.super_column.name).setColumn(c.name));
-                validateColumnData(metadata, cosc.super_column.name, c);
-            }
-        }
-
-        if (cosc.counter_column != null)
-        {
-            if (!isCommutative)
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("invalid operation for non commutative table " + metadata.cfName);
-
-            validateColumnPath(metadata, new ColumnPath(metadata.cfName).setSuper_column((ByteBuffer)null).setColumn(cosc.counter_column.name));
-        }
-
-        if (cosc.counter_super_column != null)
-        {
-            if (!isCommutative)
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("invalid operation for non commutative table " + metadata.cfName);
-
-            for (CounterColumn c : cosc.counter_super_column.columns)
-                validateColumnPath(metadata, new ColumnPath(metadata.cfName).setSuper_column(cosc.counter_super_column.name).setColumn(c.name));
-        }
-    }
-
-    private static void validateTtl(Column column) throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        if (column.isSetTtl())
-        {
-            if (column.ttl < 0)
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("ttl must be greater or equal to 0");
-
-            if (column.ttl > Attributes.MAX_TTL)
-                throw new org.apache.cassandra.exceptions.InvalidRequestException(String.format("ttl is too large. requested (%d) maximum (%d)", column.ttl, Attributes.MAX_TTL));
-        }
-        else
-        {
-            // if it's not set, then it should be zero -- here we are just checking to make sure Thrift doesn't change that contract with us.
-            assert column.ttl == 0;
-        }
-    }
-
-    public static void validateMutation(CFMetaData metadata, Mutation mut)
-            throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        ColumnOrSuperColumn cosc = mut.column_or_supercolumn;
-        Deletion del = mut.deletion;
-
-        int nulls = 0;
-        if (cosc == null) nulls++;
-        if (del == null) nulls++;
-
-        if (nulls != 1)
-        {
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("mutation must have one and only one of column_or_supercolumn or deletion");
-        }
-
-        if (cosc != null)
-        {
-            validateColumnOrSuperColumn(metadata, cosc);
-        }
-        else
-        {
-            validateDeletion(metadata, del);
-        }
-    }
-
-    public static void validateDeletion(CFMetaData metadata, Deletion del) throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-
-        if (del.super_column != null)
-            validateColumnNames(metadata, (ByteBuffer)null, Arrays.asList(del.super_column));
-
-        if (del.predicate != null)
-            validateSlicePredicate(metadata, del.super_column, del.predicate);
-
-        if (!metadata.isSuper() && del.super_column != null)
-        {
-            String msg = String.format("Deletion of super columns is not possible on a standard table (KeySpace=%s Table=%s Deletion=%s)", metadata.ksName, metadata.cfName, del);
-            throw new org.apache.cassandra.exceptions.InvalidRequestException(msg);
-        }
-
-        if (metadata.isCounter())
-        {
-            // forcing server timestamp even if a timestamp was set for coherence with other counter operation
-            del.timestamp = FBUtilities.timestampMicros();
-        }
-        else if (!del.isSetTimestamp())
-        {
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("Deletion timestamp is not optional for non commutative table " + metadata.cfName);
-        }
-    }
-
-    public static void validateSlicePredicate(CFMetaData metadata, ByteBuffer scName, SlicePredicate predicate) throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        if (predicate.column_names == null && predicate.slice_range == null)
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("A SlicePredicate must be given a list of Columns, a SliceRange, or both");
-
-        if (predicate.slice_range != null)
-            validateRange(metadata, new ColumnParent(metadata.cfName).setSuper_column(scName), predicate.slice_range);
-
-        if (predicate.column_names != null)
-            validateColumnNames(metadata, scName, predicate.column_names);
-    }
-
-    /**
-     * Validates the data part of the column (everything in the column object but the name, which is assumed to be valid)
-     */
-    public static void validateColumnData(CFMetaData metadata, ByteBuffer scName, Column column) throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        validateTtl(column);
-        if (!column.isSetValue())
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("Column value is required");
-        if (!column.isSetTimestamp())
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("Column timestamp is required");
-
-        try
-        {
-            LegacyLayout.LegacyCellName cn = LegacyLayout.decodeCellName(metadata, scName, column.name);
-            cn.column.type.validateCellValue(column.value);
-        }
-        catch (UnknownColumnException e)
-        {
-            throw new org.apache.cassandra.exceptions.InvalidRequestException(e.getMessage());
-        }
-        catch (MarshalException me)
-        {
-            if (logger.isTraceEnabled())
-                logger.trace("rejecting invalid value {}", ByteBufferUtil.bytesToHex(summarize(column.value)));
-
-            throw new org.apache.cassandra.exceptions.InvalidRequestException(String.format("(%s) [%s][%s][%s] failed validation",
-                                                                      me.getMessage(),
-                                                                      metadata.ksName,
-                                                                      metadata.cfName,
-                                                                      (getThriftColumnNameComparator(metadata, scName)).getString(column.name)));
-        }
-
-    }
-
-    /**
-     * Return, at most, the first 64K of the buffer. This avoids very large column values being
-     * logged in their entirety.
-     */
-    private static ByteBuffer summarize(ByteBuffer buffer)
-    {
-        int MAX = Short.MAX_VALUE;
-        if (buffer.remaining() <= MAX)
-            return buffer;
-        return (ByteBuffer) buffer.slice().limit(buffer.position() + MAX);
-    }
-
-
-    public static void validatePredicate(CFMetaData metadata, ColumnParent column_parent, SlicePredicate predicate)
-            throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        if (predicate.column_names == null && predicate.slice_range == null)
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("predicate column_names and slice_range may not both be null");
-        if (predicate.column_names != null && predicate.slice_range != null)
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("predicate column_names and slice_range may not both be present");
-
-        if (predicate.getSlice_range() != null)
-            validateRange(metadata, column_parent, predicate.slice_range);
-        else
-            validateColumnNames(metadata, column_parent, predicate.column_names);
-    }
-
-    public static void validateKeyRange(CFMetaData metadata, ByteBuffer superColumn, KeyRange range) throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        if ((range.start_key == null) == (range.start_token == null)
-            || (range.end_key == null) == (range.end_token == null))
-        {
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("exactly one each of {start key, start token} and {end key, end token} must be specified");
-        }
-
-        // (key, token) is supported (for wide-row CFRR) but not (token, key)
-        if (range.start_token != null && range.end_key != null)
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("start token + end key is not a supported key range");
-
-        IPartitioner p = metadata.partitioner;
-
-        if (range.start_key != null && range.end_key != null)
-        {
-            Token startToken = p.getToken(range.start_key);
-            Token endToken = p.getToken(range.end_key);
-            if (startToken.compareTo(endToken) > 0 && !endToken.isMinimum())
-            {
-                if (p.preservesOrder())
-                    throw new org.apache.cassandra.exceptions.InvalidRequestException("start key must sort before (or equal to) finish key in your partitioner!");
-                else
-                    throw new org.apache.cassandra.exceptions.InvalidRequestException("start key's token sorts after end key's token.  this is not allowed; you probably should not specify end key at all except with an ordered partitioner");
-            }
-        }
-        else if (range.start_key != null && range.end_token != null)
-        {
-            // start_token/end_token can wrap, but key/token should not
-            PartitionPosition stop = p.getTokenFactory().fromString(range.end_token).maxKeyBound();
-            if (PartitionPosition.ForKey.get(range.start_key, p).compareTo(stop) > 0 && !stop.isMinimum())
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("Start key's token sorts after end token");
-        }
-
-        validateFilterClauses(metadata, range.row_filter);
-
-        if (!isEmpty(range.row_filter) && superColumn != null)
-        {
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("super columns are not supported for indexing");
-        }
-
-        if (range.count <= 0)
-        {
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("maxRows must be positive");
-        }
-    }
-
-    private static boolean isEmpty(List<IndexExpression> clause)
-    {
-        return clause == null || clause.isEmpty();
-    }
-
-    public static void validateIndexClauses(CFMetaData metadata, IndexClause index_clause)
-    throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        if (index_clause.expressions.isEmpty())
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("index clause list may not be empty");
-
-        if (!validateFilterClauses(metadata, index_clause.expressions))
-            throw new org.apache.cassandra.exceptions.InvalidRequestException("No indexed columns present in index clause with operator EQ");
-    }
-
-    // return true if index_clause contains an indexed columns with operator EQ
-    public static boolean validateFilterClauses(CFMetaData metadata, List<IndexExpression> index_clause)
-    throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        if (isEmpty(index_clause))
-            // no filter to apply
-            return false;
-
-        SecondaryIndexManager idxManager = Keyspace.open(metadata.ksName).getColumnFamilyStore(metadata.cfName).indexManager;
-        AbstractType<?> nameValidator = getThriftColumnNameComparator(metadata, null);
-
-        boolean isIndexed = false;
-        for (IndexExpression expression : index_clause)
-        {
-            try
-            {
-                nameValidator.validate(expression.column_name);
-            }
-            catch (MarshalException me)
-            {
-                throw new org.apache.cassandra.exceptions.InvalidRequestException(String.format("[%s]=[%s] failed name validation (%s)",
-                                                                                  ByteBufferUtil.bytesToHex(expression.column_name),
-                                                                                  ByteBufferUtil.bytesToHex(expression.value),
-                                                                                  me.getMessage()));
-            }
-
-            if (expression.value.remaining() > 0xFFFF)
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("Index expression values may not be larger than 64K");
-
-            ColumnDefinition def = metadata.getColumnDefinition(expression.column_name);
-            if (def == null)
-            {
-                if (!metadata.isCompactTable())
-                    throw new org.apache.cassandra.exceptions.InvalidRequestException(String.format("Unknown column %s", nameValidator.getString(expression.column_name)));
-
-                def = metadata.compactValueColumn();
-            }
-
-            try
-            {
-                def.type.validate(expression.value);
-            }
-            catch (MarshalException me)
-            {
-                throw new org.apache.cassandra.exceptions.InvalidRequestException(String.format("[%s]=[%s] failed value validation (%s)",
-                                                                                  ByteBufferUtil.bytesToHex(expression.column_name),
-                                                                                  ByteBufferUtil.bytesToHex(expression.value),
-                                                                                  me.getMessage()));
-            }
-
-            for(Index index : idxManager.listIndexes())
-                isIndexed |= index.supportsExpression(def, Operator.valueOf(expression.op.name()));
-        }
-
-        return isIndexed;
-    }
-
-    public static void validateKeyspaceNotYetExisting(String newKsName) throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        // keyspace names must be unique case-insensitively because the keyspace name becomes the directory
-        // where we store CF sstables.  Names that differ only in case would thus cause problems on
-        // case-insensitive filesystems (NTFS, most installations of HFS+).
-        for (String ksName : Schema.instance.getKeyspaces())
-        {
-            if (ksName.equalsIgnoreCase(newKsName))
-                throw new org.apache.cassandra.exceptions.InvalidRequestException(String.format("Keyspace names must be case-insensitively unique (\"%s\" conflicts with \"%s\")",
-                                                                                  newKsName,
-                                                                                  ksName));
-        }
-    }
-
-    public static void validateKeyspaceNotSystem(String modifiedKeyspace) throws org.apache.cassandra.exceptions.InvalidRequestException
-    {
-        if (SchemaConstants.isSystemKeyspace(modifiedKeyspace))
-            throw new org.apache.cassandra.exceptions.InvalidRequestException(String.format("%s keyspace is not user-modifiable", modifiedKeyspace));
-    }
-
-    //public static IDiskAtomFilter asIFilter(SlicePredicate sp, CFMetaData metadata, ByteBuffer superColumn)
-    //{
-    //    SliceRange sr = sp.slice_range;
-    //    IDiskAtomFilter filter;
-
-    //    CellNameType comparator = metadata.isSuper()
-    //                            ? new SimpleDenseCellNameType(metadata.comparator.subtype(superColumn == null ? 0 : 1))
-    //                            : metadata.comparator;
-    //    if (sr == null)
-    //    {
-
-    //        SortedSet<CellName> ss = new TreeSet<CellName>(comparator);
-    //        for (ByteBuffer bb : sp.column_names)
-    //            ss.add(comparator.cellFromByteBuffer(bb));
-    //        filter = new NamesQueryFilter(ss);
-    //    }
-    //    else
-    //    {
-    //        filter = new SliceQueryFilter(comparator.fromByteBuffer(sr.start),
-    //                                      comparator.fromByteBuffer(sr.finish),
-    //                                      sr.reversed,
-    //                                      sr.count);
-    //    }
-
-    //    if (metadata.isSuper())
-    //        filter = SuperColumns.fromSCFilter(metadata.comparator, superColumn, filter);
-    //    return filter;
-    //}
-}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4881d9c3/src/java/org/apache/cassandra/tools/NodeProbe.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeProbe.java b/src/java/org/apache/cassandra/tools/NodeProbe.java
index a48baf8..97f6e50 100644
--- a/src/java/org/apache/cassandra/tools/NodeProbe.java
+++ b/src/java/org/apache/cassandra/tools/NodeProbe.java
@@ -978,21 +978,6 @@ public class NodeProbe implements AutoCloseable
         return ssProxy.isGossipRunning();
     }
 
-    public void stopThriftServer()
-    {
-        ssProxy.stopRPCServer();
-    }
-
-    public void startThriftServer()
-    {
-        ssProxy.startRPCServer();
-    }
-
-    public boolean isThriftServerRunning()
-    {
-        return ssProxy.isRPCServerRunning();
-    }
-
     public void stopCassandraDaemon()
     {
         ssProxy.stopDaemon();


Mime
View raw message