Update (or insert) new keyspace definition

@param ksm The metadata about keyspace
180260
public void setKeyspaceDefinition(KSMetaData ksm)
    {
        assert ksm != null;
        keyspaces.put(ksm.name, ksm);
    }
319785
public void createKeyspace(String keyspace) {
        Map<String, String> replicationSimpleOneExtra = new HashMap<>();
        replicationSimpleOneExtra.put("'class'", "'SimpleStrategy'");
        replicationSimpleOneExtra.put("'replication_factor'", "1");
        String query = this.cassandraqueryUtils.createKeyspaceQuery(true,
                keyspace, this.cassandraqueryUtils
                        .createKeyspaceReplication(replicationSimpleOneExtra),
                "");
        LOGGER.debug(query);
        executeQuery(query);
    }
1248935
public static void setOutputKeyspace(Configuration conf, String keyspace)
    {
        if (keyspace == null)
            throw new UnsupportedOperationException("keyspace may not be null");

        conf.set(OUTPUT_KEYSPACE_CONFIG, keyspace);
    }
652846
@Override
    public V put(K key, V value)
    {
        BinarySet<Entry<K,V>> es = (BinarySet<Entry<K,V>>) entrySet;
        Entry<K,V> oldEntry = es.addEntry(entry(key, value));
        if (oldEntry != null)
        {
            return oldEntry.getValue();
        }
        return null;
    }
478446
private void updateEntry(HashtableEntry entry)
                    throws IOException, EOFException, FileManagerException, ClassNotFoundException {
        //
        // We'll write the header, key, and data into a byte arry first,
        // then allocate, seek, and write with a single write operation.
        // It is necessary to buffer the data first like this because we cannot
        // determine the size of storage to allocate without first examining the
        // size of the serialize object.
        //

        //
        // Serialize key and data.  If the data is already a byte[] array, we can
        // bypass serialization.
        //
        byte[] serializedKey = entry.serializedKey;
        int keySize = 0;
        byte[] serializedValue = null;
        int valueSize = -1;
        int bytes = 0;
        byte[] serializedCacheValue = entry.serializedCacheValue;
        int cacheValueSize = -1;
        int dataSize = HTENTRY_OVERHEAD_SIZE;

        if (serializedKey == null) {
            if (keyout == null) {
                keyout = new ByteArrayPlusOutputStream(500);
            } else {
                keyout.reset();
            }
            serializeTimer.reset();
            ObjectOutputStream out = new ObjectOutputStream(keyout);
            out.writeObject(entry.key);
            out.close();
            serializedKey = keyout.getTheBuffer();
            keySize = keyout.size();
            bytes_serialized += keySize;
        } else {
            keySize = entry.serializedKey.length;
        }
        dataSize += keySize;

        if (entry.value != null) {
            if (isByteArray(entry.value)) {
                bytes = 1;
                serializedValue = (byte[]) entry.value;
                if (entry.valuelen != -1) {
                    valueSize = entry.valuelen;
                } else {
                    valueSize = serializedValue.length;
                }
            } else {
                if (dataout == null) {
                    dataout = new ByteArrayPlusOutputStream(500);
                } else {
                    dataout.reset();
                }
                ObjectOutputStream out = new ObjectOutputStream(dataout);
                out.writeObject(entry.value);
                out.close();
                serializedValue = dataout.getTheBuffer();
                valueSize = dataout.size();
                bytes_serialized += valueSize;
                //
                // If an unusally large object is written it bloats the buffer, which can
                // hog resources.  If this happens dump the static buffer and start a new 
                // one on the next write.
                //
                if (valueSize > 100000) {
                    dataout = null;
                }
            }
        }

        serialize_time += serializeTimer.elapsed();

        int allocateSize = DWORDSIZE + // room for "next"
                           SWORDSIZE + // room for fastpath hash key
                           DWORDSIZE + // room for old format: last-modified
                                       //          new format: validator expiration time(VET)
                           DWORDSIZE + // room for old format: last-referenced;   // LI4337-17
                                       //          new format: H-Word = unused 
                                       //                      L-word = cache value hashcode 
                           DWORDSIZE + // room for first_created
                           DWORDSIZE + // room for expiration (RET)
                           DWORDSIZE + // room for flag + object size
                           SWORDSIZE + // room for size of the key
                           keySize + // room for serialized key
                           SWORDSIZE + // room for bytes flag
                           SWORDSIZE; // room for size of the value

        if (valueSize != -1) {
            allocateSize += valueSize; // room for serialized value
            dataSize += valueSize; // add value size to data size 
        }

        if (this.bHasCacheValue && !entry.bAliasId) {
            allocateSize += SWORDSIZE; // room for size of cacheValue
            if (serializedCacheValue != null) { // any cacheValue?
                cacheValueSize = serializedCacheValue.length; // size of the cacheValue
                allocateSize += cacheValueSize; // room for serialized cacheValue
                dataSize += cacheValueSize; // add cacheValue size to data size
            }
        }
        if (dataSize % 512 != 0) { // size adjustment for 512 blocks
            dataSize = (dataSize / 512 + 1) * 512;
        }
        //System.out.println("**** HashtableOnDisk: id=" + entry.key + " size=" + dataSize + " allocateSize=" + allocateSize);
        long tempData = 0;
        if (entry.bAliasId) {
            tempData = HTENTRY_MAGIC + HTENTRY_VERSION + HTENTRY_ALIAS_ID + dataSize;
        } else {
            tempData = HTENTRY_MAGIC + HTENTRY_VERSION + dataSize;
        }

        // end write key and value
        //
        // physical allocation
        //

        // For testing for cache id 
        //String testId = (String)entry.key;
        //if (testId.indexOf("928") > 0 || testId.indexOf("1028") > 0) {
        //    throw new IOException(com.ibm.ws.cache.HTODDynacache.DISK_CACHE_IN_GB_OVER_LIMIT_MSG);
        //}
        // For testing for depid/template
        //if (!this.bHasCacheValue) {
        //    String testId = (String)entry.key;
        //    if (testId.indexOf("926") > 0) {
        //        throw new IOException(com.ibm.ws.cache.HTODDynacache.DISK_CACHE_IN_GB_OVER_LIMIT_MSG);
        //    }
        //}
        entry.location = filemgr.allocate(allocateSize);

        initWriteBuffer();
        headerout.writeLong(entry.next);
        headerout.writeInt(entry.hash);
        //headerout.writeLong(System.currentTimeMillis());  // old format: last update
        headerout.writeLong(entry.validatorExpiration); // new format: VET
        //headerout.writeLong(System.currentTimeMillis());  // old format: last reference
        headerout.writeInt(0); // new format: unused    // LI4337-17
        headerout.writeInt(entry.cacheValueHashcode); //             cache value hashcode
        headerout.writeLong(entry.first_created); // when object is first created
        headerout.writeLong(entry.expiration); // expiration (RET) 
        headerout.writeLong(tempData); // write magic, version, flag & data size 
        headerout.writeInt(keySize);
        headerout.flush();

        //
        // Physical write the record like this:
        filemgr.seek(entry.location);
        filemgr.write(headeroutbuf);
        //
        // int keysize;            length of key
        // byte[] serialized key;  The key
        // int valueSize           length of value
        // int value_is_byte_array 0 if value is serialized obj 1 if a byte array
        // byte[] value            serialized value
        //
        filemgr.write(serializedKey, 0, keySize);
        filemgr.writeInt(bytes);
        filemgr.writeInt(valueSize);
        if (valueSize != -1) {
            filemgr.write(serializedValue, 0, valueSize);
        }

        //
        // if there is any cacheValue
        // int cacheValueSize      size of cacheValue - -1 if cacheValue is empty
        // byte[] cacheValue   serialized cacheValue
        //
        if (this.bHasCacheValue) {
            filemgr.writeInt(cacheValueSize);
            if (cacheValueSize != -1) {
                filemgr.write(serializedCacheValue, 0, cacheValueSize);
            }
        }

        //if (serializedCacheValue != null) {
        //   traceDebug("updateEntry()", "cacheName=" + this.htoddc.cacheName + " key=" + entry.key + " allocateSize=" + allocateSize + " dataSize=" + dataSize + " valueSize=" + valueSize + " cacheValueSize=" + cacheValueSize);
        //} else {
        //    traceDebug("updateEntry()", "cacheName=" + this.htoddc.cacheName + " key=" + entry.key + " allocateSize=" + allocateSize + " valueSize=" + valueSize);
        //}
    }
137606
@NonNull
  public static UpdateStart update(@Nullable CqlIdentifier keyspace, @NonNull CqlIdentifier table) {
    return new DefaultUpdate(keyspace, table);
  }
32859
public void updateEvent(String key, String value) {
        updateEvent(key, value, true, true);
    }
131500
@NonNull
  public SimpleStatementBuilder setKeyspace(@Nullable String keyspaceName) {
    return setKeyspace(keyspaceName == null ? null : CqlIdentifier.fromCql(keyspaceName));
  }
487966
private void executeAddKeySpace(Tree statement)
    {

        if (!CliMain.isConnected())
            return;

        // first value is the keyspace name, after that it is all key=value
        String keyspaceName = CliUtils.unescapeSQLString(statement.getChild(0).getText());
        KsDef ksDef = new KsDef(keyspaceName, DEFAULT_PLACEMENT_STRATEGY, new LinkedList<CfDef>());

        try
        {
            String mySchemaVersion = thriftClient.system_add_keyspace(updateKsDefAttributes(statement, ksDef));
            sessionState.out.println(mySchemaVersion);

            keyspacesMap.put(keyspaceName, thriftClient.describe_keyspace(keyspaceName));
        }
        catch (InvalidRequestException e)
        {
            throw new RuntimeException(e);
        }
        catch (Exception e)
        {
            throw new RuntimeException(e);
        }
    }
396270
public void dropKeyspace() {
        String cqlKeyspace = m_dbservice.getKeyspace();
        m_logger.info("Dropping keyspace: {}", cqlKeyspace);
        StringBuilder cql = new StringBuilder();
        cql.append("DROP KEYSPACE ");
        cql.append(cqlKeyspace);
        cql.append(";");
        executeCQL(cql.toString());
    }
345980
public Map<String, CFMetaData> getKeyspaceMetaData(String keyspaceName)
    {
        assert keyspaceName != null;
        KSMetaData ksm = keyspaces.get(keyspaceName);
        assert ksm != null;
        return ksm.cfMetaData();
    }
1350796
@NonNull
  public static AlterKeyspaceStart alterKeyspace(@NonNull String keyspaceName) {
    return alterKeyspace(CqlIdentifier.fromCql(keyspaceName));
  }
777995
@Nullable
  public synchronized V put(K key, V value) {
    // We do remove and insert instead of just replace, in order to cause a structural change
    // to the map, as we always want the latest inserted element to be last in the queue.
    V oldValue = mMap.remove(key);
    mSizeInBytes -= getValueSizeInBytes(oldValue);
    mMap.put(key, value);
    mSizeInBytes += getValueSizeInBytes(value);
    return oldValue;
  }
92476
public void deleteKeyspace(KeyspaceImpl keyspace) {
        Lock lock = lockManager.getLock(getLockingKey(keyspace));
        lock.lock();
        try {
            if (keyspaceCacheMap.containsKey(keyspace)) {
                KeyspaceCacheContainer container = keyspaceCacheMap.remove(keyspace);
                container.graph().close();
                container.invalidateSessions();
            }
        } finally {
            lock.unlock();
        }
    }
220369
private static void updateConfKeys(Configuration conf, String suffix,
      String nameserviceId) {
    String value = conf.get(FSConstants.DFS_NAMENODE_HTTP_ADDRESS_KEY + suffix
        + (nameserviceId.isEmpty() ? "" : ("." + nameserviceId)));
    if (value != null) {
      conf.set(FSConstants.DFS_NAMENODE_HTTP_ADDRESS_KEY, value);
    }
  }
1302361
protected void update(List<TableInfo> tableInfos)
    {
        try
        {
            createOrUpdateKeyspace(tableInfos);
        }
        catch (Exception ex)
        {
            log.error("Error occurred while creating {}, Caused by: .", databaseName, ex);
            throw new SchemaGenerationException(ex);
        }
    }
1031013
public void add(K key, V value) {
		List<V> values = this.targetMap.get(key);
		if (values == null) {
			values = new LinkedList<V>();
			this.targetMap.put(key, values);
		}
		values.add(value);
	}