protected void allowIOResumption() { try { if (broker.getPersistenceAdapter() != null) { broker.getPersistenceAdapter().allowIOResumption(); } } catch (IOException e) { LOG.warn("Failed to allow IO resumption", e); } }
/** * Delete all messages from the persistent store * * @throws IOException */ public void deleteAllMessages() throws IOException { getPersistenceAdapter().deleteAllMessages(); }
@Override protected boolean hasLockOwnership() throws IOException { boolean hasLock = true; if (broker.getPersistenceAdapter() instanceof JDBCPersistenceAdapter) { JDBCPersistenceAdapter jdbcPersistenceAdapter = (JDBCPersistenceAdapter) broker.getPersistenceAdapter(); Locker locker = jdbcPersistenceAdapter.getLocker(); if (locker != null) { try { if (!locker.keepAlive()) { hasLock = false; } } catch (SuppressReplyException ignoreWhileHandlingInProgress) { } catch (IOException ignored) { } if (!hasLock) { LOG.warn("Lock keepAlive failed, no longer lock owner with: {}", locker); throw new IOException("Lock keepAlive failed, no longer lock owner with: " + locker); } } } return hasLock; }
private long getStoredSequenceIdForMessage(MessageId messageId) { try { return brokerService.getPersistenceAdapter().getLastProducerSequenceId(messageId.getProducerId()); } catch (IOException ignored) { LOG.debug("Failed to determine last producer sequence id for: {}", messageId, ignored); } return -1; }
protected long getStoredSequenceIdForMessage(MessageId messageId) { try { return brokerService.getPersistenceAdapter().getLastProducerSequenceId(messageId.getProducerId()); } catch (IOException ignored) { LOG.debug("Failed to determine last producer sequence id for: {}", messageId, ignored); } return -1; }
@Override protected boolean hasLockOwnership() throws IOException { boolean hasLock = true; if (broker.getPersistenceAdapter() instanceof LockableServiceSupport) { Locker locker = ((LockableServiceSupport) broker.getPersistenceAdapter()).getLocker(); if (locker != null) { try { if (!locker.keepAlive()) { hasLock = false; } } catch (SuppressReplyException ignoreWhileHandlingInProgress) { } catch (IOException ignored) { } if (!hasLock) { LOG.warn("Lock keepAlive failed, no longer lock owner with: {}", locker); throw new IOException("Lock keepAlive failed, no longer lock owner with: " + locker); } } } return hasLock; } }
@Override public void gc() throws Exception { brokerService.getBroker().gc(); try { brokerService.getPersistenceAdapter().checkpoint(true); } catch (IOException e) { LOG.error("Failed to checkpoint persistence adapter on gc request", e); } }
/** * Schedules a periodic task based on schedulePeriodForDiskLimitCheck to * update store and temporary store limits if the amount of available space * plus current store size is less than the existin configured limit */ protected void scheduleDiskUsageLimitsCheck() throws IOException { if (schedulePeriodForDiskUsageCheck > 0 && (getPersistenceAdapter() != null || getTmpDataDirectory() != null)) { Runnable diskLimitCheckTask = new Runnable() { @Override public void run() { try { checkStoreUsageLimits(); } catch (Throwable e) { LOG.error("Failed to check persistent disk usage limits", e); } try { checkTmpStoreUsageLimits(); } catch (Throwable e) { LOG.error("Failed to check temporary store usage limits", e); } } }; scheduler.executePeriodically(diskLimitCheckTask, schedulePeriodForDiskUsageCheck); } }
private boolean hasNoLocalChanged(SubscriptionInfo info1, ConsumerInfo info2) throws IOException { //Not all persistence adapters store the noLocal value for a subscription PersistenceAdapter adapter = broker.getBrokerService().getPersistenceAdapter(); if (adapter instanceof NoLocalSubscriptionAware) { if (info1.isNoLocal() ^ info2.isNoLocal()) { return true; } } return false; }
/** * @return the tempDataStore */ public synchronized PListStore getTempDataStore() { if (tempDataStore == null && !hasStartException()) { if (!isPersistent()) { return null; } try { PersistenceAdapter pa = getPersistenceAdapter(); if( pa!=null && pa instanceof PListStore) { return (PListStore) pa; } } catch (IOException e) { throw new RuntimeException(e); } try { String clazz = "org.apache.activemq.store.kahadb.plist.PListStoreImpl"; this.tempDataStore = (PListStore) getClass().getClassLoader().loadClass(clazz).newInstance(); this.tempDataStore.setDirectory(getTmpDataDirectory()); configureService(tempDataStore); } catch (ClassNotFoundException e) { throw new RuntimeException("Kahadb class PListStoreImpl not found. Add activemq-kahadb jar or set persistent to false on BrokerService.", e); } catch (Exception e) { throw new RuntimeException(e); } } return tempDataStore; }
/** * Check that the store usage limit is not greater than max usable * space and adjust if it is */ protected void checkStoreUsageLimits() throws Exception { final SystemUsage usage = getSystemUsage(); if (getPersistenceAdapter() != null) { PersistenceAdapter adapter = getPersistenceAdapter(); checkUsageLimit(adapter.getDirectory(), usage.getStoreUsage(), usage.getStoreUsage().getPercentLimit()); long maxJournalFileSize = 0; long storeLimit = usage.getStoreUsage().getLimit(); if (adapter instanceof JournaledStore) { maxJournalFileSize = ((JournaledStore) adapter).getJournalMaxFileLength(); } if (storeLimit > 0 && storeLimit < maxJournalFileSize) { LOG.error("Store limit is " + storeLimit / (1024 * 1024) + " mb, whilst the max journal file size for the store is: " + maxJournalFileSize / (1024 * 1024) + " mb, " + "the store will not accept any data when used."); } } }
if (brokerService != null && brokerService.getPersistenceAdapter() != null) { PersistenceAdapter adapter = brokerService.getPersistenceAdapter(); File dir = adapter.getDirectory(); if (brokerService.isPersistent()) {
PersistenceAdapter pa = getPersistenceAdapter(); if (pa != null) { this.jobSchedulerStore = pa.createJobSchedulerStore(); PersistenceAdapter pa = getPersistenceAdapter(); if (pa != null && pa instanceof JobSchedulerStore) { this.jobSchedulerStore = (JobSchedulerStore) pa;
/** * Factory method to create the core region broker onto which interceptors * are added * * @throws Exception */ protected Broker createRegionBroker() throws Exception { if (destinationInterceptors == null) { destinationInterceptors = createDefaultDestinationInterceptor(); } configureServices(destinationInterceptors); DestinationInterceptor destinationInterceptor = new CompositeDestinationInterceptor(destinationInterceptors); if (destinationFactory == null) { destinationFactory = new DestinationFactoryImpl(this, getTaskRunnerFactory(), getPersistenceAdapter()); } return createRegionBroker(destinationInterceptor); }
public SystemUsage getSystemUsage() { try { if (systemUsage == null) { systemUsage = new SystemUsage("Main", getPersistenceAdapter(), getTempDataStore(), getJobSchedulerStore()); systemUsage.setExecutor(getExecutor()); systemUsage.getMemoryUsage().setLimit(1024L * 1024 * 1024 * 1); // 1 GB systemUsage.getTempUsage().setLimit(1024L * 1024 * 1024 * 50); // 50 GB systemUsage.getStoreUsage().setLimit(1024L * 1024 * 1024 * 100); // 100 GB systemUsage.getJobSchedulerUsage().setLimit(1024L * 1024 * 1024 * 50); // 50 GB addService(this.systemUsage); } return systemUsage; } catch (IOException e) { LOG.error("Cannot create SystemUsage", e); throw new RuntimeException("Fatally failed to create SystemUsage" + e.getMessage(), e); } }
private void doStartPersistenceAdapter() throws Exception { PersistenceAdapter persistenceAdapterToStart = getPersistenceAdapter(); if (persistenceAdapterToStart == null) { checkStartException();
private boolean hasDurableSubChanged(ConsumerInfo info1, ConsumerInfo info2) throws IOException { if (info1.getSelector() != null ^ info2.getSelector() != null) { return true; } if (info1.getSelector() != null && !info1.getSelector().equals(info2.getSelector())) { return true; } //Not all persistence adapters store the noLocal value for a subscription PersistenceAdapter adapter = broker.getBrokerService().getPersistenceAdapter(); if (adapter instanceof NoLocalSubscriptionAware) { if (info1.isNoLocal() ^ info2.isNoLocal()) { return true; } } return !info1.getDestination().equals(info2.getDestination()); }
stopper.stop(getPersistenceAdapter()); persistenceAdapter = null; if (isUseJmx()) {
private ProducerBrokerExchange getProducerBrokerExchange(ProducerId id) throws IOException { ProducerBrokerExchange result = producerExchanges.get(id); if (result == null) { synchronized (producerExchanges) { result = new ProducerBrokerExchange(); TransportConnectionState state = lookupConnectionState(id); context = state.getContext(); result.setConnectionContext(context); if (context.isReconnect() || (context.isNetworkConnection() && connector.isAuditNetworkProducers())) { result.setLastStoredSequenceId(brokerService.getPersistenceAdapter().getLastProducerSequenceId(id)); } SessionState ss = state.getSessionState(id.getParentId()); if (ss != null) { result.setProducerState(ss.getProducerState(id)); ProducerState producerState = ss.getProducerState(id); if (producerState != null && producerState.getInfo() != null) { ProducerInfo info = producerState.getInfo(); result.setMutable(info.getDestination() == null || info.getDestination().isComposite()); } } producerExchanges.put(id, result); } } else { context = result.getConnectionContext(); } return result; }
broker = new TransactionBroker(broker, getPersistenceAdapter().createTransactionStore()); if (isPopulateJMSXUserID()) { UserIDBroker userIDBroker = new UserIDBroker(broker);