Package org.elasticsearch.common.settings

Examples of org.elasticsearch.common.settings.SettingsException


    }
  }

  private void validateConfigurationString(String value, String configFieldName) throws SettingsException {
    if (Utils.isEmpty(value)) {
      throw new SettingsException("No default '" + configFieldName + "' configuration found!");
    }
  }
View Full Code Here


    }
  }

  private void validateConfigurationObject(Object value, String configFieldName) throws SettingsException {
    if (value == null) {
      throw new SettingsException("No default '" + configFieldName + "' configuration found!");
    }
  }
View Full Code Here

          remoteSettings.get("remoteClientClass"), null));
      if (remoteClientClass != null) {
        try {
          remoteSystemClient = (IRemoteSystemClient) Class.forName(remoteClientClass).newInstance();
        } catch (Exception e) {
          throw new SettingsException("Unable to instantiate class defined by 'remote/remoteClientClass': "
              + e.getMessage());
        }
      } else {
        remoteSystemClient = new GetJSONClient();
      }
      remoteSystemClient.init(remoteSettings, allIndexedSpacesKeysNextRefresh != Long.MAX_VALUE, this);
    } else {
      throw new SettingsException("'remote' element of river configuration structure not found");
    }

    Map<String, Object> indexSettings = null;
    if (settings.containsKey("index")) {
      indexSettings = (Map<String, Object>) settings.get("index");
      indexName = XContentMapValues.nodeStringValue(indexSettings.get("index"), riverName.name());
      typeName = XContentMapValues.nodeStringValue(indexSettings.get("type"), INDEX_DOCUMENT_TYPE_NAME_DEFAULT);
    } else {
      indexName = riverName.name();
      typeName = INDEX_DOCUMENT_TYPE_NAME_DEFAULT;
    }

    Map<String, Object> activityLogSettings = null;
    if (settings.containsKey("activity_log")) {
      activityLogSettings = (Map<String, Object>) settings.get("activity_log");
      activityLogIndexName = Utils
          .trimToNull(XContentMapValues.nodeStringValue(activityLogSettings.get("index"), null));
      if (activityLogIndexName == null) {
        throw new SettingsException(
            "'activity_log/index' element of river configuration structure must be defined with some string");
      }
      activityLogTypeName = Utils.trimToNull(XContentMapValues.nodeStringValue(activityLogSettings.get("type"),
          INDEX_ACTIVITY_TYPE_NAME_DEFAULT));
    }
View Full Code Here

        for (Map<String, Object> ppc : preproclist) {
          try {
            indexStructureBuilder.addDataPreprocessor(StructuredContentPreprocessorFactory.createPreprocessor(ppc,
                client));
          } catch (IllegalArgumentException e) {
            throw new SettingsException(e.getMessage(), e);
          }
        }
      }
    }
  }
View Full Code Here

        if (Strings.hasText(bodySettings)) {
            try {
                updateSettings.put(ImmutableSettings.settingsBuilder().loadFromSource(bodySettings).build());
            } catch (Exception e) {
                try {
                    channel.sendResponse(new XContentThrowableRestResponse(request, BAD_REQUEST, new SettingsException("Failed to parse index settings", e)));
                } catch (IOException e1) {
                    logger.warn("Failed to send response", e1);
                }
                return;
            }
View Full Code Here

                // its plain settings, parse and set them
                try {
                    createIndexRequest.settings(request.contentAsString());
                } catch (Exception e) {
                    try {
                        channel.sendResponse(new XContentThrowableRestResponse(request, BAD_REQUEST, new SettingsException("Failed to parse index settings", e)));
                    } catch (IOException e1) {
                        logger.warn("Failed to send response", e1);
                        return;
                    }
                }
View Full Code Here

    String type = null;
    if (settings.containsKey("es_connection")) {
      Map<String, Object> sourceClientSettings = (Map<String, Object>) settings.get("es_connection");
      type = XContentMapValues.nodeStringValue(sourceClientSettings.get("type"), null);
      if (Utils.isEmpty(type)) {
        throw new SettingsException("es_connection/type element of configuration structure not found or empty");
      }
      if ("local".equalsIgnoreCase(type)) {
        sourceClient = new SourceClientESClient(client);
      } else if ("remote".equalsIgnoreCase(type)) {
        sourceClient = new SourceClientESTransportClient(sourceClientSettings);
      } else if ("rest".equalsIgnoreCase(type)) {
        sourceClient = new SourceClientREST(sourceClientSettings);
      } else {
        throw new SettingsException("es_connection/type value '" + type
            + "' is invalid. Use one of local, remote, rest");
      }
    } else {
      throw new SettingsException("'es_connection' element of river configuration structure not found");
    }

    Map<String, Map<String, Object>> indexersMap = (Map<String, Map<String, Object>>) settings.get("indexers");
    if (indexersMap != null && !indexersMap.isEmpty()) {
      for (String name : indexersMap.keySet()) {
        name = name.trim();
        if (indexers.containsKey(name)) {
          throw new SettingsException("Duplicate 'indexers/" + name + "' section");
        }
        Map<String, Object> ic = indexersMap.get(name);
        SysinfoType infoType = SysinfoType.parseConfiguration((String) ic.get("info_type"));
        String indexName = configMandatoryString(ic, "index_name", name);
        String typeName = configMandatoryString(ic, "index_type", name);
        long indexingPeriod = Utils.parseTimeValue(ic, "period", 30, TimeUnit.SECONDS);
        Map<String, String> params = (Map<String, String>) ic.get("params");
        indexers.put(name, new SysinfoIndexer(name, sourceClient, client, infoType, indexName, typeName,
            indexingPeriod, params));
      }
    } else {
      throw new SettingsException("'indexers' element of river configuration structure not found or is empty");
    }

    logger.info("Sysinfo River configured for connection type '{}' and {} indexers.", type, indexers.size());
  }
View Full Code Here

  }

  private String configMandatoryString(Map<String, Object> settings, String key, String parentName) {
    String s = (String) settings.get(key);
    if (Utils.isEmpty(s)) {
      throw new SettingsException("'indexers/" + parentName + "/" + key
          + "' river configuration element not found or is empty");
    }
    return s;
  }
View Full Code Here

   */
  public SourceClientREST(Map<String, Object> sourceClientSettings) throws SettingsException {

    restAPIUrlBase = prepareAPIURLFromBaseURL((String) sourceClientSettings.get("urlBase"));
    if (restAPIUrlBase == null) {
      throw new SettingsException("Parameter es_connection/urlBase must be set!");
    }

    URL url = null;
    try {
      url = new URL(restAPIUrlBase);
    } catch (MalformedURLException e) {
      throw new SettingsException("Parameter es_connection/urlBase is malformed: " + e.getMessage());
    }

    PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager();
    connectionManager.setDefaultMaxPerRoute(20);
    connectionManager.setMaxTotal(20);
View Full Code Here

    XContentParser parser = null;
    try {
      parser = XContentFactory.xContent(XContentType.JSON).createParser(Utils.class.getResourceAsStream(filePath));
      return parser.mapAndClose();
    } catch (IOException e) {
      throw new SettingsException(e.getMessage(), e);
    } finally {
      if (parser != null)
        parser.close();
    }
  }
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.settings.SettingsException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.