Package org.apache.activemq.usage

Examples of org.apache.activemq.usage.SystemUsage


        this.store = store;
        this.destination = destination;
        // let's copy the enabled property from the parent DestinationStatistics
        this.destinationStatistics.setEnabled(parentStats.isEnabled());
        this.destinationStatistics.setParent(parentStats);
        this.systemUsage = new SystemUsage(brokerService.getProducerSystemUsage(), destination.toString());
        this.memoryUsage = this.systemUsage.getMemoryUsage();
        this.memoryUsage.setUsagePortion(1.0f);
        this.regionBroker = brokerService.getRegionBroker();
        this.scheduler = brokerService.getBroker().getScheduler();
    }
View Full Code Here


    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
View Full Code Here

     * @throws IOException
     */
    public SystemUsage getConsumerSystemUsage() throws IOException {
        if (this.consumerSystemUsaage == null) {
            if (splitSystemUsageForProducersConsumers) {
                this.consumerSystemUsaage = new SystemUsage(getSystemUsage(), "Consumer");
                float portion = consumerSystemUsagePortion / 100f;
                this.consumerSystemUsaage.getMemoryUsage().setUsagePortion(portion);
                addService(this.consumerSystemUsaage);
            } else {
                consumerSystemUsaage = getSystemUsage();
View Full Code Here

     * @throws IOException
     */
    public SystemUsage getProducerSystemUsage() throws IOException {
        if (producerSystemUsage == null) {
            if (splitSystemUsageForProducersConsumers) {
                producerSystemUsage = new SystemUsage(getSystemUsage(), "Producer");
                float portion = producerSystemUsagePortion / 100f;
                producerSystemUsage.getMemoryUsage().setUsagePortion(portion);
                addService(producerSystemUsage);
            } else {
                producerSystemUsage = getSystemUsage();
View Full Code Here

            }
        }
    }

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

        if (memLimit > jvmLimit) {
            usage.getMemoryUsage().setPercentOfJvmHeap(70);
            LOG.error("Memory Usage for the Broker (" + memLimit / (1024 * 1024) +
                      " mb) is more than the maximum available for the JVM: " +
                      jvmLimit / (1024 * 1024) + " mb - resetting to 70% of maximum available: " + (usage.getMemoryUsage().getLimit() / (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()) {
                    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 - resetting to maximum available disk space: " +
                            dirFreeSpace / (1024 * 1024) + " mb");
                    usage.getStoreUsage().setLimit(dirFreeSpace);
                }
            }

            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()) {
                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 - resetting to maximum available " +
                        dirFreeSpace / (1024 * 1024) + " mb.");
                usage.getTempUsage().setLimit(dirFreeSpace);
            }

            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()) {
                    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 - resetting to " +
                            dirFreeSpace / (1024 * 1024) + " mb.");
                    usage.getJobSchedulerUsage().setLimit(dirFreeSpace);
                }
            }
        }
    }
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.setDouble("averageMessageSize",stats.getMessageSize().getAverageSize());
                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

        policyMap.setPolicyEntries(entries);
        broker.setDestinationPolicy(policyMap);
        // Set destinations
        broker.setDestinations(new ActiveMQDestination[] { destination });
        // Set system usage
        SystemUsage memoryManager = new SystemUsage();
        MemoryUsage memoryUsage = new MemoryUsage();
        memoryUsage.setLimit(TEN_MB);
        memoryManager.setMemoryUsage(memoryUsage);
        StoreUsage storeUsage = new StoreUsage();
        storeUsage.setLimit(TWENTY_MB);
        memoryManager.setStoreUsage(storeUsage);
        TempUsage tempDiskUsage = new TempUsage();
        tempDiskUsage.setLimit(TEN_MB);
        memoryManager.setTempUsage(tempDiskUsage);
        broker.setSystemUsage(memoryManager);
        // Set the persistent adapter
        KahaDBPersistenceAdapter persistenceAdapter = new KahaDBPersistenceAdapter();
        persistenceAdapter.setJournalMaxFileLength((int)TEN_MB);
        // Delete all current messages...
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

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

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

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

        final PolicyEntry entry = new PolicyEntry();
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

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.