ringbuffer java例子_Java RingBuffer.publish方法代碼示例「建议收藏」

ringbuffer java例子_Java RingBuffer.publish方法代碼示例「建议收藏」本文整理匯總了Java中com.lmax.disruptor.RingBuffer.publish方法的典型用法代碼示例。如果您正苦於以下問題:JavaRingBuffer.publish方法的具體用法?JavaRingBuffer.publish怎麽用?JavaRingBuffer.publish使用的例子?那麽恭喜您,這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

本文整理匯總了Java中com.lmax.disruptor.RingBuffer.publish方法的典型用法代碼示例。如果您正苦於以下問題:Java RingBuffer.publish方法的具體用法?Java RingBuffer.publish怎麽用?Java RingBuffer.publish使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.lmax.disruptor.RingBuffer的用法示例。

在下文中一共展示了RingBuffer.publish方法的23個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

示例1: channelRead0

​點讚 3

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 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,

示例2: channelRead0

​點讚 3

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 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,

示例3: stampSequenceIdAndPublishToRingBuffer

​點讚 3

import com.lmax.disruptor.RingBuffer; //導入方法依賴的package包/類

protected final long stampSequenceIdAndPublishToRingBuffer(RegionInfo hri, WALKeyImpl key,

WALEdit edits, boolean inMemstore, RingBuffer 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,

示例4: synchronousFire

​點讚 3

import com.lmax.disruptor.RingBuffer; //導入方法依賴的package包/類

@Override

public void synchronousFire( final Object event ) {

eventCount.increment();

CountDownLatch latch = new CountDownLatch( handlers.size() );

try {

RingBuffer 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,

示例5: channelRead0

​點讚 2

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 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,

示例6: channelRead0

​點讚 2

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 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,

示例7: runDisruptorPass

​點讚 2

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 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,

示例8: runDisruptorPass

​點讚 2

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 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,

示例9: runDisruptorPass

​點讚 2

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 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,

示例10: runDisruptorPass

​點讚 2

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 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,

示例11: runDisruptorPass

​點讚 2

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 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,

示例12: publish

​點讚 2

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 list) {

RingBuffer 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,

示例13: onNext

​點讚 2

import com.lmax.disruptor.RingBuffer; //導入方法依賴的package包/類

public static void onNext(E value, RingBuffer> ringBuffer) {

if (value == null) {

throw SpecificationExceptions.spec_2_13_exception();

}

final long seqId = ringBuffer.next();

final MutableSignal signal = ringBuffer.get(seqId);

signal.type = MutableSignal.Type.NEXT;

signal.value = value;

ringBuffer.publish(seqId);

}

開發者ID:camunda,項目名稱:camunda-bpm-reactor,代碼行數:13,

示例14: onError

​點讚 2

import com.lmax.disruptor.RingBuffer; //導入方法依賴的package包/類

public static void onError(Throwable error, RingBuffer> ringBuffer) {

if (error == null) {

throw SpecificationExceptions.spec_2_13_exception();

}

final long seqId = ringBuffer.next();

final MutableSignal signal = ringBuffer.get(seqId);

signal.type = MutableSignal.Type.ERROR;

signal.value = null;

signal.error = error;

ringBuffer.publish(seqId);

}

開發者ID:camunda,項目名稱:camunda-bpm-reactor,代碼行數:15,

示例15: onComplete

​點讚 2

import com.lmax.disruptor.RingBuffer; //導入方法依賴的package包/類

public static void onComplete(RingBuffer> ringBuffer) {

final long seqId = ringBuffer.next();

final MutableSignal signal = ringBuffer.get(seqId);

signal.type = MutableSignal.Type.COMPLETE;

signal.value = null;

signal.error = null;

ringBuffer.publish(seqId);

}

開發者ID:camunda,項目名稱:camunda-bpm-reactor,代碼行數:11,

示例16: process

​點讚 2

import com.lmax.disruptor.RingBuffer; //導入方法依賴的package包/類

public void process() throws IOException {

try (FastBufferedInputStream stream = new FastBufferedInputStream(inputStreamFactory.get())) {

Preconditions.checkArgument(phaser.getRegisteredParties() == 0);

phaser.register();

disruptor.start();

RingBuffer extends TwoPhaseEvent> ringBuffer = disruptor.getRingBuffer();

long cursor = ringBuffer.next();

LineBytesBuffer buffer = ringBuffer.get(cursor).input();

long lineNo = 0;

ringBuffer.get(cursor).lineNo(lineNo);

boolean needToSkipNext = skipFirst;

while (buffer.readLineFrom(stream)) {

if (needToSkipNext) {

needToSkipNext = false;

continue;

}

lineNo++;

ringBuffer.publish(cursor);

cursor = ringBuffer.next();

buffer = ringBuffer.get(cursor).input();

ringBuffer.get(cursor).lineNo(lineNo);

}

disruptor.shutdown();

phaser.arriveAndAwaitAdvance();

phaser.arriveAndDeregister();

} finally {

afterDisruptorProcessed();

}

}

開發者ID:scaled-ml,項目名稱:Scaled-ML,代碼行數:30,

示例17: main

​點讚 2

import com.lmax.disruptor.RingBuffer; //導入方法依賴的package包/類

public static void main(String[] args) {

final List handlers = new ArrayList<>(NUMBER_CONSUMERS);

RingBuffer ringBuffer = RingBuffer.createSingleProducer(

ValueEvent.EVENT_FACTORY, RING_SIZE, new SleepingWaitStrategy());

start = System.nanoTime();

//Create consumers

for(int i = 0; i < NUMBER_CONSUMERS; i++) {

ValueEventHandler1PMC handler = new ValueEventHandler1PMC(start, handlers);

handlers.add(handler);

SequenceBarrier barrier = ringBuffer.newBarrier();

BatchEventProcessor eventProcessor = new BatchEventProcessor(

ringBuffer,barrier, handler);

ringBuffer.addGatingSequences(eventProcessor.getSequence());

// Each EventProcessor can run on a separate thread

EXECUTOR.submit(eventProcessor);

}

for(int i = 0; i < SAMPLES_SIZE; i++) {

// Publishers claim events in sequence

long sequence = ringBuffer.next();

ValueEvent event = ringBuffer.get(sequence);

event.setValue(i); // this could be more complex with multiple fields

// make the event available to EventProcessors

ringBuffer.publish(sequence);

}

}

開發者ID:iproduct,項目名稱:low-latency-high-throughput,代碼行數:35,

示例18: channelRead0

​點讚 2

import com.lmax.disruptor.RingBuffer; //導入方法依賴的package包/類

@Override

protected void channelRead0(ChannelHandlerContext ctx, O msg) throws Exception {

Session session = SESSIONS.get(ctx.channel().id());

if (null == session) {

return;

}

RingBuffer 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,代碼行數:16,

示例19: fire

​點讚 2

import com.lmax.disruptor.RingBuffer; //導入方法依賴的package包/類

@Override

public void fire( final Object event ) {

eventCount.increment();

RingBuffer ringBuffer = disruptor.getRingBuffer();

long sequence = ringBuffer.next();

try {

StatisticEventHolder holder = ringBuffer.get( sequence );

holder.set( event );

holder.setLatch( null );

} finally {

ringBuffer.publish( sequence );

}

}

開發者ID:Tetha,項目名稱:bifroest,代碼行數:14,

示例20: run

​點讚 2

import com.lmax.disruptor.RingBuffer; //導入方法依賴的package包/類

@Override

public void run(){

_logger.info(“Node run starting…”);

Executor executor = Executors.newCachedThreadPool();

Disruptor disruptor = new Disruptor<>(SurfEvent.EVENT_FACTORY, 128, executor);

disruptor.handleEventsWith(this);

RingBuffer buffer = disruptor.start();

VDSEventListImpl events = null;

while(!_shutdown){

try{

events = _eventListPool.borrowObject(0);

while(events.getEventsList().isEmpty()) {

_source.read(events);

}

if(_needsAck){

Object obj = _acksource.getInputObject();

// Hacking this in for now

// Need to actually ack the object after Kinesis consumes it: TODO

_acksource.updateInputObject(obj);

}

long seq = buffer.next();

SurfEvent event = buffer.get(seq);

event.setEventlist(events);

buffer.publish(seq);

}

catch(Exception ex){

_logger.error(“Exception while reading data:”, ex);

ex.printStackTrace();

}

}

}

開發者ID:InformaticaCorp,項目名稱:Surf,代碼行數:34,

示例21: publishExchangeOnRingBuffer

​點讚 2

import com.lmax.disruptor.RingBuffer; //導入方法依賴的package包/類

private void publishExchangeOnRingBuffer(final Exchange exchange,

final RingBuffer ringBuffer) {

final long sequence = ringBuffer.next();

ringBuffer.get(sequence).setExchange(exchange, uniqueConsumerCount);

ringBuffer.publish(sequence);

}

開發者ID:HydAu,項目名稱:Camel,代碼行數:7,

示例22: tryPublishExchangeOnRingBuffer

​點讚 2

import com.lmax.disruptor.RingBuffer; //導入方法依賴的package包/類

private void tryPublishExchangeOnRingBuffer(final Exchange exchange, final RingBuffer ringBuffer) throws InsufficientCapacityException {

final long sequence = ringBuffer.tryNext();

ringBuffer.get(sequence).setExchange(exchange, uniqueConsumerCount);

ringBuffer.publish(sequence);

}

開發者ID:HydAu,項目名稱:Camel,代碼行數:6,

示例23: main

​點讚 2

import com.lmax.disruptor.RingBuffer; //導入方法依賴的package包/類

public static void main(String[] args) {

RingBuffer ringBuffer = RingBuffer.createSingleProducer(

ValueEvent.EVENT_FACTORY, RING_SIZE, new SleepingWaitStrategy());

start = System.nanoTime();

//Create first consumer

ValueEventHandler1PMCSequenceFirst handler = new ValueEventHandler1PMCSequenceFirst(start);

SequenceBarrier barrier;

barrier = ringBuffer.newBarrier();

BatchEventProcessor firstEventProcessor = new BatchEventProcessor(

ringBuffer,barrier, handler);

//ringBuffer.addGatingSequences(firstEventProcessor.getSequence());

// Each EventProcessor can run on a separate thread

EXECUTOR.submit(firstEventProcessor);

//Create second consumer

ValueEventHandler1PMCSequenceSecond handler2 = new ValueEventHandler1PMCSequenceSecond(start);

SequenceBarrier barrier2 = ringBuffer.newBarrier(firstEventProcessor.getSequence());

BatchEventProcessor secondEventProcessor = new BatchEventProcessor(

ringBuffer,barrier2, handler2);

ringBuffer.addGatingSequences(secondEventProcessor.getSequence());

// Each EventProcessor can run on a separate thread

EXECUTOR.submit(secondEventProcessor);

for(int i = 0; i < SAMPLES_SIZE; i++) {

// Publishers claim events in sequence

long sequence = ringBuffer.next();

ValueEvent event = ringBuffer.get(sequence);

event.setValue(i); // this could be more complex with multiple fields

// make the event available to EventProcessors

ringBuffer.publish(sequence);

}

}

開發者ID:iproduct,項目名稱:low-latency-high-throughput,代碼行數:42,

注:本文中的com.lmax.disruptor.RingBuffer.publish方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/195233.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • navicat连接sqlserver数据库Windows验证_pb连接mysql数据库

    navicat连接sqlserver数据库Windows验证_pb连接mysql数据库连接配置方式如图:有时候Navicat并没有初始化安装sqlncli,所以连接的时候会报没有默认驱动,如图:解决方法:在navicat目录下找到对应驱动,点击安装即可,安装过程中设置为全部允许安装…

  • 如何修改手机IP地址

    如何修改手机IP地址说起手机换IP大家可能没有对电脑换IP那么熟悉,但是现在智能手机能做到事情越来越多,手机换IP也成为许多工作需要,一部分人还不知道怎么操作,就跟着小编一起来看看手机换IP的几种方法。一、手动换IP这个适合偶尔换IP,时间富裕的朋友,我们使用手机进行开关飞行模式,这样就可以进行换IP。也可以找到手机设置点进去先进入WiFi热点的列表,点击所连接的WiFi热点的名字。选择“修改网度络”,然后勾选“显示高级选项版”,就可以进行IP设置了。还有一种比较简单,就是用软件辅助换IP,这里以芝麻代理为例

  • linux复制文件夹及赋予权限

    1.cp命令命令:cpdir1/a.docdir2表示将dir1下的a.doc文件复制到dir2目录下cp-rdir1dir2表示将dir1及其dir1下所包含的文件复制到dir2下cp-rdir1/.dir2表示将dir1下的文件复制到dir2,不包括dir1目录说明:cp参数-i:询问,如果目标文件已经存在,则会询问是否覆盖;2.scp命令例如:scpid_rsa.pubrouter_17@IP:/home/router_17/.ssh/authori…

  • RBAC权限管理

    RBAC权限管理

  • forkjoinpool 弊端_oracle数据库分页查询sql

    forkjoinpool 弊端_oracle数据库分页查询sql使用forkjoin框架分页查询所有数据的例子importio.swagger.annotations.ApiOperation;importlombok.AllArgsConstructor;importlombok.extern.slf4j.Slf4j;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.context.annotation.PropertySou

  • 【Lucene4.8教程之四】分析

    【Lucene4.8教程之四】分析

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号