Examples of SystemUsage


Examples of org.apache.activemq.usage.SystemUsage

            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());
                       
            LOG.info("Success");

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

Examples of org.apache.activemq.usage.SystemUsage

    }

    public SystemUsage getSystemUsage() {
        try {
            if (systemUsage == null) {
                systemUsage = new SystemUsage("Main", getPersistenceAdapter(), getTempDataStore());
                systemUsage.setExecutor(getExecutor());
                systemUsage.getMemoryUsage().setLimit(1024 * 1024 * 64); // Default
                                                                         // 64
                                                                         // Meg
                systemUsage.getTempUsage().setLimit(1024L * 1024 * 1000 * 50); // 50
View Full Code Here

Examples of org.apache.activemq.usage.SystemUsage

     * @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

Examples of org.apache.activemq.usage.SystemUsage

     * @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

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 KahaDBPersistenceAdapter) {
                KahaDBPersistenceAdapter kahaDB = (KahaDBPersistenceAdapter) adapter;
                maxJournalFileSize = kahaDB.getJournalMaxFileLength();
            } else if (adapter instanceof AMQPersistenceAdapter) {
                AMQPersistenceAdapter amqAdapter = (AMQPersistenceAdapter) adapter;
                maxJournalFileSize = amqAdapter.getMaxFileLength();
            }

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

            long maxJournalFileSize;

            if (usage.getTempUsage().getStore() != null) {
                maxJournalFileSize = usage.getTempUsage().getStore().getJournalMaxFileLength();
            } else {
                maxJournalFileSize = org.apache.kahadb.journal.Journal.DEFAULT_MAX_FILE_LENGTH;
            }

            if (storeLimit < maxJournalFileSize) {
View Full Code Here

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

Examples of org.apache.activemq.usage.SystemUsage

        }
    }

    private void createBrokerWithTempStoreLimit() throws Exception {
        brokerService = new BrokerService();
        SystemUsage usage = brokerService.getSystemUsage();
        usage.getTempUsage().setLimit(1025*1024*15);

        // put something in the temp store to on demand initialise it
        PList dud = brokerService.getTempDataStore().getPList("dud");
        dud.addFirst("A", new ByteSequence("A".getBytes()));
    }
View Full Code Here

Examples of org.apache.activemq.usage.SystemUsage

    }

    @Test
    public void testAddToEmptyCursorWhenTempStoreIsFull() throws Exception {
        createBrokerWithTempStoreLimit();
        SystemUsage usage = brokerService.getSystemUsage();
        assertTrue("temp store is full: %" + usage.getTempUsage().getPercentUsage(), usage.getTempUsage().isFull());

        underTest = new FilePendingMessageCursor(brokerService.getBroker(), "test", false);
        underTest.setSystemUsage(usage);

        // ok to add
View Full Code Here

Examples of org.apache.activemq.usage.SystemUsage

    }

    @Test
    public void testAddRemoveAddIndexSize() throws Exception {
        brokerService = new BrokerService();
        SystemUsage usage = brokerService.getSystemUsage();
        usage.getMemoryUsage().setLimit(1024*150);
        String body = new String(new byte[1024]);
        Destination destination = new Queue(brokerService, new ActiveMQQueue("Q"), null, new DestinationStatistics(), null);

        underTest = new FilePendingMessageCursor(brokerService.getBroker(), "test", false);
        underTest.setSystemUsage(usage);

        LOG.info("start");
        final PageFile pageFile =  underTest.getDiskList().getPageFile();
        LOG.info("page count: " +pageFile.getPageCount());
        LOG.info("free count: " + pageFile.getFreePageCount());
        LOG.info("content size: " +pageFile.getPageContentSize());

        final long initialPageCount =  pageFile.getPageCount();

        final int numMessages = 1000;

        for (int j=0; j<10; j++) {
            // ensure free pages are reused
            for (int i=0; i< numMessages; i++) {
                ActiveMQMessage mqMessage = new ActiveMQMessage();
                mqMessage.setStringProperty("body", body);
                mqMessage.setMessageId(new MessageId("1:2:3:" + i));
                mqMessage.setMemoryUsage(usage.getMemoryUsage());
                mqMessage.setRegionDestination(destination);
                underTest.addMessageLast(new IndirectMessageReference(mqMessage));
            }
            assertFalse("cursor is not full " + usage.getTempUsage(), underTest.isFull());

            underTest.reset();
            long receivedCount = 0;
            while(underTest.hasNext()) {
                MessageReference ref = underTest.next();
View Full Code Here

Examples of org.apache.activemq.usage.SystemUsage

        tempUsage.setLimit(TEMP_USAGE);

        StoreUsage storeUsage = new StoreUsage();
        storeUsage.setLimit(STORE_USAGE);

        SystemUsage systemUsage = new SystemUsage();
        systemUsage.setMemoryUsage(memoryUsage);
        systemUsage.setTempUsage(tempUsage);
        systemUsage.setStoreUsage(storeUsage);
        answer.setSystemUsage(systemUsage);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.