List of usage examples for java.util.concurrent LinkedBlockingDeque LinkedBlockingDeque
public LinkedBlockingDeque()
From source file:org.wso2.carbon.identity.notification.mgt.EventDistributionTask.java
/** * Overridden constructor to initiate notification sending modules and thread pool size * * @param notificationSendingModules List of notification sending modules registered * @param threadPoolSize Size of thread pool for notification sending components *///w w w . ja va 2s .com public EventDistributionTask(List<NotificationSendingModule> notificationSendingModules, int threadPoolSize) { this.notificationSendingModules = notificationSendingModules; this.eventQueue = new LinkedBlockingDeque<PublisherEvent>(); NotificationManagementServiceDataHolder.getInstance() .setThreadPool(Executors.newFixedThreadPool(threadPoolSize)); }
From source file:org.wso2.carbon.identity.event.EventDistributionTask.java
/** * Overridden constructor to initiate notification sending modules and thread pool size * * @param notificationSendingModules List of notification sending modules registered * @param threadPoolSize Size of thread pool for notification sending components *//*from ww w . j av a 2 s . c om*/ public EventDistributionTask(List<AbstractEventHandler> notificationSendingModules, int threadPoolSize) { this.notificationSendingModules = notificationSendingModules; this.eventQueue = new LinkedBlockingDeque<Event>(); IdentityEventServiceDataHolder.getInstance().setThreadPool(Executors.newFixedThreadPool(threadPoolSize)); }
From source file:org.spf4j.recyclable.impl.ObjectPoolVsApache.java
@Test(timeout = 200000) public void testPerformance() throws ObjectCreationException, ObjectBorrowException, InterruptedException, TimeoutException, ObjectReturnException, ObjectDisposeException, ExecutionException { System.out.println("poolUse"); final RecyclingSupplier<ExpensiveTestObject> pool = new RecyclingSupplierBuilder(10, new ExpensiveTestObjectFactory(1000, 100, 0, 1)).build(); final org.apache.commons.pool.impl.GenericObjectPool apool = new GenericObjectPool( new ExpensiveTestObjectFactoryApache(1000, 10, 0, 1), 10); ExecutorService execService = Executors.newFixedThreadPool(10); BlockingQueue<Future<Integer>> completionQueue = new LinkedBlockingDeque<Future<Integer>>(); RetryExecutor<Integer> exec = new RetryExecutor<>(execService, 8, 16, 5000, Callables.DEFAULT_EXCEPTION_RETRY_PREDICATE, completionQueue); long zpooltime = testPool(exec, pool, completionQueue); long apooltime = testPoolApache(exec, apool, completionQueue); Assert.assertTrue("apache pool must be slower", apooltime > zpooltime); }
From source file:org.wso2.andes.kernel.slot.SlotDeletingTask.java
/** * Create an instance of SlotDeletingTask * * @param maxNumberOfPendingSlots max number of pending slots to be deleted (used to raise a WARN) *///ww w .j a va 2 s .c o m public SlotDeletingTask(int maxNumberOfPendingSlots) { this.id = UUID.randomUUID(); this.maxNumberOfPendingSlots = maxNumberOfPendingSlots; this.slotsToDelete = new LinkedBlockingDeque<>(); }
From source file:com.espertech.esper.regression.nwtable.TestTableMTGroupedFAFReadFAFWriteChain.java
private void tryMT(int numInserted) throws Exception { String epl = "create table MyTable (key int primary key, p0 int);"; epService.getEPAdministrator().getDeploymentAdmin().parseDeploy(epl); List<BaseRunnable> runnables = new ArrayList<BaseRunnable>(); LinkedBlockingDeque<Integer> insertOutQ = new LinkedBlockingDeque<Integer>(); InsertRunnable insert = new InsertRunnable(epService, numInserted, insertOutQ); runnables.add(insert);//ww w .j a va 2 s . co m LinkedBlockingDeque<Integer> selectOutQ = new LinkedBlockingDeque<Integer>(); SelectRunnable select = new SelectRunnable(epService, insertOutQ, selectOutQ); runnables.add(select); LinkedBlockingDeque<Integer> updateOutQ = new LinkedBlockingDeque<Integer>(); UpdateRunnable update = new UpdateRunnable(epService, selectOutQ, updateOutQ); runnables.add(update); LinkedBlockingDeque<Integer> deleteOutQ = new LinkedBlockingDeque<Integer>(); DeleteRunnable delete = new DeleteRunnable(epService, updateOutQ, deleteOutQ); runnables.add(delete); // start Thread[] threads = new Thread[runnables.size()]; for (int i = 0; i < runnables.size(); i++) { threads[i] = new Thread(runnables.get(i)); threads[i].start(); } // join for (Thread t : threads) { t.join(); } // assert for (BaseRunnable runnable : runnables) { assertNull(runnable.getException()); assertEquals("failed for " + runnable, numInserted + 1, runnable.getNumberOfOperations()); // account for -1 indicator } }
From source file:org.wso2.andes.kernel.PreDeliveryExpiryMessageDeletionTask.java
/** * Create a task that keeps expired messages and delete them in batches. *///w w w. j ava2 s. c o m PreDeliveryExpiryMessageDeletionTask() { this.messageStoresUnavailable = null; this.messageStoresUnavailable = null; this.moveExpiredToDLC = AndesConfigurationManager .readValue(AndesConfiguration.PERFORMANCE_TUNING_MOVE_EXPIRED_MESSAGES_TO_DLC); this.expiredMessages = new LinkedBlockingDeque<>(); // Register AndesRecoveryTask class as a StoreHealthListener FailureObservingStoreManager.registerStoreHealthListener(this); }
From source file:com.espertech.esper.regression.nwtable.TestTableMTGroupedAccessReadIntoTableWriteNewRowCreation.java
private void tryMT(int numEvents) throws Exception { String epl = "create table varTotal (key string primary key, total sum(int));\n" + "into table varTotal select theString, sum(intPrimitive) as total from SupportBean group by theString;\n" + "@Name('listen') select varTotal[p00].total as c0 from SupportBean_S0;\n"; epService.getEPAdministrator().getDeploymentAdmin().parseDeploy(epl); epService.getEPRuntime().sendEvent(new SupportBean("A", 10)); LinkedBlockingDeque<String> queueCreated = new LinkedBlockingDeque<String>(); WriteRunnable writeRunnable = new WriteRunnable(epService, numEvents, queueCreated); ReadRunnable readRunnable = new ReadRunnable(epService, numEvents, queueCreated); // start//from www. jav a 2 s. co m Thread t1 = new Thread(writeRunnable); Thread t2 = new Thread(readRunnable); t1.start(); t2.start(); // join log.info("Waiting for completion"); t1.join(); t2.join(); assertNull(writeRunnable.getException()); assertNull(readRunnable.getException()); }
From source file:org.apache.sysml.runtime.controlprogram.paramserv.ParamServer.java
ParamServer(ListObject model, String aggFunc, Statement.PSUpdateType updateType, ExecutionContext ec, int workerNum) { _gradientsQueue = new LinkedBlockingDeque<>(); _modelMap = new HashMap<>(workerNum); IntStream.range(0, workerNum).forEach(i -> { // Create a single element blocking queue for workers to receive the broadcasted model _modelMap.put(i, new ArrayBlockingQueue<>(1)); });/*from w ww .jav a 2s . c o m*/ _model = model; _aggService = new AggregationService(aggFunc, updateType, ec, workerNum); try { _aggService.broadcastModel(); } catch (InterruptedException e) { throw new DMLRuntimeException("Param server: failed to broadcast the initial model.", e); } BasicThreadFactory factory = new BasicThreadFactory.Builder().namingPattern("agg-service-pool-thread-%d") .build(); _es = Executors.newSingleThreadExecutor(factory); }
From source file:com.willwinder.universalgcodesender.BufferedCommunicatorTest.java
@Before public void setUp() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException { EasyMock.reset(mockConnection, mockScl); instance = new BufferedCommunicatorImpl(); instance.setConnection(mockConnection); instance.setListenAll(mockScl);//from w w w . j a v a 2s . c o m cb = new LinkedBlockingDeque<>(); asl = new LinkedBlockingDeque<>(); instance.setQueuesForTesting(cb, asl); // Initialize private variable. Field f = AbstractCommunicator.class.getDeclaredField("launchEventsInDispatchThread"); f.setAccessible(true); f.set(instance, false); EasyMock.reset(mockConnection, mockScl); }
From source file:org.wso2.carbon.apimgt.gateway.throttling.publisher.ThrottleDataPublisher.java
/** * This method will initialize throttle data publisher. Inside this we will start executor and initialize data * publisher which we used to publish throttle data. *//*from ww w . j av a 2 s.c o m*/ public ThrottleDataPublisher() { ThrottleProperties throttleProperties = ServiceReferenceHolder.getInstance().getThrottleProperties(); if (throttleProperties != null) { dataPublisherPool = ThrottleDataPublisherPool.getInstance(); ThrottleProperties.DataPublisher dataPublisherConfiguration = ServiceReferenceHolder.getInstance() .getThrottleProperties().getDataPublisher(); if (dataPublisherConfiguration.isEnabled()) { ThrottleProperties.DataPublisherThreadPool dataPublisherThreadPoolConfiguration = ServiceReferenceHolder .getInstance().getThrottleProperties().getDataPublisherThreadPool(); try { executor = new DataPublisherThreadPoolExecutor( dataPublisherThreadPoolConfiguration.getCorePoolSize(), dataPublisherThreadPoolConfiguration.getMaximumPoolSize(), dataPublisherThreadPoolConfiguration.getKeepAliveTime(), TimeUnit.SECONDS, new LinkedBlockingDeque<Runnable>() { }); dataPublisher = new DataPublisher(dataPublisherConfiguration.getType(), dataPublisherConfiguration.getReceiverUrlGroup(), dataPublisherConfiguration.getAuthUrlGroup(), dataPublisherConfiguration.getUsername(), dataPublisherConfiguration.getPassword()); } catch (DataEndpointAgentConfigurationException e) { log.error( "Error in initializing binary data-publisher to send requests to global throttling engine " + e.getMessage(), e); } catch (DataEndpointException e) { log.error( "Error in initializing binary data-publisher to send requests to global throttling engine " + e.getMessage(), e); } catch (DataEndpointConfigurationException e) { log.error( "Error in initializing binary data-publisher to send requests to global throttling engine " + e.getMessage(), e); } catch (DataEndpointAuthenticationException e) { log.error( "Error in initializing binary data-publisher to send requests to global throttling engine " + e.getMessage(), e); } catch (TransportException e) { log.error( "Error in initializing binary data-publisher to send requests to global throttling engine " + e.getMessage(), e); } } } }