Examples of WriteableIndexerModel


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

    @Test
    public void testLocking() throws Exception {
        ZooKeeperItf zk1 = ZkUtil.connect("localhost:" + ZK_CLIENT_PORT, 15000);
        ZooKeeperItf zk2 = ZkUtil.connect("localhost:" + ZK_CLIENT_PORT, 15000);
        WriteableIndexerModel model1 = null;
        WriteableIndexerModel model2 = null;
        String indexerName = "lock_test_indexer";
        try {
            model1 = new IndexerModelImpl(zk1, "/test");
            model2 = new IndexerModelImpl(zk2, "/test");

            // Create an index
            IndexerDefinition indexer1 = new IndexerDefinitionBuilder()
                    .name(indexerName)
                    .configuration("foo".getBytes(Charsets.UTF_8))
                    .build();
            model1.addIndexer(indexer1);

            // Lock the index via the first client
            String lock = model1.lockIndexer(indexerName);

            // Try to update it via the second client
            indexer1 = new IndexerDefinitionBuilder()
                    .startFrom(indexer1)
                    .configuration("foo1".getBytes(Charsets.UTF_8))
                    .build();

            try {
                model2.updateIndexer(indexer1, lock + "foo");
                fail("Expected exception");
            } catch (IndexerUpdateException e) {
                // verify the exception says something about locks
                assertTrue(e.getMessage().contains("lock"));
            }
View Full Code Here

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

        //
        if (System.getProperty("os.name").startsWith("Windows")) {
            System.out.println("Skipping the Batch index build scenario since this does not work under Windows.");
        } else {
            // Disable incremental index updating
            WriteableIndexerModel indexerModel = lilyProxy.getLilyServerProxy().getIndexerModel();
            String lock = indexerModel.lockIndexer(indexName);
            String subscriptionId;
            try {
                IndexerDefinition index = indexerModel.getIndexer(indexName);
                subscriptionId = index.getSubscriptionId();

                indexerModel.updateIndexer(new IndexerDefinitionBuilder()
                        .startFrom(index)
                        .incrementalIndexingState(IndexerDefinition.IncrementalIndexingState.DO_NOT_SUBSCRIBE)
                        .build(), lock);
            } finally {
                indexerModel.unlockIndexer(lock);
            }

            lilyProxy.getHBaseProxy().waitOnReplicationPeerStopped(subscriptionId);

            // Create record
View Full Code Here

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

     *                               the index, this is important for synchronous indexing.
     */
    public void addIndex(IndexerDefinition indexerDefinition, long timeout,
                         boolean waitForIndexerModel, boolean waitForSep, boolean waitForIndexerRegistry) throws Exception {
        long tryUntil = System.currentTimeMillis() + timeout;
        WriteableIndexerModel indexerModel = getIndexerModel();
        indexerModel.addIndexer(indexerDefinition);

        if (waitForIndexerModel) {
            // Wait for subscriptionId to be known by indexerModel
            String subscriptionId = waitOnIndexSubscriptionId(indexerDefinition.getName(), tryUntil, timeout);
            if (subscriptionId == null) {
View Full Code Here

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

    public String waitOnIndexSubscriptionId(String indexName, long timeout) throws Exception {
        return waitOnIndexSubscriptionId(indexName, System.currentTimeMillis() + timeout, timeout);
    }

    private String waitOnIndexSubscriptionId(String indexName, long tryUntil, long timeout) throws Exception {
        WriteableIndexerModel indexerModel = getIndexerModel();
        String subscriptionId = null;

        // Wait for index to be known by indexerModel
        while (!indexerModel.hasIndexer(indexName) && System.currentTimeMillis() < tryUntil) {
            Thread.sleep(10);
        }
        if (!indexerModel.hasIndexer(indexName)) {
            log.info("Index '" + indexName + "' not known to indexerModel within " + timeout + "ms");
            return subscriptionId;
        }

        IndexerDefinition indexDefinition = indexerModel.getIndexer(indexName);
        subscriptionId = indexDefinition.getSubscriptionId();
        while (subscriptionId == null && System.currentTimeMillis() < tryUntil) {
            Thread.sleep(10);
            subscriptionId = indexerModel.getIndexer(indexName).getSubscriptionId();
        }
        if (subscriptionId == null) {
            log.info("SubscriptionId for index '" + indexName + "' not known to indexerModel within " + timeout + "ms");
        }
        return subscriptionId;
View Full Code Here

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

     *                  will return as soon as the batch indexing is finished, it is only in case something goes
     *                  wrong that this timeout will prevent endless hanging. An exception is thrown in case
     *                  the batch indexing did not finish within this timeout.
     */
    public void batchBuildIndex(String indexName, String[] batchCliArgs, long timeOut) throws Exception {
        WriteableIndexerModel model = getIndexerModel();

        try {
            String lock = model.lockIndexer(indexName);
            try {
                IndexerDefinition index = model.getIndexer(indexName);
                IndexerDefinitionBuilder builder = new IndexerDefinitionBuilder()
                        .startFrom(index)
                        .batchIndexingState(IndexerDefinition.BatchIndexingState.BUILD_REQUESTED)
                        .batchIndexCliArguments(batchCliArgs);
                model.updateIndexer(builder.build(), lock);
            } finally {
                model.unlockIndexer(lock);
            }
        } catch (Exception e) {
            throw new Exception("Error launching batch index build.", e);
        }

        try {
            // Now wait until its finished
            long tryUntil = System.currentTimeMillis() + timeOut;
            while (System.currentTimeMillis() < tryUntil) {
                Thread.sleep(100);
                IndexerDefinition definition = model.getIndexer(indexName);

                if (definition.getBatchIndexingState() == IndexerDefinition.BatchIndexingState.INACTIVE) {
                    Long amountFailed = null;
                    //Long amountFailed = definition.getLastBatchBuildInfo().getCounters().get(COUNTER_NUM_FAILED_RECORDS);
                    boolean successFlag = definition.getLastBatchBuildInfo().isFinishedSuccessful();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.