当前位置: 首页>>代码示例>>Java>>正文


Java RepositorySettings类代码示例

本文整理汇总了Java中org.elasticsearch.repositories.RepositorySettings的典型用法代码示例。如果您正苦于以下问题:Java RepositorySettings类的具体用法?Java RepositorySettings怎么用?Java RepositorySettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RepositorySettings类属于org.elasticsearch.repositories包,在下文中一共展示了RepositorySettings类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: FsRepository

import org.elasticsearch.repositories.RepositorySettings; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:33,代码来源:FsRepository.java

示例2: GridFsRepository

import org.elasticsearch.repositories.RepositorySettings; //导入依赖的package包/类
/**
 * Constructs new BlobStoreRepository
 * @param name                 repository name
 * @param repositorySettings   repository settings
 * @param indexShardRepository an instance of IndexShardRepository
 * @param gridFsService and instance of GridFsService
 */
@Inject
protected GridFsRepository(RepositoryName name, RepositorySettings repositorySettings, IndexShardRepository indexShardRepository, GridFsService gridFsService) {
    super(name.getName(), repositorySettings, indexShardRepository);

    String database = repositorySettings.settings().get("database", componentSettings.get("database"));
    if (database == null) {
        throw new RepositoryException(name.name(), "No database defined for GridFS repository");
    }

    String bucket = repositorySettings.settings().get("bucket", "fs");
    String host = repositorySettings.settings().get("gridfs_host", "localhost");
    int port = repositorySettings.settings().getAsInt("gridfs_port", 27017);
    String username = repositorySettings.settings().get("gridfs_username");
    String password = repositorySettings.settings().get("gridfs_password");

    int concurrentStreams = repositorySettings.settings().getAsInt("concurrent_streams", componentSettings.getAsInt("concurrent_streams", 5));
    ExecutorService concurrentStreamPool = EsExecutors.newScaling(1, concurrentStreams, 5, TimeUnit.SECONDS, EsExecutors.daemonThreadFactory(settings, "[gridfs_stream]"));
    blobStore = new GridFsBlobStore(settings, gridFsService.mongoDB(host, port, database, username, password), bucket, concurrentStreamPool);
    this.chunkSize = repositorySettings.settings().getAsBytesSize("chunk_size", componentSettings.getAsBytesSize("chunk_size", null));
    this.compress = repositorySettings.settings().getAsBoolean("compress", componentSettings.getAsBoolean("compress", true));
    this.basePath = BlobPath.cleanPath();
}
 
开发者ID:kzwang,项目名称:elasticsearch-repository-gridfs,代码行数:30,代码来源:GridFsRepository.java

示例3: SshRepository

import org.elasticsearch.repositories.RepositorySettings; //导入依赖的package包/类
@Inject
public SshRepository(final RepositoryName name,
    final RepositorySettings repositorySettings,
    final IndexShardRepository indexShardRepository,
    final ThreadPool threadPool) throws IOException {
    super(name.getName(), repositorySettings, indexShardRepository);

    try {
        blobStore = new SshBlobStore(settings, new JSchClient(
            settings, repositorySettings, threadPool));
    } catch (final JSchException e) {
        throw new RepositoryException(name.name(),
            "Failed to initialize SSH configuration.", e);
    }

    chunkSize = repositorySettings.settings().getAsBytesSize("chunk_size",
        settings.getAsBytesSize("chunk_size", null));
    compress = repositorySettings.settings().getAsBoolean("compress",
        settings.getAsBoolean("compress", false));
    basePath = BlobPath.cleanPath();
}
 
开发者ID:codelibs,项目名称:elasticsearch-repository-ssh,代码行数:22,代码来源:SshRepository.java

示例4: BlobStoreRepository

import org.elasticsearch.repositories.RepositorySettings; //导入依赖的package包/类
/**
 * Constructs new BlobStoreRepository
 *
 * @param repositoryName       repository name
 * @param repositorySettings   repository settings
 * @param indexShardRepository an instance of IndexShardRepository
 */
protected BlobStoreRepository(String repositoryName, RepositorySettings repositorySettings, IndexShardRepository indexShardRepository) {
    super(repositorySettings.globalSettings());
    this.repositoryName = repositoryName;
    this.indexShardRepository = (BlobStoreIndexShardRepository) indexShardRepository;
    snapshotRateLimiter = getRateLimiter(repositorySettings, "max_snapshot_bytes_per_sec", new ByteSizeValue(40, ByteSizeUnit.MB));
    restoreRateLimiter = getRateLimiter(repositorySettings, "max_restore_bytes_per_sec", new ByteSizeValue(40, ByteSizeUnit.MB));
    readOnly = repositorySettings.settings().getAsBoolean("readonly", false);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:16,代码来源:BlobStoreRepository.java

示例5: getRateLimiter

import org.elasticsearch.repositories.RepositorySettings; //导入依赖的package包/类
/**
 * Configures RateLimiter based on repository and global settings
 *
 * @param repositorySettings repository settings
 * @param setting            setting to use to configure rate limiter
 * @param defaultRate        default limiting rate
 * @return rate limiter or null of no throttling is needed
 */
private RateLimiter getRateLimiter(RepositorySettings repositorySettings, String setting, ByteSizeValue defaultRate) {
    ByteSizeValue maxSnapshotBytesPerSec = repositorySettings.settings().getAsBytesSize(setting,
            settings.getAsBytesSize(setting, defaultRate));
    if (maxSnapshotBytesPerSec.bytes() <= 0) {
        return null;
    } else {
        return new RateLimiter.SimpleRateLimiter(maxSnapshotBytesPerSec.mbFrac());
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:BlobStoreRepository.java

示例6: CloudFilesRepository

import org.elasticsearch.repositories.RepositorySettings; //导入依赖的package包/类
@Inject
protected CloudFilesRepository(String repositoryName, RepositorySettings repositorySettings, IndexShardRepository indexShardRepository, CloudFilesService cloudFilesService) {
    super(repositoryName, repositorySettings, indexShardRepository);

    final String container = repositorySettings.settings().get("container", componentSettings.get("container"));
    if(container == null || container.equals("")){
        throw new RepositoryException(repositoryName, "No container defined for cloud files gateway.");
    }

    final String dataCenter = repositorySettings.settings().get("region", componentSettings.get("region", "ORD"));
    final int concurrentStreams = repositorySettings.settings().getAsInt("concurrent_streams", componentSettings.getAsInt("concurrent_streams", 5));
    ExecutorService concurrentStreamPool = EsExecutors.newScaling(1, concurrentStreams, 5, TimeUnit.SECONDS, EsExecutors.daemonThreadFactory(settings, "[cloudfiles_stream]"));
    final Location location = new LocationBuilder()
            .scope(LocationScope.REGION)
            .id(dataCenter)
            .description(String.format("Rackspace's %s datacenter.", dataCenter))
            .build();

    blobStore = new CloudFilesBlobStore(settings, cloudFilesService.context(), container, location, concurrentStreamPool);
    this.chunkSize = repositorySettings.settings().getAsBytesSize("chunk_size", componentSettings.getAsBytesSize("chunk_size", new ByteSizeValue(100, ByteSizeUnit.MB)));
    this.compress = repositorySettings.settings().getAsBoolean("compress", componentSettings.getAsBoolean("compress", false));
    logger.debug("using container [{}], data center [{}], chunk_size [{}], concurrent_streams [{}]", container, dataCenter, chunkSize, concurrentStreams);
    String basePath = repositorySettings.settings().get("base_path", null);
    if (Strings.hasLength(basePath)) {
        BlobPath path = new BlobPath();
        for(String elem : Strings.splitStringToArray(basePath, '/')) {
            path = path.add(elem);
        }
        this.basePath = path;
    } else {
        this.basePath = BlobPath.cleanPath();
    }
}
 
开发者ID:jlinn,项目名称:elasticsearch-cloud-rackspace,代码行数:34,代码来源:CloudFilesRepository.java

示例7: SwiftRepository

import org.elasticsearch.repositories.RepositorySettings; //导入依赖的package包/类
/**
 * Constructs new BlobStoreRepository
 * 
 * @param name
 *            repository name
 * @param repositorySettings
 *            repository settings
 * @param indexShardRepository
 *            an instance of IndexShardRepository
 * @param swiftService
 *            an instance of SwiftService
 */
@Inject
public SwiftRepository(RepositoryName name, RepositorySettings repositorySettings, IndexShardRepository indexShardRepository, SwiftService swiftService) {
    super(name.getName(), repositorySettings, indexShardRepository);

    String url = repositorySettings.settings().get("swift_url");
    if (url == null) {
        throw new RepositoryException(name.name(), "No url defined for swift repository");
    }

    String container = repositorySettings.settings().get("swift_container");
    if (container == null) {
        throw new RepositoryException(name.name(), "No container defined for swift repository");
    }

    String username = repositorySettings.settings().get("swift_username", "");
    String password = repositorySettings.settings().get("swift_password", "");
    String tenantName = repositorySettings.settings().get("swift_tenantname", "");
    String authMethod = repositorySettings.settings().get("swift_authmethod", "");
    String preferredRegion = repositorySettings.settings().get("swift_preferred_region", null);
    Account account = SwiftAccountFactory.createAccount(swiftService, url, username, password, tenantName, authMethod, preferredRegion);

    blobStore = new SwiftBlobStore(settings, account, container);
    this.chunkSize = repositorySettings.settings().getAsBytesSize("chunk_size",
            settings.getAsBytesSize("chunk_size", new ByteSizeValue(5, ByteSizeUnit.GB)));
    this.compress = repositorySettings.settings().getAsBoolean("compress",
            settings.getAsBoolean("compress", false));
    this.basePath = BlobPath.cleanPath();
}
 
开发者ID:wikimedia,项目名称:search-repository-swift,代码行数:41,代码来源:SwiftRepository.java

示例8: testConstructorNoContainer

import org.elasticsearch.repositories.RepositorySettings; //导入依赖的package包/类
@Test(expected = RepositoryException.class)
public void testConstructorNoContainer(){
    new CloudFilesRepository("test", new RepositorySettings(ImmutableSettings.EMPTY, ImmutableSettings.EMPTY), indexShardRepository, cloudFilesService);
}
 
开发者ID:jlinn,项目名称:elasticsearch-cloud-rackspace,代码行数:5,代码来源:CloudFilesRepositoryTest.java

示例9: testConstructor

import org.elasticsearch.repositories.RepositorySettings; //导入依赖的package包/类
@Test
public void testConstructor(){
    String name = "testRepo";
    String region = "DFW";
    String container = "testContainer";

    // Omit the region setting. Should default to "ORD"
    Settings settings = ImmutableSettings.builder()
            .put("container", container)
            .build();

    CloudFilesRepository repository = new CloudFilesRepository(name, new RepositorySettings(ImmutableSettings.EMPTY, settings), indexShardRepository, cloudFilesService);
    assertEquals("ORD", ((CloudFilesBlobStore) repository.blobStore()).getLocation().getId());

    // include the region setting this time
    settings = ImmutableSettings.builder()
            .put("container", container)
            .put("region", region)
            .build();

    repository = new CloudFilesRepository(name, new RepositorySettings(ImmutableSettings.EMPTY, settings), indexShardRepository, cloudFilesService);
    assertEquals(region, ((CloudFilesBlobStore) repository.blobStore()).getLocation().getId());

    Settings globalSettings = ImmutableSettings.builder()
            .put("repositories.cloudfiles.region", "IAD")
            .build();
    settings = ImmutableSettings.builder()
            .put("container", container)
            .build();

    repository = new CloudFilesRepository(name, new RepositorySettings(globalSettings, settings), indexShardRepository, cloudFilesService);
    // the region setting from the global settings should be used
    assertEquals("IAD", ((CloudFilesBlobStore) repository.blobStore()).getLocation().getId());

    globalSettings = ImmutableSettings.builder()
            .put("repositories.cloudfiles.region", "IAD")
            .build();
    settings = ImmutableSettings.builder()
            .put("container", container)
            .put("region", "DFW")
            .build();

    repository = new CloudFilesRepository(name, new RepositorySettings(globalSettings, settings), indexShardRepository, cloudFilesService);
    // the region setting from the global settings should be overridden
    assertEquals("DFW", ((CloudFilesBlobStore) repository.blobStore()).getLocation().getId());
}
 
开发者ID:jlinn,项目名称:elasticsearch-cloud-rackspace,代码行数:47,代码来源:CloudFilesRepositoryTest.java

示例10: JSchClient

import org.elasticsearch.repositories.RepositorySettings; //导入依赖的package包/类
public JSchClient(final Settings componentSettings,
    final RepositorySettings repositorySettings,
    final ThreadPool threadPool) throws JSchException {

    SshConfig config = new SshConfig();
    config.setHost(repositorySettings.settings().get("host", componentSettings.get("host")));
    config.setPort(
        repositorySettings.settings().getAsInt("port", componentSettings.getAsInt("port", 22)));
    config.setUsername(
        repositorySettings.settings().get("username", componentSettings.get("username")));
    config.setPassword(
        repositorySettings.settings().get("password", componentSettings.get("password")));
    config.setLocation(
        repositorySettings.settings().get("location", componentSettings.get("location", "~/")));
    config.setPrivateKey(
        repositorySettings.settings().get("private_key", componentSettings.get("private_key")));
    config.setPassphrase(
        repositorySettings.settings().get("passphrase", componentSettings.get("passphrase")));
    config.setKnownHosts(
        repositorySettings.settings().get("known_hosts", componentSettings.get("known_hosts")));
    config.setIgnoreHostKeyChecking(repositorySettings.settings()
        .getAsBoolean("ignore_host_key",
            componentSettings.getAsBoolean("ignore_host_key", false)));

    if (config.getPassword() == null && config.getPrivateKey() == null) {
        throw new JSchException(
            "A password and private key for SSH are empty.");
    }

    this.config = config;

    GenericKeyedObjectPoolConfig poolConfig = new GenericKeyedObjectPoolConfig();
    poolConfig.setMaxTotalPerKey(5);
    poolConfig.setMinEvictableIdleTimeMillis(repositorySettings.settings()
        .getAsLong("session_expire", componentSettings.getAsLong("session_expire", 60000L)));

    TimeValue cleanInterval = repositorySettings.settings().getAsTime("clean_interval",
        componentSettings.getAsTime("clean_interval", TimeValue.timeValueMinutes(1)));
    poolConfig.setJmxEnabled(false);
    poolConfig.setTimeBetweenEvictionRunsMillis(cleanInterval.getMillis());
    this.sshPool = new SshPool(config, poolConfig);

}
 
开发者ID:codelibs,项目名称:elasticsearch-repository-ssh,代码行数:44,代码来源:JSchClient.java


注:本文中的org.elasticsearch.repositories.RepositorySettings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。