当前位置: 首页>>代码示例>>Java>>正文


Java RingBuffer.publish方法代码示例

本文整理汇总了Java中com.lmax.disruptor.RingBuffer.publish方法的典型用法代码示例。如果您正苦于以下问题:Java RingBuffer.publish方法的具体用法?Java RingBuffer.publish怎么用?Java RingBuffer.publish使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.lmax.disruptor.RingBuffer的用法示例。


在下文中一共展示了RingBuffer.publish方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: channelRead0

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, O msg) throws Exception {
    UUID uuid = CHANNEL_UUID.get(ctx.channel());
    if (null != uuid) {
        NetSession session = SESSIONS.get(uuid);
        if (null != session) {
            RingBuffer<ConcurrentEvent> ringBuffer = THREAD_LOCAL.get().getRingBuffer();
            long next = ringBuffer.next();
            try {
                ConcurrentEvent commandEvent = ringBuffer.get(next);
                commandEvent.setValues(newExecutor(session, msg));
            } finally {
                ringBuffer.publish(next);
            }
        }
    }
}
 
开发者ID:ogcs,项目名称:Okra-Ax,代码行数:18,代码来源:DisruptorAdapterHandler.java

示例2: channelRead0

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, O msg) throws Exception {
    UUID uuid = CHANNEL_UUID.get(ctx.channel());
    if (null != uuid) {
        Session session = SESSIONS.get(uuid);
        if (null != session) {
            RingBuffer<ConcurrentEvent> ringBuffer = THREAD_LOCAL.get().getRingBuffer();
            long next = ringBuffer.next();
            try {
                ConcurrentEvent commandEvent = ringBuffer.get(next);
                commandEvent.setValues(newExecutor(session, msg));
            } finally {
                ringBuffer.publish(next);
            }
        }
    }
}
 
开发者ID:ogcs,项目名称:Okra,代码行数:18,代码来源:DisruptorAdapterHandler.java

示例3: stampSequenceIdAndPublishToRingBuffer

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
protected final long stampSequenceIdAndPublishToRingBuffer(RegionInfo hri, WALKeyImpl key,
    WALEdit edits, boolean inMemstore, RingBuffer<RingBufferTruck> ringBuffer)
    throws IOException {
  if (this.closed) {
    throw new IOException(
        "Cannot append; log is closed, regionName = " + hri.getRegionNameAsString());
  }
  MutableLong txidHolder = new MutableLong();
  MultiVersionConcurrencyControl.WriteEntry we = key.getMvcc().begin(() -> {
    txidHolder.setValue(ringBuffer.next());
  });
  long txid = txidHolder.longValue();
  try (TraceScope scope = TraceUtil.createTrace(implClassName + ".append")) {
    FSWALEntry entry = new FSWALEntry(txid, key, edits, hri, inMemstore);
    entry.stampRegionSequenceId(we);
    ringBuffer.get(txid).load(entry);
  } finally {
    ringBuffer.publish(txid);
  }
  return txid;
}
 
开发者ID:apache,项目名称:hbase,代码行数:22,代码来源:AbstractFSWAL.java

示例4: synchronousFire

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
public void synchronousFire( final Object event ) {
    eventCount.increment();
    CountDownLatch latch = new CountDownLatch( handlers.size() );
    try {
        RingBuffer<StatisticEventHolder> ringBuffer = disruptor.getRingBuffer();
        long sequence = ringBuffer.next();
        try {
            StatisticEventHolder holder = ringBuffer.get( sequence );
            holder.set( event );
            holder.setLatch( latch );
        } finally {
            ringBuffer.publish( sequence );
        }
        latch.await();
    } catch ( InterruptedException e ) {
        return;
    }
}
 
开发者ID:Tetha,项目名称:bifroest,代码行数:20,代码来源:DisruptorEventBus.java

示例5: channelRead0

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, GpcCall msg) throws Exception {
    NetSession session = NET_SESSION_MAP.get(ctx.channel().id());
    if (null == session)
        return;
    RingBuffer<ConcurrentEvent> ringBuffer = THREAD_LOCAL.get().getRingBuffer();
    long next = ringBuffer.next();
    try {
        ConcurrentEvent commandEvent = ringBuffer.get(next);
        commandEvent.setValues(newExecutor(session, msg));
    } finally {
        ringBuffer.publish(next);
    }
}
 
开发者ID:ogcs,项目名称:Okra-Ax,代码行数:15,代码来源:GpcEventDispatcher.java

示例6: channelRead0

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, O msg) throws Exception {
    NetSession session = SESSIONS.get(ctx.channel().id());
    if (null == session) {
        return;
    }
    RingBuffer<ConcurrentEvent> ringBuffer = THREAD_LOCAL.get().getRingBuffer();
    long next = ringBuffer.next();
    try {
        ConcurrentEvent commandEvent = ringBuffer.get(next);
        commandEvent.setValues(newExecutor(session, msg));
    } finally {
        ringBuffer.publish(next);
    }
}
 
开发者ID:ogcs,项目名称:Okra-Ax,代码行数:16,代码来源:DisruptorAdapterBy41xHandler.java

示例7: runDisruptorPass

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
protected long runDisruptorPass() throws InterruptedException
{
    final CountDownLatch latch = new CountDownLatch(1);
    long expectedCount = batchEventProcessor.getSequence().get() + ITERATIONS * BATCH_SIZE;
    handler.reset(latch, expectedCount);
    executor.submit(batchEventProcessor);
    long start = System.currentTimeMillis();

    final RingBuffer<ValueEvent> rb = ringBuffer;

    for (long i = 0; i < ITERATIONS; i++)
    {
        long hi = rb.next(BATCH_SIZE);
        long lo = hi - (BATCH_SIZE - 1);
        for (long l = lo; l <= hi; l++)
        {
            rb.get(l).setValue(i);
        }
        rb.publish(lo, hi);
    }

    latch.await();
    long opsPerSecond = (BATCH_SIZE * ITERATIONS * 1000L) / (System.currentTimeMillis() - start);
    waitForEventProcessorSequence(expectedCount);
    batchEventProcessor.halt();

    failIfNot(expectedResult, handler.getValue());

    return opsPerSecond;
}
 
开发者ID:winwill2012,项目名称:disruptor-code-analysis,代码行数:32,代码来源:OneToOneSequencedBatchThroughputTest.java

示例8: runDisruptorPass

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
protected long runDisruptorPass() throws InterruptedException
{
    final CountDownLatch latch = new CountDownLatch(1);
    long expectedCount = poller.getSequence().get() + ITERATIONS;
    pollRunnable.reset(latch, expectedCount);
    executor.submit(pollRunnable);
    long start = System.currentTimeMillis();

    final RingBuffer<ValueEvent> rb = ringBuffer;

    for (long i = 0; i < ITERATIONS; i++)
    {
        long next = rb.next();
        rb.get(next).setValue(i);
        rb.publish(next);
    }

    latch.await();
    long opsPerSecond = (ITERATIONS * 1000L) / (System.currentTimeMillis() - start);
    waitForEventProcessorSequence(expectedCount);
    pollRunnable.halt();

    failIfNot(expectedResult, pollRunnable.getValue());

    return opsPerSecond;
}
 
开发者ID:winwill2012,项目名称:disruptor-code-analysis,代码行数:28,代码来源:OneToOneSequencedPollerThroughputTest.java

示例9: runDisruptorPass

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
protected long runDisruptorPass() throws InterruptedException
{
    final CountDownLatch latch = new CountDownLatch(1);
    long expectedCount = batchEventProcessor.getSequence().get() + ITERATIONS;
    handler.reset(latch, expectedCount);
    executor.submit(batchEventProcessor);
    long start = System.currentTimeMillis();

    final RingBuffer<ValueEvent> rb = ringBuffer;

    for (long i = 0; i < ITERATIONS; i++)
    {
        long next = rb.next();
        rb.get(next).setValue(i);
        rb.publish(next);
    }

    latch.await();
    long opsPerSecond = (ITERATIONS * 1000L) / (System.currentTimeMillis() - start);
    waitForEventProcessorSequence(expectedCount);
    batchEventProcessor.halt();

    failIfNot(expectedResult, handler.getValue());

    return opsPerSecond;
}
 
开发者ID:winwill2012,项目名称:disruptor-code-analysis,代码行数:28,代码来源:OneToOneSequencedThroughputTest.java

示例10: runDisruptorPass

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
protected long runDisruptorPass() throws InterruptedException
{
    final CountDownLatch latch = new CountDownLatch(1);
    long expectedCount = batchEventProcessor.getSequence().get() + ITERATIONS;
    handler.reset(latch, ITERATIONS);
    executor.submit(batchEventProcessor);
    long start = System.currentTimeMillis();

    final RingBuffer<long[]> rb = ringBuffer;

    for (long i = 0; i < ITERATIONS; i++)
    {
        long next = rb.next();
        long[] event = rb.get(next);
        for (int j = 0; j < event.length; j++)
        {
            event[j] = i;
        }
        rb.publish(next);
    }

    latch.await();
    long opsPerSecond = (ITERATIONS * ARRAY_SIZE * 1000L) / (System.currentTimeMillis() - start);
    waitForEventProcessorSequence(expectedCount);
    batchEventProcessor.halt();

    PerfTestUtil.failIf(0, handler.getValue());

    return opsPerSecond;
}
 
开发者ID:winwill2012,项目名称:disruptor-code-analysis,代码行数:32,代码来源:OneToOneSequencedLongArrayThroughputTest.java

示例11: runDisruptorPass

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
@Override
protected long runDisruptorPass() throws Exception
{
    byte[] data = this.data;

    final CountDownLatch latch = new CountDownLatch(1);
    long expectedCount = processor.getSequence().get() + ITERATIONS;
    handler.reset(latch, ITERATIONS);
    executor.execute(processor);
    long start = System.currentTimeMillis();

    final RingBuffer<ByteBuffer> rb = buffer;

    for (long i = 0; i < ITERATIONS; i++)
    {
        long next = rb.next();
        ByteBuffer event = rb.get(next);
        event.clear();
        event.put(data);
        event.flip();
        rb.publish(next);
    }

    latch.await();
    long opsPerSecond = (ITERATIONS * 1000L) / (System.currentTimeMillis() - start);
    waitForEventProcessorSequence(expectedCount);
    processor.halt();

    return opsPerSecond;
}
 
开发者ID:winwill2012,项目名称:disruptor-code-analysis,代码行数:31,代码来源:OneToOneOnHeapThroughputTest.java

示例12: publish

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
/**
 * Publish record task to record special table's log.
 *
 * @param struct The table struct.
 * @param list   The log data list.
 */
public void publish(Struct struct, List<String[]> list) {
    RingBuffer<LogRecordTask> rb = disruptor.getRingBuffer();
    long next = rb.next();
    try {
        LogRecordTask event = rb.get(next);
        event.setValues(struct, list);
    } finally {
        rb.publish(next);
    }
}
 
开发者ID:ogcs,项目名称:Okra-LOG,代码行数:17,代码来源:MissionBoard.java

示例13: onNext

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
public static <E> void onNext(E value, RingBuffer<MutableSignal<E>> ringBuffer) {
  if (value == null) {
    throw SpecificationExceptions.spec_2_13_exception();
  }

  final long seqId = ringBuffer.next();
  final MutableSignal<E> signal = ringBuffer.get(seqId);
  signal.type = MutableSignal.Type.NEXT;
  signal.value = value;

  ringBuffer.publish(seqId);
}
 
开发者ID:camunda,项目名称:camunda-bpm-reactor,代码行数:13,代码来源:RingBufferSubscriberUtils.java

示例14: onError

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
public static <E> void onError(Throwable error, RingBuffer<MutableSignal<E>> ringBuffer) {
  if (error == null) {
    throw SpecificationExceptions.spec_2_13_exception();
  }

  final long seqId = ringBuffer.next();
  final MutableSignal<E> signal = ringBuffer.get(seqId);

  signal.type = MutableSignal.Type.ERROR;
  signal.value = null;
  signal.error = error;

  ringBuffer.publish(seqId);
}
 
开发者ID:camunda,项目名称:camunda-bpm-reactor,代码行数:15,代码来源:RingBufferSubscriberUtils.java

示例15: onComplete

import com.lmax.disruptor.RingBuffer; //导入方法依赖的package包/类
public static <E> void onComplete(RingBuffer<MutableSignal<E>> ringBuffer) {
  final long seqId = ringBuffer.next();
  final MutableSignal<E> signal = ringBuffer.get(seqId);

  signal.type = MutableSignal.Type.COMPLETE;
  signal.value = null;
  signal.error = null;

  ringBuffer.publish(seqId);
}
 
开发者ID:camunda,项目名称:camunda-bpm-reactor,代码行数:11,代码来源:RingBufferSubscriberUtils.java


注:本文中的com.lmax.disruptor.RingBuffer.publish方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。