public boolean isAlias(String query) { Map<String, Object> aliases = (Map<String, Object>) get(query, null); return (aliases.size() > 1); }
public MappingSet getMappings(String query, boolean includeTypeName) { if (includeTypeName) { query = query + "?include_type_name=true"; } Map<String, Object> result = get(query, null); if (result != null && !result.isEmpty()) { return FieldParser.parseMappings(result, includeTypeName); } return null; }
public boolean waitForHealth(String index, Health health, TimeValue timeout) { StringBuilder sb = new StringBuilder("/_cluster/health/"); sb.append(index); sb.append("?wait_for_status="); sb.append(health.name().toLowerCase(Locale.ROOT)); sb.append("&timeout="); sb.append(timeout.toString()); return (Boolean.TRUE.equals(get(sb.toString(), "timed_out"))); }
public Health getHealth(String index) { StringBuilder sb = new StringBuilder("/_cluster/health/"); sb.append(index); String status = get(sb.toString(), "status"); if (status == null) { throw new EsHadoopIllegalStateException("Could not determine index health, returned status was null. Bailing out..."); } return Health.valueOf(status.toUpperCase()); }
@Override public Response execute() { StringBuilder path = new StringBuilder(); if (indices.size() > 0) { path.append(StringUtils.concatenate(indices)); } else { path.append("_all"); } path.append("/_alias"); if (aliases.size() > 0) { path.append("/").append(StringUtils.concatenate(aliases)); } return new Response((Map<String, Object>) client.get(path.toString(), null)); }
public List<NodeInfo> getHttpNodes(boolean clientNodeOnly) { Map<String, Map<String, Object>> nodesData = get("_nodes/http", "nodes"); List<NodeInfo> nodes = new ArrayList<NodeInfo>(); for (Entry<String, Map<String, Object>> entry : nodesData.entrySet()) { NodeInfo node = new NodeInfo(entry.getKey(), entry.getValue()); if (node.hasHttp() && (!clientNodeOnly || node.isClient())) { nodes.add(node); } } return nodes; }
public EsMajorVersion remoteEsVersion() { Map<String, String> result = get("", "version"); if (result == null || !StringUtils.hasText(result.get("number"))) { throw new EsHadoopIllegalStateException("Unable to retrieve elasticsearch version."); } return EsMajorVersion.parse(result.get("number")); }
public List<List<Map<String, Object>>> targetShards(String index, String routing) { List<List<Map<String, Object>>> shardsJson = null; // https://github.com/elasticsearch/elasticsearch/issues/2726 String target = index + "/_search_shards"; if (routing != null) { target += "?routing=" + HttpEncodingTools.encode(routing); } if (indexReadMissingAsEmpty) { Request req = new SimpleRequest(GET, null, target); Response res = executeNotFoundAllowed(req); if (res.status() == HttpStatus.OK) { shardsJson = parseContent(res.body(), "shards"); } else { shardsJson = Collections.emptyList(); } } else { shardsJson = get(target, "shards"); } return shardsJson; }
@SuppressWarnings("unchecked") public Map<String, Object> getMapping(String query) { return (Map<String, Object>) get(query, null); }
public boolean isAlias(String query) { Map<String, Object> aliases = (Map<String, Object>) get(query, null); return (aliases.size() > 1); }
public boolean isAlias(String query) { Map<String, Object> aliases = (Map<String, Object>) get(query, null); return (aliases.size() > 1); }
public boolean waitForHealth(String index, Health health, TimeValue timeout) { StringBuilder sb = new StringBuilder("/_cluster/health/"); sb.append(index); sb.append("?wait_for_status="); sb.append(health.name().toLowerCase(Locale.ROOT)); sb.append("&timeout="); sb.append(timeout.toString()); return (Boolean.TRUE.equals(get(sb.toString(), "timed_out"))); }
public boolean health(String index, HEALTH health, TimeValue timeout) { StringBuilder sb = new StringBuilder("/_cluster/health/"); sb.append(index); sb.append("?wait_for_status="); sb.append(health.name().toLowerCase(Locale.ROOT)); sb.append("&timeout="); sb.append(timeout.toString()); return (Boolean.TRUE.equals(get(sb.toString(), "timed_out"))); }
public boolean waitForHealth(String index, Health health, TimeValue timeout) { StringBuilder sb = new StringBuilder("/_cluster/health/"); sb.append(index); sb.append("?wait_for_status="); sb.append(health.name().toLowerCase(Locale.ROOT)); sb.append("&timeout="); sb.append(timeout.toString()); return (Boolean.TRUE.equals(get(sb.toString(), "timed_out"))); }
public boolean waitForHealth(String index, Health health, TimeValue timeout) { StringBuilder sb = new StringBuilder("/_cluster/health/"); sb.append(index); sb.append("?wait_for_status="); sb.append(health.name().toLowerCase(Locale.ROOT)); sb.append("&timeout="); sb.append(timeout.toString()); return (Boolean.TRUE.equals(get(sb.toString(), "timed_out"))); }
public Health getHealth(String index) { StringBuilder sb = new StringBuilder("/_cluster/health/"); sb.append(index); String status = get(sb.toString(), "status"); if (status == null) { throw new EsHadoopIllegalStateException("Could not determine index health, returned status was null. Bailing out..."); } return Health.valueOf(status.toUpperCase()); }
public List<NodeInfo> getHttpNodes(boolean clientNodeOnly) { Map<String, Map<String, Object>> nodesData = get("_nodes/http", "nodes"); List<NodeInfo> nodes = new ArrayList<NodeInfo>(); for (Entry<String, Map<String, Object>> entry : nodesData.entrySet()) { NodeInfo node = new NodeInfo(entry.getKey(), entry.getValue()); if (node.hasHttp() && (!clientNodeOnly || node.isClient())) { nodes.add(node); } } return nodes; }
public List<NodeInfo> getHttpNodes(boolean clientNodeOnly) { Map<String, Map<String, Object>> nodesData = get("_nodes/http", "nodes"); List<NodeInfo> nodes = new ArrayList<NodeInfo>(); for (Entry<String, Map<String, Object>> entry : nodesData.entrySet()) { NodeInfo node = new NodeInfo(entry.getKey(), entry.getValue()); if (node.hasHttp() && (!clientNodeOnly || node.isClient())) { nodes.add(node); } } return nodes; }
public List<NodeInfo> getHttpNodes(boolean clientNodeOnly) { Map<String, Map<String, Object>> nodesData = get("_nodes/http", "nodes"); List<NodeInfo> nodes = new ArrayList<NodeInfo>(); for (Entry<String, Map<String, Object>> entry : nodesData.entrySet()) { NodeInfo node = new NodeInfo(entry.getKey(), entry.getValue()); if (node.hasHttp() && (!clientNodeOnly || node.isClient())) { nodes.add(node); } } return nodes; }
public EsMajorVersion remoteEsVersion() { Map<String, String> result = get("", "version"); if (result == null || !StringUtils.hasText(result.get("number"))) { throw new EsHadoopIllegalStateException("Unable to retrieve elasticsearch version."); } return EsMajorVersion.parse(result.get("number")); }