/** @param packet */ private void handleLargeMessageWrite(final ReplicationLargeMessageWriteMessage packet) throws Exception { ReplicatedLargeMessage message = lookupLargeMessage(packet.getMessageId(), false); if (message != null) { message.addBytes(packet.getBody()); } }
@Override public synchronized void stop() throws Exception { if (!started) { return; } // Channel may be null if there isn't a connection to a live server if (channel != null) { channel.close(); } for (ReplicatedLargeMessage largeMessage : largeMessages.values()) { largeMessage.releaseResources(); } largeMessages.clear(); for (Entry<JournalContent, Map<Long, JournalSyncFile>> entry : filesReservedForSync.entrySet()) { for (JournalSyncFile filesReserved : entry.getValue().values()) { filesReserved.close(); } } filesReservedForSync.clear(); if (journals != null) { for (Journal j : journals) { if (j instanceof FileWrapperJournal) j.stop(); } } for (ConcurrentMap<Integer, Page> map : pageIndex.values()) { for (Page page : map.values()) { try { page.sync(); page.close(); } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorClosingPageOnReplication(e); } } } pageManager.stop(); pageIndex.clear(); final CountDownLatch latch = new CountDownLatch(1); executor.execute( new Runnable() { @Override public void run() { latch.countDown(); } }); latch.await(30, TimeUnit.SECONDS); // Storage needs to be the last to stop storageManager.stop(); started = false; }
private void createLargeMessage(final long id, boolean liveToBackupSync) { ReplicatedLargeMessage msg; if (liveToBackupSync) { msg = new LargeServerMessageInSync(storageManager); } else { msg = storageManager.createLargeMessage(); } msg.setDurable(true); msg.setMessageID(id); largeMessages.put(id, msg); }