Package org.apache.cassandra.config

Examples of org.apache.cassandra.config.KSMetaData


        if (list.isEmpty())
            return false;

        for (int i = 0; i < list.size() -1; i++)
        {
            KSMetaData ksm1 = Schema.instance.getKSMetaData(list.get(i));
            KSMetaData ksm2 = Schema.instance.getKSMetaData(list.get(i + 1));
            if (!ksm1.strategyClass.equals(ksm2.strategyClass) ||
                    !Iterators.elementsEqual(ksm1.strategyOptions.entrySet().iterator(),
                                             ksm2.strategyOptions.entrySet().iterator()))
                return false;
        }
View Full Code Here


    public KsDef describe_keyspace(String keyspaceName) throws NotFoundException, InvalidRequestException
    {
        validateLogin();

        KSMetaData ksm = Schema.instance.getKSMetaData(keyspaceName);
        if (ksm == null)
            throw new NotFoundException();

        return ksm.toThrift();
    }
View Full Code Here

        session.commit(true);
        User user = session.getUser();
        user.checkAdmin();

        try {
            KSMetaData ksm = Schema.instance.getKSMetaData(keyspaceName);
            // In the (very) unlikely case the keyspace was dropped since validate()
            if (ksm == null) //validate方法中已检查过了,如果存在一些并发场景,有可能在validate方法到这里之间把ks删除了
                throw new InvalidRequestException("Unknown keyspace " + keyspaceName);

            MigrationManager.announceKeyspaceUpdate(defs.asKSMetadataUpdate(ksm), false);
View Full Code Here

        return 0;
    }

    public void validate() {
        try {
            KSMetaData ksm = Schema.instance.getKSMetaData(keyspaceName);
            if (ksm == null)
                throw new InvalidRequestException("Unknown keyspace " + keyspaceName);
            if (ksm.name.equalsIgnoreCase(Keyspace.SYSTEM_KS))
                throw new InvalidRequestException("Cannot alter system keyspace");
View Full Code Here

    {
        if (Schema.instance.getKSMetaData(AUTH_KS) == null)
        {
            try
            {
                KSMetaData ksm = KSMetaData.newKeyspace(AUTH_KS, SimpleStrategy.class.getName(), ImmutableMap.of("replication_factor", "1"), true);
                MigrationManager.announceNewKeyspace(ksm, 0);
            }
            catch (Exception e)
            {
                throw new AssertionError(e); // shouldn't ever happen.
View Full Code Here

        }

        // add entries to system schema columnfamilies for the hardcoded system definitions
        for (String ksname : Schema.systemKeyspaceNames)
        {
            KSMetaData ksmd = Schema.instance.getKSMetaData(ksname);

            // delete old, possibly obsolete entries in schema columnfamilies
            for (String cfname : Arrays.asList(SystemTable.SCHEMA_KEYSPACES_CF, SystemTable.SCHEMA_COLUMNFAMILIES_CF, SystemTable.SCHEMA_COLUMNS_CF))
            {
                String req = String.format("DELETE FROM system.%s WHERE keyspace_name = '%s'", cfname, ksmd.name);
                processInternal(req);
            }

            // (+1 to timestamp to make sure we don't get shadowed by the tombstones we just added)
            ksmd.toSchema(FBUtilities.timestampMicros() + 1).apply();
        }
    }
View Full Code Here

     * This is equivalent to calling commit. Applies the changes to
     * to the table that is obtained by calling Table.open().
     */
    public void apply() throws IOException
    {
        KSMetaData ksm = DatabaseDescriptor.getTableDefinition(getTable());
       
        Table.open(table_).apply(this, ksm.isDurableWrites());
    }
View Full Code Here

    }

    private Table(String table)
    {
        name = table;
        KSMetaData ksm = DatabaseDescriptor.getKSMetaData(table);
        try
        {
            createReplicationStrategy(ksm);
        }
        catch (ConfigurationException e)
View Full Code Here

        assert defs.size() > 0;
        assert defs.size() == DatabaseDescriptor.getNonSystemTables().size();
        for (KSMetaData loaded : defs)
        {
            KSMetaData defined = DatabaseDescriptor.getTableDefinition(loaded.name);
            assert defined.equals(loaded);
        }
    }
View Full Code Here

    @Test
    public void addNewCF() throws ConfigurationException, IOException, ExecutionException, InterruptedException
    {
        final String ks = "Keyspace1";
        final String cf = "BrandNewCf";
        KSMetaData original = DatabaseDescriptor.getTableDefinition(ks);

        CFMetaData newCf = addTestCF(original.name, cf, "A New Column Family");

        assert !DatabaseDescriptor.getTableDefinition(ks).cfMetaData().containsKey(newCf.cfName);
        new AddColumnFamily(newCf).apply();
View Full Code Here

TOP

Related Classes of org.apache.cassandra.config.KSMetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.