orderedExecutorFactory = new OrderedExecutorFactory(threadPool);
protected final OrderedExecutorFactory getOrderedExecutor() { final ExecutorService executor = Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()); executorSet.add(executor); return new OrderedExecutorFactory(executor); }
@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); }
@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); }
@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 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 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; }
@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); }
@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); } }
@Test public void testIncorrectFileSizeHigher() { 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 + align, fileSize); }
@Override @Before public void setUp() throws Exception { super.setUp(); executor = Executors.newFixedThreadPool(10, ActiveMQThreadFactory.defaultThreadFactory()); factory = new OrderedExecutorFactory(executor); }
@Override protected NodeManager createNodeManager() throws Exception { switch (nodeManagerType) { case InVM: return new InVMNodeManager(false); case Jdbc: final ThreadFactory daemonThreadFactory = t -> { final Thread th = new Thread(t); th.setDaemon(true); return th; }; final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(daemonThreadFactory); scheduledExecutorServices.add(scheduledExecutorService); final ExecutorService executor = Executors.newFixedThreadPool(2, daemonThreadFactory); executors.add(executor); final DatabaseStorageConfiguration dbConf = createDefaultDatabaseStorageConfiguration(); final ExecutorFactory executorFactory = new OrderedExecutorFactory(executor); return JdbcNodeManager.with(dbConf, scheduledExecutorService, executorFactory, (code, message, file) -> { code.printStackTrace(); Assert.fail(message); }); default: throw new AssertionError("enum type not supported!"); } }
protected void initializeJournal(Configuration configuration) throws Exception { this.config = configuration; executor = Executors.newFixedThreadPool(5, ActiveMQThreadFactory.defaultThreadFactory()); executorFactory = new OrderedExecutorFactory(executor); scheduledExecutorService = new ScheduledThreadPoolExecutor(configuration.getScheduledThreadPoolMaxSize(), new ThreadFactory() { @Override public Thread newThread(Runnable r) { return new Thread(r); } }); HierarchicalRepository<AddressSettings> addressSettingsRepository = new HierarchicalObjectRepository<>(config.getWildcardConfiguration()); addressSettingsRepository.setDefault(new AddressSettings()); if (configuration.isJDBC()) { storageManager = new JDBCJournalStorageManager(config, null, scheduledExecutorService, executorFactory, executorFactory, null); PagingStoreFactory pageStoreFactory = new PagingStoreFactoryDatabase((DatabaseStorageConfiguration) configuration.getStoreConfiguration(), storageManager, 1000L, scheduledExecutorService, executorFactory, false, null); pagingmanager = new PagingManagerImpl(pageStoreFactory, addressSettingsRepository, configuration.getManagementAddress()); } else { storageManager = new JournalStorageManager(config, EmptyCriticalAnalyzer.getInstance(), executorFactory, executorFactory); PagingStoreFactory pageStoreFactory = new PagingStoreFactoryNIO(storageManager, config.getPagingLocation(), 1000L, scheduledExecutorService, executorFactory, true, null); pagingmanager = new PagingManagerImpl(pageStoreFactory, addressSettingsRepository, configuration.getManagementAddress()); } }
protected void initializeJournal(Configuration configuration) throws Exception { this.config = configuration; executor = Executors.newFixedThreadPool(5, ActiveMQThreadFactory.defaultThreadFactory()); executorFactory = new OrderedExecutorFactory(executor); scheduledExecutorService = new ScheduledThreadPoolExecutor(configuration.getScheduledThreadPoolMaxSize(), new ThreadFactory() { @Override public Thread newThread(Runnable r) { return new Thread(r); } }); HierarchicalRepository<AddressSettings> addressSettingsRepository = new HierarchicalObjectRepository<>(config.getWildcardConfiguration()); addressSettingsRepository.setDefault(new AddressSettings()); if (configuration.isJDBC()) { storageManager = new JDBCJournalStorageManager(config, null, scheduledExecutorService, executorFactory, executorFactory, null); PagingStoreFactory pageStoreFactory = new PagingStoreFactoryDatabase((DatabaseStorageConfiguration) configuration.getStoreConfiguration(), storageManager, 1000L, scheduledExecutorService, executorFactory, false, null); pagingmanager = new PagingManagerImpl(pageStoreFactory, addressSettingsRepository, configuration.getManagementAddress()); } else { storageManager = new JournalStorageManager(config, EmptyCriticalAnalyzer.getInstance(), executorFactory, executorFactory); PagingStoreFactory pageStoreFactory = new PagingStoreFactoryNIO(storageManager, config.getPagingLocation(), 1000L, scheduledExecutorService, executorFactory, true, null); pagingmanager = new PagingManagerImpl(pageStoreFactory, addressSettingsRepository, configuration.getManagementAddress()); } }
orderedExecutorFactory = new OrderedExecutorFactory(threadPool);
orderedExecutorFactory = new OrderedExecutorFactory(threadPool);
orderedExecutorFactory = new OrderedExecutorFactory(threadPool);
orderedExecutorFactory = new OrderedExecutorFactory(threadPool);
orderedExecutorFactory = new OrderedExecutorFactory(threadPool);
@Test public void testMoveOverPaging() throws Exception { AssertionLoggerHandler.startCapture(); ExecutorService threadPool = Executors.newCachedThreadPool(); try { manager.setMaxFolders(3); for (int i = 1; i <= 10; i++) { HierarchicalRepository<AddressSettings> addressSettings = new HierarchicalObjectRepository<>(); AddressSettings settings = new AddressSettings(); settings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE); addressSettings.setDefault(settings); final StorageManager storageManager = new NullStorageManager(); PagingStoreFactoryNIO storeFactory = new PagingStoreFactoryNIO(storageManager, dataLocation, 100, null, new OrderedExecutorFactory(threadPool), true, null); PagingManagerImpl managerImpl = new PagingManagerImpl(storeFactory, addressSettings, -1, ActiveMQDefaultConfiguration.getDefaultManagementAddress()); managerImpl.start(); PagingStore store = managerImpl.getPageStore(new SimpleString("simple-test")); store.startPaging(); store.stop(); managerImpl.stop(); manager.doMove(); Assert.assertEquals(Math.min(i, manager.getMaxFolders()), manager.getNumberOfFolders()); } Assert.assertFalse("The loggers are complaining about address.txt", AssertionLoggerHandler.findText("address.txt")); } finally { AssertionLoggerHandler.stopCapture(); threadPool.shutdown(); } }