Github user peterj99a commented on a diff in the pull request:

    https://github.com/apache/usergrid/pull/584#discussion_r150619585
  
    --- Diff: 
stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/direct/DirectFirstEventServiceImpl.java
 ---
    @@ -0,0 +1,194 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.usergrid.corepersistence.asyncevents.direct;
    +
    +import 
org.apache.usergrid.corepersistence.asyncevents.AsyncEventServiceImpl;
    +import org.apache.usergrid.corepersistence.asyncevents.EventBuilder;
    +import 
org.apache.usergrid.corepersistence.asyncevents.model.ElasticsearchIndexEvent;
    +import 
org.apache.usergrid.corepersistence.index.IndexLocationStrategyFactory;
    +import org.apache.usergrid.corepersistence.index.IndexProcessorFig;
    +import 
org.apache.usergrid.corepersistence.index.settings.QueueIndexingStrategy;
    +import 
org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
    +import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
    +import org.apache.usergrid.persistence.core.rx.RxTaskScheduler;
    +import org.apache.usergrid.persistence.index.EntityIndexFactory;
    +import org.apache.usergrid.persistence.index.impl.IndexOperationMessage;
    +import org.apache.usergrid.persistence.index.impl.IndexProducer;
    +import org.apache.usergrid.persistence.map.MapManagerFactory;
    +import org.apache.usergrid.persistence.queue.LegacyQueueFig;
    +import org.apache.usergrid.persistence.queue.LegacyQueueManagerFactory;
    +import org.apache.usergrid.persistence.queue.LegacyQueueMessage;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.io.Serializable;
    +import java.util.ArrayList;
    +import java.util.List;
    +import java.util.UUID;
    +import java.util.stream.Collectors;
    +
    +/**
    + * Implementation of the AsyncEventService that writes first directly to ES
    + * and then submits to ASW as a backup.
    + *
    + * Created by peterajohnson on 8/29/17.
    + */
    +public class DirectFirstEventServiceImpl extends AsyncEventServiceImpl {
    +
    +
    +    private static final Logger logger = 
LoggerFactory.getLogger(DirectFirstEventServiceImpl.class);
    +
    +    private boolean indexDebugMode = false;
    +    private QueueIndexingStrategy configQueueIndexingStrategy = 
QueueIndexingStrategy.ASYNC;
    +
    +    private BufferedQueue<Serializable> bufferedBatchQueue = new 
BufferedQueueNOP<>();
    +
    +    public DirectFirstEventServiceImpl(LegacyQueueManagerFactory 
queueManagerFactory, IndexProcessorFig indexProcessorFig, IndexProducer 
indexProducer, MetricsFactory metricsFactory, EntityCollectionManagerFactory 
entityCollectionManagerFactory, IndexLocationStrategyFactory 
indexLocationStrategyFactory, EntityIndexFactory entityIndexFactory, 
EventBuilder eventBuilder, MapManagerFactory mapManagerFactory, LegacyQueueFig 
queueFig, RxTaskScheduler rxTaskScheduler) {
    +        super(queueManagerFactory, indexProcessorFig, indexProducer, 
metricsFactory, entityCollectionManagerFactory, indexLocationStrategyFactory, 
entityIndexFactory, eventBuilder, mapManagerFactory, queueFig, rxTaskScheduler);
    +
    +        //bufferedBatchQueue = new BufferedQueueImpl<>(5000, 100, 
TimeUnit.MILLISECONDS);
    +        bufferedBatchQueue.setConsumer((c) -> { dispatchToES(c); });
    +
    +        configQueueIndexingStrategy = 
QueueIndexingStrategy.get(queueFig.getQueueStrategy());
    +
    +        indexDebugMode = Boolean.valueOf(queueFig.getQueueDebugMode());
    +
    +    }
    +
    +    protected void dispatchToES(final List<Serializable> bodies) {
    +
    +        List<LegacyQueueMessage> messages = new ArrayList<>();
    +        for (Serializable body : bodies) {
    +            String uuid = UUID.randomUUID().toString();
    +            LegacyQueueMessage message = new LegacyQueueMessage(uuid, 
"handle_" + uuid, body, "put type here");
    --- End diff --
    
    Yeah the "put type here" was in the original implementation.  I just copied 
it over to keep it the same


---

Reply via email to