Example usage for org.apache.solr.client.solrj.response ConfigSetAdminResponse getErrorMessages

List of usage examples for org.apache.solr.client.solrj.response ConfigSetAdminResponse getErrorMessages

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj.response ConfigSetAdminResponse getErrorMessages.

Prototype

@SuppressWarnings("unchecked")
    public NamedList<String> getErrorMessages() 

Source Link

Usage

From source file:org.wso2.extension.siddhi.store.solr.impl.SolrClientServiceImpl.java

License:Open Source License

public boolean initCollection(CollectionConfiguration config) throws SolrClientServiceException {
    String table = config.getCollectionName();
    String tableNameWithDomain = SolrTableUtils.getCollectionNameWithDomainName(config.getDomainName(), table);
    initSolrClientForTable(config);/*from   w ww  . jav  a  2 s. c om*/
    try {
        if (!collectionExists(table)) {
            if (!collectionConfigExists(table)) {
                ConfigSetAdminResponse configSetResponse = createInitialSolrCollectionConfig(config);
                Object errors = configSetResponse.getErrorMessages();
                if (configSetResponse.getStatus() == 0 && errors == null) {
                    return createSolrCollection(tableNameWithDomain, config);
                } else {
                    throw new SolrClientServiceException("Error in deploying initial solr configset for "
                            + "table: " + tableNameWithDomain + ", Response code: "
                            + configSetResponse.getStatus() + " , errors: " + errors.toString());
                }
            } else {
                return createSolrCollection(tableNameWithDomain, config);
            }
        } else {
            return false;
        }
    } catch (SolrServerException | IOException | SolrException e) {
        throw new SolrClientServiceException(
                "error while creating the index for table: " + table + " error: " + e.getMessage(), e);
    }
}

From source file:org.wso2.extension.siddhi.store.solr.impl.SolrClientServiceImpl.java

License:Open Source License

public boolean deleteCollection(String table) throws SolrClientServiceException {
    try {/* w  w  w. j  a va2s  .  com*/
        if (collectionExists(table)) {
            SiddhiSolrClient client = getSolrServiceClientByCollection(table);
            CollectionConfiguration configuration = tableToConfigMapping.get(table);
            if (configuration == null) {
                throw new SolrClientServiceException(
                        "Configuration is not set for table: " + table + ", call initCollection() first");
            }
            String tableNameWithDomain = SolrTableUtils
                    .getCollectionNameWithDomainName(configuration.getDomainName(), table);
            CollectionAdminRequest.Delete deleteRequest = CollectionAdminRequest
                    .deleteCollection(tableNameWithDomain);
            CollectionAdminResponse deleteRequestResponse = deleteRequest.process(client, tableNameWithDomain);
            if (deleteRequestResponse.isSuccess() && collectionConfigExists(table)) {
                ConfigSetAdminRequest.Delete configSetAdminRequest = new ConfigSetAdminRequest.Delete();
                configSetAdminRequest.setConfigSetName(tableNameWithDomain);
                ConfigSetAdminResponse configSetResponse = configSetAdminRequest.process(client);
                Object errors = configSetResponse.getErrorMessages();
                if (configSetResponse.getStatus() == 0 && errors == null) {
                    tableToConfigMapping.remove(table);
                    return tryToCloseClient(configuration);
                } else {
                    throw new SolrClientServiceException(
                            "Error in deleting index for table: " + table + ", " + ", Response code: "
                                    + configSetResponse.getStatus() + " , errors: " + errors.toString());
                }
            }
        }
    } catch (IOException | SolrServerException | SolrException e) {
        log.error("error while deleting the index for table: " + table + ": " + e.getMessage(), e);
        throw new SolrClientServiceException(
                "error while deleting the index for table: " + table + ", error: " + e.getMessage(), e);
    }
    return false;
}