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

    https://github.com/apache/storm/pull/2241#discussion_r129496848
  
    --- Diff: storm-client/src/jvm/org/apache/storm/utils/JCQueue.java ---
    @@ -0,0 +1,324 @@
    +/*
    + * 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.storm.utils;
    +
    +// TODO: Add metrics to count how often consume() sees empty Q, publish() 
fails, avg consume count, avg batch size for flush() on flushTuple
    +// TODO: Document topology.producer.batch.size, 
topology.flush.tuple.freq.millis & deprecations, topology.spout.recvq.skips
    +// TODO: During back pressure... should update metrics
    +// TODO: Remove return 1L in Worker.java. Need a yield strategy if recvQ 
is empty (topology.disruptor.wait.timeout.millis ?)
    +// TODO: Need a yield strategy if outQ is full.
    +// TODO: Remove max.spout.pending
    +
    +import org.apache.storm.metric.api.IStatefulObject;
    +import org.apache.storm.metric.internal.RateTracker;
    +import org.jctools.queues.ConcurrentCircularArrayQueue;
    +import org.jctools.queues.MessagePassingQueue;
    +import org.jctools.queues.MpscArrayQueue;
    +import org.jctools.queues.SpscArrayQueue;
    +
    +import java.util.ArrayList;
    +import java.util.HashMap;
    +
    +
    +public final class JCQueue implements IStatefulObject {
    +
    +    public enum ProducerKind { SINGLE, MULTI };
    +
    +    public static final Object INTERRUPT = new Object();
    +
    +    private ThroughputMeter emptyMeter = new ThroughputMeter("EmptyBatch");
    +
    +    private interface Inserter {
    +        // blocking call that can be interrupted with Thread.interrupt()
    +        void add(Object obj) throws InterruptedException ;
    +        void flush() throws InterruptedException ;
    +    }
    +
    +    /* Thread safe. Same instance can be used across multiple threads */
    +    private static class DirectInserter implements Inserter {
    +        private JCQueue q;
    +
    +        public DirectInserter(JCQueue q) {
    +            this.q = q;
    +        }
    +
    +        /** Blocking call, that can be interrupted via Thread.interrupt */
    +        @Override
    +        public void add(Object obj) throws InterruptedException {
    +            boolean inserted = q.publishInternal(obj);
    +            while(!inserted) {
    +                Thread.yield();
    --- End diff --
    
    It may be better to busy spin for few times and then yield.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to