All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gemstone.gemfire.distributed.internal.RuntimeDistributionConfigImpl Maven / Gradle / Ivy

There is a newer version: 2.0-BETA
Show newest version
/*
 * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
 *
 * Licensed 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. See accompanying
 * LICENSE file.
 */
   
package com.gemstone.gemfire.distributed.internal;

import java.io.File;

import com.gemstone.gemfire.GemFireIOException;
import com.gemstone.gemfire.internal.ConfigSource;
import com.gemstone.gemfire.internal.ManagerLogWriter;

/**
 * Provides an implementation of DistributionConfig that
 * is used at runtime by a {@link InternalDistributedSystem}. It allows
 * for dynamic reconfig of the app the owns it.
 * 
 * The attribute settor methods in this class all assume that they are
 * being called at runtime. If they are called from some other ConfigSource
 * then those calls should come through setAttributeObject and it will
 * set the attSourceMap to the correct source after these methods return.
 *
 * @author Darrel Schneider
 *
 * @since 3.0
 */
public final class RuntimeDistributionConfigImpl
  extends DistributionConfigImpl  {

  private static final long serialVersionUID = -805637520096606113L;
  transient private final InternalDistributedSystem ds;

  //////////////////////  Constructors  //////////////////////

  /**
   * Create a new RuntimeDistributionConfigImpl from the
   * contents of another DistributionConfig.
   */
  public RuntimeDistributionConfigImpl(InternalDistributedSystem ds) {
    super(ds.getOriginalConfig());
    this.ds = ds;
    this.modifiable = false;
  }

  ////////////////////  Configuration Methods  ////////////////////

  @Override
  public void setLogLevel(int value) {
    checkLogLevel(value);
    this.logLevel = value;
    getAttSourceMap().put(LOG_LEVEL_NAME, ConfigSource.runtime());
    ((ManagerLogWriter)this.ds.getLogWriter()).configChanged();
  }
  @Override
  public boolean isLogLevelModifiable() {
    return true;
  }
  
  @Override
  public void setStatisticSamplingEnabled(boolean value) {
    checkStatisticSamplingEnabled(value);
    this.statisticSamplingEnabled = value;
    getAttSourceMap().put(STATISTIC_SAMPLING_ENABLED_NAME, ConfigSource.runtime());
  }
  @Override
  public boolean isStatisticSamplingEnabledModifiable() {
    return true;
  }
  @Override
  public void setStatisticSampleRate(int value) {
    checkStatisticSampleRate(value);
    if (value < DEFAULT_STATISTIC_SAMPLE_RATE) {
      // fix 48228
      this.ds.getLogWriter().info("Setting statistic-sample-rate to " + DEFAULT_STATISTIC_SAMPLE_RATE + " instead of the requested " + value + " because VSD does not work with sub-second sampling.");
      value = DEFAULT_STATISTIC_SAMPLE_RATE;
    }
    this.statisticSampleRate = value;
  }
  @Override
  public boolean isStatisticSampleRateModifiable() {
    return true;
  }
  @Override
  public void setStatisticArchiveFile(File value) {
    checkStatisticArchiveFile(value);
    if (value == null) {
      value = new File("");
    }
    try {
      this.ds.getStatSampler().changeArchive(value);
    } catch (GemFireIOException ex) {
      throw new IllegalArgumentException(ex.getMessage());
    }
    this.statisticArchiveFile = value;
    getAttSourceMap().put(STATISTIC_ARCHIVE_FILE_NAME, ConfigSource.runtime());
  }
  @Override
  public boolean isStatisticArchiveFileModifiable() {
    return true;
  }

  @Override
  public void setArchiveDiskSpaceLimit(int value) {
    checkArchiveDiskSpaceLimit(value);
    this.archiveDiskSpaceLimit = value;
    getAttSourceMap().put(ARCHIVE_DISK_SPACE_LIMIT_NAME, ConfigSource.runtime());
  }
  @Override
  public boolean isArchiveDiskSpaceLimitModifiable() {
    return true;
  }
  @Override
  public void setArchiveFileSizeLimit(int value) {
    checkArchiveFileSizeLimit(value);
    this.archiveFileSizeLimit = value;
    getAttSourceMap().put(ARCHIVE_FILE_SIZE_LIMIT_NAME, ConfigSource.runtime());
  }
  @Override
  public boolean isArchiveFileSizeLimitModifiable() {
    return true;
  }
  @Override
  public void setLogDiskSpaceLimit(int value) {
    checkLogDiskSpaceLimit(value);
    this.logDiskSpaceLimit = value;
    getAttSourceMap().put(LOG_DISK_SPACE_LIMIT_NAME, ConfigSource.runtime());
  }
  @Override
  public boolean isLogDiskSpaceLimitModifiable() {
    return true;
  }
  @Override
  public void setLogFileSizeLimit(int value) {
    checkLogFileSizeLimit(value);
    this.logFileSizeLimit = value;
    getAttSourceMap().put(this.LOG_FILE_SIZE_LIMIT_NAME, ConfigSource.runtime());
  }
  @Override
  public boolean isLogFileSizeLimitModifiable() {
    return true;
  }

  public DistributionConfig takeSnapshot() {
    return new DistributionConfigSnapshot(this);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy