Examples of BytesArray


Examples of org.elasticsearch.common.bytes.BytesArray

            }

            modifiedContent += "]}}," + postReqContent;
            log.debug("modified request content = " + modifiedContent);
                       
            request.setContent(new BytesArray(modifiedContent));
            request.setAttribute(TomcatHttpServerRestRequest.REQUEST_CONTENT_ATTRIBUTE, request.getContent());

          }
        }
      }
View Full Code Here

Examples of org.elasticsearch.common.bytes.BytesArray

    }

    @Override
    public BytesArray toBytesArray() {
        if (buffer.hasArray()) {
            return new BytesArray(buffer.array(), buffer.arrayOffset() + buffer.readerIndex(), buffer.readableBytes());
        }
        return copyBytesArray();
    }
View Full Code Here

Examples of org.elasticsearch.common.bytes.BytesArray

    @Override
    public BytesArray copyBytesArray() {
        byte[] copy = new byte[buffer.readableBytes()];
        buffer.getBytes(buffer.readerIndex(), copy);
        return new BytesArray(copy);
    }
View Full Code Here

Examples of org.elasticsearch.common.bytes.BytesArray

                String cmd = args[0];
                if ("get".equals(cmd)) {
                    request = new MemcachedRestRequest(RestRequest.Method.GET, args[1], null, -1, false);
                    if (args.length > 3) {
                        BytesRef bytesRef = new BytesRef(args[2]);
                        request.setData(new BytesArray(bytesRef));
                    }
                    return request;
                } else if ("delete".equals(cmd)) {
                    request = new MemcachedRestRequest(RestRequest.Method.DELETE, args[1], null, -1, false);
                    //                if (args.length > 3) {
View Full Code Here

Examples of org.elasticsearch.common.bytes.BytesArray

        if (request.getQueryString() != null) {
            RestUtils.decodeQueryString(request.getQueryString(), 0, params);
        }

        content = new BytesArray(Streams.copyToByteArray(request.getInputStream()));
        request.setAttribute(REQUEST_CONTENT_ATTRIBUTE, content);
    }
View Full Code Here

Examples of org.elasticsearch.common.bytes.BytesArray

public class SQLBulkArgsParseElementTest {

    private Object[][] parse(String bulk_args) throws Exception {
        SQLXContentSourceContext context = new SQLXContentSourceContext();
        String json = "{\"bulk_args\":" + bulk_args + "}";
        BytesArray bytes = new BytesArray(json);
        XContentParser parser = XContentFactory.xContent(bytes).createParser(bytes);
        parser.nextToken();
        parser.nextToken();
        parser.nextToken();
        SQLBulkArgsParseElement bulkArgsParseElement = new SQLBulkArgsParseElement();
View Full Code Here

Examples of org.elasticsearch.common.bytes.BytesArray

        byte[] buffer = new byte[32];
        random.nextBytes(buffer);
        return XContentFactory.jsonBuilder()
                .startObject()
                .field("areaInSqKm", random.nextFloat())
                .field("continent", new BytesArray(buffer, 0, 4).toUtf8())
                .field("countryCode", new BytesArray(buffer, 4, 8).toUtf8())
                .field("countryName", new BytesArray(buffer, 8, 24).toUtf8())
                .field("population", random.nextInt(Integer.MAX_VALUE))
                .endObject()
                .bytes().toBytes();
    }
View Full Code Here

Examples of org.elasticsearch.common.bytes.BytesArray

                mock(TransportCreateIndexAction.class),
                false,
                false,
                1
        );
        bulkShardProcessor.add("foo", new BytesArray("{\"foo\": \"bar1\"}"), "1", null);

        verify(transportShardBulkAction).execute(
                any(BulkShardRequest.class),
                bulkShardResponseListener.capture());
        ActionListener<BulkShardResponse> listener = bulkShardResponseListener.getValue();
        listener.onFailure(new RuntimeException("a random exception"));

        assertFalse(bulkShardProcessor.add("foo", new BytesArray("{\"foo\": \"bar2\"}"), "2", null));

        try {
            bulkShardProcessor.result().get();
        } catch (ExecutionException e) {
            throw e.getCause();
View Full Code Here

Examples of org.elasticsearch.common.bytes.BytesArray

                false,
                false,
                1
        );

        bulkShardProcessor.add("foo", new BytesArray("{\"foo\": \"bar1\"}"), "1", null);
        verify(transportShardBulkAction).execute(
                any(BulkShardRequest.class),
                bulkShardResponseListener.capture());

        final ActionListener<BulkShardResponse> listener = bulkShardResponseListener.getValue();

        listener.onFailure(new EsRejectedExecutionException());
        // wait, failure retry lock is done in decoupled thread
        Thread.sleep(1);

        final ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(2);
        final AtomicBoolean hadBlocked = new AtomicBoolean(false);
        final AtomicBoolean hasBlocked = new AtomicBoolean(true);
        final CountDownLatch latch = new CountDownLatch(1);
        scheduledExecutorService.execute(new Runnable() {
            @Override
            public void run() {
                scheduledExecutorService.schedule(new Runnable() {
                    @Override
                    public void run() {
                        hadBlocked.set(hasBlocked.get());
                        latch.countDown();
                    }
                }, 10, TimeUnit.MILLISECONDS);
                bulkShardProcessor.add("foo", new BytesArray("{\"foo\": \"bar2\"}"), "2", null);
                hasBlocked.set(false);
            }
        });
        latch.await();
        assertTrue(hadBlocked.get());
View Full Code Here

Examples of org.elasticsearch.common.bytes.BytesArray

    protected String restSQLExecute(String source, boolean includeTypes) throws IOException {
        XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
        builder.generator().usePrettyPrint();
        SQLXContentSourceContext context = new SQLXContentSourceContext();
        SQLXContentSourceParser parser = new SQLXContentSourceParser(context);
        parser.parseSource(new BytesArray(source));

        SQLBaseResponse sqlResponse;
        Object[][] bulkArgs = context.bulkArgs();
        if (bulkArgs != null && bulkArgs.length > 0) {
            SQLBulkRequestBuilder requestBuilder = new SQLBulkRequestBuilder(client());
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.