Examples of BytesArray


Examples of org.elasticsearch.hadoop.util.BytesArray

        }
    }

    public static void putMapping(String index, byte[] content) throws Exception {
        RestClient rc = new ExtendedRestClient();
        BytesArray bs = new BytesArray(content);
        rc.putMapping(index, index + "/_mapping", bs.bytes());
        rc.close();
    }
View Full Code Here

Examples of org.elasticsearch.hadoop.util.BytesArray

    public void testEmptyBulkWrite() throws Exception {
        TestSettings testSettings = new TestSettings("rest/emptybulk");
        testSettings.setProperty(ConfigurationOptions.ES_SERIALIZATION_WRITER_VALUE_CLASS, JdkValueWriter.class.getName());
        RestRepository restRepo = new RestRepository(testSettings);
        RestClient client = restRepo.getRestClient();
        client.bulk(new Resource(testSettings, false), new TrackingBytesArray(new BytesArray("{}")));
        restRepo.waitForYellow();
        restRepo.close();
        client.close();
    }
View Full Code Here

Examples of org.elasticsearch.hadoop.util.BytesArray

        public String get(String index) throws IOException {
            return IOUtils.asString(execute(Request.Method.GET, index));
        }

        public String post(String index, byte[] buffer) throws IOException {
            return IOUtils.asString(execute(Request.Method.POST, index, new BytesArray(buffer)).body());
        }
View Full Code Here

Examples of org.elasticsearch.hadoop.util.BytesArray

        public String post(String index, byte[] buffer) throws IOException {
            return IOUtils.asString(execute(Request.Method.POST, index, new BytesArray(buffer)).body());
        }

        public String put(String index, byte[] buffer) throws IOException {
            return IOUtils.asString(execute(PUT, index, new BytesArray(buffer)).body());
        }
View Full Code Here

Examples of org.elasticsearch.hadoop.util.BytesArray

    }


    @Test
    public void testInvalidRequest() throws Exception {
        BytesArray be = new BytesArray("{\"index\":{\"_index\":\"mroldapi\",\"_type\":\"pattern-format-2179-10-06-with-id\"\"_id\":\"185\"}}" +
"{\"url\":\"http://www.last.fm/music/Reamonn\",\"@timestamp\":\"2179-10-06T19:20:25.000Z\",\"name\":\"Reamonn\",\"number\":\"185\",\"picture\":\"http://userserve-ak.last.fm/serve/252/45094837.png\"}");

        String error = "JsonParseException[Unexpected character ('\"' (code 34)): was expecting comma to separate OBJECT entries at [Source: [B@6e26dd20; line: 1, column: 75]]";

        assertEquals("0-06-with-id\"\"_id\":\"", ErrorUtils.extractJsonParse(error, be));
View Full Code Here

Examples of org.elasticsearch.hadoop.util.BytesArray

                    log.warn(String.format("No mapping found [%s] and no schema found; letting Elasticsearch perform auto-mapping...",  settings.getResourceWrite()));
                }
                else {
                    log.info(String.format("No mapping found [%s], creating one based on given schema", settings.getResourceWrite()));
                    ContentBuilder builder = ContentBuilder.generate(schemaWriter).value(schema).flush();
                    BytesArray content = ((FastByteArrayOutputStream) builder.content()).bytes();
                    builder.close();
                    client.putMapping(content);
                    if (log.isDebugEnabled()) {
                        log.debug(String.format("Creating ES mapping [%s] from schema [%s]", content.toString(), schema));
                    }
                }
            }
            client.close();
        }
View Full Code Here

Examples of org.elasticsearch.hadoop.util.BytesArray

        // NB: dynamically get the stats since the transport can change
        long start = network.transportStats().netTotalTime;
        try {
            // use post instead of get to avoid some weird encoding issues (caused by the long URL)
            InputStream is = execute(POST, "_search/scroll?scroll=" + scrollKeepAlive.toString(),
                    new BytesArray(scrollId.getBytes(StringUtils.UTF_8))).body();
            stats.scrollTotal++;
            return is;
        } finally {
            stats.scrollTotalTime += network.transportStats().netTotalTime - start;
        }
View Full Code Here

Examples of org.elasticsearch.hadoop.util.BytesArray

    public void putMapping(String index, String mapping, byte[] bytes) {
        // create index first (if needed) - it might return 403
        touch(index);

        execute(PUT, mapping, new BytesArray(bytes));
    }
View Full Code Here

Examples of org.elasticsearch.hadoop.util.BytesArray

        if (query.startsWith("?")) {
            uriQuery.putAll(initUriQuery(query));
        }
        else if (query.startsWith("{")) {
            // TODO: add early, basic JSON validation
            bodyQuery = new BytesArray(query);
        }
        else {
            try {
                // must be a resource
                InputStream in = settings.loadResource(query);
                // peek the stream
                int first = in.read();
                if (Integer.valueOf('?').equals(first)) {
                    uriQuery.putAll(initUriQuery(IOUtils.asString(in)));
                }
                else {
                    bodyQuery = new BytesArray(1024);
                    bodyQuery.add(first);
                    IOUtils.asBytes(bodyQuery, in);
                }
            } catch (IOException ex) {
                throw new EsHadoopIllegalArgumentException(String.format("Cannot determine specified query - doesn't appear to be URI or JSON based and location [%s] cannot be opened", query));
View Full Code Here

Examples of org.elasticsearch.hadoop.util.BytesArray

    public List<Object[]> read(InputStream content) throws IOException {
        Assert.notNull(content);

        if (log.isTraceEnabled()) {
            //copy content
            BytesArray copy = IOUtils.asBytes(content);
            content = new FastByteArrayInputStream(copy);
            log.trace("About to parse scroll content " + copy);
        }

        this.parser = new JacksonJsonParser(content);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.