orderedExecutorFactory = new OrderedExecutorFactory(threadPool);
public static boolean flushExecutor(Executor executor) { return flushExecutor(executor, 30, TimeUnit.SECONDS); }
@Override public Connection createConnection() { if (InVMConnector.failOnCreateConnection) { InVMConnector.incFailures(); logger.debug("Returning null on InVMConnector for tests"); // For testing only return null; } if (acceptor == null) { return null; } if (acceptor.getConnectionsAllowed() == -1 || acceptor.getConnectionCount() < acceptor.getConnectionsAllowed()) { Connection conn = internalCreateConnection(acceptor.getHandler(), new Listener(), acceptor.getExecutorFactory().getExecutor()); acceptor.connect((String) conn.getID(), handler, this, executorFactory.getExecutor()); return conn; } else { if (logger.isDebugEnabled()) { logger.debug(new StringBuilder().append("Connection limit of ").append(acceptor.getConnectionsAllowed()).append(" reached. Refusing connection.")); } return null; } }
protected final OrderedExecutorFactory getOrderedExecutor() { final ExecutorService executor = Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()); executorSet.add(executor); return new OrderedExecutorFactory(executor); }
public boolean flushAppendExecutor(long timeout, TimeUnit unit) throws InterruptedException { return OrderedExecutorFactory.flushExecutor(appendExecutor, timeout, unit); }
@Override public synchronized void start() { if (state != JournalState.STOPPED) { throw new IllegalStateException("Journal " + this + " is not stopped, state is " + state); } if (providedIOThreadPool == null) { ThreadFactory factory = AccessController.doPrivileged(new PrivilegedAction<ThreadFactory>() { @Override public ThreadFactory run() { return new ActiveMQThreadFactory("ArtemisIOThread", true, JournalImpl.class.getClassLoader()); } }); threadPool = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L,TimeUnit.SECONDS, new SynchronousQueue(), factory); ioExecutorFactory = new OrderedExecutorFactory(threadPool); } else { ioExecutorFactory = providedIOThreadPool; } filesExecutor = ioExecutorFactory.getExecutor(); compactorExecutor = ioExecutorFactory.getExecutor(); appendExecutor = ioExecutorFactory.getExecutor(); filesRepository.setExecutor(filesExecutor); fileFactory.start(); setJournalState(JournalState.STARTED); }
public static boolean flushExecutor(Executor executor) { return flushExecutor(executor, 30, TimeUnit.SECONDS); }
@Override public synchronized void start() { if (state != JournalState.STOPPED) { throw new IllegalStateException("Journal " + this + " is not stopped, state is " + state); } if (providedIOThreadPool == null) { ThreadFactory factory = AccessController.doPrivileged(new PrivilegedAction<ThreadFactory>() { @Override public ThreadFactory run() { return new ActiveMQThreadFactory("ArtemisIOThread", true, JournalImpl.class.getClassLoader()); } }); threadPool = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L,TimeUnit.SECONDS, new SynchronousQueue(), factory); ioExecutorFactory = new OrderedExecutorFactory(threadPool); } else { ioExecutorFactory = providedIOThreadPool; } filesExecutor = ioExecutorFactory.getExecutor(); compactorExecutor = ioExecutorFactory.getExecutor(); appendExecutor = ioExecutorFactory.getExecutor(); filesRepository.setExecutor(filesExecutor); fileFactory.start(); setJournalState(JournalState.STARTED); }
public static boolean flushExecutor(Executor executor) { return flushExecutor(executor, 30, TimeUnit.SECONDS); }
@Override @Before public void setUp() throws Exception { super.setUp(); tFactory = new ActiveMQThreadFactory("ActiveMQ-ReplicationTest", false, this.getClass().getClassLoader()); executor = Executors.newCachedThreadPool(tFactory); scheduledExecutor = new ScheduledThreadPoolExecutor(10, tFactory); factory = new OrderedExecutorFactory(executor); }
public static boolean flushExecutor(Executor executor) { return flushExecutor(executor, 30, TimeUnit.SECONDS); }
this.threadPoolSupplied = true; this.executorFactory = new OrderedExecutorFactory(threadPool); this.ioExecutorFactory = new OrderedExecutorFactory(serviceRegistry.getIOExecutorService()); } else { ThreadFactory tFactory = AccessController.doPrivileged(new PrivilegedAction<ThreadFactory>() { this.ioExecutorFactory = new OrderedExecutorFactory(ioExecutorPool);
public boolean flushAppendExecutor(long timeout, TimeUnit unit) throws InterruptedException { return OrderedExecutorFactory.flushExecutor(appendExecutor, timeout, unit); }
public InVMConnector(final Map<String, Object> configuration, final BufferHandler handler, final ClientConnectionLifeCycleListener listener, final Executor closeExecutor, final Executor threadPool, ClientProtocolManager protocolManager) { super(configuration); this.listener = listener; id = ConfigurationHelper.getIntProperty(TransportConstants.SERVER_ID_PROP_NAME, 0, configuration); bufferPoolingEnabled = ConfigurationHelper.getBooleanProperty(TransportConstants.BUFFER_POOLING, TransportConstants.DEFAULT_BUFFER_POOLING, configuration); this.handler = handler; this.closeExecutor = closeExecutor; executorFactory = new OrderedExecutorFactory(getInVMExecutor()); InVMRegistry registry = InVMRegistry.instance; acceptor = registry.getAcceptor(id); this.protocolManager = protocolManager; }
public static boolean flushExecutor(Executor executor) { return flushExecutor(executor, 30, TimeUnit.SECONDS); }
public InVMAcceptor(final String name, final ClusterConnection clusterConnection, final Map<String, Object> configuration, final BufferHandler handler, final ServerConnectionLifeCycleListener listener, final Map<String, ProtocolManager> protocolMap, final Executor threadPool) { super(protocolMap); this.name = name; this.clusterConnection = clusterConnection; this.configuration = configuration; this.handler = handler; this.listener = listener; id = ConfigurationHelper.getIntProperty(TransportConstants.SERVER_ID_PROP_NAME, 0, configuration); executorFactory = new OrderedExecutorFactory(threadPool); connectionsAllowed = ConfigurationHelper.getLongProperty(TransportConstants.CONNECTIONS_ALLOWED, TransportConstants.DEFAULT_CONNECTIONS_ALLOWED, configuration); enableBufferPooling = ConfigurationHelper.getBooleanProperty(TransportConstants.BUFFER_POOLING, TransportConstants.DEFAULT_BUFFER_POOLING, configuration); directDeliver = ConfigurationHelper.getBooleanProperty(TransportConstants.DIRECT_DELIVER, TransportConstants.DEFAULT_DIRECT_DELIVER, configuration); }
public static boolean flushExecutor(Executor executor) { return flushExecutor(executor, 30, TimeUnit.SECONDS); }
@Test public void testIncorrectFileSizeHalf() { ConfigurationImpl config = new ConfigurationImpl(); int origFileSize = config.getJournalFileSize(); config.setJournalFileSize(origFileSize + (align / 2)); JournalStorageManager manager = new JournalStorageManager(config,EmptyCriticalAnalyzer.getInstance(), new OrderedExecutorFactory(null), new OrderedExecutorFactory(null)); int fileSize = manager.getMessageJournal().getFileSize(); Assert.assertEquals(origFileSize + align, fileSize); } }
public static boolean flushExecutor(Executor executor) { return flushExecutor(executor, 30, TimeUnit.SECONDS); }
@Test public void testIncorrectFileSizeLower() { ConfigurationImpl config = new ConfigurationImpl(); int origFileSize = config.getJournalFileSize(); config.setJournalFileSize(origFileSize + (align / 2 - 1)); JournalStorageManager manager = new JournalStorageManager(config, EmptyCriticalAnalyzer.getInstance(), new OrderedExecutorFactory(null), new OrderedExecutorFactory(null)); int fileSize = manager.getMessageJournal().getFileSize(); Assert.assertEquals(origFileSize, fileSize); }