public CompatConfig(final Environment environment) { super(); this.staticSettings = environment.settings(); }
public static String resolve(String originalPath, String propName, Settings settings, Path configPath, boolean mustBeValid) { log.debug("Path is is {}", originalPath); String path = originalPath; final Environment env = new Environment(settings, configPath); if(env != null && originalPath != null && originalPath.length() > 0) { path = env.configFile().resolve(originalPath).toAbsolutePath().toString(); log.debug("Resolved {} to {} against {}", originalPath, path, env.configFile().toAbsolutePath().toString()); } if(mustBeValid) { checkPath(path, propName); } if("".equals(path)) { path = null; } return path; }
private Dictionary(Configuration cfg) { this.configuration = cfg; this.props = new Properties(); this.conf_dir = cfg.getEnvironment().configFile().resolve(AnalysisIkPlugin.PLUGIN_NAME); Path configFile = conf_dir.resolve(FILE_NAME); InputStream input = null; try { logger.info("try load config from {}", configFile); input = new FileInputStream(configFile.toFile()); } catch (FileNotFoundException e) { conf_dir = cfg.getConfigInPluginDir(); configFile = conf_dir.resolve(FILE_NAME); try { logger.info("try load config from {}", configFile); input = new FileInputStream(configFile.toFile()); } catch (FileNotFoundException ex) { // We should report origin exception logger.error("ik-analyzer", e); } } if (input != null) { try { props.loadFromXML(input); } catch (InvalidPropertiesFormatException e) { logger.error("ik-analyzer", e); } catch (IOException e) { logger.error("ik-analyzer", e); } } }
/** * Returns all shard paths excluding custom shard path. Note: Shards are only allocated on one of the * returned paths. The returned array may contain paths to non-existing directories. * * @see IndexSettings#hasCustomDataPath() * @see #resolveCustomLocation(IndexSettings, ShardId) * */ public Path[] availableShardPaths(ShardId shardId) { assertEnvIsLocked(); final NodePath[] nodePaths = nodePaths(); final Path[] shardLocations = new Path[nodePaths.length]; for (int i = 0; i < nodePaths.length; i++) { shardLocations[i] = nodePaths[i].resolve(shardId); } return shardLocations; }
/** * Returns all index paths. */ public Path[] indexPaths(Index index) { assertEnvIsLocked(); Path[] indexPaths = new Path[nodePaths.length]; for (int i = 0; i < nodePaths.length; i++) { indexPaths[i] = nodePaths[i].resolve(index); } return indexPaths; }
/** * Deletes the shard with an already acquired shard lock. * @param reason the reason for the shard deletion * @param lock the lock of the shard to delete * @param indexSettings the shards index settings. * @throws IOException if an IOException occurs */ @Override public void deleteShardStore(String reason, ShardLock lock, IndexSettings indexSettings) throws IOException { ShardId shardId = lock.getShardId(); logger.trace("{} deleting shard reason [{}]", shardId, reason); nodeEnv.deleteShardDirectoryUnderLock(lock, indexSettings); }
public ShardLockObtainFailedException(ShardId shardId, String message, Throwable cause) { super(buildMessage(shardId, message), cause); this.setShard(shardId); }
/** * Returns an array of all of the nodes data locations. * @throws IllegalStateException if the node is not configured to store local locations */ public Path[] nodeDataPaths() { assertEnvIsLocked(); Path[] paths = new Path[nodePaths.length]; for(int i=0;i<paths.length;i++) { paths[i] = nodePaths[i].path; } return paths; }
/** * Resolve the custom path for a index's shard. * Uses the {@code IndexMetaData.SETTING_DATA_PATH} setting to determine * the root path for the index. * * @param indexSettings settings for the index * @param shardId shard to resolve the path to */ public Path resolveCustomLocation(IndexSettings indexSettings, final ShardId shardId) { return resolveCustomLocation(indexSettings, shardId, sharedDataPath, nodeLockId); }
/** * returns the unique uuid describing this node. The uuid is persistent in the data folder of this node * and remains across restarts. **/ public String nodeId() { // we currently only return the ID and hide the underlying nodeMetaData implementation in order to avoid // confusion with other "metadata" like node settings found in elasticsearch.yml. In future // we can encapsulate both (and more) in one NodeMetaData (or NodeSettings) object ala IndexSettings return nodeMetaData.nodeId(); }
/** * Resolve the custom path for a index's shard. * Uses the {@code IndexMetaData.SETTING_DATA_PATH} setting to determine * the root path for the index. * * @param indexSettings settings for the index */ private Path resolveIndexCustomLocation(IndexSettings indexSettings) { return resolveIndexCustomLocation(indexSettings, sharedDataPath, nodeLockId); }
/** * Resolve the custom path for a index's shard. * Uses the {@code IndexMetaData.SETTING_DATA_PATH} setting to determine * the root path for the index. * * @param indexSettings settings for the index */ public Path resolveBaseCustomLocation(IndexSettings indexSettings) { return resolveBaseCustomLocation(indexSettings, sharedDataPath, nodeLockId); }
/** * Return all directory names in the nodes/{node.id}/indices directory for the given node path. * * @param nodePath the path * @return all directories that could be indices for the given node path. * @throws IOException if an I/O exception occurs traversing the filesystem */ public Set<String> availableIndexFoldersForPath(final NodePath nodePath) throws IOException { return availableIndexFoldersForPath(nodePath, p -> false); }
/** * Returns all folder names in ${data.paths}/nodes/{node.id}/indices folder */ public Set<String> availableIndexFolders() throws IOException { return availableIndexFolders(p -> false); }
public NodeMetaData build() { return new NodeMetaData(nodeId); } }
@Override public List<String> run() { final Path confPath = new Environment(settings, configPath).configFile().toAbsolutePath(); if(Files.isDirectory(confPath, LinkOption.NOFOLLOW_LINKS)) { try (Stream<Path> s = Files.walk(confPath)) { return s .distinct() .map(p->sha256(p)) .collect(Collectors.toList()); } catch (Exception e) { log.error(e); return null; } } return Collections.emptyList(); } });
public ComplianceConfig(final Environment environment, final IndexResolverReplacer irr, final AuditLog auditLog) { super(); this.settings = environment.settings(); this.environment = environment; this.irr = irr;
public ShardLockObtainFailedException(ShardId shardId, String message) { super(buildMessage(shardId, message)); this.setShard(shardId); }
@Override public List<Path> run() { final Path confPath = new Environment(settings, configPath).configFile().toAbsolutePath(); if(Files.isDirectory(confPath, LinkOption.NOFOLLOW_LINKS)) { try (Stream<Path> s = Files.walk(confPath)) { return s .distinct() .filter(p->checkFilePermissions(p)) .collect(Collectors.toList()); } catch (Exception e) { log.error(e); return null; } } return Collections.emptyList(); } });