alluxio.master.meta.JournalSpaceMonitor Maven / Gradle / Ivy
The newest version!
/*
* The Alluxio Open Foundation licenses this work under the Apache License, version 2.0
* (the "License"). You may not use this work except in compliance with the License, which is
* available at www.apache.org/licenses/LICENSE-2.0
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied, as more fully set forth in the License.
*
* See the NOTICE file distributed with this work for information regarding copyright ownership.
*/
package alluxio.master.meta;
import alluxio.AlluxioURI;
import alluxio.conf.AlluxioConfiguration;
import alluxio.conf.PropertyKey;
import alluxio.heartbeat.HeartbeatExecutor;
import alluxio.metrics.MetricKey;
import alluxio.metrics.MetricsSystem;
import alluxio.shell.CommandReturn;
import alluxio.util.LogUtils;
import alluxio.util.ShellUtils;
import alluxio.wire.JournalDiskInfo;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
* A heartbeat executor which periodically tracks the amount of disk space available for a
* particular path, generally the disk holding the journal.
*
* This monitor is only applicable to systems which are running on the Linux OS and which are
* running the embedded journal. Other configurations are invalid. Running this monitor on such
* systems is undefined behavior.
*/
public class JournalSpaceMonitor implements HeartbeatExecutor {
private static final Logger LOG = LoggerFactory.getLogger(JournalSpaceMonitor.class);
/**
* Convenience method for {@link #JournalSpaceMonitor(String, long)}.
*
* @param configuration the current alluxio configuration
*/
public JournalSpaceMonitor(AlluxioConfiguration configuration) {
this(configuration.getString(PropertyKey.MASTER_JOURNAL_FOLDER), configuration.getInt(
PropertyKey.MASTER_JOURNAL_SPACE_MONITOR_PERCENT_FREE_THRESHOLD));
}
private final String mJournalPath;
private final long mWarnCapacityPercentThreshold;
// Used to store information for metrics gauges
private final AtomicReference
© 2015 - 2025 Weber Informatics LLC | Privacy Policy