当前位置: 首页>>代码示例>>Java>>正文


Java IndexAlreadyExistsException类代码示例

本文整理汇总了Java中org.elasticsearch.indices.IndexAlreadyExistsException的典型用法代码示例。如果您正苦于以下问题:Java IndexAlreadyExistsException类的具体用法?Java IndexAlreadyExistsException怎么用?Java IndexAlreadyExistsException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IndexAlreadyExistsException类属于org.elasticsearch.indices包,在下文中一共展示了IndexAlreadyExistsException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setException

import org.elasticsearch.indices.IndexAlreadyExistsException; //导入依赖的package包/类
private void setException(SettableFuture<Long> result, Throwable e, CreateTableAnalyzedStatement statement) {
    e = Exceptions.unwrap(e);
    String message = e.getMessage();
    // sometimes message is empty
    if ("mapping [default]".equals(message) && e.getCause() != null) {
        // this is a generic mapping parse exception,
        // the cause has usually a better more detailed error message
        result.setException(e.getCause());
    } else if (statement.ifNotExists() &&
               (e instanceof IndexAlreadyExistsException
                || (e instanceof IndexTemplateAlreadyExistsException && statement.templateName() != null))) {
        result.set(null);
    } else {
        result.setException(e);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:TableCreator.java

示例2: createIndexAndExecuteUpsertRequest

import org.elasticsearch.indices.IndexAlreadyExistsException; //导入依赖的package包/类
private void createIndexAndExecuteUpsertRequest(final UpsertByIdNode.Item item,
                                                final SettableFuture<TaskResult> futureResult) {
    transportCreateIndexAction.execute(
            new CreateIndexRequest(item.index()).cause("upsert single item"),
            new ActionListener<CreateIndexResponse>() {
        @Override
        public void onResponse(CreateIndexResponse createIndexResponse) {
            executeUpsertRequest(item, futureResult);
        }

        @Override
        public void onFailure(Throwable e) {
            e = ExceptionsHelper.unwrapCause(e);
            if (e instanceof IndexAlreadyExistsException) {
                executeUpsertRequest(item, futureResult);
            } else {
                futureResult.setException(e);
            }

        }
    });
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:23,代码来源:UpsertByIdTask.java

示例3: doExecute

import org.elasticsearch.indices.IndexAlreadyExistsException; //导入依赖的package包/类
@Override
protected void doExecute(final Task task, final DeleteRequest request, final ActionListener<DeleteResponse> listener) {
    ClusterState state = clusterService.state();
    if (autoCreateIndex.shouldAutoCreate(request.index(), state)) {
        createIndexAction.execute(task, new CreateIndexRequest(request).index(request.index()).cause("auto(delete api)")
            .masterNodeTimeout(request.timeout()), new ActionListener<CreateIndexResponse>() {
            @Override
            public void onResponse(CreateIndexResponse result) {
                innerExecute(task, request, listener);
            }

            @Override
            public void onFailure(Throwable e) {
                if (ExceptionsHelper.unwrapCause(e) instanceof IndexAlreadyExistsException) {
                    // we have the index, do it
                    innerExecute(task, request, listener);
                } else {
                    listener.onFailure(e);
                }
            }
        });
    } else {
        innerExecute(task, request, listener);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:26,代码来源:TransportDeleteAction.java

示例4: updateIndexName

import org.elasticsearch.indices.IndexAlreadyExistsException; //导入依赖的package包/类
private void updateIndexName(Configuration config) {
	this.logIndexPrefix = config.getProperty("workflow.elasticsearch.tasklog.index.name", "task_log");
	this.logIndexName = this.logIndexPrefix + "_" + sdf.format(new Date());

	try {
		client.admin().indices().prepareGetIndex().addIndices(logIndexName).execute().actionGet();
	} catch (IndexNotFoundException infe) {
		try {
			client.admin().indices().prepareCreate(logIndexName).execute().actionGet();
		} catch (IndexAlreadyExistsException ilee) {

		} catch (Exception e) {
			log.error(e.getMessage(), e);
		}
	}
}
 
开发者ID:Netflix,项目名称:conductor,代码行数:17,代码来源:ElasticSearchDAO.java

示例5: createLiferayIndexInESServer

import org.elasticsearch.indices.IndexAlreadyExistsException; //导入依赖的package包/类
/**
 * Creates the liferay index in Elasticsearch server with default dynamic
 * mapping template.
 */
private void createLiferayIndexInESServer() {
    try {
        CreateIndexResponse createIndexResponse = client.admin().indices()
                .prepareCreate(ElasticsearchIndexerConstants.ELASTIC_SEARCH_LIFERAY_INDEX)
                .addMapping("_default_", loadMappings())
                .setSettings(loadSettings())
                .execute().actionGet();

        _log.info("Index created with dynamic template mapping provided, Result:"
                + createIndexResponse.isAcknowledged());
    } catch (IndexAlreadyExistsException iaeEx) {
        _log.warn("Index already exists, no need to create again....");
    } catch (Exception e) {
    	_log.error("Failed to load file for elasticsearch mapping settings", e);
    }
}
 
开发者ID:rivetlogic,项目名称:liferay-elasticsearch-integration,代码行数:21,代码来源:ElasticsearchConnector.java

示例6: createContentIndex

import org.elasticsearch.indices.IndexAlreadyExistsException; //导入依赖的package包/类
public static boolean createContentIndex(Client esClient, String name) {
    checkNotNull(esClient);
    ActionFuture<IndicesExistsResponse> exists = esClient.admin().indices().exists(
            Requests.indicesExistsRequest(name)
    );
    if (!timeoutGet(exists).isExists()) {
        try {
            LOG.info("Creating index {}", name);
            timeoutGet(esClient.admin().indices().create(Requests.createIndexRequest(name)));
        } catch (IndexAlreadyExistsException e) {
            LOG.info("Index already exists: {}", e);
            return false;
        }
        return true;
    } else {
        LOG.info("Index {} exists", name);
        return false;
    }
}
 
开发者ID:atlasapi,项目名称:atlas-deer,代码行数:20,代码来源:ElasticsearchIndexCreator.java

示例7: start

import org.elasticsearch.indices.IndexAlreadyExistsException; //导入依赖的package包/类
@Override
public void start() {
    logger.info("starting Jolokia river: hosts [{}], uri [{}], strategy [{}], index [{}]/[{}]",
            riverSetting.getHosts(), riverSetting.getUrl(), strategy, indexName, typeName);
    try {
        riverFlow.startDate(new Date());
        riverMouth.createIndexIfNotExists(indexSettings, typeMapping);
    } catch (Exception e) {
        if (ExceptionsHelper.unwrapCause(e) instanceof IndexAlreadyExistsException) {
            riverFlow.startDate(null);
            // that's fine, continue.
        } else if (ExceptionsHelper.unwrapCause(e) instanceof ClusterBlockException) {
            // ok, not recovered yet..., lets start indexing and hope we recover by the first bulk
        } else {
            logger.warn("failed to create index [{}], disabling Jolokia river...", e, indexName);
            return;
        }
    }
    thread = EsExecutors.daemonThreadFactory(settings.globalSettings(), "Jolokia river [" + riverName.name() + '/' + strategy + ']')
            .newThread(riverFlow);
    thread.start();
}
 
开发者ID:cwikman,项目名称:elasticsearch-river-jolokia,代码行数:23,代码来源:JolokiaRiver.java

示例8: validateAndFilterExistingIndices

import org.elasticsearch.indices.IndexAlreadyExistsException; //导入依赖的package包/类
private void validateAndFilterExistingIndices(ClusterState currentState,
                                              List<String> indicesToCreate,
                                              BulkCreateIndicesRequest request) {
    for (String index : request.indices()) {
        try {
            createIndexService.validateIndexName(index, currentState);
            indicesToCreate.add(index);
        } catch (IndexAlreadyExistsException e) {
            // ignore
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:TransportBulkCreateIndicesAction.java

示例9: esToCrateException

import org.elasticsearch.indices.IndexAlreadyExistsException; //导入依赖的package包/类
/**
 * Returns the cause throwable of a {@link org.elasticsearch.transport.RemoteTransportException}
 * and {@link org.elasticsearch.action.search.ReduceSearchPhaseException}.
 * Also transform throwable to {@link io.crate.exceptions.CrateException}.
 */
private Throwable esToCrateException(Throwable e) {
    e = Exceptions.unwrap(e);

    if (e instanceof IllegalArgumentException || e instanceof ParsingException) {
        return new SQLParseException(e.getMessage(), (Exception) e);
    } else if (e instanceof UnsupportedOperationException) {
        return new UnsupportedFeatureException(e.getMessage(), (Exception) e);
    } else if (e instanceof DocumentAlreadyExistsException) {
        return new DuplicateKeyException(
                "A document with the same primary key exists already", e);
    } else if (e instanceof IndexAlreadyExistsException) {
        return new TableAlreadyExistsException(((IndexAlreadyExistsException) e).getIndex(), e);
    } else if ((e instanceof InvalidIndexNameException)) {
        if (e.getMessage().contains("already exists as alias")) {
            // treat an alias like a table as aliases are not officially supported
            return new TableAlreadyExistsException(((InvalidIndexNameException) e).getIndex(),
                    e);
        }
        return new InvalidTableNameException(((InvalidIndexNameException) e).getIndex(), e);
    } else if (e instanceof InvalidIndexTemplateException) {
        PartitionName partitionName = PartitionName.fromIndexOrTemplate(((InvalidIndexTemplateException) e).name());
        return new InvalidTableNameException(partitionName.tableIdent().fqn(), e);
    } else if (e instanceof IndexNotFoundException) {
        return new TableUnknownException(((IndexNotFoundException) e).getIndex(), e);
    } else if (e instanceof org.elasticsearch.common.breaker.CircuitBreakingException) {
        return new CircuitBreakingException(e.getMessage());
    } else if (e instanceof InterruptedException) {
        return new JobKilledException();
    } else if (e instanceof RepositoryMissingException) {
        return new RepositoryUnknownException(((RepositoryMissingException) e).repository());
    } else if (e instanceof SnapshotMissingException) {
        return new SnapshotUnknownException(((SnapshotMissingException) e).snapshot(), e);
    } else if (e instanceof InvalidSnapshotNameException) {
        if (((InvalidSnapshotNameException) e).getDetailedMessage().contains("snapshot with such name already exists")) {
            return new SnapShotAlreadyExistsExeption(((InvalidSnapshotNameException) e).snapshot());
        }
    }
    return e;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:45,代码来源:TransportBaseSQLAction.java

示例10: validateIndexName

import org.elasticsearch.indices.IndexAlreadyExistsException; //导入依赖的package包/类
public void validateIndexName(String index, ClusterState state) {
    if (state.routingTable().hasIndex(index)) {
        throw new IndexAlreadyExistsException(new Index(index));
    }
    if (state.metaData().hasIndex(index)) {
        throw new IndexAlreadyExistsException(new Index(index));
    }
    if (!Strings.validFileName(index)) {
        throw new InvalidIndexNameException(new Index(index), index, "must not contain the following characters " + Strings.INVALID_FILENAME_CHARS);
    }
    if (index.contains("#")) {
        throw new InvalidIndexNameException(new Index(index), index, "must not contain '#'");
    }
    if (index.charAt(0) == '_') {
        throw new InvalidIndexNameException(new Index(index), index, "must not start with '_'");
    }
    if (!index.toLowerCase(Locale.ROOT).equals(index)) {
        throw new InvalidIndexNameException(new Index(index), index, "must be lowercase");
    }
    int byteCount = 0;
    try {
        byteCount = index.getBytes("UTF-8").length;
    } catch (UnsupportedEncodingException e) {
        // UTF-8 should always be supported, but rethrow this if it is not for some reason
        throw new ElasticsearchException("Unable to determine length of index name", e);
    }
    if (byteCount > MAX_INDEX_NAME_BYTES) {
        throw new InvalidIndexNameException(new Index(index), index,
                "index name is too long, (" + byteCount +
                " > " + MAX_INDEX_NAME_BYTES + ")");
    }
    if (state.metaData().hasAlias(index)) {
        throw new InvalidIndexNameException(new Index(index), index, "already exists as alias");
    }
    if (index.equals(".") || index.equals("..")) {
        throw new InvalidIndexNameException(new Index(index), index, "must not be '.' or '..'");
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:39,代码来源:MetaDataCreateIndexService.java

示例11: masterOperation

import org.elasticsearch.indices.IndexAlreadyExistsException; //导入依赖的package包/类
@Override
protected void masterOperation(final CreateIndexRequest request, final ClusterState state, final ActionListener<CreateIndexResponse> listener) {
    String cause = request.cause();
    if (cause.length() == 0) {
        cause = "api";
    }

    final String indexName = indexNameExpressionResolver.resolveDateMathExpression(request.index());
    final CreateIndexClusterStateUpdateRequest updateRequest = new CreateIndexClusterStateUpdateRequest(request, cause, indexName, request.updateAllTypes())
            .ackTimeout(request.timeout()).masterNodeTimeout(request.masterNodeTimeout())
            .settings(request.settings()).mappings(request.mappings())
            .aliases(request.aliases()).customs(request.customs());

    createIndexService.createIndex(updateRequest, new ActionListener<ClusterStateUpdateResponse>() {

        @Override
        public void onResponse(ClusterStateUpdateResponse response) {
            listener.onResponse(new CreateIndexResponse(response.isAcknowledged()));
        }

        @Override
        public void onFailure(Throwable t) {
            if (t instanceof IndexAlreadyExistsException) {
                logger.trace("[{}] failed to create", t, request.index());
            } else {
                logger.debug("[{}] failed to create", t, request.index());
            }
            listener.onFailure(t);
        }
    });
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:32,代码来源:TransportCreateIndexAction.java

示例12: doExecute

import org.elasticsearch.indices.IndexAlreadyExistsException; //导入依赖的package包/类
@Override
protected void doExecute(final UpdateRequest request, final ActionListener<UpdateResponse> listener) {
    // if we don't have a master, we don't have metadata, that's fine, let it find a master using create index API
    if (autoCreateIndex.shouldAutoCreate(request.index(), clusterService.state())) {
        createIndexAction.execute(new CreateIndexRequest(request).index(request.index()).cause("auto(update api)").masterNodeTimeout(request.timeout()), new ActionListener<CreateIndexResponse>() {
            @Override
            public void onResponse(CreateIndexResponse result) {
                innerExecute(request, listener);
            }

            @Override
            public void onFailure(Throwable e) {
                if (ExceptionsHelper.unwrapCause(e) instanceof IndexAlreadyExistsException) {
                    // we have the index, do it
                    try {
                        innerExecute(request, listener);
                    } catch (Throwable e1) {
                        listener.onFailure(e1);
                    }
                } else {
                    listener.onFailure(e);
                }
            }
        });
    } else {
        innerExecute(request, listener);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:29,代码来源:TransportUpdateAction.java

示例13: doExecute

import org.elasticsearch.indices.IndexAlreadyExistsException; //导入依赖的package包/类
@Override
protected void doExecute(final Task task, final IndexRequest request, final ActionListener<IndexResponse> listener) {
    // if we don't have a master, we don't have metadata, that's fine, let it find a master using create index API
    ClusterState state = clusterService.state();
    if (autoCreateIndex.shouldAutoCreate(request.index(), state)) {
        CreateIndexRequest createIndexRequest = new CreateIndexRequest(request);
        createIndexRequest.index(request.index());
        createIndexRequest.mapping(request.type());
        createIndexRequest.cause("auto(index api)");
        createIndexRequest.masterNodeTimeout(request.timeout());
        createIndexAction.execute(task, createIndexRequest, new ActionListener<CreateIndexResponse>() {
            @Override
            public void onResponse(CreateIndexResponse result) {
                innerExecute(task, request, listener);
            }

            @Override
            public void onFailure(Throwable e) {
                if (ExceptionsHelper.unwrapCause(e) instanceof IndexAlreadyExistsException) {
                    // we have the index, do it
                    try {
                        innerExecute(task, request, listener);
                    } catch (Throwable e1) {
                        listener.onFailure(e1);
                    }
                } else {
                    listener.onFailure(e);
                }
            }
        });
    } else {
        innerExecute(task, request, listener);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:35,代码来源:TransportIndexAction.java

示例14: createIndexAndMapping

import org.elasticsearch.indices.IndexAlreadyExistsException; //导入依赖的package包/类
private void createIndexAndMapping(Client client) {
    // Create the Index and Mappings before indexing the entities:
    try {
        createIndex(client, getIndexName());
        createMapping(client, getIndexName(), getMapping());
    } catch (IndexAlreadyExistsException e) {
        // No need to worry. Someone else has already initialized the Elasticsearch database...
    }
}
 
开发者ID:bytefish,项目名称:FlinkExperiments,代码行数:10,代码来源:BaseElasticSearchSink.java

示例15: createIndex

import org.elasticsearch.indices.IndexAlreadyExistsException; //导入依赖的package包/类
private void createIndex(final String type, final String indexName) {
  // 加载配置文件
  final String indexConfig = indexConfigLoader.load(type);

  // 创建索引
  try {
    client.admin().indices().prepareCreate(indexName).setSource(indexConfig).execute().actionGet();
  } catch (IndexAlreadyExistsException ex) {
    log.error("conflict while create index: {}, it's not serious.", indexName);
  }
}
 
开发者ID:Yirendai,项目名称:cicada,代码行数:12,代码来源:DayRotatedIndexManager.java


注:本文中的org.elasticsearch.indices.IndexAlreadyExistsException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。