|
|
@ -6,6 +6,7 @@ import com.lmax.disruptor.dsl.Disruptor; |
|
|
import com.lmax.disruptor.dsl.ProducerType; |
|
|
import com.lmax.disruptor.dsl.ProducerType; |
|
|
import com.techsor.datacenter.sender.dao.DashboardStatisticsDao; |
|
|
import com.techsor.datacenter.sender.dao.DashboardStatisticsDao; |
|
|
import com.techsor.datacenter.sender.disruptor.*; |
|
|
import com.techsor.datacenter.sender.disruptor.*; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.context.annotation.Bean; |
|
|
import org.springframework.context.annotation.Bean; |
|
|
import org.springframework.context.annotation.Configuration; |
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
|
|
|
|
|
@ -14,6 +15,12 @@ import java.util.concurrent.Executors; |
|
|
@Configuration |
|
|
@Configuration |
|
|
public class DisruptorConfig { |
|
|
public class DisruptorConfig { |
|
|
|
|
|
|
|
|
|
|
|
@Value("${accumulate.batch-size:100}") |
|
|
|
|
|
private int accumulateBatchSize; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${measure.batch-size:100}") |
|
|
|
|
|
private int measureBatchSize; |
|
|
|
|
|
|
|
|
@Bean |
|
|
@Bean |
|
|
public Disruptor<MeasureEvent> measureDisruptor(DashboardStatisticsDao dao) { |
|
|
public Disruptor<MeasureEvent> measureDisruptor(DashboardStatisticsDao dao) { |
|
|
|
|
|
|
|
|
@ -27,7 +34,7 @@ public class DisruptorConfig { |
|
|
new BlockingWaitStrategy() |
|
|
new BlockingWaitStrategy() |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
disruptor.handleEventsWith(new MeasureEventHandler(dao)); |
|
|
disruptor.handleEventsWith(new MeasureEventHandler(dao, measureBatchSize)); |
|
|
disruptor.start(); |
|
|
disruptor.start(); |
|
|
|
|
|
|
|
|
return disruptor; |
|
|
return disruptor; |
|
|
@ -51,7 +58,7 @@ public class DisruptorConfig { |
|
|
new BlockingWaitStrategy() |
|
|
new BlockingWaitStrategy() |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
disruptor.handleEventsWith(new AccumulateEventHandler(dao)); |
|
|
disruptor.handleEventsWith(new AccumulateEventHandler(dao, accumulateBatchSize)); |
|
|
disruptor.start(); |
|
|
disruptor.start(); |
|
|
|
|
|
|
|
|
return disruptor; |
|
|
return disruptor; |
|
|
|