use of alluxio.conf.PropertyKey in project alluxio by Alluxio.
the class MetricsSystem method constructSourceName.
/**
* Constructs the source name of metrics in this {@link MetricsSystem}.
*/
private static String constructSourceName() {
PropertyKey sourceKey = null;
switch(CommonUtils.PROCESS_TYPE.get()) {
case MASTER:
sourceKey = PropertyKey.MASTER_HOSTNAME;
break;
case WORKER:
sourceKey = PropertyKey.WORKER_HOSTNAME;
break;
case CLIENT:
sourceKey = PropertyKey.USER_APP_ID;
break;
case JOB_MASTER:
sourceKey = PropertyKey.JOB_MASTER_HOSTNAME;
break;
case JOB_WORKER:
sourceKey = PropertyKey.JOB_WORKER_HOSTNAME;
break;
default:
break;
}
AlluxioConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
if (sourceKey != null && conf.isSet(sourceKey)) {
return conf.getString(sourceKey);
}
String hostName;
// is not resolved on metrics reporting
try {
hostName = NetworkAddressUtils.getLocalHostMetricName(sResolveTimeout);
} catch (RuntimeException e) {
hostName = "unknown";
LOG.error("Can't find local host name", e);
}
return hostName;
}
use of alluxio.conf.PropertyKey in project alluxio by Alluxio.
the class DefaultMetaMaster method updateConfiguration.
@Override
public Map<String, Boolean> updateConfiguration(Map<String, String> propertiesMap) {
Map<String, Boolean> result = new HashMap<>();
int successCount = 0;
for (Map.Entry<String, String> entry : propertiesMap.entrySet()) {
try {
PropertyKey key = PropertyKey.fromString(entry.getKey());
if (ServerConfiguration.getBoolean(PropertyKey.CONF_DYNAMIC_UPDATE_ENABLED) && key.isDynamic()) {
String oldValue = ServerConfiguration.getString(key);
ServerConfiguration.set(key, entry.getValue(), Source.RUNTIME);
result.put(entry.getKey(), true);
successCount++;
LOG.info("Property {} has been updated to \"{}\" from \"{}\"", key.getName(), entry.getValue(), oldValue);
} else {
LOG.debug("Update a non-dynamic property {} is not allowed", key.getName());
result.put(entry.getKey(), false);
}
} catch (Exception e) {
result.put(entry.getKey(), false);
LOG.error("Failed to update property {} to {}", entry.getKey(), entry.getValue(), e);
}
}
LOG.debug("Update {} properties, succeed {}.", propertiesMap.size(), successCount);
return result;
}
use of alluxio.conf.PropertyKey in project alluxio by Alluxio.
the class ServerConfigurationChecker method fillConfMap.
/**
* Fills the configuration map.
*
* @param targetMap the map to fill
* @param recordMap the map to get data from
*/
private void fillConfMap(Map<PropertyKey, Map<Optional<String>, List<String>>> targetMap, Map<Address, List<ConfigRecord>> recordMap) {
for (Map.Entry<Address, List<ConfigRecord>> record : recordMap.entrySet()) {
Address address = record.getKey();
String addressStr = String.format("%s:%s", address.getHost(), address.getRpcPort());
for (ConfigRecord conf : record.getValue()) {
PropertyKey key = conf.getKey();
if (key.getConsistencyLevel() == ConsistencyCheckLevel.IGNORE) {
continue;
}
Optional<String> value = conf.getValue();
targetMap.putIfAbsent(key, new HashMap<>());
Map<Optional<String>, List<String>> values = targetMap.get(key);
values.putIfAbsent(value, new ArrayList<>());
values.get(value).add(addressStr);
}
}
}
use of alluxio.conf.PropertyKey in project alluxio by Alluxio.
the class DefaultBlockWorker method getConfiguration.
@Override
public Configuration getConfiguration(GetConfigurationPOptions options) {
// NOTE(cc): there is no guarantee that the returned cluster and path configurations are
// consistent snapshot of the system's state at a certain time, the path configuration might
// be in a newer state. But it's guaranteed that the hashes are respectively correspondent to
// the properties.
Configuration.Builder builder = Configuration.newBuilder();
if (!options.getIgnoreClusterConf()) {
Set<PropertyKey> keys = ServerConfiguration.keySet();
for (PropertyKey key : ServerConfiguration.keySet()) {
if (key.isBuiltIn()) {
Source source = ServerConfiguration.getSource(key);
Object value = ServerConfiguration.getOrDefault(key, null, ConfigurationValueOptions.defaults().useDisplayValue(true).useRawValue(options.getRawValue()));
builder.addClusterProperty(key.getName(), value, source);
}
}
// NOTE(cc): assumes that ServerConfiguration is read-only when master is running, otherwise,
// the following hash might not correspond to the above cluster configuration.
builder.setClusterConfHash(ServerConfiguration.hash());
}
return builder.build();
}
use of alluxio.conf.PropertyKey in project alluxio by Alluxio.
the class DefaultStorageTier method initStorageTier.
private void initStorageTier(boolean isMultiTier) throws BlockAlreadyExistsException, IOException, WorkerOutOfSpaceException {
String tmpDir = ServerConfiguration.getString(PropertyKey.WORKER_DATA_TMP_FOLDER);
PropertyKey tierDirPathConf = PropertyKey.Template.WORKER_TIERED_STORE_LEVEL_DIRS_PATH.format(mTierOrdinal);
String[] dirPaths = ServerConfiguration.getString(tierDirPathConf).split(",");
for (int i = 0; i < dirPaths.length; i++) {
dirPaths[i] = CommonUtils.getWorkerDataDirectory(dirPaths[i], ServerConfiguration.global());
}
PropertyKey tierDirCapacityConf = PropertyKey.Template.WORKER_TIERED_STORE_LEVEL_DIRS_QUOTA.format(mTierOrdinal);
String rawDirQuota = ServerConfiguration.getString(tierDirCapacityConf);
Preconditions.checkState(rawDirQuota.length() > 0, PreconditionMessage.ERR_TIER_QUOTA_BLANK);
String[] dirQuotas = rawDirQuota.split(",");
PropertyKey tierDirMediumConf = PropertyKey.Template.WORKER_TIERED_STORE_LEVEL_DIRS_MEDIUMTYPE.format(mTierOrdinal);
String rawDirMedium = ServerConfiguration.getString(tierDirMediumConf);
Preconditions.checkState(rawDirMedium.length() > 0, "Tier medium type configuration should not be blank");
String[] dirMedium = rawDirMedium.split(",");
// Set reserved bytes on directories if tier aligning is enabled.
long reservedBytes = 0;
if (isMultiTier && ServerConfiguration.getBoolean(PropertyKey.WORKER_MANAGEMENT_TIER_ALIGN_ENABLED)) {
reservedBytes = ServerConfiguration.getBytes(PropertyKey.WORKER_MANAGEMENT_TIER_ALIGN_RESERVED_BYTES);
}
mDirs = new HashMap<>(dirPaths.length);
mLostStorage = new ArrayList<>();
long totalCapacity = 0;
for (int i = 0; i < dirPaths.length; i++) {
int index = i >= dirQuotas.length ? dirQuotas.length - 1 : i;
int mediumTypeindex = i >= dirMedium.length ? dirMedium.length - 1 : i;
long capacity = FormatUtils.parseSpaceSize(dirQuotas[index]);
try {
StorageDir dir = DefaultStorageDir.newStorageDir(this, i, capacity, reservedBytes, dirPaths[i], dirMedium[mediumTypeindex]);
totalCapacity += capacity;
mDirs.put(i, dir);
} catch (IOException | InvalidPathException e) {
LOG.error("Unable to initialize storage directory at {}", dirPaths[i], e);
mLostStorage.add(dirPaths[i]);
continue;
}
// Delete tmp directory.
String tmpDirPath = PathUtils.concatPath(dirPaths[i], tmpDir);
try {
FileUtils.deletePathRecursively(tmpDirPath);
} catch (IOException e) {
if (FileUtils.exists(tmpDirPath)) {
LOG.error("Failed to clean up temporary directory: {}.", tmpDirPath);
}
}
}
mCapacityBytes = totalCapacity;
if (mTierAlias.equals(Constants.MEDIUM_MEM) && mDirs.size() == 1) {
checkEnoughMemSpace(mDirs.values().iterator().next());
}
}
Aggregations