Package org.apache.activemq.usage

Examples of org.apache.activemq.usage.SystemUsage


        broker.setUseJmx(true);
        broker.setAdvisorySupport(false);
        broker.setDeleteAllMessagesOnStartup(true);

        setDefaultPersistenceAdapter(broker);
        SystemUsage sysUsage = broker.getSystemUsage();
        MemoryUsage memUsage = new MemoryUsage();
        memUsage.setLimit((1024 * 1024));
        StoreUsage storeUsage = new StoreUsage();
        storeUsage.setLimit((1024 * 1024) * 38);
        TempUsage tmpUsage = new TempUsage();
        tmpUsage.setLimit((1024 * 1024) * 38);

        PolicyEntry defaultPolicy = new PolicyEntry();
        // defaultPolicy.setTopic("FooTwo");
        defaultPolicy.setProducerFlowControl(false);
        defaultPolicy.setMemoryLimit(10 * 1024);

        PolicyMap policyMap = new PolicyMap();
        policyMap.setDefaultEntry(defaultPolicy);

        sysUsage.setMemoryUsage(memUsage);
        sysUsage.setStoreUsage(storeUsage);
        sysUsage.setTempUsage(tmpUsage);

        broker.setDestinationPolicy(policyMap);
        broker.setSystemUsage(sysUsage);

        broker.addConnector("tcp://localhost:0").setName("Default");
View Full Code Here


   
    public void createBroker(Configurer configurer) throws Exception {
        broker = new BrokerService();
        configurePersistenceAdapter(broker);
       
        SystemUsage usage = new SystemUsage();
        MemoryUsage memoryUsage = new MemoryUsage();
        memoryUsage.setLimit(MESSAGE_LENGTH_BYTES * 200 * NUM_SENDERS_AND_RECEIVERS);
        usage.setMemoryUsage(memoryUsage);
        broker.setSystemUsage(usage);
       
       

        broker.addConnector(BROKER_CONNECTOR);       
View Full Code Here

        connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
    }

    private void applyMemoryLimitPolicy(BrokerService broker) {
        final SystemUsage memoryManager = new SystemUsage();
        memoryManager.getMemoryUsage().setLimit(5818230784L);
        memoryManager.getStoreUsage().setLimit(6442450944L);
        memoryManager.getTempUsage().setLimit(3221225472L);
        broker.setSystemUsage(memoryManager);

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

    @Test
    public void testAddRemoveAddIndexSize() throws Exception {
        brokerService = new BrokerService();
        brokerService.setUseJmx(false);
        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 =  ((PListImpl)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

            }
        });

        executorService.shutdown();
        assertTrue("consumers executor finished on time", executorService.awaitTermination(5*60, TimeUnit.SECONDS));
        final SystemUsage usage = brokerService.getSystemUsage();
        assertTrue("Store is not hogged", Wait.waitFor(new Wait.Condition() {

            @Override
            public boolean isSatisified() throws Exception {
                long storeUsage = usage.getStoreUsage().getUsage();
                LOG.info("Store Usage: " + storeUsage);
                return storeUsage < 5 * maxFileLength;
            }
        }));
        assertTrue("no exceptions", exceptions.isEmpty());
View Full Code Here

        BrokerService brokerService = broker.getBrokerService();
        if (brokerService != null && brokerService.getPersistenceAdapter() != null) {
            PersistenceAdapter adapter = brokerService.getPersistenceAdapter();
            File dir = adapter.getDirectory();
            if (brokerService.isPersistent()) {
                SystemUsage usage = brokerService.getSystemUsage();
                if (dir != null && usage != null) {
                    String dirPath = dir.getAbsolutePath();
                    if (!dir.isAbsolute()) {
                        dir = new File(dirPath);
                    }


                    while (dir != null && !dir.isDirectory()) {
                        dir = dir.getParentFile();
                    }
                    long storeSize = adapter.size();
                    long storeLimit = usage.getStoreUsage().getLimit();
                    long dirFreeSpace = dir.getUsableSpace();

                    if (storeSize != 0) {
                        int val = (int) ((storeSize * 100) / storeLimit);
                        if (val > 90) {
                            answer.add(new HealthStatus("org.apache.activemq.StoreLimit", "WARNING", "Message Store size is within " + val + "% of its limit", adapter.toString()));
                        }
                    }


                    if ((storeLimit - storeSize) > dirFreeSpace) {
                        String message = "Store limit is " + storeLimit / (1024 * 1024) +
                                " mb, whilst the data directory: " + dir.getAbsolutePath() +
                                " only has " + dirFreeSpace / (1024 * 1024) + " mb of usable space";
                        answer.add(new HealthStatus("org.apache.activemq.FreeDiskSpaceLeft", "WARNING", message, adapter.toString()));
                    }


                }
                File tmpDir = brokerService.getTmpDataDirectory();
                if (tmpDir != null) {

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

                    long storeSize = usage.getTempUsage().getUsage();
                    long storeLimit = usage.getTempUsage().getLimit();
                    while (tmpDir != null && !tmpDir.isDirectory()) {
                        tmpDir = tmpDir.getParentFile();
                    }

                    int val = (int) ((storeSize * 100) / storeLimit);
                    if (val > 90) {
                        answer.add(new HealthStatus("org.apache.activemq.TempStoreLimit", "WARNING", "TempMessage Store size is within " + val + "% of its limit", adapter.toString()));
                    }


                }


            }
        }

        if (brokerService != null && brokerService.getJobSchedulerStore() != null) {
            JobSchedulerStore scheduler = brokerService.getJobSchedulerStore();
            File dir = scheduler.getDirectory();
            if (brokerService.isPersistent()) {
                SystemUsage usage = brokerService.getSystemUsage();
                if (dir != null && usage != null) {
                    String dirPath = dir.getAbsolutePath();
                    if (!dir.isAbsolute()) {
                        dir = new File(dirPath);
                    }


                    while (dir != null && !dir.isDirectory()) {
                        dir = dir.getParentFile();
                    }
                    long storeSize = scheduler.size();
                    long storeLimit = usage.getJobSchedulerUsage().getLimit();
                    long dirFreeSpace = dir.getUsableSpace();

                    if (storeSize != 0) {
                        int val = (int) ((storeSize * 100) / storeLimit);
                        if (val > 90) {
View Full Code Here

        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

    public void createBroker(Configurer configurer) throws Exception {
        broker = new BrokerService();
        AMQPersistenceAdapterFactory persistenceFactory = new AMQPersistenceAdapterFactory();
        persistenceFactory.setDataDirectory(dataDirFile);
       
        SystemUsage usage = new SystemUsage();
        MemoryUsage memoryUsage = new MemoryUsage();
        memoryUsage.setLimit(MESSAGE_LENGTH_BYTES * 200 * NUM_SENDERS_AND_RECEIVERS);
        usage.setMemoryUsage(memoryUsage);
        broker.setSystemUsage(usage);
       
        broker.setPersistenceFactory(persistenceFactory);

        broker.addConnector(BROKER_CONNECTOR);       
View Full Code Here

    protected void configureBroker(long memoryLimit, long systemLimit) throws Exception {
        broker.setDeleteAllMessagesOnStartup(true);
        broker.addConnector(bindAddress);
        broker.setPersistent(true);
       
        SystemUsage systemUsage = broker.getSystemUsage();
        systemUsage.setSendFailIfNoSpace(true);
        systemUsage.getMemoryUsage().setLimit(systemLimit);
       
        PolicyEntry policy = new PolicyEntry();
        policy.setProducerFlowControl(true);
        policy.setUseCache(true);
        PolicyMap pMap = new PolicyMap();
View Full Code Here

                queueMessageStore, destinationStatistics, null);

        queueMessageStore.start();

        QueueStorePrefetch underTest = new QueueStorePrefetch(queue);
        SystemUsage systemUsage = new SystemUsage();
        // ensure memory limit is reached
        systemUsage.getMemoryUsage().setLimit(messageBytesSize * (count + 2));
        underTest.setSystemUsage(systemUsage);
        underTest.setEnableAudit(false);
        underTest.start();

        final ConnectionContext contextNotInTx = new ConnectionContext();
        for (int i = 0; i < count; i++) {
            ActiveMQTextMessage msg = getMessage(i);
            msg.setMemoryUsage(systemUsage.getMemoryUsage());

            queueMessageStore.addMessage(contextNotInTx, msg);
            underTest.addMessageLast(msg);
        }

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.