Search in sources :

Example 56 with AlluxioConfiguration

use of alluxio.conf.AlluxioConfiguration in project alluxio by Alluxio.

the class MetadataCachingBaseFileSystem method asyncUpdateFileAccessTime.

/**
 * Asynchronously update file's last access time.
 *
 * @param path the path to the file
 */
@VisibleForTesting
public void asyncUpdateFileAccessTime(AlluxioURI path) {
    if (mDisableUpdateFileAccessTime) {
        return;
    }
    try {
        mAccessTimeUpdater.submit(() -> {
            try {
                AlluxioConfiguration conf = mFsContext.getPathConf(path);
                GetStatusPOptions getStatusOptions = FileSystemOptions.getStatusDefaults(conf).toBuilder().setAccessMode(Bits.READ).setUpdateTimestamps(true).build();
                super.getStatus(path, getStatusOptions);
            } catch (IOException | AlluxioException e) {
                LOG.error("Failed to update access time for " + path, e);
            }
        });
    } catch (RejectedExecutionException e) {
        LOG.warn("Failed to submit a task to update access time for {}: {}", path, e.toString());
    }
}
Also used : IOException(java.io.IOException) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) GetStatusPOptions(alluxio.grpc.GetStatusPOptions) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) AlluxioException(alluxio.exception.AlluxioException) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 57 with AlluxioConfiguration

use of alluxio.conf.AlluxioConfiguration in project alluxio by Alluxio.

the class AlluxioFuse method main.

/**
 * Running this class will mount the file system according to the options passed to this function
 * {@link #parseOptions(String[], AlluxioConfiguration)}. The user-space fuse application will
 * stay on the foreground and keep the file system mounted. The user can unmount the file system
 * by gracefully killing (SIGINT) the process.
 *
 * @param args arguments to run the command line
 */
public static void main(String[] args) {
    LOG.info("Alluxio version: {}-{}", RuntimeConstants.VERSION, ProjectConstants.REVISION);
    AlluxioConfiguration conf = InstancedConfiguration.defaults();
    FileSystemContext fsContext = FileSystemContext.create(conf);
    try {
        InetSocketAddress confMasterAddress = fsContext.getMasterClientContext().getConfMasterInquireClient().getPrimaryRpcAddress();
        RetryUtils.retry("load cluster default configuration with master " + confMasterAddress, () -> fsContext.getClientContext().loadConfIfNotLoaded(confMasterAddress), RetryUtils.defaultClientRetry(conf.getDuration(PropertyKey.USER_RPC_RETRY_MAX_DURATION), conf.getDuration(PropertyKey.USER_RPC_RETRY_BASE_SLEEP_MS), conf.getDuration(PropertyKey.USER_RPC_RETRY_MAX_SLEEP_MS)));
    } catch (IOException e) {
        LOG.warn("Failed to load cluster default configuration for Fuse process. " + "Proceed with local configuration for FUSE: {}", e.toString());
    }
    conf = fsContext.getClusterConf();
    final FuseMountOptions opts = parseOptions(args, conf);
    if (opts == null) {
        System.exit(1);
    }
    CommonUtils.PROCESS_TYPE.set(CommonUtils.ProcessType.CLIENT);
    MetricsSystem.startSinks(conf.getString(PropertyKey.METRICS_CONF_FILE));
    if (conf.getBoolean(PropertyKey.FUSE_WEB_ENABLED)) {
        FuseWebServer webServer = new FuseWebServer(NetworkAddressUtils.ServiceType.FUSE_WEB.getServiceName(), NetworkAddressUtils.getBindAddress(NetworkAddressUtils.ServiceType.FUSE_WEB, ServerConfiguration.global()));
        webServer.start();
    }
    startJvmMonitorProcess();
    try (FileSystem fs = FileSystem.Factory.create(fsContext)) {
        FuseUmountable fuseUmountable = launchFuse(fs, conf, opts, true);
    } catch (IOException e) {
        LOG.error("Failed to launch FUSE", e);
        System.exit(-1);
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) FileSystem(alluxio.client.file.FileSystem) FileSystemContext(alluxio.client.file.FileSystemContext) IOException(java.io.IOException) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration)

Example 58 with AlluxioConfiguration

use of alluxio.conf.AlluxioConfiguration in project alluxio by Alluxio.

the class ValidateEnv method runTasks.

private static int runTasks(String target, String name, CommandLine cmd) throws InterruptedException {
    // Validate against root path
    AlluxioConfiguration conf = InstancedConfiguration.defaults();
    String rootPath = conf.getString(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS);
    ValidateEnv validate = new ValidateEnv(rootPath, conf);
    boolean success;
    switch(target) {
        case "local":
        case "worker":
        case "master":
            success = validate.validateLocal(target, name, cmd);
            break;
        case "all":
            success = validate.validateMasters(name, cmd);
            success = validate.validateWorkers(name, cmd) && success;
            success = validate.validateLocal("cluster", name, cmd) && success;
            break;
        case "workers":
            success = validate.validateWorkers(name, cmd);
            break;
        case "masters":
            success = validate.validateMasters(name, cmd);
            break;
        default:
            printHelp("Invalid target.");
            return -2;
    }
    return success ? 0 : -1;
}
Also used : AlluxioConfiguration(alluxio.conf.AlluxioConfiguration)

Example 59 with AlluxioConfiguration

use of alluxio.conf.AlluxioConfiguration 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);
    }
}
Also used : Path(java.nio.file.Path) InstancedConfiguration(alluxio.conf.InstancedConfiguration) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration)

Example 60 with AlluxioConfiguration

use of alluxio.conf.AlluxioConfiguration 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;
}
Also used : Configuration(alluxio.wire.Configuration) GetConfigurationPOptions(alluxio.grpc.GetConfigurationPOptions) PathConfiguration(alluxio.conf.path.PathConfiguration) Options(org.apache.commons.cli.Options) CommandUtils(alluxio.cli.CommandUtils) IOException(java.io.IOException) HashMap(java.util.HashMap) PropertyKey(alluxio.conf.PropertyKey) AlluxioProperties(alluxio.conf.AlluxioProperties) ArrayList(java.util.ArrayList) List(java.util.List) Context(alluxio.cli.fsadmin.command.Context) AlluxioURI(alluxio.AlluxioURI) Map(java.util.Map) AbstractFsAdminCommand(alluxio.cli.fsadmin.command.AbstractFsAdminCommand) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) CommandLine(org.apache.commons.cli.CommandLine) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Comparator(java.util.Comparator) InstancedConfiguration(alluxio.conf.InstancedConfiguration) InvalidArgumentException(alluxio.exception.status.InvalidArgumentException) Property(alluxio.wire.Property) Option(org.apache.commons.cli.Option) PathConfiguration(alluxio.conf.path.PathConfiguration) Configuration(alluxio.wire.Configuration) PathConfiguration(alluxio.conf.path.PathConfiguration) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) InstancedConfiguration(alluxio.conf.InstancedConfiguration) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) InstancedConfiguration(alluxio.conf.InstancedConfiguration) AlluxioProperties(alluxio.conf.AlluxioProperties) ArrayList(java.util.ArrayList) List(java.util.List) Property(alluxio.wire.Property) PropertyKey(alluxio.conf.PropertyKey) AlluxioURI(alluxio.AlluxioURI)

Aggregations

AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)62 Test (org.junit.Test)20 InstancedConfiguration (alluxio.conf.InstancedConfiguration)17 IOException (java.io.IOException)11 AlluxioURI (alluxio.AlluxioURI)7 UnderFileSystemFactory (alluxio.underfs.UnderFileSystemFactory)7 ArrayList (java.util.ArrayList)7 AlluxioProperties (alluxio.conf.AlluxioProperties)5 PropertyKey (alluxio.conf.PropertyKey)5 OpenFilePOptions (alluxio.grpc.OpenFilePOptions)5 HealthCheckClient (alluxio.HealthCheckClient)4 FileSystemContext (alluxio.client.file.FileSystemContext)4 InStreamOptions (alluxio.client.file.options.InStreamOptions)4 InetSocketAddress (java.net.InetSocketAddress)4 Constants (alluxio.Constants)3 AlluxioBlockStore (alluxio.client.block.AlluxioBlockStore)3 FileSystem (alluxio.client.file.FileSystem)3 URIStatus (alluxio.client.file.URIStatus)3 ReadRequest (alluxio.grpc.ReadRequest)3 InputStream (java.io.InputStream)3