use of java.util.concurrent.ArrayBlockingQueue in project camel by apache.
the class CollectionProducerTest method testCollectionProducer.
public void testCollectionProducer() throws Exception {
Queue<Exchange> queue = new ArrayBlockingQueue<Exchange>(10);
Endpoint endpoint = context.getEndpoint("seda://foo");
MyProducer my = new MyProducer(endpoint, queue);
my.start();
Exchange exchange = new DefaultExchange(context);
exchange.getIn().setBody("Hello World");
my.process(exchange);
Exchange top = queue.poll();
assertNotNull(top);
assertEquals("Hello World", top.getIn().getBody());
}
use of java.util.concurrent.ArrayBlockingQueue in project camel by apache.
the class SedaQueueTest method testQueueRef.
public void testQueueRef() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello World");
template.sendBody("seda:array?queue=#arrayQueue", "Hello World");
SedaEndpoint sedaEndpoint = resolveMandatoryEndpoint("seda:array?queue=#arrayQueue", SedaEndpoint.class);
assertTrue(sedaEndpoint.getQueue() instanceof ArrayBlockingQueue);
}
use of java.util.concurrent.ArrayBlockingQueue in project redisson by redisson.
the class RedissonLiveObjectServiceTest method testNoTransformation.
@Test
public void testNoTransformation() {
RLiveObjectService service = redisson.getLiveObjectService();
TestClassNoTransformation ts = new TestClassNoTransformation();
ts = service.persist(ts);
HashMap<String, String> m = new HashMap<>();
ts.setContent(m);
assertTrue(HashMap.class.isAssignableFrom(ts.getContent().getClass()));
assertFalse(RMap.class.isAssignableFrom(ts.getContent().getClass()));
HashSet<String> s = new HashSet<>();
ts.setContent(s);
assertTrue(HashSet.class.isAssignableFrom(ts.getContent().getClass()));
assertFalse(RSet.class.isAssignableFrom(ts.getContent().getClass()));
TreeSet<String> ss = new TreeSet<>();
ts.setContent(ss);
assertTrue(TreeSet.class.isAssignableFrom(ts.getContent().getClass()));
assertFalse(RSortedSet.class.isAssignableFrom(ts.getContent().getClass()));
ArrayList<String> al = new ArrayList<>();
ts.setContent(al);
assertTrue(ArrayList.class.isAssignableFrom(ts.getContent().getClass()));
assertFalse(RList.class.isAssignableFrom(ts.getContent().getClass()));
ConcurrentHashMap<String, String> chm = new ConcurrentHashMap<>();
ts.setContent(chm);
assertTrue(ConcurrentHashMap.class.isAssignableFrom(ts.getContent().getClass()));
assertFalse(RMap.class.isAssignableFrom(ts.getContent().getClass()));
ArrayBlockingQueue<String> abq = new ArrayBlockingQueue<>(10);
abq.add("111");
ts.setContent(abq);
assertTrue(ArrayBlockingQueue.class.isAssignableFrom(ts.getContent().getClass()));
assertFalse(RBlockingQueue.class.isAssignableFrom(ts.getContent().getClass()));
ConcurrentLinkedQueue<String> clq = new ConcurrentLinkedQueue<>();
ts.setContent(clq);
assertTrue(ConcurrentLinkedQueue.class.isAssignableFrom(ts.getContent().getClass()));
assertFalse(RQueue.class.isAssignableFrom(ts.getContent().getClass()));
LinkedBlockingDeque<String> lbdq = new LinkedBlockingDeque<>();
ts.setContent(lbdq);
assertTrue(LinkedBlockingDeque.class.isAssignableFrom(ts.getContent().getClass()));
assertFalse(RBlockingDeque.class.isAssignableFrom(ts.getContent().getClass()));
LinkedList<String> ll = new LinkedList<>();
ts.setContent(ll);
assertTrue(LinkedList.class.isAssignableFrom(ts.getContent().getClass()));
assertFalse(RDeque.class.isAssignableFrom(ts.getContent().getClass()));
}
use of java.util.concurrent.ArrayBlockingQueue in project uavstack by uavorg.
the class MonitorAgent method startMDSListenServer.
private void startMDSListenServer() {
boolean isStartMDFListener = DataConvertHelper.toBoolean(this.getConfigManager().getFeatureConfiguration(this.feature, "http.enable"), false);
if (isStartMDFListener == true) {
// start MDFListenServer
int port = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.port"));
int backlog = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.backlog"));
int core = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.core"));
int max = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.max"));
int bqsize = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.bqsize"));
mdfListenServer = new MDFListenServer("MDFListenServer", this.feature, "mdfhandlers");
@SuppressWarnings({ "rawtypes", "unchecked" }) ThreadPoolExecutor exe = new ThreadPoolExecutor(core, max, 30000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(bqsize));
mdfListenServer.start(exe, port, backlog);
if (log.isTraceEnable()) {
log.info(this, "MDFListenServer started");
}
}
}
use of java.util.concurrent.ArrayBlockingQueue in project uavstack by uavorg.
the class HeartBeatServerAgent method start.
@Override
public void start() {
// init cache manager
String cacheServerAddress = this.getConfigManager().getFeatureConfiguration(this.feature, "store.addr");
int minConcurrent = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.min"));
int maxConcurrent = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.max"));
int queueSize = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.bqsize"));
String password = this.getConfigManager().getFeatureConfiguration(this.feature, "store.concurrent.pwd");
CacheManager cm = CacheManagerFactory.build(cacheServerAddress, minConcurrent, maxConcurrent, queueSize, password);
this.getConfigManager().registerComponent(this.feature, "HBCacheManager", cm);
// start HeartBeatServerListenWorker
hbServerListenWorker = new HeartBeatServerListenWorker("HeartBeatServerListenWorker", this.feature, "hbhandlers");
int port = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.port"));
int backlog = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.backlog"));
int core = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.core"));
int max = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.max"));
int bqsize = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.bqsize"));
@SuppressWarnings({ "rawtypes", "unchecked" }) ThreadPoolExecutor exe = new ThreadPoolExecutor(core, max, 30000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(bqsize));
hbServerListenWorker.start(exe, port, backlog);
if (log.isTraceEnable()) {
log.info(this, "HeartBeatServerListenWorker started");
}
// start HeartBeatQueryListenWorker
hbqueryListenWorker = new HeartBeatQueryListenWorker("HeartBeatQueryListenWorker", this.feature, "hbqueryhandlers");
int qport = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.qport"));
@SuppressWarnings({ "rawtypes", "unchecked" }) ThreadPoolExecutor qexe = new ThreadPoolExecutor(core, max, 30000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(bqsize));
hbqueryListenWorker.start(qexe, qport, backlog);
if (log.isTraceEnable()) {
log.info(this, "HeartBeatQueryListenWorker started");
}
// start HeartBeatServerLifeKeeper
boolean isStartLifeKeeper = Boolean.parseBoolean(this.getConfigManager().getFeatureConfiguration(this.feature, "lifekeeper.enable"));
if (!isStartLifeKeeper) {
return;
}
HeartBeatServerLifeKeeper hbserverLifeKeepWorker = new HeartBeatServerLifeKeeper("HeartBeatServerLifeKeeper", this.feature);
long interval = Long.parseLong(this.getConfigManager().getFeatureConfiguration(this.feature, "lifekeeper.interval"));
long randomDely = new Random().nextInt(3) + 3;
this.getTimerWorkManager().scheduleWorkInPeriod("HeartBeatServerLifeKeeper", hbserverLifeKeepWorker, randomDely * 1000, interval);
if (log.isTraceEnable()) {
log.info(this, "HeartBeatServerLifeKeeper started");
}
}
Aggregations