Package com.ngdata.hbaseindexer.model.api

Examples of com.ngdata.hbaseindexer.model.api.IndexerValidityException


    }

    private void assertValid(IndexerDefinition indexer) throws IndexerValidityException {
        if (indexer.getName() == null || indexer.getName().length() == 0)
            throw new IndexerValidityException("Name should not be null or zero-length");

        if (indexer.getConfiguration() == null)
            throw new IndexerValidityException("Configuration should not be null.");

        if (indexer.getLifecycleState() == null)
            throw new IndexerValidityException("General state should not be null.");

        if (indexer.getBatchIndexingState() == null)
            throw new IndexerValidityException("Build state should not be null.");

        if (indexer.getIncrementalIndexingState() == null)
            throw new IndexerValidityException("Update state should not be null.");

        // TODO FIXME disabled this code (after copying from Lily)
//       boolean hasShards = index.getSolrShards() != null && !index.getSolrShards().isEmpty();
//       boolean hasCollection = index.getSolrCollection() != null;
//       boolean hasZkConnectionString = index.getZkConnectionString() != null && !index.getZkConnectionString().isEmpty();
//
//       if (hasCollection && hasShards) {
//           throw new IndexValidityException("Ambiguous solr configuration in index defintion. Setting a solr " +
//                   "collection together with solr shards has no use. Set either the solr shards or collection.");
//       }
//
//       if (hasShards && hasZkConnectionString) {
//           throw new IndexValidityException("Ambiguous solr configuration in index defintion. Setting a solr " +
//                   "zookeeper connection together with solr shards has no use. Set either the solr shards or " +
//                   "zookeeper connection.");
//       }
//       if (!hasShards && !hasZkConnectionString) {
//           throw new IndexValidityException("Incomplete solr configuration in index defintion. You need at least " +
//                   "a shard or a zookeeper connection string.");
//       }

//        for (String shard : index.getSolrShards().values()) {
//            try {
//                URI uri = new URI(shard);
//                if (!uri.isAbsolute()) {
//                    throw new IndexValidityException("Solr shard URI is not absolute: " + shard);
//                }
//            } catch (URISyntaxException e) {
//                throw new IndexValidityException("Invalid Solr shard URI: " + shard);
//            }
//        }

        // TODO FIXME disabled this code (after copying from Lily)
//        if (index.getShardingConfiguration() != null) {
//            // parse it + check used shards -> requires dependency on the engine or moving the relevant classes
//            // to the model
//            ShardSelector selector;
//            try {
//                selector = JsonShardSelectorBuilder.build(index.getShardingConfiguration());
//            } catch (ShardingConfigException e) {
//                throw new IndexValidityException("Error with sharding configuration.", e);
//            }
//
//            Set<String> shardNames = index.getSolrShards().keySet();
//
//            for (String shard : selector.getShards()) {
//                if (!shardNames.contains(shard)) {
//                    throw new IndexValidityException("The sharding configuration refers to a shard that is not" +
//                    " in the set of available shards. Shard: " + shard);
//                }
//            }
//        }
//
//        try {
//            IndexerConfBuilder.validate(new ByteArrayInputStream(index.getConfiguration()));
//        } catch (IndexerConfException e) {
//            throw new IndexValidityException("The indexer configuration is not XML well-formed or valid.", e);
//        }
//
        if (indexer.getBatchIndexCliArguments() != null && indexer.getBatchIndexingState() !=
                BatchIndexingState.BUILD_REQUESTED) {
            throw new IndexerValidityException("The build state must be set to BUILD_REQUESTED when setting batchIndexCliArguments");
        }
    }
View Full Code Here

TOP

Related Classes of com.ngdata.hbaseindexer.model.api.IndexerValidityException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.