Java Code Examples for org.elasticsearch.common.collect.Tuple#tuple()
The following examples show how to use
org.elasticsearch.common.collect.Tuple#tuple() .
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: KibanaSeed.java From openshift-elasticsearch-plugin with Apache License 2.0 | 6 votes |
private Tuple<Boolean, Project> seedOperationsIndexPatterns(final OpenshiftRequestContext context, String kibanaVersion) { boolean changed = false; for (String pattern : settings.getKibanaOpsIndexPatterns()) { if (!pluginClient.documentExists(context.getKibanaIndex(), INDICIES_TYPE, pattern)) { LOGGER.trace("Creating index-pattern '{}'", pattern); String source = StringUtils.replace(mappingLoader.getOperationsMappingsTemplate(), "$TITLE$", pattern); pluginClient.createDocument(context.getKibanaIndex(), INDICIES_TYPE, pattern, source); changed = true; } } // if current.default not set, load String defaultPattern = settings.getKibanaOpsIndexPatterns().size() > 0 ? settings.getKibanaOpsIndexPatterns().iterator().next() : ""; String indexPattern = kibanaUtils.getDefaultIndexPattern(context.getKibanaIndex(), defaultPattern); return Tuple.tuple(changed, new Project(indexPattern, null)); }
Example 2
Source File: RemoteMonitor.java From elasticsearch-analysis-hanlp with Apache License 2.0 | 5 votes |
/** * 解析默认信息 * * @param location 配置路径 * @return 返回new Tuple<路径, 默认词性> */ private Tuple<String, Nature> analysisDefaultInfo(String location) { Nature defaultNature = Nature.n; String path = location; int cut = location.indexOf(' '); if (cut > 0) { // 有默认词性 String nature = location.substring(cut + 1); path = location.substring(0, cut); defaultNature = LexiconUtility.convertStringToNature(nature); } return Tuple.tuple(path, defaultNature); }
Example 3
Source File: KibanaSeed.java From openshift-elasticsearch-plugin with Apache License 2.0 | 5 votes |
public void setDashboards(final OpenshiftRequestContext context, String kibanaVersion, final String projectPrefix) { if (!pluginClient.indexExists(defaultKibanaIndex)) { LOGGER.debug("Default Kibana index '{}' does not exist. Skipping Kibana seeding", defaultKibanaIndex); return; } LOGGER.debug("Begin setDashboards: projectPrefix '{}' for user '{}' projects '{}' kibanaIndex '{}'", projectPrefix, context.getUser(), context.getProjects(), context.getKibanaIndex()); // We want to seed the Kibana user index initially // since the logic from Kibana has changed to create before this plugin // starts... Tuple<Boolean, Project> action = Tuple.tuple(initialSeedKibanaIndex(context), Project.EMPTY); if (context.isOperationsUser()) { action = seedOperationsIndexPatterns(context, kibanaVersion); } else { action = seedUsersIndexPatterns(context, kibanaVersion); } if (action.v2() != null && !Project.EMPTY.equals(action.v2())) { boolean defaultIndexPatternExists = pluginClient.documentExists(context.getKibanaIndex(), INDICIES_TYPE, action.v2().getName()); GetResponse config = pluginClient.getDocument(context.getKibanaIndex(), CONFIG_DOC_TYPE, kibanaVersion); if(!defaultIndexPatternExists || !config.isExists() || StringUtils.isBlank(kibanaUtils.getDefaultIndexPattern(config))){ setDefaultProject(context.getKibanaIndex(), action.v2(), kibanaVersion); action = Tuple.tuple(true, action.v2()); } } if (action.v1()) { pluginClient.refreshIndices(context.getKibanaIndex()); } }
Example 4
Source File: StatsTables.java From Elasticsearch with Apache License 2.0 | 4 votes |
/** * Generate a unique ID for an operation based on jobId and operationId. */ private static Tuple<Integer, UUID> uniqueOperationId(int operationId, UUID jobId) { return Tuple.tuple(operationId, jobId); }
Example 5
Source File: KibanaSeed.java From openshift-elasticsearch-plugin with Apache License 2.0 | 4 votes |
private Tuple<Boolean, Project> seedUsersIndexPatterns(final OpenshiftRequestContext context, final String kibanaVersion) { boolean changed = false; Set<Project> projectsFromIndexPatterns = kibanaUtils.getProjectsFromIndexPatterns(context); LOGGER.debug("Found '{}' Index patterns for user", projectsFromIndexPatterns.size()); Set<Project> projects = context.getProjects(); List<Project> projectsWithIndices = filterProjectsWithIndices(projects); LOGGER.debug("projects for '{}' that have existing index patterns: '{}'", context.getUser(), projectsWithIndices); if (projectsWithIndices.isEmpty()) { projectsWithIndices.add(KibanaUtils.EMPTY_PROJECT); } Collections.sort(projectsWithIndices); // If none have been set yet BulkBuilder bulkBuilder = pluginClient.newBulkBuilder(); Project defaultProject = projectsWithIndices.isEmpty() ? Project.EMPTY : projectsWithIndices.get(0); if (projectsFromIndexPatterns.isEmpty()) { create(bulkBuilder, context.getKibanaIndex(), projectsWithIndices, projectsFromIndexPatterns); bulkBuilder.execute(); changed = true; } else { List<Project> common = new ArrayList<Project>(projectsFromIndexPatterns); common.retainAll(projectsWithIndices); projectsWithIndices.removeAll(common); projectsFromIndexPatterns.removeAll(common); // if we aren't a cluster-admin, make sure we're deleting the // ADMIN_ALIAS_NAME if (!context.isOperationsUser()) { LOGGER.debug("user is not a cluster admin, ensure they don't keep/have the admin alias pattern"); projectsFromIndexPatterns.add(KibanaUtils.ALL_ALIAS); } // check if we're going to be adding or removing any index-patterns if (!projectsWithIndices.isEmpty() || !projectsFromIndexPatterns.isEmpty()) { changed = true; } // for any to create (remaining in projects) call createIndices, // createSearchmapping?, create dashboard create(bulkBuilder, context.getKibanaIndex(), projectsWithIndices, projectsFromIndexPatterns); // cull any that are in ES but not in OS (remaining in indexPatterns) remove(bulkBuilder, context.getKibanaIndex(), projectsFromIndexPatterns); bulkBuilder.execute(); common.addAll(projectsWithIndices); Collections.sort(common); // Set default index to first index in common if we removed the default String defaultIfNotSet = !common.isEmpty() ? common.get(0).getName() : Project.EMPTY.getName(); String pattern = kibanaUtils.getDefaultIndexPattern(context.getKibanaIndex(), defaultIfNotSet); defaultProject = new Project(pattern, null); } return Tuple.tuple(changed, defaultProject); }