Search in sources :

Example 1 with EnvironmentMutableConfig

use of com.sleepycat.je.EnvironmentMutableConfig in project voldemort by voldemort.

the class BdbStorageEngine method beginBatchModifications.

@Override
public boolean beginBatchModifications() {
    if (checkpointerOffForBatchWrites) {
        synchronized (this) {
            numOutstandingBatchWriteJobs++;
            // turn the checkpointer off for the first job
            if (numOutstandingBatchWriteJobs == 1) {
                logger.info("Turning checkpointer off for batch writes");
                EnvironmentMutableConfig mConfig = environment.getMutableConfig();
                mConfig.setConfigParam(EnvironmentConfig.ENV_RUN_CHECKPOINTER, Boolean.toString(false));
                environment.setMutableConfig(mConfig);
                return true;
            }
        }
    }
    return false;
}
Also used : EnvironmentMutableConfig(com.sleepycat.je.EnvironmentMutableConfig)

Example 2 with EnvironmentMutableConfig

use of com.sleepycat.je.EnvironmentMutableConfig in project voldemort by voldemort.

the class BdbStorageConfiguration method update.

/**
 * Detect what has changed in the store definition and rewire BDB
 * environments accordingly.
 *
 * @param storeDef updated store definition
 */
public void update(StoreDefinition storeDef) {
    if (!useOneEnvPerStore)
        throw new VoldemortException("Memory foot print can be set only when using different environments per store");
    String storeName = storeDef.getName();
    Environment environment = environments.get(storeName);
    // change reservation amount of reserved store
    if (!unreservedStores.contains(environment) && storeDef.hasMemoryFootprint()) {
        EnvironmentMutableConfig mConfig = environment.getMutableConfig();
        long currentCacheSize = mConfig.getCacheSize();
        long newCacheSize = storeDef.getMemoryFootprintMB() * ByteUtils.BYTES_PER_MB;
        if (currentCacheSize != newCacheSize) {
            long newReservedCacheSize = this.reservedCacheSize - currentCacheSize + newCacheSize;
            // check that we leave a 'minimum' shared cache
            if ((voldemortConfig.getBdbCacheSize() - newReservedCacheSize) < voldemortConfig.getBdbMinimumSharedCache()) {
                throw new StorageInitializationException("Reservation of " + storeDef.getMemoryFootprintMB() + " MB for store " + storeName + " violates minimum shared cache size of " + voldemortConfig.getBdbMinimumSharedCache());
            }
            this.reservedCacheSize = newReservedCacheSize;
            adjustCacheSizes();
            mConfig.setCacheSize(newCacheSize);
            environment.setMutableConfig(mConfig);
            logger.info("Setting private cache for store " + storeDef.getName() + " to " + newCacheSize);
        }
    } else {
        // versa since the sharedCache param is not mutable
        throw new VoldemortException("Cannot switch between shared and private cache dynamically");
    }
}
Also used : StorageInitializationException(voldemort.store.StorageInitializationException) EnvironmentMutableConfig(com.sleepycat.je.EnvironmentMutableConfig) Environment(com.sleepycat.je.Environment) VoldemortException(voldemort.VoldemortException)

Example 3 with EnvironmentMutableConfig

use of com.sleepycat.je.EnvironmentMutableConfig in project voldemort by voldemort.

the class BdbStorageConfiguration method adjustCacheSizes.

/**
 * When a reservation is made, we need to shrink the shared cache
 * accordingly to guarantee memory foot print of the new store. NOTE: This
 * is not an instantaneous operation. Changes will take effect only when
 * traffic is thrown and eviction happens.( Won't happen until Network ports
 * are opened anyway which is rightfully done after storage service).When
 * changing this dynamically, we might want to block until the shared cache
 * shrinks enough
 */
private void adjustCacheSizes() {
    long newSharedCacheSize = voldemortConfig.getBdbCacheSize() - this.reservedCacheSize;
    logger.info("Setting the shared cache size to " + newSharedCacheSize);
    for (Environment environment : unreservedStores) {
        EnvironmentMutableConfig mConfig = environment.getMutableConfig();
        mConfig.setCacheSize(newSharedCacheSize);
        environment.setMutableConfig(mConfig);
    }
}
Also used : EnvironmentMutableConfig(com.sleepycat.je.EnvironmentMutableConfig) Environment(com.sleepycat.je.Environment)

Example 4 with EnvironmentMutableConfig

use of com.sleepycat.je.EnvironmentMutableConfig in project voldemort by voldemort.

the class BdbStorageEngine method endBatchModifications.

@Override
public boolean endBatchModifications() {
    if (checkpointerOffForBatchWrites) {
        synchronized (this) {
            numOutstandingBatchWriteJobs--;
            // turn the checkpointer back on if the last job finishes
            if (numOutstandingBatchWriteJobs == 0) {
                logger.info("Turning checkpointer on");
                EnvironmentMutableConfig mConfig = environment.getMutableConfig();
                mConfig.setConfigParam(EnvironmentConfig.ENV_RUN_CHECKPOINTER, Boolean.toString(true));
                environment.setMutableConfig(mConfig);
                return true;
            }
        }
    }
    return false;
}
Also used : EnvironmentMutableConfig(com.sleepycat.je.EnvironmentMutableConfig)

Example 5 with EnvironmentMutableConfig

use of com.sleepycat.je.EnvironmentMutableConfig in project qpid-broker-j by apache.

the class EnvironmentUtils method updateMutableConfig.

public static void updateMutableConfig(Environment environment, Set<String> paramsSetByDefault, boolean includeHA, final ConfiguredObject<?> object) {
    EnvironmentMutableConfig mutableConfig = environment.getMutableConfig();
    final Set<String> contextVariables = object.getContextKeys(false);
    for (Map.Entry<String, ConfigParam> entry : EnvironmentParams.SUPPORTED_PARAMS.entrySet()) {
        String paramName = entry.getKey();
        ConfigParam param = entry.getValue();
        if (param.isMutable() && (includeHA || !param.isForReplication())) {
            boolean contextValueSet = contextVariables.contains(paramName);
            boolean currentlySetInEnv = mutableConfig.isConfigParamSet(paramName);
            String contextValue = contextValueSet ? object.getContextValue(String.class, paramName) : null;
            contextValueSet = (contextValue != null);
            try {
                if (contextValueSet) {
                    if (!currentlySetInEnv || !contextValue.equals(mutableConfig.getConfigParam(paramName))) {
                        mutableConfig.setConfigParam(paramName, contextValue);
                        LOGGER.debug("Setting BDB configuration parameter '{}' to value '{}'.", param, contextValue);
                    }
                } else if (currentlySetInEnv && !paramsSetByDefault.contains(paramName)) {
                    mutableConfig.setConfigParam(paramName, param.getDefault());
                    LOGGER.debug("Setting BDB configuration parameter '{}' to its default value.", param);
                }
            } catch (IllegalArgumentException e) {
                LOGGER.warn("Unable to set BDB configuration parameter '{}' to value '{}'.", param, contextValue, e);
            }
        }
    }
}
Also used : ConfigParam(com.sleepycat.je.config.ConfigParam) EnvironmentMutableConfig(com.sleepycat.je.EnvironmentMutableConfig) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TreeMap(java.util.TreeMap)

Aggregations

EnvironmentMutableConfig (com.sleepycat.je.EnvironmentMutableConfig)7 Environment (com.sleepycat.je.Environment)3 ConfigParam (com.sleepycat.je.config.ConfigParam)1 ReplicatedEnvironment (com.sleepycat.je.rep.ReplicatedEnvironment)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 ConnectionScopedRuntimeException (org.apache.qpid.server.util.ConnectionScopedRuntimeException)1 ServerScopedRuntimeException (org.apache.qpid.server.util.ServerScopedRuntimeException)1 VoldemortException (voldemort.VoldemortException)1 StorageInitializationException (voldemort.store.StorageInitializationException)1