org.elasticsearch.index.IndexNotFoundException Java Examples
The following examples show how to use
org.elasticsearch.index.IndexNotFoundException.
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: EsRetryOnParticularErrorTest.java From io with Apache License 2.0 | 6 votes |
/** * EsIndex_searchメソッドで初回にIndexMissingExceptionが投げられた場合のテスト. */ @Test public void EsIndex_searchメソッドで初回にIndexMissingExceptionが投げられた場合のテスト() { PowerMockito.mockStatic(EsClientException.class); EsIndexImpl esIndexObject = Mockito.spy(new EsIndexImpl("dummy", "", 0, 0, null)); // EsIndex#asyncIndexSearch()が呼ばれた場合に、IndexMissingExceptionを投げる。 // 送出する例外オブジェクトのモックを作成 IndexNotFoundException toBeThrown = new IndexNotFoundException("abc"); Mockito.doThrow(toBeThrown) .when(esIndexObject) .asyncIndexSearch(Mockito.anyString(), Mockito.anyMapOf(String.class, Object.class)); // メソッド呼び出し DcSearchResponse result = esIndexObject.search("dummyRoutingId", (Map<String, Object>) null); assertNull(result); }
Example #2
Source File: InternalCountOperation.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public long count(String index, int shardId, WhereClause whereClause) throws IOException, InterruptedException { IndexService indexService; try { indexService = indicesService.indexServiceSafe(index); } catch (IndexNotFoundException e) { if (PartitionName.isPartition(index)) { return 0L; } throw e; } IndexShard indexShard = indexService.shardSafe(shardId); try (Engine.Searcher searcher = indexShard.acquireSearcher("count-operation")) { LuceneQueryBuilder.Context queryCtx = queryBuilder.convert( whereClause, indexService.mapperService(), indexService.fieldData(), indexService.cache()); if (Thread.interrupted()) { throw new InterruptedException(); } return searcher.searcher().count(queryCtx.query()); } }
Example #3
Source File: RetryOnFailureResultReceiverTest.java From crate with Apache License 2.0 | 6 votes |
@Test public void testRetryIsInvokedOnIndexNotFoundException() throws Exception { AtomicInteger numRetries = new AtomicInteger(0); BaseResultReceiver resultReceiver = new BaseResultReceiver(); ClusterState initialState = clusterService.state(); RetryOnFailureResultReceiver retryOnFailureResultReceiver = new RetryOnFailureResultReceiver( clusterService, initialState, indexName -> true, resultReceiver, UUID.randomUUID(), (newJobId, receiver) -> numRetries.incrementAndGet()); // Must have a different cluster state then the initial state to trigger a retry clusterService.submitStateUpdateTask("dummy", new DummyUpdate()); assertBusy(() -> assertThat(initialState, Matchers.not(sameInstance(clusterService.state())))); retryOnFailureResultReceiver.fail(new IndexNotFoundException("t1")); assertThat(numRetries.get(), is(1)); }
Example #4
Source File: EsRetryOnParticularErrorTest.java From io with Apache License 2.0 | 6 votes |
/** * EsType_getメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト. */ @Test public void EsType_getメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト() { PowerMockito.mockStatic(EsClientException.class); EsTypeImpl esTypeObject = Mockito.spy(new EsTypeImpl("dummy", "Test", "TestRoutingId", 0, 0, null)); // EsType#asyncGet()が呼ばれた場合に、IndexMissingExceptionを根本原因に持つ例外を投げる。 // 送出する例外オブジェクトを作成 SettingsException toBeThrown = new SettingsException("foo", new IndexNotFoundException("dummy")); Mockito.doThrow(toBeThrown) .when(esTypeObject) .asyncGet(Mockito.anyString(), Mockito.anyBoolean()); // メソッド呼び出し DcGetResponse result = esTypeObject.get("dummyId", true); assertNull(result); }
Example #5
Source File: EsRetryOnParticularErrorTest.java From io with Apache License 2.0 | 6 votes |
/** * EsType_updateメソッドで初回にIndexMissingExceptionが投げられた場合のテスト. */ @Test public void EsType_updateメソッドで初回にIndexMissingExceptionが投げられた場合のテスト() { PowerMockito.mockStatic(EsClientException.class); EsTypeImpl esTypeObject = Mockito.spy(new EsTypeImpl("dummy", "Test", "TestRoutingId", 0, 0, null)); // EsType#asyncIndex()が呼ばれた場合に、IndexMissingExceptionを投げる。 // 送出する例外オブジェクトのモックを作成 IndexNotFoundException toBeThrown = new IndexNotFoundException("abc"); Mockito.doThrow(toBeThrown) .when(esTypeObject) .asyncIndex(Mockito.anyString(), Mockito.anyMapOf(String.class, Object.class), (OpType) Mockito.anyObject(), Mockito.anyLong()); // メソッド呼び出し try { esTypeObject.update("dummyId", null, 1); fail("EsClientException should be thrown."); } catch (EsClientException.EsIndexMissingException e) { assertTrue(e.getCause() instanceof IndexNotFoundException); } }
Example #6
Source File: EsRetryOnParticularErrorTest.java From io with Apache License 2.0 | 6 votes |
/** * EsType_updateメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト. */ @Test public void EsType_updateメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト() { PowerMockito.mockStatic(EsClientException.class); EsTypeImpl esTypeObject = Mockito.spy(new EsTypeImpl("dummy", "Test", "TestRoutingId", 0, 0, null)); // EsType#asyncIndex()が呼ばれた場合に、IndexMissingExceptionを投げる。 // 送出する例外オブジェクトを作成 SettingsException toBeThrown = new SettingsException("foo", new IndexNotFoundException("dummy")); Mockito.doThrow(toBeThrown) .when(esTypeObject) .asyncIndex(Mockito.anyString(), Mockito.anyMapOf(String.class, Object.class), (OpType) Mockito.anyObject(), Mockito.anyLong()); // メソッド呼び出し try { esTypeObject.update("dummyId", null, 1); fail("EsClientException should be thrown."); } catch (EsClientException.EsIndexMissingException e) { assertTrue(e.getCause() instanceof SettingsException); assertTrue(e.getCause().getCause() instanceof IndexNotFoundException); } }
Example #7
Source File: EsRetryOnParticularErrorTest.java From io with Apache License 2.0 | 6 votes |
/** * EsType_searchメソッドで初回にIndexNotFoundExceptionが投げられた場合のテスト. */ @Test public void EsType_searchメソッドで初回にIndexNotFoundExceptionが投げられた場合のテスト() { PowerMockito.mockStatic(EsClientException.class); EsTypeImpl esTypeObject = Mockito.spy(new EsTypeImpl("dummy", "Test", "TestRoutingId", 0, 0, null)); // EsType#asyncSearch()が呼ばれた場合に、IndexMissingExceptionを投げる。 // 送出する例外オブジェクトのモックを作成 IndexNotFoundException toBeThrown = new IndexNotFoundException("abc"); Mockito.doThrow(toBeThrown) .when(esTypeObject) .asyncSearch(Mockito.anyMapOf(String.class, Object.class)); // メソッド呼び出し DcSearchResponse result = esTypeObject.search(null); assertTrue(result.isNullResponse()); }
Example #8
Source File: EsRetryOnParticularErrorTest.java From io with Apache License 2.0 | 6 votes |
/** * EsType_searchメソッドで初回にIndexNotFoundExceptionを根本原因に持つ例外が投げられた場合のテスト. */ @Test public void EsType_searchメソッドで初回にIndexNotFoundExceptionを根本原因に持つ例外が投げられた場合のテスト() { PowerMockito.mockStatic(EsClientException.class); EsTypeImpl esTypeObject = Mockito.spy(new EsTypeImpl("dummy", "Test", "TestRoutingId", 0, 0, null)); // EsType#asyncSearch()が呼ばれた場合に、IndexMissingExceptionを根本原因に持つ例外を投げる。 // 送出する例外オブジェクトを作成 SettingsException toBeThrown = new SettingsException("foo", new IndexNotFoundException("dummy")); Mockito.doThrow(toBeThrown) .when(esTypeObject) .asyncSearch(Mockito.anyMapOf(String.class, Object.class)); // メソッド呼び出し DcSearchResponse result = esTypeObject.search(null); assertTrue(result.isNullResponse()); }
Example #9
Source File: EsRetryOnParticularErrorTest.java From io with Apache License 2.0 | 6 votes |
/** * EsType_deleteメソッドで初回にIndexMissingExceptionが投げられた場合のテスト. */ @Test public void EsType_deleteメソッドで初回にIndexMissingExceptionが投げられた場合のテスト() { PowerMockito.mockStatic(EsClientException.class); EsTypeImpl esTypeObject = Mockito.spy(new EsTypeImpl("dummy", "Test", "TestRoutingId", 0, 0, null)); // EsType#asyncDelete()が呼ばれた場合に、IndexMissingExceptionを投げる。 // 送出する例外オブジェクトのモックを作成 IndexNotFoundException toBeThrown = new IndexNotFoundException("abc"); Mockito.doThrow(toBeThrown) .when(esTypeObject) .asyncDelete(Mockito.anyString(), Mockito.anyLong()); // メソッド呼び出し try { esTypeObject.delete("dummyId", 1); fail("EsClientException should be thrown."); } catch (EsClientException.EsIndexMissingException e) { assertTrue(e.getCause() instanceof IndexNotFoundException); } }
Example #10
Source File: AnomalyResultTransportAction.java From anomaly-detection with Apache License 2.0 | 6 votes |
private void findException(Throwable cause, String adID, AtomicReference<AnomalyDetectionException> failure) { if (cause instanceof Error) { // we cannot do anything with Error. LOG.error(new ParameterizedMessage("Error during prediction for {}: ", adID), cause); return; } Exception causeException = (Exception) cause; if (isException(causeException, ResourceNotFoundException.class, RESOURCE_NOT_FOUND_EXCEPTION_NAME_UNDERSCORE) || (causeException instanceof IndexNotFoundException && causeException.getMessage().contains(CommonName.CHECKPOINT_INDEX_NAME))) { failure.set(new ResourceNotFoundException(adID, causeException.getMessage())); } else if (isException(causeException, LimitExceededException.class, LIMIT_EXCEEDED_EXCEPTION_NAME_UNDERSCORE)) { failure.set(new LimitExceededException(adID, causeException.getMessage())); } else if (causeException instanceof ElasticsearchTimeoutException) { // we can have ElasticsearchTimeoutException when a node tries to load RCF or // threshold model failure.set(new InternalFailure(adID, causeException)); } else { // some unexpected bugs occur while predicting anomaly failure.set(new EndRunException(adID, "We might have bugs.", causeException, false)); } }
Example #11
Source File: RoutingTable.java From crate with Apache License 2.0 | 6 votes |
/** * All the *active* primary shards for the provided indices grouped (each group is a single element, consisting * of the primary shard). This is handy for components that expect to get group iterators, but still want in some * cases to iterate over all primary shards (and not just one shard in replication group). * * @param indices The indices to return all the shards (replicas) * @return All the primary shards grouped into a single shard element group each * @throws IndexNotFoundException If an index passed does not exists */ public GroupShardsIterator<ShardIterator> activePrimaryShardsGrouped(String[] indices, boolean includeEmpty) { // use list here since we need to maintain identity across shards ArrayList<ShardIterator> set = new ArrayList<>(); for (String index : indices) { IndexRoutingTable indexRoutingTable = index(index); if (indexRoutingTable == null) { throw new IndexNotFoundException(index); } for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) { ShardRouting primary = indexShardRoutingTable.primaryShard(); if (primary.active()) { set.add(primary.shardsIt()); } else if (includeEmpty) { // we need this for counting properly, just make it an empty one set.add(new PlainShardIterator(primary.shardId(), Collections.<ShardRouting>emptyList())); } } } return new GroupShardsIterator<>(set); }
Example #12
Source File: EsRetryOnParticularErrorTest.java From io with Apache License 2.0 | 6 votes |
/** * EsType_putMappingメソッドで初回にIndexMissingExceptionが投げられた場合のテスト. */ @Test public void EsType_putMappingメソッドで初回にIndexMissingExceptionが投げられた場合のテスト() { PowerMockito.mockStatic(EsClientException.class); EsTypeImpl esTypeObject = Mockito.spy(new EsTypeImpl("dummy", "Test", "TestRoutingId", 0, 0, null)); // EsType#asyncPutMapping()が呼ばれた場合に、IndexMissingExceptionを投げる。 // 送出する例外オブジェクトのモックを作成 IndexNotFoundException toBeThrown = new IndexNotFoundException("abc"); Mockito.doThrow(toBeThrown) .when(esTypeObject) .asyncPutMapping(Mockito.anyMapOf(String.class, Object.class)); // メソッド呼び出し try { esTypeObject.putMapping(null); fail("EsClientException should be thrown."); } catch (EsClientException.EsIndexMissingException e) { assertTrue(e.getCause() instanceof IndexNotFoundException); } }
Example #13
Source File: EsRetryOnParticularErrorTest.java From io with Apache License 2.0 | 6 votes |
/** * EsType_getメソッドで初回にIndexMissingExceptionが投げられた場合のテスト. */ @Test public void EsType_getメソッドで初回にIndexMissingExceptionが投げられた場合のテスト() { PowerMockito.mockStatic(EsClientException.class); EsTypeImpl esTypeObject = Mockito.spy(new EsTypeImpl("dummy", "Test", "TestRoutingId", 0, 0, null)); // EsType#asyncGet()が呼ばれた場合に、IndexMissingExceptionを投げる。 // 送出する例外オブジェクトのモックを作成 IndexNotFoundException toBeThrown = new IndexNotFoundException("abc"); Mockito.doThrow(toBeThrown) .when(esTypeObject) .asyncGet(Mockito.anyString(), Mockito.anyBoolean()); // メソッド呼び出し DcGetResponse result = esTypeObject.get("dummyId", true); assertNull(result); }
Example #14
Source File: DocTableInfo.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Nullable private Routing getRouting(ClusterState state, WhereClause whereClause, String preference, final List<ShardId> missingShards) { final Map<String, Map<String, List<Integer>>> locations = new TreeMap<>(); GroupShardsIterator shardIterators; try { shardIterators = getShardIterators(whereClause, preference, state); } catch (IndexNotFoundException e) { return new Routing(locations); } fillLocationsFromShardIterators(locations, shardIterators, missingShards); if (missingShards.isEmpty()) { return new Routing(locations); } else { return null; } }
Example #15
Source File: AbstractRetryableEsRequestTest.java From io with Apache License 2.0 | 6 votes |
/** * リトライ対象例外が続き_リトライ5回目でリトライ対象外の例外が発生した場合、EsClientExceptionが投げられること. */ @Test(expected = EsClientException.class) public void リトライ対象例外が続き_リトライ5回目でリトライ対象外の例外が発生した場合_EsClientExceptionが投げられること() { TestRequest requestMock = Mockito.spy(new TestRequest()); ClusterBlockException toBeThrown = Mockito.mock(ClusterBlockException.class); IndexNotFoundException toBeThrown2 = new IndexNotFoundException("abc"); Mockito.doThrow(toBeThrown) // 初回 .doThrow(toBeThrown) // リトライ1回目 .doThrow(toBeThrown) // リトライ2回目 .doThrow(toBeThrown) // リトライ3回目 .doThrow(toBeThrown) // リトライ4回目 .doThrow(toBeThrown2) // リトライ5回目 .when(requestMock) .doProcess(); try { requestMock.doRequest(); fail("Should not return"); } finally { // doProcessが6回呼び出されるはず Mockito.verify(requestMock, Mockito.times(6)).doProcess(); Mockito.verify(requestMock, Mockito.times(0)).onParticularError(Mockito.any(ElasticsearchException.class)); } }
Example #16
Source File: AnomalyDetectionIndices.java From anomaly-detection with Apache License 2.0 | 6 votes |
private void deleteIndexIteration(String[] toDelete) { for (String index : toDelete) { DeleteIndexRequest singleDeleteRequest = new DeleteIndexRequest(index); adminClient.indices().delete(singleDeleteRequest, ActionListener.wrap(singleDeleteResponse -> { if (!singleDeleteResponse.isAcknowledged()) { logger.error("Retrying deleting {} does not succeed.", index); } }, exception -> { if (exception instanceof IndexNotFoundException) { logger.info("{} was already deleted.", index); } else { logger.error(new ParameterizedMessage("Retrying deleting {} does not succeed.", index), exception); } })); } }
Example #17
Source File: EsRetryTest.java From io with Apache License 2.0 | 6 votes |
/** * ドキュメント新規作成時_初回でIndexMissingExceptionが発生した場合にEsClient_EsIndexMissingExceptionが返されること. */ @Test(expected = EsClientException.EsIndexMissingException.class) public void ドキュメント新規作成時_初回でIndexMissingExceptionが発生した場合にEsClient_EsIndexMissingExceptionが返されること() { PowerMockito.mockStatic(EsClientException.class); EsTypeImpl esTypeObject = Mockito.spy(new EsTypeImpl("dummy", "Test", "TestRoutingId", 0, 0, null)); // EsType#asyncIndex()が呼ばれた場合に、IndexMissingExceptionを投げる。 // 送出する例外オブジェクトのモックを作成 IndexNotFoundException toBeThrown = new IndexNotFoundException("dummy"); Mockito.doThrow(toBeThrown) .when(esTypeObject) .asyncIndex(Mockito.anyString(), Mockito.anyMapOf(String.class, Object.class), Mockito.any(OpType.class), Mockito.anyLong()); // メソッド呼び出し esTypeObject.create("dummyId", null); fail("EsIndexMissingException should be thrown."); }
Example #18
Source File: ElasticsearchMetaAlertDaoTest.java From metron with Apache License 2.0 | 6 votes |
@Test public void testUpdateShouldUpdateOnMissingMetaAlertIndex() throws Exception { ElasticsearchDao elasticsearchDao = mock(ElasticsearchDao.class); ElasticsearchMetaAlertRetrieveLatestDao elasticsearchMetaAlertRetrieveLatestDao = mock(ElasticsearchMetaAlertRetrieveLatestDao.class); MetaAlertConfig metaAlertConfig = mock(MetaAlertConfig.class); ElasticsearchMetaAlertUpdateDao emauDao = spy(new ElasticsearchMetaAlertUpdateDao(elasticsearchDao, elasticsearchMetaAlertRetrieveLatestDao, metaAlertConfig, 1)); doThrow(new IndexNotFoundException(ElasticsearchMetaAlertDao.METAALERTS_INDEX)).when(emauDao).getMetaAlertsForAlert("alert_one"); Document update = new Document(new HashMap<>(), "alert_one", "", 0L); emauDao.update(update, Optional.empty()); Map<Document, Optional<String>> expectedUpdate = new HashMap<Document, Optional<String>>() {{ put(update, Optional.empty()); }}; verify(elasticsearchDao).batchUpdate(expectedUpdate); }
Example #19
Source File: ElasticSearchDAOV5.java From conductor with Apache License 2.0 | 6 votes |
private void addIndex(String indexName) { try { elasticSearchClient.admin() .indices() .prepareGetIndex() .addIndices(indexName) .execute() .actionGet(); } catch (IndexNotFoundException infe) { try { CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName); createIndexRequest.settings(Settings.builder() .put("index.number_of_shards", config.getElasticSearchIndexShardCount()) .put("index.number_of_replicas", config.getElasticSearchIndexReplicationCount()) ); elasticSearchClient.admin() .indices() .create(createIndexRequest) .actionGet(); } catch (ResourceAlreadyExistsException done) { // no-op } } }
Example #20
Source File: BlobIntegrationTest.java From crate with Apache License 2.0 | 6 votes |
@Nullable private BlobShard getBlobShard(String digest) { Iterable<BlobIndicesService> services = internalCluster().getInstances(BlobIndicesService.class); Iterator<BlobIndicesService> it = services.iterator(); BlobShard blobShard = null; while (it.hasNext()) { BlobIndicesService nextService = it.next(); try { blobShard = nextService.localBlobShard(".blob_test", digest); } catch (ShardNotFoundException | IndexNotFoundException e) { continue; } if (blobShard != null) { break; } } return blobShard; }
Example #21
Source File: IndexNameExpressionResolver.java From crate with Apache License 2.0 | 6 votes |
@Override public List<String> resolve(Context context, List<String> expressions) { IndicesOptions options = context.getOptions(); MetaData metaData = context.getState().metaData(); if (options.expandWildcardsClosed() == false && options.expandWildcardsOpen() == false) { return expressions; } if (isEmptyOrTrivialWildcard(expressions)) { return resolveEmptyOrTrivialWildcard(options, metaData); } Set<String> result = innerResolve(context, expressions, options, metaData); if (result == null) { return expressions; } if (result.isEmpty() && !options.allowNoIndices()) { IndexNotFoundException infe = new IndexNotFoundException((String)null); infe.setResources("index_or_alias", expressions.toArray(new String[0])); throw infe; } return new ArrayList<>(result); }
Example #22
Source File: TransportClusterHealthAction.java From Elasticsearch with Apache License 2.0 | 6 votes |
private ClusterHealthResponse clusterHealth(ClusterHealthRequest request, ClusterState clusterState, int numberOfPendingTasks, int numberOfInFlightFetch, TimeValue pendingTaskTimeInQueue) { if (logger.isTraceEnabled()) { logger.trace("Calculating health based on state version [{}]", clusterState.version()); } if (request.getHeader(LoginUserContext.TENANT_FILTER) != null) { clusterState = AuthService.filterState(clusterState, clusterState.metaData(), (Long) request.getHeader(LoginUserContext.TENANT_FILTER)); } String[] concreteIndices; try { concreteIndices = indexNameExpressionResolver.concreteIndices(clusterState, request); } catch (IndexNotFoundException e) { // one of the specified indices is not there - treat it as RED. ClusterHealthResponse response = new ClusterHealthResponse(clusterName.value(), Strings.EMPTY_ARRAY, clusterState, numberOfPendingTasks, numberOfInFlightFetch, UnassignedInfo.getNumberOfDelayedUnassigned(clusterState), pendingTaskTimeInQueue); response.setStatus(ClusterHealthStatus.RED); return response; } return new ClusterHealthResponse(clusterName.value(), concreteIndices, clusterState, numberOfPendingTasks, numberOfInFlightFetch, UnassignedInfo.getNumberOfDelayedUnassigned(clusterState), pendingTaskTimeInQueue); }
Example #23
Source File: EsRetry2Test.java From io with Apache License 2.0 | 6 votes |
/** * ドキュメント新規作成時_初回でIndexMissingExceptionが発生した場合にEsClient_EsIndexMissingExceptionが返されること. */ @Test(expected = EsClientException.EsIndexMissingException.class) public void ドキュメント新規作成時_初回でIndexMissingExceptionが発生した場合にEsClient_EsIndexMissingExceptionが返されること() { PowerMockito.mockStatic(EsClientException.class); EsTypeImpl esTypeObject = Mockito.spy(new EsTypeImpl("dummy", "Test", "TestRoutingId", 0, 0, null)); // EsType#asyncIndex()が呼ばれた場合に、IndexMissingExceptionを投げる。 // 送出する例外オブジェクトのモックを作成 IndexNotFoundException toBeThrown = new IndexNotFoundException("dummy"); Mockito.doThrow(toBeThrown) .when(esTypeObject) .asyncIndex(Mockito.anyString(), Mockito.anyMapOf(String.class, Object.class), Mockito.any(OpType.class), Mockito.anyLong()); // メソッド呼び出し esTypeObject.create("dummyId", null); fail("EsIndexMissingException should be thrown."); }
Example #24
Source File: EsRetryOnParticularErrorTest.java From io with Apache License 2.0 | 6 votes |
/** * EsIndex_searchメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト. */ @Test public void EsIndex_searchメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト() { PowerMockito.mockStatic(EsClientException.class); EsIndexImpl esIndexObject = Mockito.spy(new EsIndexImpl("dummy", "", 0, 0, null)); // EsIndex#asyncIndexSearch()が呼ばれた場合に、IndexMissingExceptionを根本原因に持つ例外を投げる。 // 送出する例外オブジェクトを作成 SettingsException toBeThrown = new SettingsException("foo", new IndexNotFoundException("dummy")); Mockito.doThrow(toBeThrown) .when(esIndexObject) .asyncIndexSearch(Mockito.anyString(), Mockito.anyMapOf(String.class, Object.class)); // メソッド呼び出し DcSearchResponse result = esIndexObject.search("dummyRoutingId", (Map<String, Object>) null); assertNull(result); }
Example #25
Source File: DocTableInfo.java From Elasticsearch with Apache License 2.0 | 6 votes |
private GroupShardsIterator getShardIterators(WhereClause whereClause, @Nullable String preference, ClusterState clusterState) throws IndexNotFoundException { String[] routingIndices = concreteIndices; if (whereClause.partitions().size() > 0) { routingIndices = whereClause.partitions().toArray(new String[whereClause.partitions().size()]); } Map<String, Set<String>> routingMap = null; if (whereClause.clusteredBy().isPresent()) { routingMap = indexNameExpressionResolver.resolveSearchRouting( clusterState, whereClause.routingValues(), routingIndices); } return clusterService.operationRouting().searchShards( clusterState, routingIndices, routingMap, preference ); }
Example #26
Source File: MetaDataCreateIndexService.java From crate with Apache License 2.0 | 5 votes |
static IndexMetaData validateResize(ClusterState state, String sourceIndex, Set<String> targetIndexMappingsTypes, String targetIndexName, Settings targetIndexSettings) { if (state.metaData().hasIndex(targetIndexName)) { throw new ResourceAlreadyExistsException(state.metaData().index(targetIndexName).getIndex()); } final IndexMetaData sourceMetaData = state.metaData().index(sourceIndex); if (sourceMetaData == null) { throw new IndexNotFoundException(sourceIndex); } // ensure index is read-only if (state.blocks().indexBlocked(ClusterBlockLevel.WRITE, sourceIndex) == false) { throw new IllegalStateException("index " + sourceIndex + " must be read-only to resize index. use \"index.blocks.write=true\""); } if ((targetIndexMappingsTypes.size() > 1 || (targetIndexMappingsTypes.isEmpty() || targetIndexMappingsTypes.contains(MapperService.DEFAULT_MAPPING)) == false)) { throw new IllegalArgumentException("mappings are not allowed when resizing indices" + ", all mappings are copied from the source index"); } if (IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.exists(targetIndexSettings)) { // this method applies all necessary checks ie. if the target shards are less than the source shards // of if the source shards are divisible by the number of target shards IndexMetaData.getRoutingFactor(sourceMetaData.getNumberOfShards(), IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.get(targetIndexSettings)); } return sourceMetaData; }
Example #27
Source File: TransportSQLActionTest.java From crate with Apache License 2.0 | 5 votes |
@Test public void testIndexNotFoundExceptionIsRaisedIfDeletedAfterPlan() throws Throwable { expectedException.expect(IndexNotFoundException.class); execute("create table t (name string)"); ensureYellow(); PlanForNode plan = plan("select * from t"); execute("drop table t"); try { execute(plan).getResult(); } catch (Throwable t) { throw SQLExceptions.unwrap(t); } }
Example #28
Source File: EsTypeImpl.java From io with Apache License 2.0 | 5 votes |
@Override IndexResponse onParticularError(ElasticsearchException e) { if (e instanceof IndexNotFoundException || e.getCause() instanceof IndexNotFoundException) { throw new EsClientException.EsIndexMissingException(e); } if (e instanceof VersionConflictEngineException) { throw new EsClientException.EsVersionConflictException(e); } if (e instanceof MapperParsingException) { throw new EsClientException.EsSchemaMismatchException(e); } throw e; }
Example #29
Source File: ElasticSearchListeningMessageSearchIndex.java From james-project with Apache License 2.0 | 5 votes |
@Override public Mono<Flags> retrieveIndexedFlags(Mailbox mailbox, MessageUid uid) { RoutingKey routingKey = routingKeyFactory.from(mailbox.getMailboxId()); return elasticSearchIndexer.get(indexIdFor(mailbox.getMailboxId(), uid), routingKey) .filter(GetResponse::isExists) .map(GetResponse::getSourceAsMap) .map(this::extractFlags) .switchIfEmpty(Mono.error(() -> new IndexNotFoundException( String.format("Index for message %s in mailbox %s not found", uid.toString(), mailbox.getMailboxId().serialize())))); }
Example #30
Source File: Elasticsearch.java From sfs with Apache License 2.0 | 5 votes |
protected Observable<Void> deleteIndex(VertxContext<Server> vertxContext, String index) { return Defer.just(index) .flatMap(new IndexDelete(vertxContext)) .doOnNext(success -> Preconditions.checkState(success, "Failed to delete index %s", index)) .map(new ToVoid<>()) .onErrorResumeNext(throwable -> { if (ExceptionHelper.containsException(IndexNotFoundException.class, throwable)) { return Defer.aVoid(); } else { return Observable.error(throwable); } }); }