Package org.elasticsearch

Examples of org.elasticsearch.ElasticSearchIllegalArgumentException


        if (text == null && request.hasContent()) {
            text = request.contentAsString();
        }
        if (text == null) {
            try {
                channel.sendResponse(new XContentThrowableRestResponse(request, new ElasticSearchIllegalArgumentException("text is missing")));
            } catch (IOException e1) {
                logger.warn("Failed to send response", e1);
            }
            return;
        }
View Full Code Here


            indicesAliasesRequest.timeout(request.paramAsTime("timeout", timeValueSeconds(10)));
            XContentParser parser = XContentFactory.xContent(request.contentByteArray(), request.contentByteArrayOffset(), request.contentLength())
                    .createParser(request.contentByteArray(), request.contentByteArrayOffset(), request.contentLength());
            XContentParser.Token token = parser.nextToken();
            if (token == null) {
                throw new ElasticSearchIllegalArgumentException("No action is specified");
            }
            while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
                if (token == XContentParser.Token.START_ARRAY) {
                    while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
                        if (token == XContentParser.Token.FIELD_NAME) {
                            String action = parser.currentName();
                            AliasAction.Type type;
                            if ("add".equals(action)) {
                                type = AliasAction.Type.ADD;
                            } else if ("remove".equals(action)) {
                                type = AliasAction.Type.REMOVE;
                            } else {
                                throw new ElasticSearchIllegalArgumentException("Alias action [" + action + "] not supported");
                            }
                            String index = null;
                            String alias = null;
                            Map<String, Object> filter = null;
                            String routing = null;
                            boolean routingSet = false;
                            String indexRouting = null;
                            boolean indexRoutingSet = false;
                            String searchRouting = null;
                            boolean searchRoutingSet = false;
                            String currentFieldName = null;
                            while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
                                if (token == XContentParser.Token.FIELD_NAME) {
                                    currentFieldName = parser.currentName();
                                } else if (token == XContentParser.Token.VALUE_STRING) {
                                    if ("index".equals(currentFieldName)) {
                                        index = parser.text();
                                    } else if ("alias".equals(currentFieldName)) {
                                        alias = parser.text();
                                    } else if ("routing".equals(currentFieldName)) {
                                        routing = parser.textOrNull();
                                        routingSet = true;
                                    } else if ("indexRouting".equals(currentFieldName) || "index-routing".equals(currentFieldName) || "index_routing".equals(currentFieldName)) {
                                        indexRouting = parser.textOrNull();
                                        indexRoutingSet = true;
                                    } else if ("searchRouting".equals(currentFieldName) || "search-routing".equals(currentFieldName) || "search_routing".equals(currentFieldName)) {
                                        searchRouting = parser.textOrNull();
                                        searchRoutingSet = true;
                                    }
                                } else if (token == XContentParser.Token.START_OBJECT) {
                                    if ("filter".equals(currentFieldName)) {
                                        filter = parser.mapOrdered();
                                    }
                                }
                            }
                            if (index == null) {
                                throw new ElasticSearchIllegalArgumentException("Alias action [" + action + "] requires an [index] to be set");
                            }
                            if (alias == null) {
                                throw new ElasticSearchIllegalArgumentException("Alias action [" + action + "] requires an [alias] to be set");
                            }
                            if (type == AliasAction.Type.ADD) {
                                AliasAction aliasAction = newAddAliasAction(index, alias).filter(filter);
                                if (routingSet) {
                                    aliasAction.routing(routing);
View Full Code Here

            if (source.containsKey("order")) {
                putRequest.order(XContentMapValues.nodeIntegerValue(source.get("order"), putRequest.order()));
            }
            if (source.containsKey("settings")) {
                if (!(source.get("settings") instanceof Map)) {
                    throw new ElasticSearchIllegalArgumentException("Malformed settings section, should include an inner object");
                }
                putRequest.settings((Map<String, Object>) source.get("settings"));
            }
            if (source.containsKey("mappings")) {
                Map<String, Object> mappings = (Map<String, Object>) source.get("mappings");
                for (Map.Entry<String, Object> entry : mappings.entrySet()) {
                    if (!(entry.getValue() instanceof Map)) {
                        throw new ElasticSearchIllegalArgumentException("Malformed mappings section for type [" + entry.getKey() + "], should include an inner object describing the mapping");
                    }
                    putRequest.mapping(entry.getKey(), (Map<String, Object>) entry.getValue());
                }
            }
        } catch (Exception e) {
View Full Code Here

        if ("http".equals(protocol)) {
            clientConfiguration.setProtocol(Protocol.HTTP);
        } else if ("https".equals(protocol)) {
            clientConfiguration.setProtocol(Protocol.HTTPS);
        } else {
            throw new ElasticSearchIllegalArgumentException("No protocol supported [" + protocol + "], can either be [http] or [https]");
        }
        String account = componentSettings.get("access_key", settings.get("cloud.account"));
        String key = componentSettings.get("secret_key", settings.get("cloud.key"));

        if (account == null) {
            throw new ElasticSearchIllegalArgumentException("No s3 access_key defined for s3 gateway");
        }
        if (key == null) {
            throw new ElasticSearchIllegalArgumentException("No s3 secret_key defined for s3 gateway");
        }

        String proxyHost = componentSettings.get("proxy_host");
        if (proxyHost != null) {
            String portString = componentSettings.get("proxy_port", "80");
            Integer proxyPort;
            try {
                proxyPort = Integer.parseInt(portString, 10);
            } catch (NumberFormatException ex) {
                throw new ElasticSearchIllegalArgumentException("The configured proxy port value [" + portString + "] is invalid", ex);
            }
            clientConfiguration.withProxyHost(proxyHost).setProxyPort(proxyPort);
        }

        this.client = new AmazonEC2Client(new BasicAWSCredentials(account, key), clientConfiguration);

        if (componentSettings.get("ec2.endpoint") != null) {
            client.setEndpoint(componentSettings.get("ec2.endpoint"));
        } else if (componentSettings.get("region") != null) {
            String endpoint;
            String region = componentSettings.get("region");
            if ("us-east".equals(region.toLowerCase())) {
                endpoint = "ec2.us-east-1.amazonaws.com";
            } else if ("us-east-1".equals(region.toLowerCase())) {
                endpoint = "ec2.us-east-1.amazonaws.com";
            } else if ("us-west".equals(region.toLowerCase())) {
                endpoint = "ec2.us-west-1.amazonaws.com";
            } else if ("us-west-1".equals(region.toLowerCase())) {
                endpoint = "ec2.us-west-1.amazonaws.com";
            } else if ("ap-southeast".equals(region.toLowerCase())) {
                endpoint = "ec2.ap-southeast-1.amazonaws.com";
            } else if ("ap-southeast-1".equals(region.toLowerCase())) {
                endpoint = "ec2.ap-southeast-1.amazonaws.com";
            } else if ("eu-west".equals(region.toLowerCase())) {
                endpoint = "ec2.eu-west-1.amazonaws.com";
            } else if ("eu-west-1".equals(region.toLowerCase())) {
                endpoint = "ec2.eu-west-1.amazonaws.com";
            } else {
                throw new ElasticSearchIllegalArgumentException("No automatic endpoint could be derived from region [" + region + "]");
            }
            if (endpoint != null) {
                client.setEndpoint(endpoint);
            }
        }
View Full Code Here

        super(settings, threadPool, clusterService);

        this.closeFileSystem = componentSettings.getAsBoolean("close_fs", true);
        String uri = componentSettings.get("uri");
        if (uri == null) {
            throw new ElasticSearchIllegalArgumentException("hdfs gateway requires the 'uri' setting to be set");
        }
        String path = componentSettings.get("path");
        if (path == null) {
            throw new ElasticSearchIllegalArgumentException("hdfs gateway requires the 'path' path setting to be set");
        }
        Path hPath = new Path(new Path(path), clusterName.value());

        int concurrentStreams = componentSettings.getAsInt("concurrent_streams", 5);
        this.concurrentStreamPool = DynamicExecutors.newScalingThreadPool(1, concurrentStreams, TimeValue.timeValueSeconds(5).millis(), EsExecutors.daemonThreadFactory(settings, "[s3_stream]"));
View Full Code Here

        if ("http".equals(protocol)) {
            clientConfiguration.setProtocol(Protocol.HTTP);
        } else if ("https".equals(protocol)) {
            clientConfiguration.setProtocol(Protocol.HTTPS);
        } else {
            throw new ElasticSearchIllegalArgumentException("No protocol supported [" + protocol + "], can either be [http] or [https]");
        }
        String account = componentSettings.get("access_key", settings.get("cloud.account"));
        String key = componentSettings.get("secret_key", settings.get("cloud.key"));

        if (account == null) {
            throw new ElasticSearchIllegalArgumentException("No s3 access_key defined for s3 gateway");
        }
        if (key == null) {
            throw new ElasticSearchIllegalArgumentException("No s3 secret_key defined for s3 gateway");
        }

        String proxyHost = componentSettings.get("proxy_host");
        if (proxyHost != null) {
            String portString = componentSettings.get("proxy_port", "80");
            Integer proxyPort;
            try {
                proxyPort = Integer.parseInt(portString, 10);
            } catch (NumberFormatException ex) {
                throw new ElasticSearchIllegalArgumentException("The configured proxy port value [" + portString + "] is invalid", ex);
            }
            clientConfiguration.withProxyHost(proxyHost).setProxyPort(proxyPort);
        }

        this.client = new AmazonS3Client(new BasicAWSCredentials(account, key), clientConfiguration);

        if (componentSettings.get("s3.endpoint") != null) {
            client.setEndpoint(componentSettings.get("s3.endpoint"));
        } else if (componentSettings.get("region") != null) {
            String endpoint;
            String region = componentSettings.get("region");
            if ("us-east".equals(region.toLowerCase())) {
                endpoint = "s3.amazonaws.com";
            } else if ("us-east-1".equals(region.toLowerCase())) {
                endpoint = "s3.amazonaws.com";
            } else if ("us-west".equals(region.toLowerCase())) {
                endpoint = "s3-us-west-1.amazonaws.com";
            } else if ("us-west-1".equals(region.toLowerCase())) {
                endpoint = "s3-us-west-1.amazonaws.com";
            } else if ("ap-southeast".equals(region.toLowerCase())) {
                endpoint = "s3-ap-southeast-1.amazonaws.com";
            } else if ("ap-southeast-1".equals(region.toLowerCase())) {
                endpoint = "s3-ap-southeast-1.amazonaws.com";
            } else if ("eu-west".equals(region.toLowerCase())) {
                endpoint = null; // no specific endpoint for EU (still can be used for region)
            } else if ("eu-west-1".equals(region.toLowerCase())) {
                endpoint = null; // no specific endpoint for EU (still can be used for region)
            } else {
                throw new ElasticSearchIllegalArgumentException("No automatic endpoint could be derived from region [" + region + "]");
            }
            if (endpoint != null) {
                client.setEndpoint(endpoint);
            }
        }
View Full Code Here

    @Override public Object compile(String script) {
        NativeScriptFactory scriptFactory = scripts.get(script);
        if (scriptFactory != null) {
            return scriptFactory;
        }
        throw new ElasticSearchIllegalArgumentException("Native script [" + script + "] not found");
    }
View Full Code Here

            return compiled;
        }
        // not the end of the world if we compile it twice...
        ScriptEngineService service = scriptEngines.get(lang);
        if (service == null) {
            throw new ElasticSearchIllegalArgumentException("script_lang not supported [" + lang + "]");
        }
        compiled = new CompiledScript(lang, service.compile(script));
        cache.put(cacheKey, compiled);
        return compiled;
    }
View Full Code Here

        Map<String, Settings> nativeSettings = settings.getGroups("script.native");
        for (Map.Entry<String, Settings> entry : nativeSettings.entrySet()) {
            String name = entry.getKey();
            Class<? extends NativeScriptFactory> type = entry.getValue().getAsClass("type", NativeScriptFactory.class);
            if (type == NativeScriptFactory.class) {
                throw new ElasticSearchIllegalArgumentException("type is missing for native script [" + name + "]");
            }
            scriptsBinder.addBinding(name).to(type);
        }

        Multibinder<ScriptEngineService> multibinder = Multibinder.newSetBinder(binder(), ScriptEngineService.class);
View Full Code Here

    private FieldLookup loadFieldData(String name) {
        FieldLookup data = cachedFieldData.get(name);
        if (data == null) {
            FieldMapper mapper = mapperService.smartNameFieldMapper(name);
            if (mapper == null) {
                throw new ElasticSearchIllegalArgumentException("No field found for [" + name + "]");
            }
            data = new FieldLookup(mapper);
            cachedFieldData.put(name, data);
        }
        if (data.doc() == null) {
View Full Code Here

TOP

Related Classes of org.elasticsearch.ElasticSearchIllegalArgumentException

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.