本文整理汇总了Java中org.elasticsearch.common.io.BytesStream类的典型用法代码示例。如果您正苦于以下问题:Java BytesStream类的具体用法?Java BytesStream怎么用?Java BytesStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BytesStream类属于org.elasticsearch.common.io包,在下文中一共展示了BytesStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.elasticsearch.common.io.BytesStream; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
initMocks(this);
BytesReference bytesReference = mock(BytesReference.class);
BytesStream bytesStream = mock(BytesStream.class);
when(nameBuilder.getIndexName(any(Event.class))).thenReturn("foo_index");
when(bytesReference.toBytes()).thenReturn("{\"body\":\"test\"}".getBytes());
when(bytesStream.bytes()).thenReturn(bytesReference);
when(serializer.getContentBuilder(any(Event.class)))
.thenReturn(bytesStream);
when(elasticSearchClient.prepareIndex(anyString(), anyString()))
.thenReturn(indexRequestBuilder);
when(indexRequestBuilder.setSource(bytesReference)).thenReturn(
indexRequestBuilder);
fixture = new ElasticSearchTransportClient(elasticSearchClient, serializer);
fixture.setBulkRequestBuilder(bulkRequestBuilder);
}
示例2: setUp
import org.elasticsearch.common.io.BytesStream; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
initMocks(this);
BytesReference bytesReference = mock(BytesReference.class);
BytesStream bytesStream = mock(BytesStream.class);
when(nameBuilder.getIndexName(any(Event.class))).thenReturn("foo_index");
//when(bytesReference.toBytes()).thenReturn("{\"body\":\"test\"}".getBytes());
when(bytesStream.bytes()).thenReturn(bytesReference);
when(serializer.getContentBuilder(any(Event.class)))
.thenReturn(bytesStream);
when(elasticSearchClient.prepareIndex(anyString(), anyString()))
.thenReturn(indexRequestBuilder);
when(indexRequestBuilder.setSource(bytesReference)).thenReturn(
indexRequestBuilder);
fixture = new ElasticSearchTransportClient(elasticSearchClient, serializer);
fixture.setBulkRequestBuilder(bulkRequestBuilder);
}
示例3: setUp
import org.elasticsearch.common.io.BytesStream; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
initMocks(this);
BytesReference bytesReference = mock(BytesReference.class);
BytesStream bytesStream = mock(BytesStream.class);
when(nameBuilder.getIndexName(any(Event.class))).thenReturn(INDEX_NAME);
when(bytesReference.toBytesArray()).thenReturn(new BytesArray(MESSAGE_CONTENT));
when(bytesStream.bytes()).thenReturn(bytesReference);
serializer = new ExtendedElasticSearchLogStashEventSerializer();
Map<String, String> headers = Maps.newHashMap();
String message = "body";
event = EventBuilder.withBody(message.getBytes(charset));
event.setHeaders(headers);
fixture = new ElasticSearchRestClient(HOSTS, serializer, httpClient);
}
示例4: prepareIndexRequest
import org.elasticsearch.common.io.BytesStream; //导入依赖的package包/类
@Override
protected void prepareIndexRequest(IndexRequestBuilder indexRequest,
String indexName, String indexType, Event event) throws IOException {
BytesStream contentBuilder = serializer.getContentBuilder(event);
indexRequest.setIndex(indexName)
.setType(indexType)
.setSource(contentBuilder.bytes());
}
示例5: setUp
import org.elasticsearch.common.io.BytesStream; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
initMocks(this);
BytesReference bytesReference = mock(BytesReference.class);
BytesStream bytesStream = mock(BytesStream.class);
when(nameBuilder.getIndexName(any(Event.class))).thenReturn(INDEX_NAME);
when(bytesReference.toBytesArray()).thenReturn(new BytesArray(MESSAGE_CONTENT));
when(bytesStream.bytes()).thenReturn(bytesReference);
when(serializer.getContentBuilder(any(Event.class))).thenReturn(bytesStream);
fixture = new ElasticSearchRestClient(HOSTS, serializer, httpClient);
}
示例6: setUp
import org.elasticsearch.common.io.BytesStream; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
initMocks(this);
BytesReference bytesReference = mock(BytesReference.class);
BytesStream bytesStream = mock(BytesStream.class);
when(nameBuilder.getIndexName(any(Event.class))).thenReturn(INDEX_NAME);
//when(bytesReference.toBytesArray()).thenReturn(new BytesArray(MESSAGE_CONTENT));
when(bytesStream.bytes()).thenReturn(bytesReference);
when(serializer.getContentBuilder(any(Event.class))).thenReturn(bytesStream);
fixture = new ElasticSearchRestClient(HOSTS, serializer, httpClient);
}
示例7: setUp
import org.elasticsearch.common.io.BytesStream; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
initMocks(this);
BytesStream bytesStream = mock(BytesStream.class);
when(elasticSearchClient.prepareIndex(anyString(), anyString()))
.thenReturn(indexRequestBuilder);
when(indexRequestBuilder.setSource(document)).thenReturn(indexRequestBuilder);
fixture = new TransportDocumentLoader(elasticSearchClient);
fixture.setBulkRequestBuilder(bulkRequestBuilder);
}
示例8: prepareIndexRequest
import org.elasticsearch.common.io.BytesStream; //导入依赖的package包/类
@Override
protected void prepareIndexRequest(IndexRequestBuilder indexRequest, String indexName, String indexType, Event event) throws IOException {
BytesStream contentBuilder = serializer.getContentBuilder(event);
BytesReference contentBytes = contentBuilder.bytes();
indexRequest.setIndex(indexName).setType(indexType).setSource(contentBytes);
String hashId = docIdBuilder.getDocumentId(contentBytes);
if (null != hashId && !hashId.isEmpty())
indexRequest.setId(hashId.toString());
}
开发者ID:gigya,项目名称:flume-ng-elasticsearch-ser-ex,代码行数:10,代码来源:ExtendedElasticSearchIndexRequestBuilderFactory.java
示例9: getContentBuilder
import org.elasticsearch.common.io.BytesStream; //导入依赖的package包/类
@Override
public BytesStream getContentBuilder(final Event event) throws IOException {
final XContentBuilder builder = jsonBuilder().startObject();
appendBody(builder, event);
appendHeaders(builder, event);
return builder;
}
开发者ID:jaibeermalik,项目名称:searchanalytics-bigdata,代码行数:8,代码来源:ElasticSearchJsonBodyEventSerializer.java
示例10: prepareIndexRequest
import org.elasticsearch.common.io.BytesStream; //导入依赖的package包/类
@Override
protected void prepareIndexRequest(IndexRequestBuilder indexRequest, String indexName, String indexType, Event event)
throws IOException {
BytesStream contentBuilder = serializer.getContentBuilder(event);
indexRequest.setIndex(indexName).setType(indexType).setSource(contentBuilder.bytes());
setId(indexRequest, event);
}
开发者ID:DevOps-TangoMe,项目名称:flume-elasticsearch,代码行数:8,代码来源:LogstashEventSerializerIndexRequestBuilderFactory.java
示例11: bytes
import org.elasticsearch.common.io.BytesStream; //导入依赖的package包/类
@Override
public BytesReference bytes() {
close();
return ((BytesStream) bos).bytes();
}
示例12: getContentBuilder
import org.elasticsearch.common.io.BytesStream; //导入依赖的package包/类
@Override
public BytesStream getContentBuilder(Event event) throws IOException {
BytesStreamOutput fbaos = new BytesStreamOutput(4);
fbaos.write(FAKE_BYTES);
return fbaos;
}
示例13: bytesStream
import org.elasticsearch.common.io.BytesStream; //导入依赖的package包/类
/**
* Returns the actual stream used.
*/
public BytesStream bytesStream() throws IOException {
close();
return (BytesStream) bos;
}
示例14: getContentBuilder
import org.elasticsearch.common.io.BytesStream; //导入依赖的package包/类
@Override
public BytesStream getContentBuilder(Event event) throws IOException {
return getXContentBuilder(event);
}
开发者ID:gigya,项目名称:flume-ng-elasticsearch-ser-ex,代码行数:5,代码来源:ExtendedElasticSearchLogStashEventSerializer.java
示例15: getContentBuilder
import org.elasticsearch.common.io.BytesStream; //导入依赖的package包/类
@Override
public BytesStream getContentBuilder(Event event) throws IOException {
FastByteArrayOutputStream fbaos = new FastByteArrayOutputStream(4);
fbaos.write(FAKE_BYTES);
return fbaos;
}