Java Code Examples for org.elasticsearch.env.Environment#repoFiles()

The following examples show how to use org.elasticsearch.env.Environment#repoFiles() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FsRepository.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs new shared file system repository
 *
 * @param name                 repository name
 * @param repositorySettings   repository settings
 * @param indexShardRepository index shard repository
 */
@Inject
public FsRepository(RepositoryName name, RepositorySettings repositorySettings, IndexShardRepository indexShardRepository, Environment environment) throws IOException {
    super(name.getName(), repositorySettings, indexShardRepository);
    Path locationFile;
    String location = repositorySettings.settings().get("location", settings.get("repositories.fs.location"));
    if (location == null) {
        logger.warn("the repository location is missing, it should point to a shared file system location that is available on all master and data nodes");
        throw new RepositoryException(name.name(), "missing location");
    }
    locationFile = environment.resolveRepoFile(location);
    if (locationFile == null) {
        if (environment.repoFiles().length > 0) {
            logger.warn("The specified location [{}] doesn't start with any repository paths specified by the path.repo setting: [{}] ", location, environment.repoFiles());
            throw new RepositoryException(name.name(), "location [" + location + "] doesn't match any of the locations specified by path.repo");
        } else {
            logger.warn("The specified location [{}] should start with a repository path specified by the path.repo setting, but the path.repo setting was not set on this node", location);
            throw new RepositoryException(name.name(), "location [" + location + "] doesn't match any of the locations specified by path.repo because this setting is empty");
        }
    }

    blobStore = new FsBlobStore(settings, locationFile);
    this.chunkSize = repositorySettings.settings().getAsBytesSize("chunk_size", settings.getAsBytesSize("repositories.fs.chunk_size", null));
    this.compress = repositorySettings.settings().getAsBoolean("compress", settings.getAsBoolean("repositories.fs.compress", false));
    this.basePath = BlobPath.cleanPath();
}
 
Example 2
Source File: FsRepository.java    From crate with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a shared file system repository.
 */
public FsRepository(RepositoryMetaData metadata, Environment environment, NamedXContentRegistry namedXContentRegistry,
                    ThreadPool threadPool) {
    super(metadata, environment.settings(), namedXContentRegistry, threadPool, BlobPath.cleanPath());
    this.environment = environment;
    String location = REPOSITORIES_LOCATION_SETTING.get(metadata.settings());
    if (location.isEmpty()) {
        LOGGER.warn("the repository location is missing, it should point to a shared file system location"
            + " that is available on all master and data nodes");
        throw new RepositoryException(metadata.name(), "missing location");
    }
    Path locationFile = environment.resolveRepoFile(location);
    if (locationFile == null) {
        if (environment.repoFiles().length > 0) {
            LOGGER.warn("The specified location [{}] doesn't start with any "
                + "repository paths specified by the path.repo setting: [{}] ", location, environment.repoFiles());
            throw new RepositoryException(metadata.name(), "location [" + location
                + "] doesn't match any of the locations specified by path.repo");
        } else {
            LOGGER.warn("The specified location [{}] should start with a repository path specified by"
                + " the path.repo setting, but the path.repo setting was not set on this node", location);
            throw new RepositoryException(metadata.name(), "location [" + location
                + "] doesn't match any of the locations specified by path.repo because this setting is empty");
        }
    }

    if (CHUNK_SIZE_SETTING.exists(metadata.settings())) {
        this.chunkSize = CHUNK_SIZE_SETTING.get(metadata.settings());
    } else {
        this.chunkSize = REPOSITORIES_CHUNK_SIZE_SETTING.get(environment.settings());
    }
    this.basePath = BlobPath.cleanPath();
}