public MessageGroupMap createMessageGroupMap() { return new MessageGroupHashBucket(getBucketCount(), getCacheSize()); }
public MessageGroupMap createMessageGroupMap() { return new CachedMessageGroupMap(getCacheSize()); }
public boolean contains(String groupID) { int bucket = getBucketNumber(groupID); return bucket == bucketNumber; } };
public synchronized MessageGroupSet removeConsumer(ConsumerId consumerId) { SimpleMessageGroupSet ownedGroups = new SimpleMessageGroupSet(); Map<String,ConsumerId> map = new HashMap<String, ConsumerId>(); map.putAll(cache); for (Iterator<String> iter = map.keySet().iterator(); iter.hasNext();) { String group = iter.next(); ConsumerId owner = map.get(group); if (owner.equals(consumerId)) { ownedGroups.add(group); } } for (String group:ownedGroups.getUnderlyingSet()){ cache.remove(group); } return ownedGroups; }
public MessageGroupSet removeConsumer(ConsumerId consumerId) { SimpleMessageGroupSet ownedGroups = new SimpleMessageGroupSet(); for (Iterator<String> iter = map.keySet().iterator(); iter.hasNext();) { String group = iter.next(); ConsumerId owner = map.get(group); if (owner.equals(consumerId)) { ownedGroups.add(group); iter.remove(); } } return ownedGroups; }
public MessageGroupMap getMessageGroupOwners() { if (messageGroupOwners == null) { messageGroupOwners = getMessageGroupMapFactory().createMessageGroupMap(); messageGroupOwners.setDestination(this); } return messageGroupOwners; }
groupOwner = messageGroupOwners.get(groupId); if (groupOwner == null) { assignGroup(subscription, messageGroupOwners, node, groupId); messageGroupOwners.removeGroup(groupId); subscription.getConsumerInfo().decrementAssignedGroupCount(destination);
protected MessageGroupSet createMessageGroupSet(int bucketNumber, final MessageGroupSet parent) { final MessageGroupSet answer = createMessageGroupSet(bucketNumber); if (parent == null) { return answer; } else { // union the two sets together return new MessageGroupSet() { public boolean contains(String groupID) { return parent.contains(groupID) || answer.contains(groupID); } }; } }
public MessageGroupMap createMessageGroupMap() { return new SimpleMessageGroupMap(); }
/** * remove a message group = has the effect of rebalancing group */ @Override public void removeMessageGroup(@MBeanInfo("groupName") String groupName) { Queue queue = (Queue) destination; queue.getMessageGroupOwners().removeGroup(groupName); }
protected void assignGroup(Subscription subs, MessageGroupMap messageGroupOwners, MessageReference n, String groupId) throws IOException { messageGroupOwners.put(groupId, subs.getConsumerInfo().getConsumerId()); Message message = n.getMessage(); message.setJMSXGroupFirstForConsumer(true); subs.getConsumerInfo().incrementAssignedGroupCount(destination); }
/** * @return a Map of groupNames and ConsumerIds */ @Override public Map<String, String> getMessageGroups() { Queue queue = (Queue) destination; return queue.getMessageGroupOwners().getGroups(); }
/** * remove all the message groups - will rebalance all message groups across consumers */ @Override public void removeAllMessageGroups() { Queue queue = (Queue) destination; queue.getMessageGroupOwners().removeAll(); }
/** * @return the message group type implementation (simple,bucket,cached) */ @Override public String getMessageGroupType() { Queue queue = (Queue) destination; return queue.getMessageGroupOwners().getType(); }
public MessageGroupMapFactory getMessageGroupMapFactory() { if (messageGroupMapFactory == null) { try { messageGroupMapFactory = GroupFactoryFinder.createMessageGroupMapFactory(getMessageGroupMapFactoryType()); }catch(Exception e){ LOG.error("Failed to create message group Factory ",e); } } return messageGroupMapFactory; }
public synchronized ConsumerId get(String groupId) { int bucket = getBucketNumber(groupId); //excersise cache cache.get(groupId); return consumers[bucket]; }
public synchronized MessageGroupSet removeConsumer(ConsumerId consumerId) { MessageGroupSet answer = null; for (int i = 0; i < consumers.length; i++) { ConsumerId owner = consumers[i]; if (owner != null && owner.equals(consumerId)) { answer = createMessageGroupSet(i, answer); consumers[i] = null; } } if (answer == null) { // make an empty set answer = EmptyMessageGroupSet.INSTANCE; } return answer; }
public synchronized ConsumerId removeGroup(String groupId) { int bucket = getBucketNumber(groupId); ConsumerId answer = consumers[bucket]; consumers[bucket] = null; cache.remove(groupId); return answer; }
public synchronized void put(String groupId, ConsumerId consumerId) { int bucket = getBucketNumber(groupId); consumers[bucket] = consumerId; if (consumerId != null){ cache.put(groupId,consumerId.toString()); } }