use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.
the class CpCommandIntegrationTest method copyAfterWorkersNotAvailableMustCache.
@Test
public void copyAfterWorkersNotAvailableMustCache() throws Exception {
InstancedConfiguration conf = new InstancedConfiguration(ServerConfiguration.global());
conf.set(PropertyKey.USER_FILE_WRITE_TYPE_DEFAULT, "MUST_CACHE");
try (FileSystemShell fsShell = new FileSystemShell(conf)) {
File testFile = new File(sLocalAlluxioCluster.getAlluxioHome() + "/testFile");
testFile.createNewFile();
FileOutputStream fos = new FileOutputStream(testFile);
byte[] toWrite = BufferUtils.getIncreasingByteArray(100);
fos.write(toWrite);
fos.close();
fsShell.run("copyFromLocal", testFile.getPath(), "/");
Assert.assertTrue(sFileSystem.exists(new AlluxioURI("/testFile")));
sLocalAlluxioCluster.stopWorkers();
fsShell.run("cp", "/testFile", "/testFile2");
Assert.assertFalse(sFileSystem.exists(new AlluxioURI("/testFile2")));
}
}
use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.
the class ConfigurationUtils method getClusterConf.
/**
* Loads the cluster level configuration from the get configuration response,
* filters out the configuration for certain scope, and merges it with the existing configuration.
*
* @param response the get configuration RPC response
* @param conf the existing configuration
* @param scope the target scope
* @return the merged configuration
*/
public static AlluxioConfiguration getClusterConf(GetConfigurationPResponse response, AlluxioConfiguration conf, Scope scope) {
String clientVersion = conf.getString(PropertyKey.VERSION);
LOG.debug("Alluxio {} (version {}) is trying to load cluster level configurations", scope, clientVersion);
List<alluxio.grpc.ConfigProperty> clusterConfig = response.getClusterConfigsList();
Properties clusterProps = filterAndLoadProperties(clusterConfig, scope, (key, value) -> String.format("Loading property: %s (%s) -> %s", key, key.getScope(), value));
// Check version.
String clusterVersion = clusterProps.get(PropertyKey.VERSION).toString();
if (!clientVersion.equals(clusterVersion)) {
LOG.warn("Alluxio {} version ({}) does not match Alluxio cluster version ({})", scope, clientVersion, clusterVersion);
clusterProps.remove(PropertyKey.VERSION);
}
// Merge conf returned by master as the cluster default into conf object
AlluxioProperties props = conf.copyProperties();
props.merge(clusterProps, Source.CLUSTER_DEFAULT);
// Use the constructor to set cluster defaults as being loaded.
InstancedConfiguration updatedConf = new InstancedConfiguration(props, true);
updatedConf.validate();
LOG.debug("Alluxio {} has loaded cluster level configurations", scope);
return updatedConf;
}
use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.
the class UnderFileSystemFactoryRegistry method getSupportedVersions.
/**
* Get a list of supported versions for a particular UFS path.
*
* @param path the UFS URI to test
* @param ufsConf the UFS configuration for the mount
* @return a list of supported versions. The list will be empty if the particular UFS type does
* not support setting a version on the mount.
*/
public static List<String> getSupportedVersions(String path, UnderFileSystemConfiguration ufsConf) {
// copy properties to not modify the original conf.
UnderFileSystemConfiguration ufsConfCopy = UnderFileSystemConfiguration.defaults(new InstancedConfiguration(ufsConf.copyProperties()));
// unset the configuration to make sure any supported factories for the path are returned.
ufsConfCopy.unset(PropertyKey.UNDERFS_VERSION);
// Check if any versioned factory supports the default configuration
List<UnderFileSystemFactory> factories = sRegistryInstance.findAll(path, ufsConfCopy);
List<String> supportedVersions = new ArrayList<>();
for (UnderFileSystemFactory factory : factories) {
if (!factory.getVersion().isEmpty()) {
supportedVersions.add(factory.getVersion());
}
}
return supportedVersions;
}
use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.
the class StackMain method main.
/**
* @param args arguments
*/
public static void main(String[] args) {
if (args.length < 2) {
System.out.println("Usage: <mountPoint> <sourcePath> <fuseOpts e.g. -obig_writes...>");
System.exit(1);
}
Path root = Paths.get(args[1]);
Path mountPoint = Paths.get(args[0]);
StackFS fs = new StackFS(root, mountPoint);
String[] fuseOpts = new String[args.length - 2];
System.arraycopy(args, 2, fuseOpts, 0, args.length - 2);
try {
AlluxioConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
CommonUtils.PROCESS_TYPE.set(CommonUtils.ProcessType.CLIENT);
MetricsSystem.startSinks(conf.getString(PropertyKey.METRICS_CONF_FILE));
fs.mount(true, false, fuseOpts);
} catch (Exception e) {
e.printStackTrace();
fs.umount(true);
System.exit(1);
}
}
use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.
the class ShowCommand method run.
@Override
public int run(CommandLine cl) throws IOException {
String targetPath = cl.getArgs()[0];
Configuration configuration = mMetaConfigClient.getConfiguration(GetConfigurationPOptions.getDefaultInstance());
if (cl.hasOption(ALL_OPTION_NAME)) {
Map<String, AlluxioConfiguration> pathConfMap = new HashMap<>();
configuration.getPathConf().forEach((path, conf) -> {
AlluxioProperties properties = new AlluxioProperties();
conf.forEach(property -> {
PropertyKey key = PropertyKey.fromString(property.getName());
properties.set(key, property.getValue());
});
pathConfMap.put(path, new InstancedConfiguration(properties));
});
PathConfiguration pathConf = PathConfiguration.create(pathConfMap);
AlluxioURI targetUri = new AlluxioURI(targetPath);
List<PropertyKey> propertyKeys = new ArrayList<>(pathConf.getPropertyKeys(targetUri));
propertyKeys.sort(Comparator.comparing(PropertyKey::getName));
propertyKeys.forEach(key -> {
pathConf.getConfiguration(targetUri, key).ifPresent(conf -> {
mPrintStream.println(format(key.getName(), conf.get(key)));
});
});
} else if (configuration.getPathConf().containsKey(targetPath)) {
List<Property> properties = configuration.getPathConf().get(targetPath);
properties.sort(Comparator.comparing(Property::getName));
properties.forEach(property -> {
mPrintStream.println(format(property.getName(), property.getValue()));
});
}
return 0;
}
Aggregations