Package com.cloudhopper.mq.queue

Source Code of com.cloudhopper.mq.queue.QueueConfiguration

package com.cloudhopper.mq.queue;

/*
* #%L
* ch-mq
* %%
* Copyright (C) 2012 Cloudhopper by Twitter
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/

import com.cloudhopper.mq.queue.impl.QueueNameRegexList;
import com.cloudhopper.mq.util.CompositeKeyUtil;
import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.regex.Pattern;
import javax.management.MBeanServer;

/**
* Configuration for the Queue framework.
*
* @author joelauer
*/
public class QueueConfiguration {

    private String name;
    private String directory;
    private int maxQueues;
    private long maxItemsPerQueue;
    private String dataStoreUrl;
    private QueueNameRegexList localOnlyQueues;
    private boolean jmxEnabled;
    private MBeanServer mbeanServer;
    private String jmxDomain;
    private String healthCheckQueueName;

    public QueueConfiguration() {
        // default name to "queue"
        this.name = "mq";
        // default directory is "data"
        this.directory = "data";
        // default max queues to 2 bytes
        this.maxQueues = CompositeKeyUtil.getMaxQueueId(2)+1;
        // default max items to 4 bytes
        this.maxItemsPerQueue = CompositeKeyUtil.getMaxItemId(4)+1;
        this.localOnlyQueues = new QueueNameRegexList();
        // jmx defaults
        this.jmxEnabled = true;
        this.mbeanServer = ManagementFactory.getPlatformMBeanServer();
        this.jmxDomain = "com.cloudhopper.mq";
  this.healthCheckQueueName = "health.check.validation.queue";
  addLocalOnly(this.healthCheckQueueName+".*");
    }

    public void setHealthCheckQueueName(String name) {
  this.healthCheckQueueName = name;
  addLocalOnly(this.healthCheckQueueName+".*");
    }

    public String getHealthCheckQueueName() {
  return healthCheckQueueName;
    }

    public void addLocalOnly(String regex) throws IllegalArgumentException {
        this.localOnlyQueues.add(regex);
    }

    public QueueNameRegexList getLocalOnlyQueues() {
        return this.localOnlyQueues;
    }

    public boolean isJmxEnabled() {
        return this.jmxEnabled;
    }

    public void setJmxEnabled(boolean value) {
        this.jmxEnabled = value;
    }

    public void setMBeanServer(MBeanServer value) {
        this.mbeanServer = value;
    }

    public MBeanServer getMBeanServer() {
        return this.mbeanServer;
    }

    public String getJmxDomain() {
        return this.jmxDomain;
    }

    public void setJmxDomain(String value) {
        this.jmxDomain = value;
    }

    public void setName(String value) {
        this.name = value;
    }

    public String getName() {
        return this.name;
    }

    public void setDirectory(String value) {
        this.directory = value;
    }

    public String getDirectory() {
        return this.directory;
    }

    public void setMaxQueues(int value) {
        this.maxQueues = value;
        // check this values for CompositeKeyUtil -- will throw an exception
        CompositeKeyUtil.getQueueIdByteLength(maxQueues);
    }

    public int getMaxQueues() {
        return this.maxQueues;
    }

    public void setMaxItemsPerQueue(long value) {
        this.maxItemsPerQueue = value;
        // check this values for CompositeKeyUtil -- will throw an exception
        CompositeKeyUtil.getItemIdByteLength(maxItemsPerQueue);
    }

    public long getMaxItemsPerQueue() {
        return this.maxItemsPerQueue;
    }

    public void setDataStoreUrl(String value) {
        this.dataStoreUrl = value;
    }

    public String getDataStoreUrl() {
        return this.dataStoreUrl;
    }

}
TOP

Related Classes of com.cloudhopper.mq.queue.QueueConfiguration

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.