Package com.ngdata.hbaseindexer.model.api

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


            StateWatchingZooKeeper zk = null;
            try {
                zk = new StateWatchingZooKeeper(hbaseIndexerZkHost, 30000);
                IndexerModelImpl indexerModel = new IndexerModelImpl(zk, conf.get(ConfKeys.ZK_ROOT_NODE, "/ngdata/hbaseindexer"));
                IndexerDefinition indexerDefinition = indexerModel.getIndexer(hbaseIndexerName);
                hbaseIndexerComponentFactory = indexerDefinition.getIndexerComponentFactory();
                configuration = indexerDefinition.getConfiguration();
                if (indexerDefinition.getConnectionParams() != null) {
                    indexConnectionParams.putAll(indexerDefinition.getConnectionParams());
                }
                if (zkHost == null) {
                    zkHost = indexConnectionParams.get("solr.zk");
                }
                if (collection == null) {
View Full Code Here


            throw new IndexerUpdateException("You are not owner of the indexer's lock, the lock path is: " + lock);
        }

        assertValid(indexer);

        IndexerDefinition currentIndexer = getFreshIndexer(indexer.getName());

        if (currentIndexer.getLifecycleState() == LifecycleState.DELETE_REQUESTED ||
                currentIndexer.getLifecycleState() == LifecycleState.DELETING) {
            throw new IndexerUpdateException("An indexer in state " + indexer.getLifecycleState() + " cannot be modified.");
        }

        if (indexer.getBatchIndexingState() == BatchIndexingState.BUILD_REQUESTED &&
                currentIndexer.getBatchIndexingState() != BatchIndexingState.INACTIVE &&
                currentIndexer.getBatchIndexingState() != BatchIndexingState.BUILD_REQUESTED) {
            throw new IndexerUpdateException("Cannot move batch indexing state from " + currentIndexer.getBatchIndexingState() +
                    " to " + indexer.getBatchIndexingState());
        }

        if (currentIndexer.getLifecycleState() == LifecycleState.DELETE_REQUESTED) {
            throw new IndexerUpdateException("An indexer in the state " + LifecycleState.DELETE_REQUESTED +
                    " cannot be updated.");
        }

        if (!Objects.equal(currentIndexer.getActiveBatchBuildInfo(), indexer.getActiveBatchBuildInfo())) {
            throw new IndexerUpdateException("The active batch build info cannot be modified by users.");
        }

        if (!Objects.equal(currentIndexer.getLastBatchBuildInfo(), indexer.getLastBatchBuildInfo())) {
            throw new IndexerUpdateException("The last batch build info cannot be modified by users.");
        }

        updateIndexerInternal(indexer);
View Full Code Here

    }
   
    @Test
    public void testEvaluateIndexingSpecification_PullSolrZkHostFromIndexerDefinition() throws Exception {
       
        IndexerDefinition indexerDef = new IndexerDefinitionBuilder()
                .name("customsolr")
                .configuration(Resources.toByteArray(Resources.getResource(getClass(), "user_indexer.xml")))
                .connectionParams(ImmutableMap.of(
                        "solr.zk", "myZkHost/solr",
                        "solr.collection", "mycollection"))
View Full Code Here

    }
   
    @Test
    public void testIndexingSpecification_PullSolrCollectionFromIndexerDefinition() throws Exception {

        IndexerDefinition indexerDef = new IndexerDefinitionBuilder()
                .name("customcollection")
                .configuration(Resources.toByteArray(Resources.getResource(getClass(), "user_indexer.xml")))
                .connectionParams(ImmutableMap.of(
                        "solr.zk", "myZkHost/solr",
                        "solr.collection", "mycollection"))
View Full Code Here


    @Test
    public void testEvaluateIndexingSpecification_AllFromZooKeeper() throws Exception {

        IndexerDefinition indexerDef = new IndexerDefinitionBuilder()
                .name("userindexer")
                .configuration(Resources.toByteArray(Resources.getResource(getClass(), "user_indexer.xml")))
                .connectionParams(ImmutableMap.of(
                        "solr.zk", "myZkHost/solr",
                        "solr.collection", "mycollection"))
View Full Code Here

    @Test
    public void testEvaluateIndexingSpecification_CombinationOfCmdlineAndZk() throws Exception {

        // Create an indexer -- verify INDEXER_ADDED event
        IndexerDefinition indexerDef = new IndexerDefinitionBuilder()
                .name("userindexer")
                .configuration(Resources.toByteArray(Resources.getResource(getClass(), "user_indexer.xml")))
                .connectionParams(ImmutableMap.of(
                        "solr.zk", "myZkHost/solr",
                        "solr.collection", "mycollection"))
View Full Code Here

    @Override
    public String lockIndexerInternal(String indexerName, boolean checkDeleted) throws ZkLockException,
            IndexerNotFoundException, InterruptedException, KeeperException, IndexerModelException {

        IndexerDefinition indexer = getFreshIndexer(indexerName);

        if (checkDeleted) {
            if (indexer.getLifecycleState() == LifecycleState.DELETE_REQUESTED ||
                    indexer.getLifecycleState() == LifecycleState.DELETING) {
                throw new IndexerModelException("An indexer in state " + indexer.getLifecycleState() + " cannot be locked.");
            }
        }

        final String lockPath = indexerCollectionPathSlash + indexerName + "/lock";
View Full Code Here

        ZkLock.unlock(zk, lock, ignoreMissing);
    }

    @Override
    public IndexerDefinition getIndexer(String name) throws IndexerNotFoundException {
        IndexerDefinition index = indexers.get(name);
        if (index == null) {
            throw new IndexerNotFoundException(name);
        }
        return index;
    }
View Full Code Here

         * Adds or updates the given index to the internal cache.
         */
        private void refreshIndexer(final String indexerName, List<IndexerModelEvent> events)
                throws InterruptedException, KeeperException {
            try {
                IndexerDefinition indexer = loadIndexer(indexerName, true);

                IndexerDefinition oldIndexer = indexers.get(indexerName);

                if (oldIndexer != null && oldIndexer.getOccVersion() == indexer.getOccVersion()) {
                    // nothing changed
                } else {
                    final boolean isNew = oldIndexer == null;
                    indexers.put(indexerName, indexer);
                    events.add(new IndexerModelEvent(isNew ? INDEXER_ADDED : INDEXER_UPDATED, indexerName));
View Full Code Here

       
        SOLR_ZK = "127.0.0.1:" + zkClientPort + "/solr";
        INDEXER_ZK = "localhost:" + zkClientPort;
        ZooKeeperItf zkItf = ZkUtil.connect(INDEXER_ZK, 15000);
        INDEXER_MODEL = new IndexerModelImpl(zkItf, "/ngdata/hbaseindexer");
        IndexerDefinition indexerDef = new IndexerDefinitionBuilder()
        .name("zkindexerdef")
        .indexerComponentFactory(DefaultIndexerComponentFactory.class.getName())
        .configuration(Resources.toByteArray(Resources.getResource(
                HBaseMapReduceIndexerToolDirectWriteTest.class, "user_indexer.xml")))
        .connectionParams(ImmutableMap.of(
View Full Code Here

TOP

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

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.