001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.activemq.broker.region; 018 019import java.io.IOException; 020import java.util.ArrayList; 021import java.util.LinkedList; 022import java.util.List; 023import java.util.concurrent.atomic.AtomicInteger; 024import java.util.concurrent.atomic.AtomicLong; 025 026import javax.jms.JMSException; 027 028import org.apache.activemq.ActiveMQMessageAudit; 029import org.apache.activemq.broker.Broker; 030import org.apache.activemq.broker.ConnectionContext; 031import org.apache.activemq.broker.region.cursors.FilePendingMessageCursor; 032import org.apache.activemq.broker.region.cursors.PendingMessageCursor; 033import org.apache.activemq.broker.region.cursors.VMPendingMessageCursor; 034import org.apache.activemq.broker.region.policy.MessageEvictionStrategy; 035import org.apache.activemq.broker.region.policy.OldestMessageEvictionStrategy; 036import org.apache.activemq.command.ConsumerControl; 037import org.apache.activemq.command.ConsumerInfo; 038import org.apache.activemq.command.Message; 039import org.apache.activemq.command.MessageAck; 040import org.apache.activemq.command.MessageDispatch; 041import org.apache.activemq.command.MessageDispatchNotification; 042import org.apache.activemq.command.MessageId; 043import org.apache.activemq.command.MessagePull; 044import org.apache.activemq.command.Response; 045import org.apache.activemq.thread.Scheduler; 046import org.apache.activemq.transaction.Synchronization; 047import org.apache.activemq.transport.TransmitCallback; 048import org.apache.activemq.usage.SystemUsage; 049import org.slf4j.Logger; 050import org.slf4j.LoggerFactory; 051 052public class TopicSubscription extends AbstractSubscription { 053 054 private static final Logger LOG = LoggerFactory.getLogger(TopicSubscription.class); 055 private static final AtomicLong CURSOR_NAME_COUNTER = new AtomicLong(0); 056 057 protected PendingMessageCursor matched; 058 protected final SystemUsage usageManager; 059 boolean singleDestination = true; 060 Destination destination; 061 private final Scheduler scheduler; 062 063 private int maximumPendingMessages = -1; 064 private MessageEvictionStrategy messageEvictionStrategy = new OldestMessageEvictionStrategy(); 065 private int discarded; 066 private final Object matchedListMutex = new Object(); 067 private final AtomicInteger prefetchExtension = new AtomicInteger(0); 068 private int memoryUsageHighWaterMark = 95; 069 // allow duplicate suppression in a ring network of brokers 070 protected int maxProducersToAudit = 1024; 071 protected int maxAuditDepth = 1000; 072 protected boolean enableAudit = false; 073 protected ActiveMQMessageAudit audit; 074 protected boolean active = false; 075 protected boolean discarding = false; 076 077 //Used for inflight message size calculations 078 protected final Object dispatchLock = new Object(); 079 protected final List<MessageReference> dispatched = new ArrayList<MessageReference>(); 080 081 public TopicSubscription(Broker broker,ConnectionContext context, ConsumerInfo info, SystemUsage usageManager) throws Exception { 082 super(broker, context, info); 083 this.usageManager = usageManager; 084 String matchedName = "TopicSubscription:" + CURSOR_NAME_COUNTER.getAndIncrement() + "[" + info.getConsumerId().toString() + "]"; 085 if (info.getDestination().isTemporary() || broker.getTempDataStore()==null ) { 086 this.matched = new VMPendingMessageCursor(false); 087 } else { 088 this.matched = new FilePendingMessageCursor(broker,matchedName,false); 089 } 090 091 this.scheduler = broker.getScheduler(); 092 } 093 094 public void init() throws Exception { 095 this.matched.setSystemUsage(usageManager); 096 this.matched.setMemoryUsageHighWaterMark(getCursorMemoryHighWaterMark()); 097 this.matched.start(); 098 if (enableAudit) { 099 audit= new ActiveMQMessageAudit(maxAuditDepth, maxProducersToAudit); 100 } 101 this.active=true; 102 } 103 104 @Override 105 public void add(MessageReference node) throws Exception { 106 if (isDuplicate(node)) { 107 return; 108 } 109 // Lets use an indirect reference so that we can associate a unique 110 // locator /w the message. 111 node = new IndirectMessageReference(node.getMessage()); 112 getSubscriptionStatistics().getEnqueues().increment(); 113 synchronized (matchedListMutex) { 114 // if this subscriber is already discarding a message, we don't want to add 115 // any more messages to it as those messages can only be advisories generated in the process, 116 // which can trigger the recursive call loop 117 if (discarding) return; 118 119 if (!isFull() && matched.isEmpty()) { 120 // if maximumPendingMessages is set we will only discard messages which 121 // have not been dispatched (i.e. we allow the prefetch buffer to be filled) 122 dispatch(node); 123 setSlowConsumer(false); 124 } else { 125 if (info.getPrefetchSize() > 1 && matched.size() > info.getPrefetchSize()) { 126 // Slow consumers should log and set their state as such. 127 if (!isSlowConsumer()) { 128 LOG.warn("{}: has twice its prefetch limit pending, without an ack; it appears to be slow", toString()); 129 setSlowConsumer(true); 130 for (Destination dest: destinations) { 131 dest.slowConsumer(getContext(), this); 132 } 133 } 134 } 135 if (maximumPendingMessages != 0) { 136 boolean warnedAboutWait = false; 137 while (active) { 138 while (matched.isFull()) { 139 if (getContext().getStopping().get()) { 140 LOG.warn("{}: stopped waiting for space in pendingMessage cursor for: {}", toString(), node.getMessageId()); 141 getSubscriptionStatistics().getEnqueues().decrement(); 142 return; 143 } 144 if (!warnedAboutWait) { 145 LOG.info("{}: Pending message cursor [{}] is full, temp usag ({}%) or memory usage ({}%) limit reached, blocking message add() pending the release of resources.", 146 new Object[]{ 147 toString(), 148 matched, 149 matched.getSystemUsage().getTempUsage().getPercentUsage(), 150 matched.getSystemUsage().getMemoryUsage().getPercentUsage() 151 }); 152 warnedAboutWait = true; 153 } 154 matchedListMutex.wait(20); 155 } 156 // Temporary storage could be full - so just try to add the message 157 // see https://issues.apache.org/activemq/browse/AMQ-2475 158 if (matched.tryAddMessageLast(node, 10)) { 159 break; 160 } 161 } 162 if (maximumPendingMessages > 0) { 163 // calculate the high water mark from which point we 164 // will eagerly evict expired messages 165 int max = messageEvictionStrategy.getEvictExpiredMessagesHighWatermark(); 166 if (maximumPendingMessages > 0 && maximumPendingMessages < max) { 167 max = maximumPendingMessages; 168 } 169 if (!matched.isEmpty() && matched.size() > max) { 170 removeExpiredMessages(); 171 } 172 // lets discard old messages as we are a slow consumer 173 while (!matched.isEmpty() && matched.size() > maximumPendingMessages) { 174 int pageInSize = matched.size() - maximumPendingMessages; 175 // only page in a 1000 at a time - else we could blow the memory 176 pageInSize = Math.max(1000, pageInSize); 177 LinkedList<MessageReference> list = null; 178 MessageReference[] oldMessages=null; 179 synchronized(matched){ 180 list = matched.pageInList(pageInSize); 181 oldMessages = messageEvictionStrategy.evictMessages(list); 182 for (MessageReference ref : list) { 183 ref.decrementReferenceCount(); 184 } 185 } 186 int messagesToEvict = 0; 187 if (oldMessages != null){ 188 messagesToEvict = oldMessages.length; 189 for (int i = 0; i < messagesToEvict; i++) { 190 MessageReference oldMessage = oldMessages[i]; 191 discard(oldMessage); 192 } 193 } 194 // lets avoid an infinite loop if we are given a bad eviction strategy 195 // for a bad strategy lets just not evict 196 if (messagesToEvict == 0) { 197 LOG.warn("No messages to evict returned for {} from eviction strategy: {} out of {} candidates", new Object[]{ 198 destination, messageEvictionStrategy, list.size() 199 }); 200 break; 201 } 202 } 203 } 204 dispatchMatched(); 205 } 206 } 207 } 208 } 209 210 private boolean isDuplicate(MessageReference node) { 211 boolean duplicate = false; 212 if (enableAudit && audit != null) { 213 duplicate = audit.isDuplicate(node); 214 if (LOG.isDebugEnabled()) { 215 if (duplicate) { 216 LOG.debug("{}, ignoring duplicate add: {}", this, node.getMessageId()); 217 } 218 } 219 } 220 return duplicate; 221 } 222 223 /** 224 * Discard any expired messages from the matched list. Called from a 225 * synchronized block. 226 * 227 * @throws IOException 228 */ 229 protected void removeExpiredMessages() throws IOException { 230 try { 231 matched.reset(); 232 while (matched.hasNext()) { 233 MessageReference node = matched.next(); 234 node.decrementReferenceCount(); 235 if (node.isExpired()) { 236 matched.remove(); 237 getSubscriptionStatistics().getDispatched().increment(); 238 node.decrementReferenceCount(); 239 if (broker.isExpired(node)) { 240 ((Destination) node.getRegionDestination()).getDestinationStatistics().getExpired().increment(); 241 broker.messageExpired(getContext(), node, this); 242 } 243 break; 244 } 245 } 246 } finally { 247 matched.release(); 248 } 249 } 250 251 @Override 252 public void processMessageDispatchNotification(MessageDispatchNotification mdn) { 253 synchronized (matchedListMutex) { 254 try { 255 matched.reset(); 256 while (matched.hasNext()) { 257 MessageReference node = matched.next(); 258 node.decrementReferenceCount(); 259 if (node.getMessageId().equals(mdn.getMessageId())) { 260 synchronized(dispatchLock) { 261 matched.remove(); 262 getSubscriptionStatistics().getDispatched().increment(); 263 dispatched.add(node); 264 getSubscriptionStatistics().getInflightMessageSize().addSize(node.getSize()); 265 node.decrementReferenceCount(); 266 } 267 break; 268 } 269 } 270 } finally { 271 matched.release(); 272 } 273 } 274 } 275 276 @Override 277 public synchronized void acknowledge(final ConnectionContext context, final MessageAck ack) throws Exception { 278 super.acknowledge(context, ack); 279 280 // Handle the standard acknowledgment case. 281 if (ack.isStandardAck() || ack.isPoisonAck() || ack.isIndividualAck()) { 282 if (context.isInTransaction()) { 283 context.getTransaction().addSynchronization(new Synchronization() { 284 @Override 285 public void afterCommit() throws Exception { 286 updateStatsOnAck(ack); 287 dispatchMatched(); 288 } 289 }); 290 } else { 291 updateStatsOnAck(ack); 292 } 293 updatePrefetch(ack); 294 dispatchMatched(); 295 return; 296 } else if (ack.isDeliveredAck()) { 297 // Message was delivered but not acknowledged: update pre-fetch counters. 298 prefetchExtension.addAndGet(ack.getMessageCount()); 299 dispatchMatched(); 300 return; 301 } else if (ack.isExpiredAck()) { 302 updateStatsOnAck(ack); 303 updatePrefetch(ack); 304 dispatchMatched(); 305 return; 306 } else if (ack.isRedeliveredAck()) { 307 // nothing to do atm 308 return; 309 } 310 throw new JMSException("Invalid acknowledgment: " + ack); 311 } 312 313 @Override 314 public Response pullMessage(ConnectionContext context, final MessagePull pull) throws Exception { 315 316 // The slave should not deliver pull messages. 317 if (getPrefetchSize() == 0) { 318 319 final long currentDispatchedCount = getSubscriptionStatistics().getDispatched().getCount(); 320 prefetchExtension.set(pull.getQuantity()); 321 dispatchMatched(); 322 323 // If there was nothing dispatched.. we may need to setup a timeout. 324 if (currentDispatchedCount == getSubscriptionStatistics().getDispatched().getCount() || pull.isAlwaysSignalDone()) { 325 326 // immediate timeout used by receiveNoWait() 327 if (pull.getTimeout() == -1) { 328 // Send a NULL message to signal nothing pending. 329 dispatch(null); 330 prefetchExtension.set(0); 331 } 332 333 if (pull.getTimeout() > 0) { 334 scheduler.executeAfterDelay(new Runnable() { 335 336 @Override 337 public void run() { 338 pullTimeout(currentDispatchedCount, pull.isAlwaysSignalDone()); 339 } 340 }, pull.getTimeout()); 341 } 342 } 343 } 344 return null; 345 } 346 347 /** 348 * Occurs when a pull times out. If nothing has been dispatched since the 349 * timeout was setup, then send the NULL message. 350 */ 351 private final void pullTimeout(long currentDispatchedCount, boolean alwaysSendDone) { 352 synchronized (matchedListMutex) { 353 if (currentDispatchedCount == getSubscriptionStatistics().getDispatched().getCount() || alwaysSendDone) { 354 try { 355 dispatch(null); 356 } catch (Exception e) { 357 context.getConnection().serviceException(e); 358 } finally { 359 prefetchExtension.set(0); 360 } 361 } 362 } 363 } 364 365 /** 366 * Update the statistics on message ack. 367 * @param ack 368 */ 369 private void updateStatsOnAck(final MessageAck ack) { 370 synchronized(dispatchLock) { 371 boolean inAckRange = false; 372 List<MessageReference> removeList = new ArrayList<MessageReference>(); 373 for (final MessageReference node : dispatched) { 374 MessageId messageId = node.getMessageId(); 375 if (ack.getFirstMessageId() == null 376 || ack.getFirstMessageId().equals(messageId)) { 377 inAckRange = true; 378 } 379 if (inAckRange) { 380 removeList.add(node); 381 if (ack.getLastMessageId().equals(messageId)) { 382 break; 383 } 384 } 385 } 386 387 for (final MessageReference node : removeList) { 388 dispatched.remove(node); 389 getSubscriptionStatistics().getInflightMessageSize().addSize(-node.getSize()); 390 getSubscriptionStatistics().getDequeues().increment(); 391 ((Destination)node.getRegionDestination()).getDestinationStatistics().getDequeues().increment(); 392 ((Destination)node.getRegionDestination()).getDestinationStatistics().getInflight().decrement(); 393 if (info.isNetworkSubscription()) { 394 ((Destination)node.getRegionDestination()).getDestinationStatistics().getForwards().add(ack.getMessageCount()); 395 } 396 if (ack.isExpiredAck()) { 397 destination.getDestinationStatistics().getExpired().add(ack.getMessageCount()); 398 } 399 } 400 } 401 } 402 403 private void updatePrefetch(MessageAck ack) { 404 while (true) { 405 int currentExtension = prefetchExtension.get(); 406 int newExtension = Math.max(0, currentExtension - ack.getMessageCount()); 407 if (prefetchExtension.compareAndSet(currentExtension, newExtension)) { 408 break; 409 } 410 } 411 } 412 413 @Override 414 public int getPendingQueueSize() { 415 return matched(); 416 } 417 418 @Override 419 public int getDispatchedQueueSize() { 420 return (int)(getSubscriptionStatistics().getDispatched().getCount() - 421 prefetchExtension.get() - getSubscriptionStatistics().getDequeues().getCount()); 422 } 423 424 public int getMaximumPendingMessages() { 425 return maximumPendingMessages; 426 } 427 428 @Override 429 public long getDispatchedCounter() { 430 return getSubscriptionStatistics().getDispatched().getCount(); 431 } 432 433 @Override 434 public long getEnqueueCounter() { 435 return getSubscriptionStatistics().getEnqueues().getCount(); 436 } 437 438 @Override 439 public long getDequeueCounter() { 440 return getSubscriptionStatistics().getDequeues().getCount(); 441 } 442 443 /** 444 * @return the number of messages discarded due to being a slow consumer 445 */ 446 public int discarded() { 447 synchronized (matchedListMutex) { 448 return discarded; 449 } 450 } 451 452 /** 453 * @return the number of matched messages (messages targeted for the 454 * subscription but not yet able to be dispatched due to the 455 * prefetch buffer being full). 456 */ 457 public int matched() { 458 synchronized (matchedListMutex) { 459 return matched.size(); 460 } 461 } 462 463 /** 464 * Sets the maximum number of pending messages that can be matched against 465 * this consumer before old messages are discarded. 466 */ 467 public void setMaximumPendingMessages(int maximumPendingMessages) { 468 this.maximumPendingMessages = maximumPendingMessages; 469 } 470 471 public MessageEvictionStrategy getMessageEvictionStrategy() { 472 return messageEvictionStrategy; 473 } 474 475 /** 476 * Sets the eviction strategy used to decide which message to evict when the 477 * slow consumer needs to discard messages 478 */ 479 public void setMessageEvictionStrategy(MessageEvictionStrategy messageEvictionStrategy) { 480 this.messageEvictionStrategy = messageEvictionStrategy; 481 } 482 483 public int getMaxProducersToAudit() { 484 return maxProducersToAudit; 485 } 486 487 public synchronized void setMaxProducersToAudit(int maxProducersToAudit) { 488 this.maxProducersToAudit = maxProducersToAudit; 489 if (audit != null) { 490 audit.setMaximumNumberOfProducersToTrack(maxProducersToAudit); 491 } 492 } 493 494 public int getMaxAuditDepth() { 495 return maxAuditDepth; 496 } 497 498 public synchronized void setMaxAuditDepth(int maxAuditDepth) { 499 this.maxAuditDepth = maxAuditDepth; 500 if (audit != null) { 501 audit.setAuditDepth(maxAuditDepth); 502 } 503 } 504 505 public boolean isEnableAudit() { 506 return enableAudit; 507 } 508 509 public synchronized void setEnableAudit(boolean enableAudit) { 510 this.enableAudit = enableAudit; 511 if (enableAudit && audit == null) { 512 audit = new ActiveMQMessageAudit(maxAuditDepth,maxProducersToAudit); 513 } 514 } 515 516 // Implementation methods 517 // ------------------------------------------------------------------------- 518 @Override 519 public boolean isFull() { 520 return getDispatchedQueueSize() >= info.getPrefetchSize(); 521 } 522 523 @Override 524 public int getInFlightSize() { 525 return getDispatchedQueueSize(); 526 } 527 528 /** 529 * @return true when 60% or more room is left for dispatching messages 530 */ 531 @Override 532 public boolean isLowWaterMark() { 533 return getDispatchedQueueSize() <= (info.getPrefetchSize() * .4); 534 } 535 536 /** 537 * @return true when 10% or less room is left for dispatching messages 538 */ 539 @Override 540 public boolean isHighWaterMark() { 541 return getDispatchedQueueSize() >= (info.getPrefetchSize() * .9); 542 } 543 544 /** 545 * @param memoryUsageHighWaterMark the memoryUsageHighWaterMark to set 546 */ 547 public void setMemoryUsageHighWaterMark(int memoryUsageHighWaterMark) { 548 this.memoryUsageHighWaterMark = memoryUsageHighWaterMark; 549 } 550 551 /** 552 * @return the memoryUsageHighWaterMark 553 */ 554 public int getMemoryUsageHighWaterMark() { 555 return this.memoryUsageHighWaterMark; 556 } 557 558 /** 559 * @return the usageManager 560 */ 561 public SystemUsage getUsageManager() { 562 return this.usageManager; 563 } 564 565 /** 566 * @return the matched 567 */ 568 public PendingMessageCursor getMatched() { 569 return this.matched; 570 } 571 572 /** 573 * @param matched the matched to set 574 */ 575 public void setMatched(PendingMessageCursor matched) { 576 this.matched = matched; 577 } 578 579 /** 580 * inform the MessageConsumer on the client to change it's prefetch 581 * 582 * @param newPrefetch 583 */ 584 @Override 585 public void updateConsumerPrefetch(int newPrefetch) { 586 if (context != null && context.getConnection() != null && context.getConnection().isManageable()) { 587 ConsumerControl cc = new ConsumerControl(); 588 cc.setConsumerId(info.getConsumerId()); 589 cc.setPrefetch(newPrefetch); 590 context.getConnection().dispatchAsync(cc); 591 } 592 } 593 594 private void dispatchMatched() throws IOException { 595 synchronized (matchedListMutex) { 596 if (!matched.isEmpty() && !isFull()) { 597 try { 598 matched.reset(); 599 600 while (matched.hasNext() && !isFull()) { 601 MessageReference message = matched.next(); 602 message.decrementReferenceCount(); 603 matched.remove(); 604 // Message may have been sitting in the matched list a while 605 // waiting for the consumer to ak the message. 606 if (message.isExpired()) { 607 discard(message); 608 continue; // just drop it. 609 } 610 dispatch(message); 611 } 612 } finally { 613 matched.release(); 614 } 615 } 616 } 617 } 618 619 private void dispatch(final MessageReference node) throws IOException { 620 Message message = node != null ? node.getMessage() : null; 621 if (node != null) { 622 node.incrementReferenceCount(); 623 } 624 // Make sure we can dispatch a message. 625 MessageDispatch md = new MessageDispatch(); 626 md.setMessage(message); 627 md.setConsumerId(info.getConsumerId()); 628 if (node != null) { 629 md.setDestination(((Destination)node.getRegionDestination()).getActiveMQDestination()); 630 synchronized(dispatchLock) { 631 getSubscriptionStatistics().getDispatched().increment(); 632 dispatched.add(node); 633 getSubscriptionStatistics().getInflightMessageSize().addSize(node.getSize()); 634 } 635 636 // Keep track if this subscription is receiving messages from a single destination. 637 if (singleDestination) { 638 if (destination == null) { 639 destination = (Destination)node.getRegionDestination(); 640 } else { 641 if (destination != node.getRegionDestination()) { 642 singleDestination = false; 643 } 644 } 645 } 646 } 647 if (info.isDispatchAsync()) { 648 if (node != null) { 649 md.setTransmitCallback(new TransmitCallback() { 650 651 @Override 652 public void onSuccess() { 653 Destination regionDestination = (Destination) node.getRegionDestination(); 654 regionDestination.getDestinationStatistics().getDispatched().increment(); 655 regionDestination.getDestinationStatistics().getInflight().increment(); 656 node.decrementReferenceCount(); 657 } 658 659 @Override 660 public void onFailure() { 661 Destination regionDestination = (Destination) node.getRegionDestination(); 662 regionDestination.getDestinationStatistics().getDispatched().increment(); 663 regionDestination.getDestinationStatistics().getInflight().increment(); 664 node.decrementReferenceCount(); 665 } 666 }); 667 } 668 context.getConnection().dispatchAsync(md); 669 } else { 670 context.getConnection().dispatchSync(md); 671 if (node != null) { 672 Destination regionDestination = (Destination) node.getRegionDestination(); 673 regionDestination.getDestinationStatistics().getDispatched().increment(); 674 regionDestination.getDestinationStatistics().getInflight().increment(); 675 node.decrementReferenceCount(); 676 } 677 } 678 } 679 680 private void discard(MessageReference message) { 681 discarding = true; 682 try { 683 message.decrementReferenceCount(); 684 matched.remove(message); 685 discarded++; 686 if (destination != null) { 687 destination.getDestinationStatistics().getDequeues().increment(); 688 } 689 LOG.debug("{}, discarding message {}", this, message); 690 Destination dest = (Destination) message.getRegionDestination(); 691 if (dest != null) { 692 dest.messageDiscarded(getContext(), this, message); 693 } 694 broker.getRoot().sendToDeadLetterQueue(getContext(), message, this, new Throwable("TopicSubDiscard. ID:" + info.getConsumerId())); 695 } finally { 696 discarding = false; 697 } 698 } 699 700 @Override 701 public String toString() { 702 return "TopicSubscription:" + " consumer=" + info.getConsumerId() + ", destinations=" + destinations.size() + ", dispatched=" + getDispatchedQueueSize() + ", delivered=" 703 + getDequeueCounter() + ", matched=" + matched() + ", discarded=" + discarded(); 704 } 705 706 @Override 707 public void destroy() { 708 this.active=false; 709 synchronized (matchedListMutex) { 710 try { 711 matched.destroy(); 712 } catch (Exception e) { 713 LOG.warn("Failed to destroy cursor", e); 714 } 715 } 716 setSlowConsumer(false); 717 synchronized(dispatchLock) { 718 dispatched.clear(); 719 } 720 } 721 722 @Override 723 public int getPrefetchSize() { 724 return info.getPrefetchSize(); 725 } 726 727 @Override 728 public void setPrefetchSize(int newSize) { 729 info.setPrefetchSize(newSize); 730 try { 731 dispatchMatched(); 732 } catch(Exception e) { 733 LOG.trace("Caught exception on dispatch after prefetch size change."); 734 } 735 } 736}