use of com.swiftmq.mgmt.PropertyChangeException in project swiftmq-ce by iitsoftware.
the class NetworkSwiftletImpl method startup.
@Override
protected void startup(Configuration config) throws SwiftletException {
try {
ctx = new SwiftletContext(config, this);
} catch (Exception e) {
throw new SwiftletException(e.getMessage());
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "startup ...");
setConnectionManager(new ConnectionManagerImpl(ctx));
ivmScheduler = new IntraVMScheduler(ctx);
ioScheduler = new NettyIOScheduler(ctx);
Property prop = config.getProperty("reuse-serversockets");
reuseServerSocket = (Boolean) prop.getValue();
prop = config.getProperty("dns-resolve-enabled");
prop.setPropertyChangeListener(new PropertyChangeAdapter(null) {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
dnsResolve = (Boolean) newValue;
}
});
dnsResolve = (Boolean) prop.getValue();
prop = config.getProperty("zombi-connection-timeout");
zombiConnectionTimeout = (Long) prop.getValue();
prop.setPropertyChangeListener(new PropertyChangeAdapter(null) {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
zombiConnectionTimeout = (Long) newValue;
}
});
prop = config.getProperty("collect-interval");
prop.setPropertyChangeListener(new PropertyChangeAdapter(null) {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
collectInterval = (Long) newValue;
collectChanged((Long) oldValue, collectInterval);
}
});
collectInterval = (Long) prop.getValue();
if (collectOn) {
if (collectInterval > 0) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "startup: registering byte count collector");
ctx.timerSwiftlet.addTimerListener(collectInterval, this);
} else if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "startup: collect interval <= 0; no byte count collector");
}
try {
SwiftletManager.getInstance().addSwiftletManagerListener("sys$mgmt", new SwiftletManagerAdapter() {
public void swiftletStarted(SwiftletManagerEvent evt) {
try {
ctx.mgmtSwiftlet = (MgmtSwiftlet) SwiftletManager.getInstance().getSwiftlet("sys$mgmt");
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "registering MgmtListener ...");
ctx.mgmtSwiftlet.addMgmtListener(new MgmtListener() {
public void adminToolActivated() {
collectOn = true;
collectChanged(-1, collectInterval);
}
public void adminToolDeactivated() {
collectChanged(collectInterval, -1);
collectOn = false;
}
});
} catch (Exception e) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "swiftletStartet, exception=" + e);
}
}
});
} catch (Exception e) {
throw new SwiftletException(e.getMessage());
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "startup DONE");
}
use of com.swiftmq.mgmt.PropertyChangeException in project swiftmq-ce by iitsoftware.
the class RegularQueueFactory method createQueue.
public AbstractQueue createQueue(String queueName, Entity queueEntity) throws QueueException {
PersistentStore pStore = null;
NonPersistentStore nStore = null;
try {
pStore = ctx.storeSwiftlet.getPersistentStore(queueName);
nStore = ctx.storeSwiftlet.getNonPersistentStore(queueName);
} catch (Exception e) {
e.printStackTrace();
throw new QueueException(e.toString());
}
Property prop = queueEntity.getProperty(QueueManagerImpl.PROP_CACHE_SIZE);
int cacheSize = ((Integer) prop.getValue()).intValue();
prop = queueEntity.getProperty(QueueManagerImpl.PROP_CACHE_SIZE_BYTES_KB);
int cacheSizeBytesKB = ((Integer) prop.getValue()).intValue();
Cache cache = new CacheImpl(cacheSize, cacheSizeBytesKB, pStore, nStore);
cache.setCacheTable(ctx.cacheTableFactory.createCacheTable(queueName, cacheSize));
prop = queueEntity.getProperty(QueueManagerImpl.PROP_CACHE_SIZE);
prop.setPropertyChangeListener(new PropertyChangeAdapter(cache) {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
Cache myCache = (Cache) configObject;
myCache.setMaxMessages(((Integer) newValue).intValue());
}
});
prop = queueEntity.getProperty(QueueManagerImpl.PROP_CACHE_SIZE_BYTES_KB);
prop.setPropertyChangeListener(new PropertyChangeAdapter(cache) {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
Cache myCache = (Cache) configObject;
myCache.setMaxBytesKB(((Integer) newValue).intValue());
}
});
prop = queueEntity.getProperty(QueueManagerImpl.PROP_CLEANUP_INTERVAL);
long cleanUp = ((Long) prop.getValue()).longValue();
MessageQueue mq = ctx.messageQueueFactory.createMessageQueue(ctx, queueName, cache, pStore, nStore, cleanUp, myTP);
prop = queueEntity.getProperty(QueueManagerImpl.PROP_MESSAGES_MAXIMUM);
int maxMessages = ((Integer) prop.getValue()).intValue();
mq.setMaxMessages(maxMessages);
prop.setPropertyChangeListener(new PropertyChangeAdapter(mq) {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
MessageQueue myMq = (MessageQueue) configObject;
myMq.setMaxMessages(((Integer) newValue).intValue());
}
});
prop = queueEntity.getProperty(QueueManagerImpl.PROP_PERSISTENCE);
int pm = SwiftUtilities.persistenceModeToInt((String) prop.getValue());
mq.setPersistenceMode(pm);
prop.setPropertyChangeListener(new PropertyChangeAdapter(mq) {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
MessageQueue myMq = (MessageQueue) configObject;
myMq.setPersistenceMode(SwiftUtilities.persistenceModeToInt((String) newValue));
}
});
prop = queueEntity.getProperty(QueueManagerImpl.PROP_FLOWCONTROL_QUEUE_SIZE);
int fcQueueSize = ((Integer) prop.getValue()).intValue();
if (fcQueueSize >= 0)
mq.setFlowController(new FlowControllerImpl(fcQueueSize, ctx.queueManager.getMaxFlowControlDelay()));
prop.setPropertyChangeListener(new PropertyChangeAdapter(mq) {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
MessageQueue myMq = (MessageQueue) configObject;
int newFcQueueSize = ((Integer) newValue).intValue();
if (newFcQueueSize >= 0)
myMq.setFlowController(new FlowControllerImpl(newFcQueueSize, ctx.queueManager.getMaxFlowControlDelay()));
else
myMq.setFlowController(null);
}
});
prop = queueEntity.getProperty(QueueManagerImpl.PROP_DUPLICATE_DETECTION_ENABLED);
mq.setDuplicateDetectionEnabled(((Boolean) prop.getValue()).booleanValue());
prop.setPropertyChangeListener(new PropertyChangeAdapter(mq) {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
MessageQueue myMq = (MessageQueue) configObject;
myMq.setDuplicateDetectionEnabled(((Boolean) newValue).booleanValue());
}
});
prop = queueEntity.getProperty(QueueManagerImpl.PROP_DUPLICATE_DETECTION_BACKLOG_SIZE);
mq.setDuplicateDetectionBacklogSize(((Integer) prop.getValue()).intValue());
prop.setPropertyChangeListener(new PropertyChangeAdapter(mq) {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
MessageQueue myMq = (MessageQueue) configObject;
myMq.setDuplicateDetectionBacklogSize(((Integer) newValue).intValue());
}
});
prop = queueEntity.getProperty(QueueManagerImpl.PROP_CONSUMER);
if (prop != null) {
mq.setConsumerMode(ctx.consumerModeInt((String) prop.getValue()));
prop.setPropertyChangeListener(new PropertyChangeAdapter(mq) {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
MessageQueue myMq = (MessageQueue) configObject;
int cm = ctx.consumerModeInt((String) newValue);
if (cm == AbstractQueue.EXCLUSIVE && myMq.getReceiverCount() > 1)
throw new PropertyChangeException("Can't set EXCLUSIVE consumer mode - queue has already '" + myMq.getReceiverCount() + "' receivers");
myMq.setConsumerMode(cm);
}
});
}
prop = queueEntity.getProperty(QueueManagerImpl.PROP_MONITOR_ALERT_THRESHOLD);
if (prop != null) {
mq.setMonitorAlertThreshold(((Integer) prop.getValue()).intValue());
prop.setPropertyChangeListener(new PropertyChangeAdapter(mq) {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
MessageQueue myMq = (MessageQueue) configObject;
myMq.setMonitorAlertThreshold(((Integer) newValue).intValue());
}
});
}
return mq;
}
use of com.swiftmq.mgmt.PropertyChangeException in project swiftmq-ce by iitsoftware.
the class MessageGroupDispatchPolicy method init.
private void init() {
Property prop = myEntity.getProperty("message-group-enabled");
enabled = ((Boolean) prop.getValue()).booleanValue();
prop.setPropertyChangeListener(new PropertyChangeListener() {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
enabled = ((Boolean) newValue).booleanValue();
if (enabled)
restart();
else
reset();
}
});
prop = myEntity.getProperty("message-group-property");
propName = (String) prop.getValue();
prop.setPropertyChangeListener(new PropertyChangeListener() {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
if (enabled)
throw new PropertyChangeException("Please disable message grouping for this clustered queue before you change this property!");
propName = (String) newValue;
}
});
prop = myEntity.getProperty("message-group-expiration");
expiration = ((Long) prop.getValue()).longValue();
prop.setPropertyChangeListener(new PropertyChangeListener() {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
expiration = ((Long) newValue).longValue();
if (enabled && expiration != 0)
checkExpiration();
}
});
prop = myEntity.getProperty("message-group-expiration-cleanup-interval");
cleanupInterval = ((Long) prop.getValue()).longValue();
prop.setPropertyChangeListener(new PropertyChangeListener() {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
cleanupInterval = changeCleanupInterval(((Long) newValue).longValue());
}
});
}
use of com.swiftmq.mgmt.PropertyChangeException in project swiftmq-ce by iitsoftware.
the class TimerSwiftletImpl method startup.
protected void startup(Configuration config) throws SwiftletException {
logSwiftlet = (LogSwiftlet) SwiftletManager.getInstance().getSwiftlet("sys$log");
traceSwiftlet = (TraceSwiftlet) SwiftletManager.getInstance().getSwiftlet("sys$trace");
traceSpace = traceSwiftlet.getTraceSpace(TraceSwiftlet.SPACE_KERNEL);
threadpoolSwiftlet = (ThreadpoolSwiftlet) SwiftletManager.getInstance().getSwiftlet("sys$threadpool");
if (traceSpace.enabled)
traceSpace.trace(getName(), "startup, ...");
Property prop = config.getProperty("min-delay");
minDelay = ((Long) prop.getValue()).longValue();
prop.setPropertyChangeListener(new PropertyChangeAdapter(null) {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
minDelay = ((Long) newValue).longValue();
}
});
prop = config.getProperty("max-delay");
maxDelay = ((Long) prop.getValue()).longValue();
timeChangeThreshold = maxDelay + MAX_DELAY_TIME_CHANGE_ADDITION;
prop.setPropertyChangeListener(new PropertyChangeAdapter(null) {
public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
maxDelay = ((Long) newValue).longValue();
timeChangeThreshold = maxDelay + MAX_DELAY_TIME_CHANGE_ADDITION;
}
});
taskPool = threadpoolSwiftlet.getPool(TP_TASK);
taskQueue = new GapList();
timerListeners = new HashMap();
sysTimeChangeListeners = new GapList();
dispatcher = new Dispatcher();
threadpoolSwiftlet.dispatchTask(dispatcher);
if (traceSpace.enabled)
traceSpace.trace(getName(), "startup, DONE");
}
Aggregations