Package org.apache.activemq.usage

Examples of org.apache.activemq.usage.SystemUsage


            }
        }
    }

    protected void checkSystemUsageLimits() throws IOException {
        SystemUsage usage = getSystemUsage();
        long memLimit = usage.getMemoryUsage().getLimit();
        long jvmLimit = Runtime.getRuntime().maxMemory();

        if (memLimit > jvmLimit) {
            LOG.error("Memory Usage for the Broker (" + memLimit / (1024 * 1024) +
                      " mb) is more than the maximum available for the JVM: " +
                      jvmLimit / (1024 * 1024) + " mb");
        }

        if (getPersistenceAdapter() != null) {
            PersistenceAdapter adapter = getPersistenceAdapter();
            File dir = adapter.getDirectory();

            if (dir != null) {
                String dirPath = dir.getAbsolutePath();
                if (!dir.isAbsolute()) {
                    dir = new File(dirPath);
                }

                while (dir != null && dir.isDirectory() == false) {
                    dir = dir.getParentFile();
                }
                long storeLimit = usage.getStoreUsage().getLimit();
                long dirFreeSpace = dir.getUsableSpace();
                if (storeLimit > dirFreeSpace) {
                    LOG.warn("Store limit is " + storeLimit / (1024 * 1024) +
                             " mb, whilst the data directory: " + dir.getAbsolutePath() +
                             " only has " + dirFreeSpace / (1024 * 1024) + " mb of usable space");
                }
            }

            long maxJournalFileSize = 0;
            long storeLimit = usage.getStoreUsage().getLimit();

            if (adapter instanceof JournaledStore) {
                maxJournalFileSize = ((JournaledStore) adapter).getJournalMaxFileLength();
            }

            if (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.");
            }
        }

        File tmpDir = getTmpDataDirectory();
        if (tmpDir != null) {

            String tmpDirPath = tmpDir.getAbsolutePath();
            if (!tmpDir.isAbsolute()) {
                tmpDir = new File(tmpDirPath);
            }

            long storeLimit = usage.getTempUsage().getLimit();
            while (tmpDir != null && tmpDir.isDirectory() == false) {
                tmpDir = tmpDir.getParentFile();
            }
            long dirFreeSpace = tmpDir.getUsableSpace();
            if (storeLimit > dirFreeSpace) {
                LOG.error("Temporary Store limit is " + storeLimit / (1024 * 1024) +
                          " mb, whilst the temporary data directory: " + tmpDirPath +
                          " only has " + dirFreeSpace / (1024 * 1024) + " mb of usable space");
            }

            if (isPersistent()) {
                long maxJournalFileSize;

                PListStore store = usage.getTempUsage().getStore();
                if (store != null && store instanceof JournaledStore) {
                    maxJournalFileSize = ((JournaledStore) store).getJournalMaxFileLength();
                } else {
                    maxJournalFileSize = DEFAULT_MAX_FILE_LENGTH;
                }

                if (storeLimit < maxJournalFileSize) {
                    LOG.error("Temporary Store limit is " + storeLimit / (1024 * 1024) +
                              " mb, whilst the max journal file size for the temporary store is: " +
                              maxJournalFileSize / (1024 * 1024) + " mb, " +
                              "the temp store will not accept any data when used.");
                }
            }
        }

        if (getJobSchedulerStore() != null) {
            JobSchedulerStore scheduler = getJobSchedulerStore();
            File schedulerDir = scheduler.getDirectory();
            if (schedulerDir != null) {

                String schedulerDirPath = schedulerDir.getAbsolutePath();
                if (!schedulerDir.isAbsolute()) {
                    schedulerDir = new File(schedulerDirPath);
                }

                while (schedulerDir != null && schedulerDir.isDirectory() == false) {
                    schedulerDir = schedulerDir.getParentFile();
                }
                long schedularLimit = usage.getJobSchedulerUsage().getLimit();
                long dirFreeSpace = schedulerDir.getUsableSpace();
                if (schedularLimit > dirFreeSpace) {
                    LOG.warn("Job Schedular Store limit is " + schedularLimit / (1024 * 1024) +
                             " mb, whilst the data directory: " + schedulerDir.getAbsolutePath() +
                             " only has " + dirFreeSpace / (1024 * 1024) + " mb of usable space");
View Full Code Here


        brokerService.setPersistenceAdapter(persistenceAdapter);
    }

    @Override
    protected void applyMemoryLimitPolicy() throws Exception {
        final SystemUsage memoryManager = new SystemUsage();
        memoryManager.getMemoryUsage().setLimit(5818230784L);
        memoryManager.getStoreUsage().setLimit(6442450944L);
        memoryManager.getTempUsage().setLimit(3221225472L);
        brokerService.setSystemUsage(memoryManager);

        final List<PolicyEntry> policyEntries = new ArrayList<PolicyEntry>();
        final PolicyEntry entry = new PolicyEntry();
        entry.setQueue(">");
View Full Code Here

        broker.setDeleteAllMessagesOnStartup(true);
        broker.setPersistent(true);
        broker.setUseJmx(true);
        broker.addConnector("tcp://localhost:61616").setName("Default");

        SystemUsage systemUsage;
        systemUsage = new SystemUsage();
        systemUsage.getMemoryUsage().setLimit(10 * 1024 * 1024); // Just a few messags
        broker.setSystemUsage(systemUsage);

        KahaDBPersistenceAdapter kahaDBPersistenceAdapter = new KahaDBPersistenceAdapter();
        kahaDBPersistenceAdapter.setJournalMaxFileLength(16*1024);
        kahaDBPersistenceAdapter.setCleanupInterval(500);
View Full Code Here

    broker.setBrokerName("broker-" + brokerId);
    broker.setPersistent(false);
    broker.setUseJmx(true);
    broker.getManagementContext().setCreateConnector(false);

    final SystemUsage memoryManager = new SystemUsage();
    memoryManager.getMemoryUsage().setLimit(1024 * 1024 * 50); // 50 MB
    broker.setSystemUsage(memoryManager);

    final List<PolicyEntry> policyEntries = new ArrayList<PolicyEntry>();
    final PolicyEntry entry = new PolicyEntry();
    entry.setQueue(">");
View Full Code Here

            assertEquals("TimedSubsPolicy Config Error (recoverDuration)", 25000, ((TimedSubscriptionRecoveryPolicy) subsPolicy).getRecoverDuration());
            LOG.info("Success");

            // Check usage manager
            // System.out.print("Checking memory manager configurations... ");
            SystemUsage systemUsage = broker.getSystemUsage();
            assertTrue("Should have a SystemUsage", systemUsage != null);
            assertEquals("SystemUsage Config Error (MemoryUsage.limit)", 1024 * 1024 * 10, systemUsage.getMemoryUsage().getLimit());
            assertEquals("SystemUsage Config Error (MemoryUsage.percentUsageMinDelta)", 20, systemUsage.getMemoryUsage().getPercentUsageMinDelta());
            assertEquals("SystemUsage Config Error (TempUsage.limit)", 1024 * 1024 * 100, systemUsage.getTempUsage().getLimit());
            assertEquals("SystemUsage Config Error (StoreUsage.limit)", 1024 * 1024 * 1024, systemUsage.getStoreUsage().getLimit());
            assertEquals("SystemUsage Config Error (StoreUsage.name)", "foo", systemUsage.getStoreUsage().getName());

            assertNotNull(systemUsage.getStoreUsage().getStore());
            assertTrue(systemUsage.getStoreUsage().getStore() instanceof MemoryPersistenceAdapter);

            LOG.info("Success");

        } finally {
            if (broker != null) {
View Full Code Here

        brokerService.setBrokerName(brokerName);
        brokerService.setPersistent(false);
        brokerService.setUseJmx(true);

        final SystemUsage memoryManager = new SystemUsage();
        memoryManager.getMemoryUsage().setLimit(100000000);
        brokerService.setSystemUsage(memoryManager);

        final List<PolicyEntry> policyEntries = new ArrayList<PolicyEntry>();

        final PolicyEntry entry = new PolicyEntry();
View Full Code Here

    protected boolean shouldAutostart() {
        return start;
    }

    private void ensureSystemUsageHasStore() throws IOException {
        SystemUsage usage = getSystemUsage();
        if (usage.getStoreUsage().getStore() == null) {
            usage.getStoreUsage().setStore(getPersistenceAdapter());
        }
        if (usage.getTempUsage().getStore() == null) {
            usage.getTempUsage().setStore(getTempDataStore());
        }
        if (usage.getJobSchedulerUsage().getStore() == null) {
            usage.getJobSchedulerUsage().setStore(getJobSchedulerStore());
        }
    }
View Full Code Here

            LOG.info("Success");


            // Check usage manager
            // System.out.print("Checking memory manager configurations... ");
            SystemUsage systemUsage = broker.getSystemUsage();
            assertTrue("Should have a SystemUsage", systemUsage != null);
            assertEquals("SystemUsage Config Error (MemoryUsage.limit)", 1024 * 1024 * 10, systemUsage.getMemoryUsage().getLimit());
            assertEquals("SystemUsage Config Error (MemoryUsage.percentUsageMinDelta)", 20, systemUsage.getMemoryUsage().getPercentUsageMinDelta());
            assertEquals("SystemUsage Config Error (TempUsage.limit)", 1024 * 1024 * 100, systemUsage.getTempUsage().getLimit());
            assertEquals("SystemUsage Config Error (StoreUsage.limit)", 1024 * 1024 * 1024, systemUsage.getStoreUsage().getLimit());
            assertEquals("SystemUsage Config Error (StoreUsage.name)", "foo", systemUsage.getStoreUsage().getName());

            assertNotNull(systemUsage.getStoreUsage().getStore());
            assertTrue(systemUsage.getStoreUsage().getStore() instanceof LevelDBPersistenceAdapter);

            LOG.info("Success");

        } finally {
            if (broker != null) {
View Full Code Here

                if (messageSend.getProperties().containsKey(STATS_BROKER_RESET_HEADER)) {
                    getBrokerView().resetStatistics();
                }

                ActiveMQMapMessage statsMessage = new ActiveMQMapMessage();
                SystemUsage systemUsage = brokerService.getSystemUsage();
                DestinationStatistics stats = regionBroker.getDestinationStatistics();
                statsMessage.setString("brokerName", regionBroker.getBrokerName());
                statsMessage.setString("brokerId", regionBroker.getBrokerId().toString());
                statsMessage.setLong("size", stats.getMessages().getCount());
                statsMessage.setLong("enqueueCount", stats.getEnqueues().getCount());
                statsMessage.setLong("dequeueCount", stats.getDequeues().getCount());
                statsMessage.setLong("dispatchCount", stats.getDispatched().getCount());
                statsMessage.setLong("expiredCount", stats.getExpired().getCount());
                statsMessage.setLong("inflightCount", stats.getInflight().getCount());
                statsMessage.setLong("messagesCached", stats.getMessagesCached().getCount());
                statsMessage.setInt("memoryPercentUsage", systemUsage.getMemoryUsage().getPercentUsage());
                statsMessage.setLong("memoryUsage", systemUsage.getMemoryUsage().getUsage());
                statsMessage.setLong("memoryLimit", systemUsage.getMemoryUsage().getLimit());
                statsMessage.setInt("storePercentUsage", systemUsage.getStoreUsage().getPercentUsage());
                statsMessage.setLong("storeUsage", systemUsage.getStoreUsage().getUsage());
                statsMessage.setLong("storeLimit", systemUsage.getStoreUsage().getLimit());
                statsMessage.setInt("tempPercentUsage", systemUsage.getTempUsage().getPercentUsage());
                statsMessage.setLong("tempUsage", systemUsage.getTempUsage().getUsage());
                statsMessage.setLong("tempLimit", systemUsage.getTempUsage().getLimit());
                statsMessage.setDouble("averageEnqueueTime", stats.getProcessTime().getAverageTime());
                statsMessage.setDouble("maxEnqueueTime", stats.getProcessTime().getMaxTime());
                statsMessage.setDouble("minEnqueueTime", stats.getProcessTime().getMinTime());
                statsMessage.setLong("consumerCount", stats.getConsumers().getCount());
                statsMessage.setLong("producerCount", stats.getProducers().getCount());
View Full Code Here

        brokerService.setBrokerName(brokerName);
        brokerService.setPersistent(false);
        brokerService.setUseJmx(true);

        final SystemUsage memoryManager = new SystemUsage();
        memoryManager.getMemoryUsage().setLimit(5000000);
        brokerService.setSystemUsage(memoryManager);

        final List<PolicyEntry> policyEntries = new ArrayList<PolicyEntry>();

        final PolicyEntry entry = new PolicyEntry();
View Full Code Here

TOP

Related Classes of org.apache.activemq.usage.SystemUsage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.