org.elasticsearch.action.ListenableActionFuture Java Examples
The following examples show how to use
org.elasticsearch.action.ListenableActionFuture.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TermsByQueryBenchmark.java From siren-join with GNU Affero General Public License v3.0 | 6 votes |
public void warmFieldData(String parentField, String childField) { ListenableActionFuture<SearchResponse> parentSearch = null; ListenableActionFuture<SearchResponse> childSearch = null; if (parentField != null) { parentSearch = client .prepareSearch(PARENT_INDEX) .setQuery(matchAllQuery()).addAggregation(terms("parentfield").field(parentField)).execute(); } if (childField != null) { childSearch = client .prepareSearch(CHILD_INDEX) .setQuery(matchAllQuery()).addAggregation(terms("childfield").field(childField)).execute(); } if (parentSearch != null) parentSearch.actionGet(); if (childSearch != null) childSearch.actionGet(); }
Example #2
Source File: FilterJoinBenchmark.java From siren-join with GNU Affero General Public License v3.0 | 6 votes |
public void warmFieldData(String parentField, String childField) { ListenableActionFuture<SearchResponse> parentSearch = null; ListenableActionFuture<SearchResponse> childSearch = null; if (parentField != null) { parentSearch = client .prepareSearch(PARENT_INDEX) .setQuery(matchAllQuery()).addAggregation(terms("parentfield").field(parentField)).execute(); } if (childField != null) { childSearch = client .prepareSearch(CHILD_INDEX) .setQuery(matchAllQuery()).addAggregation(terms("childfield").field(childField)).execute(); } if (parentSearch != null) parentSearch.actionGet(); if (childSearch != null) childSearch.actionGet(); }
Example #3
Source File: ElasticsearchEmitterTest.java From amazon-kinesis-connectors with Apache License 2.0 | 6 votes |
@Before public void setUp() { // object under test Properties props = new Properties(); AWSCredentialsProvider creds = createMock(AWSCredentialsProvider.class); configuration = new KinesisConnectorConfiguration(props, creds); emitter = new ElasticsearchEmitter(configuration); buffer = createMock(UnmodifiableBuffer.class); mockBulkBuilder = createMock(BulkRequestBuilder.class); mockIndexBuilder = createMock(IndexRequestBuilder.class); mockFuture = createMock(ListenableActionFuture.class); mockBulkResponse = createMock(BulkResponse.class); // overwrite the elasticseach client with a mock elasticsearchClientMock = createMock(TransportClient.class); setField(emitter, "elasticsearchClient", elasticsearchClientMock); // overwrite the default backoff time with 0 seconds to speed up tests setField(emitter, "BACKOFF_PERIOD", 0); }
Example #4
Source File: SQLTransportExecutor.java From crate with Apache License 2.0 | 5 votes |
public static ListenableActionFuture<SQLResponse> execute(String stmt, @Nullable Object[] args, Session session) { PlainListenableActionFuture<SQLResponse> actionFuture = PlainListenableActionFuture.newListenableFuture(); execute(stmt, args, actionFuture, session); return actionFuture; }
Example #5
Source File: TestElasticSearchTransportClient.java From ingestion with Apache License 2.0 | 5 votes |
@Test(expected = EventDeliveryException.class) public void shouldThrowExceptionOnExecuteFailed() throws Exception { ListenableActionFuture<BulkResponse> action = (ListenableActionFuture<BulkResponse>) mock(ListenableActionFuture.class); BulkResponse response = mock(BulkResponse.class); when(bulkRequestBuilder.execute()).thenReturn(action); when(action.actionGet()).thenReturn(response); when(response.hasFailures()).thenReturn(true); fixture.addEvent(event, nameBuilder, "bar_type", 10); fixture.execute(); }
Example #6
Source File: TestElasticSearchTransportClient.java From ingestion with Apache License 2.0 | 5 votes |
@Test public void shouldExecuteBulkRequestBuilder() throws Exception { ListenableActionFuture<BulkResponse> action = (ListenableActionFuture<BulkResponse>) mock(ListenableActionFuture.class); BulkResponse response = mock(BulkResponse.class); when(bulkRequestBuilder.execute()).thenReturn(action); when(action.actionGet()).thenReturn(response); when(response.hasFailures()).thenReturn(false); fixture.addEvent(event, nameBuilder, "bar_type", 10); fixture.execute(); verify(bulkRequestBuilder).execute(); }
Example #7
Source File: InternalEsClient.java From io with Apache License 2.0 | 5 votes |
/** * Mapping定義を更新する. * @param index インデックス名 * @param type タイプ名 * @param mappings マッピング情報 * @return 非同期応答 */ public ListenableActionFuture<PutMappingResponse> putMapping(String index, String type, Map<String, Object> mappings) { PutMappingRequestBuilder builder = new PutMappingRequestBuilder(esTransportClient.admin().indices()) .setIndices(index) .setType(type) .setSource(mappings); return builder.execute(); }
Example #8
Source File: InternalEsClient.java From io with Apache License 2.0 | 5 votes |
/** * Mapping定義を更新する. * @param index インデックス名 * @param type タイプ名 * @param mappings マッピング情報 * @return 非同期応答 */ public ListenableActionFuture<PutMappingResponse> putMapping(String index, String type, Map<String, Object> mappings) { PutMappingRequestBuilder builder = new PutMappingRequestBuilder(esTransportClient.admin().indices(), PutMappingAction.INSTANCE) .setIndices(index) .setType(type) .setSource(mappings); return builder.execute(); }
Example #9
Source File: EsRetryTest.java From io with Apache License 2.0 | 4 votes |
@Override public ListenableActionFuture<PutMappingResponse> putMapping(String index, String type, Map<String, Object> mappings) { throwException(); return super.putMapping(index, type, mappings); }
Example #10
Source File: EsRetryTest.java From io with Apache License 2.0 | 4 votes |
@Override public ListenableActionFuture<PutMappingResponse> putMapping(String index, String type, Map<String, Object> mappings) { throwException(); return super.putMapping(index, type, mappings); }
Example #11
Source File: EsRetryTest.java From io with Apache License 2.0 | 4 votes |
@Override public ListenableActionFuture<PutMappingResponse> putMapping(String index, String type, Map<String, Object> mappings) { throwException(); return super.putMapping(index, type, mappings); }
Example #12
Source File: EsRetryTest.java From io with Apache License 2.0 | 4 votes |
@Override public ListenableActionFuture<PutMappingResponse> putMapping(String index, String type, Map<String, Object> mappings) { throwException(); return super.putMapping(index, type, mappings); }
Example #13
Source File: EsRetryTest.java From io with Apache License 2.0 | 4 votes |
@Override public ListenableActionFuture<PutMappingResponse> putMapping(String index, String type, Map<String, Object> mappings) { throwException(); return super.putMapping(index, type, mappings); }
Example #14
Source File: EsRetryTest.java From io with Apache License 2.0 | 4 votes |
@Override public ListenableActionFuture<PutMappingResponse> putMapping(String index, String type, Map<String, Object> mappings) { throwException(); return super.putMapping(index, type, mappings); }
Example #15
Source File: EsRetryTest.java From io with Apache License 2.0 | 4 votes |
@Override public ListenableActionFuture<PutMappingResponse> putMapping(String index, String type, Map<String, Object> mappings) { throwException(); return super.putMapping(index, type, mappings); }
Example #16
Source File: EsRetryTest.java From io with Apache License 2.0 | 4 votes |
@Override public ListenableActionFuture<PutMappingResponse> putMapping(String index, String type, Map<String, Object> mappings) { throwException(); return super.putMapping(index, type, mappings); }
Example #17
Source File: ElasticsearchEmitterTest.java From amazon-kinesis-connectors with Apache License 2.0 | 4 votes |
/** * Set the 2nd record in the passed in list to fail. * * Assert that only 1 record is returned, and that it is equal to the 2nd object in the list. * * @throws IOException */ @Test public void testRecordFails() throws IOException { List<ElasticsearchObject> records = new ArrayList<ElasticsearchObject>(); ElasticsearchObject r1 = createMockRecordAndSetExpectations("sample-index", "type", "1", "{\"name\":\"Mike\"}"); records.add(r1); // this will be the failing record. ElasticsearchObject r2 = createMockRecordAndSetExpectations("sample-index", "type", "2", "{\"name\":\"Mike\",\"badJson\":\"forgotendingquote}"); records.add(r2); ElasticsearchObject r3 = createMockRecordAndSetExpectations("sample-index", "type", "3", "{\"name\":\"Mike\"}"); records.add(r3); // mock building and executing the request mockBuildingAndExecutingRequest(records); // Verify that there is a response for each record, and that each gets touched. BulkItemResponse[] responses = new BulkItemResponse[records.size()]; for (int i = 0; i < responses.length; i++) { responses[i] = createMock(BulkItemResponse.class); // define behavior for a failing record if (i == 1) { expect(responses[i].isFailed()).andReturn(true); expect(responses[i].getFailureMessage()).andReturn("bad json error message"); Failure failure = new Failure("index", "type", "id", "foo failure message", RestStatus.BAD_REQUEST); expect(responses[i].getFailure()).andReturn(failure); } else { expect(responses[i].isFailed()).andReturn(false); } replay(responses[i]); } // verify admin client gets used to check cluster status. this case, yellow expect(mockBulkResponse.getItems()).andReturn(responses); AdminClient mockAdminClient = createMock(AdminClient.class); expect(elasticsearchClientMock.admin()).andReturn(mockAdminClient); ClusterAdminClient mockClusterAdminClient = createMock(ClusterAdminClient.class); expect(mockAdminClient.cluster()).andReturn(mockClusterAdminClient); ClusterHealthRequestBuilder mockHealthRequestBuilder = createMock(ClusterHealthRequestBuilder.class); expect(mockClusterAdminClient.prepareHealth()).andReturn(mockHealthRequestBuilder); ListenableActionFuture mockHealthFuture = createMock(ListenableActionFuture.class); expect(mockHealthRequestBuilder.execute()).andReturn(mockHealthFuture); ClusterHealthResponse mockResponse = createMock(ClusterHealthResponse.class); expect(mockHealthFuture.actionGet()).andReturn(mockResponse); expect(mockResponse.getStatus()).andReturn(ClusterHealthStatus.YELLOW); expectLastCall().times(2); replay(elasticsearchClientMock, r1, r2, r3, buffer, mockBulkBuilder, mockIndexBuilder, mockFuture, mockBulkResponse, mockAdminClient, mockClusterAdminClient, mockHealthRequestBuilder, mockHealthFuture, mockResponse); List<ElasticsearchObject> failures = emitter.emit(buffer); assertTrue(failures.size() == 1); // the emitter should return the exact object that failed assertEquals(failures.get(0), records.get(1)); verify(elasticsearchClientMock, r1, r2, r3, buffer, mockBulkBuilder, mockIndexBuilder, mockFuture, mockBulkResponse, mockAdminClient, mockClusterAdminClient, mockHealthRequestBuilder, mockHealthFuture, mockResponse); verifyRecords(records); verifyResponses(responses); }
Example #18
Source File: EsTypeImpl.java From io with Apache License 2.0 | 2 votes |
/** * 非同期でMapping定義を更新する. * @param mappings Mapping定義 * @return Mapping更新レスポンス */ public ListenableActionFuture<PutMappingResponse> asyncPutMapping(Map<String, Object> mappings) { return esClient.putMapping(this.indexName, this.name, mappings); }
Example #19
Source File: EsTypeImpl.java From io with Apache License 2.0 | 2 votes |
/** * 非同期でMapping定義を更新する. * @param mappings Mapping定義 * @return Mapping更新レスポンス */ public ListenableActionFuture<PutMappingResponse> asyncPutMapping(Map<String, Object> mappings) { return esClient.putMapping(this.indexName, this.name, mappings); }