http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/openmbean/OpenTypeSupport.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/openmbean/OpenTypeSupport.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/openmbean/OpenTypeSupport.java index 7bb3764..41e2632 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/openmbean/OpenTypeSupport.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/openmbean/OpenTypeSupport.java @@ -16,11 +16,6 @@ */ package org.apache.activemq.artemis.core.management.impl.openmbean; -import org.apache.activemq.artemis.api.core.ActiveMQBuffer; -import org.apache.activemq.artemis.api.core.Message; -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.core.server.MessageReference; - import javax.management.openmbean.ArrayType; import javax.management.openmbean.CompositeData; import javax.management.openmbean.CompositeDataSupport; @@ -36,6 +31,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.activemq.artemis.api.core.ActiveMQBuffer; +import org.apache.activemq.artemis.api.core.Message; +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.core.server.MessageReference; + public final class OpenTypeSupport { private static MessageOpenTypeFactory FACTORY = new MessageOpenTypeFactory(); @@ -49,8 +49,8 @@ public final class OpenTypeSupport { return new CompositeDataSupport(ct, fields); } - static class MessageOpenTypeFactory { + private CompositeType compositeType; private final List<String> itemNamesList = new ArrayList<>(); private final List<String> itemDescriptionsList = new ArrayList<>(); @@ -123,8 +123,7 @@ public final class OpenTypeSupport { rc.put(CompositeDataConstants.MESSAGE_ID, "" + m.getMessageID()); if (m.getUserID() != null) { rc.put(CompositeDataConstants.USER_ID, "ID:" + m.getUserID().toString()); - } - else { + } else { rc.put(CompositeDataConstants.USER_ID, ""); } rc.put(CompositeDataConstants.ADDRESS, m.getAddress().toString()); @@ -146,50 +145,42 @@ public final class OpenTypeSupport { try { rc.put(CompositeDataConstants.STRING_PROPERTIES, createTabularData(propertyMap, stringPropertyTabularType, String.class)); - } - catch (IOException e) { + } catch (IOException e) { rc.put(CompositeDataConstants.STRING_PROPERTIES, new TabularDataSupport(stringPropertyTabularType)); } try { rc.put(CompositeDataConstants.BOOLEAN_PROPERTIES, createTabularData(propertyMap, booleanPropertyTabularType, Boolean.class)); - } - catch (IOException e) { + } catch (IOException e) { rc.put(CompositeDataConstants.BOOLEAN_PROPERTIES, new TabularDataSupport(booleanPropertyTabularType)); } try { rc.put(CompositeDataConstants.BYTE_PROPERTIES, createTabularData(propertyMap, bytePropertyTabularType, Byte.class)); - } - catch (IOException e) { + } catch (IOException e) { rc.put(CompositeDataConstants.BYTE_PROPERTIES, new TabularDataSupport(bytePropertyTabularType)); } try { rc.put(CompositeDataConstants.SHORT_PROPERTIES, createTabularData(propertyMap, shortPropertyTabularType, Short.class)); - } - catch (IOException e) { + } catch (IOException e) { rc.put(CompositeDataConstants.SHORT_PROPERTIES, new TabularDataSupport(shortPropertyTabularType)); } try { rc.put(CompositeDataConstants.INT_PROPERTIES, createTabularData(propertyMap, intPropertyTabularType, Integer.class)); - } - catch (IOException e) { + } catch (IOException e) { rc.put(CompositeDataConstants.INT_PROPERTIES, new TabularDataSupport(intPropertyTabularType)); } try { rc.put(CompositeDataConstants.LONG_PROPERTIES, createTabularData(propertyMap, longPropertyTabularType, Long.class)); - } - catch (IOException e) { + } catch (IOException e) { rc.put(CompositeDataConstants.LONG_PROPERTIES, new TabularDataSupport(longPropertyTabularType)); } try { rc.put(CompositeDataConstants.FLOAT_PROPERTIES, createTabularData(propertyMap, floatPropertyTabularType, Float.class)); - } - catch (IOException e) { + } catch (IOException e) { rc.put(CompositeDataConstants.FLOAT_PROPERTIES, new TabularDataSupport(floatPropertyTabularType)); } try { rc.put(CompositeDataConstants.DOUBLE_PROPERTIES, createTabularData(propertyMap, doublePropertyTabularType, Double.class)); - } - catch (IOException e) { + } catch (IOException e) { rc.put(CompositeDataConstants.DOUBLE_PROPERTIES, new TabularDataSupport(doublePropertyTabularType)); } return rc; @@ -221,7 +212,9 @@ public final class OpenTypeSupport { return new TabularType(typeName, typeName, rowType, new String[]{"key"}); } - protected TabularDataSupport createTabularData(Map<String, Object> entries, TabularType type, Class valueType) throws IOException, OpenDataException { + protected TabularDataSupport createTabularData(Map<String, Object> entries, + TabularType type, + Class valueType) throws IOException, OpenDataException { TabularDataSupport answer = new TabularDataSupport(type); for (String key : entries.keySet()) { @@ -229,8 +222,7 @@ public final class OpenTypeSupport { if (valueType.isInstance(value)) { CompositeDataSupport compositeData = createTabularRowValue(type, key, value); answer.put(compositeData); - } - else if (valueType == String.class && value instanceof SimpleString) { + } else if (valueType == String.class && value instanceof SimpleString) { CompositeDataSupport compositeData = createTabularRowValue(type, key, value.toString()); answer.put(compositeData); } @@ -238,14 +230,15 @@ public final class OpenTypeSupport { return answer; } - protected CompositeDataSupport createTabularRowValue(TabularType type, String key, Object value) throws OpenDataException { + protected CompositeDataSupport createTabularRowValue(TabularType type, + String key, + Object value) throws OpenDataException { Map<String, Object> fields = new HashMap<>(); fields.put("key", key); fields.put("value", value); return new CompositeDataSupport(type.getRowType(), fields); } - protected void addItem(String name, String description, OpenType type) { itemNamesList.add(name); itemDescriptionsList.add(description);
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java index 9ceb8ea..522445d 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java @@ -232,12 +232,10 @@ public class MessageCounter { // create initial day counter when empty bInitialize = dayCounters.isEmpty(); - } - else if (dayCounterMax == 0) { + } else if (dayCounterMax == 0) { // disable history dayCounters.clear(); - } - else { + } else { // unlimited day history // create initial day counter when empty @@ -418,12 +416,10 @@ public class MessageCounter { if (i < hour) { if (isStartDay) { counters[i] = -1; - } - else { + } else { counters[i] = 0; } - } - else { + } else { counters[i] = -1; } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterHelper.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterHelper.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterHelper.java index 9cf41ad..1688985 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterHelper.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterHelper.java @@ -141,8 +141,7 @@ public class MessageCounterHelper { if (value == -1) { ret.append("<td></td>"); - } - else { + } else { ret.append("<td>" + value + "</td>"); total += value; @@ -172,8 +171,7 @@ public class MessageCounterHelper { private static String asDate(final long time) { if (time > 0) { return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date(time)); - } - else { + } else { return "-"; } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterManagerImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterManagerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterManagerImpl.java index a5c1be4..1fd4fbe 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterManagerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterManagerImpl.java @@ -48,7 +48,7 @@ public class MessageCounterManagerImpl implements MessageCounterManager { public MessageCounterManagerImpl(final ScheduledExecutorService scheduledThreadPool, Executor executor) { messageCounters = new HashMap<>(); - messageCountersPinger = new MessageCountersPinger(scheduledThreadPool, executor, MessageCounterManagerImpl.DEFAULT_SAMPLE_PERIOD, TimeUnit.MILLISECONDS, false); + messageCountersPinger = new MessageCountersPinger(scheduledThreadPool, executor, MessageCounterManagerImpl.DEFAULT_SAMPLE_PERIOD, TimeUnit.MILLISECONDS, false); } @Override @@ -129,10 +129,10 @@ public class MessageCounterManagerImpl implements MessageCounterManager { private class MessageCountersPinger extends ActiveMQScheduledComponent { MessageCountersPinger(ScheduledExecutorService scheduledExecutorService, - Executor executor, - long checkPeriod, - TimeUnit timeUnit, - boolean onDemand) { + Executor executor, + long checkPeriod, + TimeUnit timeUnit, + boolean onDemand) { super(scheduledExecutorService, executor, checkPeriod, timeUnit, onDemand); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingManager.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingManager.java index b70626a..5505412 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingManager.java @@ -95,8 +95,10 @@ public interface PagingManager extends ActiveMQComponent, HierarchicalRepository */ void unlock(); - /** Add size at the global count level. - * if totalSize > globalMaxSize it will return true */ + /** + * Add size at the global count level. + * if totalSize > globalMaxSize it will return true + */ PagingManager addSize(int size); boolean isUsingGlobalSize(); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java index a4a41ef..3ae7f75 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java @@ -130,7 +130,9 @@ public interface PagingStore extends ActiveMQComponent { boolean isRejectingMessages(); - /** It will return true if the destination is leaving blocking. */ + /** + * It will return true if the destination is leaving blocking. + */ boolean checkReleasedMemory(); /** http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStoreFactory.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStoreFactory.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStoreFactory.java index 942ff80..a90fd44 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStoreFactory.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStoreFactory.java @@ -34,7 +34,10 @@ public interface PagingStoreFactory { PagingStore newStore(SimpleString address, AddressSettings addressSettings); - PageCursorProvider newCursorProvider(PagingStore store, StorageManager storageManager, AddressSettings addressSettings, Executor executor); + PageCursorProvider newCursorProvider(PagingStore store, + StorageManager storageManager, + AddressSettings addressSettings, + Executor executor); void stop() throws InterruptedException; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/NonExistentPage.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/NonExistentPage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/NonExistentPage.java index 73a22ce..9b4c41e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/NonExistentPage.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/NonExistentPage.java @@ -17,9 +17,11 @@ package org.apache.activemq.artemis.core.paging.cursor; -/** This is an internal exception. - * In certain cases AfterCommit could try to decrease the reference counting on large messages. - * But if the whole page is cleaned an exception could happen, which is ok on that path, and we need to identify it. */ +/** + * This is an internal exception. + * In certain cases AfterCommit could try to decrease the reference counting on large messages. + * But if the whole page is cleaned an exception could happen, which is ok on that path, and we need to identify it. + */ public class NonExistentPage extends RuntimeException { public NonExistentPage() { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PageCursorProvider.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PageCursorProvider.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PageCursorProvider.java index b2a6aff..fd20952 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PageCursorProvider.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PageCursorProvider.java @@ -24,7 +24,9 @@ import org.apache.activemq.artemis.core.paging.PagedMessage; */ public interface PageCursorProvider { - /** Used on tests, to simulate a scenario where the VM cleared space */ + /** + * Used on tests, to simulate a scenario where the VM cleared space + */ void clearCache(); PageCache getPageCache(long pageNr); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java index a447569..768b43f 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java @@ -96,8 +96,7 @@ public class PagedReferenceImpl implements PagedReference { if (message == null) { this.messageEstimate = -1; - } - else { + } else { this.messageEstimate = message.getMessage().getMemoryEstimate(); } this.message = new WeakReference<>(message); @@ -124,8 +123,7 @@ public class PagedReferenceImpl implements PagedReference { if (messageEstimate < 0) { try { messageEstimate = getMessage().getMemoryEstimate(); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } @@ -144,12 +142,10 @@ public class PagedReferenceImpl implements PagedReference { ServerMessage msg = getMessage(); if (msg.containsProperty(Message.HDR_SCHEDULED_DELIVERY_TIME)) { deliveryTime = getMessage().getLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME); - } - else { + } else { deliveryTime = 0L; } - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); return 0L; } @@ -223,8 +219,7 @@ public class PagedReferenceImpl implements PagedReference { public void acknowledge(Transaction tx, AckReason reason) throws Exception { if (tx == null) { getQueue().acknowledge(this, reason); - } - else { + } else { getQueue().acknowledge(tx, this, reason); } } @@ -237,8 +232,7 @@ public class PagedReferenceImpl implements PagedReference { String msgToString; try { msgToString = getPagedMessage().toString(); - } - catch (Throwable e) { + } catch (Throwable e) { // in case of an exception because of a missing page, we just want toString to return null msgToString = "error:" + e.getMessage(); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/LivePageCacheImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/LivePageCacheImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/LivePageCacheImpl.java index 0d63cf0..57d2e27 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/LivePageCacheImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/LivePageCacheImpl.java @@ -64,8 +64,7 @@ public class LivePageCacheImpl implements LivePageCache { public synchronized PagedMessage getMessage(int messageNumber) { if (messageNumber < messages.size()) { return messages.get(messageNumber); - } - else { + } else { return null; } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCacheImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCacheImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCacheImpl.java index 8fd59d7..5925caf 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCacheImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCacheImpl.java @@ -47,8 +47,7 @@ class PageCacheImpl implements PageCache { public PagedMessage getMessage(final int messageNumber) { if (messageNumber < messages.length) { return messages[messageNumber]; - } - else { + } else { return null; } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java index b7c3e2e..76ad26b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java @@ -154,8 +154,7 @@ public class PageCursorProviderImpl implements PageCursorProvider { } return cache; - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } @@ -170,14 +169,12 @@ public class PageCursorProviderImpl implements PageCursorProvider { List<PagedMessage> pgdMessages = page.read(storageManager); cache.setMessages(pgdMessages.toArray(new PagedMessage[pgdMessages.size()])); - } - finally { + } finally { try { if (page != null) { page.close(false); } - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } storageManager.afterPageRead(); } @@ -293,8 +290,7 @@ public class PageCursorProviderImpl implements PageCursorProvider { if (cleanupEnabled) { cleanup(); } - } - finally { + } finally { storageManager.clearContext(); scheduledCleanup.decrementAndGet(); } @@ -316,16 +312,14 @@ public class PageCursorProviderImpl implements PageCursorProvider { for (PageSubscription sub : subscriptions) { try { sub.onPageModeCleared(tx); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn("Error while cleaning paging on queue " + sub.getQueue().getName(), e); } } try { tx.commit(); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn("Error while cleaning page, during the commit", e); } } @@ -402,35 +396,31 @@ public class PageCursorProviderImpl implements PageCursorProvider { if (pagingStore.getNumberOfPages() == 0 || pagingStore.getNumberOfPages() == 1 && pagingStore.getCurrentPage().getNumberOfMessages() == 0) { pagingStore.stopPaging(); - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace("Couldn't cleanup page on address " + this.pagingStore.getAddress() + - " as numberOfPages == " + - pagingStore.getNumberOfPages() + - " and currentPage.numberOfMessages = " + - pagingStore.getCurrentPage().getNumberOfMessages()); + " as numberOfPages == " + + pagingStore.getNumberOfPages() + + " and currentPage.numberOfMessages = " + + pagingStore.getCurrentPage().getNumberOfMessages()); } } - } - catch (Exception ex) { + } catch (Exception ex) { ActiveMQServerLogger.LOGGER.problemCleaningPageAddress(ex, pagingStore.getAddress()); return; - } - finally { + } finally { pagingStore.unlock(); } } finishCleanup(depagedPages); - } // Protected as a way to inject testing protected void cleanupComplete(ArrayList<PageSubscription> cursorList) throws Exception { if (logger.isDebugEnabled()) { logger.debug("Address " + pagingStore.getAddress() + - " is leaving page mode as all messages are consumed and acknowledged from the page store"); + " is leaving page mode as all messages are consumed and acknowledged from the page store"); } pagingStore.forceAnotherPage(); @@ -467,20 +457,17 @@ public class PageCursorProviderImpl implements PageCursorProvider { try { depagedPage.open(); pgdMessagesList = depagedPage.read(storageManager); - } - finally { + } finally { try { depagedPage.close(false); - } - catch (Exception e) { + } catch (Exception e) { } storageManager.afterPageRead(); } depagedPage.close(false); pgdMessages = pgdMessagesList.toArray(new PagedMessage[pgdMessagesList.size()]); - } - else { + } else { pgdMessages = cache.getMessages(); } @@ -491,8 +478,7 @@ public class PageCursorProviderImpl implements PageCursorProvider { softCache.remove((long) depagedPage.getPageId()); } } - } - catch (Exception ex) { + } catch (Exception ex) { ActiveMQServerLogger.LOGGER.problemCleaningPageAddress(ex, pagingStore.getAddress()); return; } @@ -513,8 +499,7 @@ public class PageCursorProviderImpl implements PageCursorProvider { complete = false; break; - } - else { + } else { if (logger.isDebugEnabled()) { logger.debug("Cursor " + cursor + " was considered **complete** at pageNr=" + minPage); } @@ -553,8 +538,7 @@ public class PageCursorProviderImpl implements PageCursorProvider { while (!storageManager.waitOnOperations(5000)) { ActiveMQServerLogger.LOGGER.problemCompletingOperations(storageManager.getContext()); } - } - finally { + } finally { for (PageSubscription cursor : cursorList) { cursor.enableAutoCleanup(); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PagePositionImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PagePositionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PagePositionImpl.java index fbf3bd6..076f872 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PagePositionImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PagePositionImpl.java @@ -86,17 +86,13 @@ public class PagePositionImpl implements PagePosition { public int compareTo(PagePosition o) { if (pageNr > o.getPageNr()) { return 1; - } - else if (pageNr < o.getPageNr()) { + } else if (pageNr < o.getPageNr()) { return -1; - } - else if (recordID > o.getRecordID()) { + } else if (recordID > o.getRecordID()) { return 1; - } - else if (recordID < o.getRecordID()) { + } else if (recordID < o.getRecordID()) { return -1; - } - else { + } else { return 0; } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionCounterImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionCounterImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionCounterImpl.java index 54dc7e9..92f313b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionCounterImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionCounterImpl.java @@ -118,8 +118,7 @@ public class PageSubscriptionCounterImpl implements PageSubscriptionCounter { long id = storage.storePendingCounter(this.subscriptionID, page.getPageId(), increment); pendingInfo = new Pair<>(id, new AtomicInteger(1)); pendingCounters.put((long) page.getPageId(), pendingInfo); - } - else { + } else { pendingInfo.getB().addAndGet(increment); } @@ -165,18 +164,15 @@ public class PageSubscriptionCounterImpl implements PageSubscriptionCounter { if (persistent) { long id = storage.storePageCounterInc(this.subscriptionID, add); incrementProcessed(id, add); - } - else { + } else { incrementProcessed(-1, add); } - } - else { + } else { if (persistent) { tx.setContainsPersistent(); long id = storage.storePageCounterInc(tx.getID(), this.subscriptionID, add); applyIncrementOnTX(tx, id, add); - } - else { + } else { applyIncrementOnTX(tx, -1, add); } } @@ -249,8 +245,7 @@ public class PageSubscriptionCounterImpl implements PageSubscriptionCounter { value.set(0); incrementRecords.clear(); } - } - finally { + } finally { storage.readUnLock(); } } @@ -333,18 +328,15 @@ public class PageSubscriptionCounterImpl implements PageSubscriptionCounter { } storage.commit(txCleanup); - } - catch (Exception e) { + } catch (Exception e) { newRecordID = recordID; ActiveMQServerLogger.LOGGER.problemCleaningPagesubscriptionCounter(e); try { storage.rollback(txCleanup); + } catch (Exception ignored) { } - catch (Exception ignored) { - } - } - finally { + } finally { recordID = newRecordID; } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java index c89161a..c1c54a2 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java @@ -172,8 +172,7 @@ final class PageSubscriptionImpl implements PageSubscription { public long getMessageCount() { if (empty) { return 0; - } - else { + } else { return counter.getValue() - deliveredCount.get(); } } @@ -222,11 +221,9 @@ final class PageSubscriptionImpl implements PageSubscription { if (autoCleanup) { cleanupEntries(false); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.problemCleaningCursorPages(e); - } - finally { + } finally { scheduledCleanupCount.decrementAndGet(); } } @@ -276,9 +273,8 @@ final class PageSubscriptionImpl implements PageSubscription { if (currentPage != null && entry.getKey() == pageStore.getCurrentPage().getPageId() && currentPage.isLive()) { logger.trace("We can't clear page " + entry.getKey() + - " now since it's the current page"); - } - else { + " now since it's the current page"); + } else { info.setPendingDelete(); completedPages.add(entry.getValue()); } @@ -375,14 +371,12 @@ final class PageSubscriptionImpl implements PageSubscription { if (cache == null) { // it will be null in the case of the current writing page return null; - } - else { + } else { PagedMessage serverMessage = cache.getMessage(retPos.getMessageNr()); if (serverMessage != null) { return cursorProvider.newReference(retPos, serverMessage, this); - } - else { + } else { return null; } } @@ -463,8 +457,7 @@ final class PageSubscriptionImpl implements PageSubscription { } if (!routed) { return false; - } - else { + } else { // if it's been routed here, we have to verify if it was acked return !getPageInfo(ref.getPosition()).isAck(ref.getPosition()); } @@ -533,8 +526,7 @@ final class PageSubscriptionImpl implements PageSubscription { PageCursorInfo pageInfo = consumedPages.get(position.getPageNr()); if (pageInfo != null) { pageInfo.decrementPendingTX(); - } - else { + } else { // this shouldn't really happen. } } @@ -590,8 +582,7 @@ final class PageSubscriptionImpl implements PageSubscription { if (info == null && empty) { logger.tracef("isComplete(%d)::::Couldn't find info and it is empty", page); return true; - } - else { + } else { boolean isDone = info != null && info.isDone(); if (logger.isTraceEnabled()) { logger.tracef("isComplete(%d):: found info=%s, isDone=%s", (Object) page, info, isDone); @@ -632,12 +623,10 @@ final class PageSubscriptionImpl implements PageSubscription { } cursorProvider.close(this); - } - catch (Exception e) { + } catch (Exception e) { try { store.rollback(tx); - } - catch (Exception ignored) { + } catch (Exception ignored) { // exception of the exception.. nothing that can be done here } } @@ -673,8 +662,7 @@ final class PageSubscriptionImpl implements PageSubscription { txDeleteCursorOnReload = store.generateID(); } store.deleteCursorAcknowledgeTransactional(txDeleteCursorOnReload, pos.getRecordID()); - } - else { + } else { pageInfo.loadACK(pos); } } @@ -725,8 +713,7 @@ final class PageSubscriptionImpl implements PageSubscription { if (completeInfo != null) { try { store.deletePageComplete(completeInfo.getRecordID()); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn("Error while deleting page-complete-record", e); } info.setCompleteInfo(null); @@ -735,8 +722,7 @@ final class PageSubscriptionImpl implements PageSubscription { if (deleteInfo.getRecordID() >= 0) { try { store.deleteCursorAcknowledge(deleteInfo.getRecordID()); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn("Error while deleting page-complete-record", e); } } @@ -783,8 +769,7 @@ final class PageSubscriptionImpl implements PageSubscription { private boolean match(final ServerMessage message) { if (filter == null) { return true; - } - else { + } else { return filter.match(message); } } @@ -817,8 +802,7 @@ final class PageSubscriptionImpl implements PageSubscription { // This could become null if the page file was deleted, or if the queue was removed maybe? // it's better to diagnose it (based on support tickets) instead of NPE ActiveMQServerLogger.LOGGER.nullPageCursorInfo(this.getPagingStore().getAddress().toString(), pos.toString(), cursorId); - } - else { + } else { info.addACK(pos); } @@ -856,8 +840,7 @@ final class PageSubscriptionImpl implements PageSubscription { private PageTransactionInfo getPageTransaction(final PagedReference reference) throws ActiveMQException { if (reference.getPagedMessage().getTransactionID() >= 0) { return pageStore.getPagingManager().getTransaction(reference.getPagedMessage().getTransactionID()); - } - else { + } else { return null; } } @@ -930,8 +913,7 @@ final class PageSubscriptionImpl implements PageSubscription { ", isDone=" + this.isDone() + " wasLive = " + wasLive; - } - catch (Exception e) { + } catch (Exception e) { return "PageCursorInfo::pageNr=" + pageId + " numberOfMessage = " + numberOfMessages + @@ -949,8 +931,7 @@ final class PageSubscriptionImpl implements PageSubscription { if (cache != null) { wasLive = cache.isLive(); this.cache = new WeakReference<>(cache); - } - else { + } else { wasLive = false; } } @@ -1012,13 +993,12 @@ final class PageSubscriptionImpl implements PageSubscription { if (logger.isTraceEnabled()) { try { logger.trace("numberOfMessages = " + getNumberOfMessages() + - " confirmed = " + - (confirmed.get() + 1) + - " pendingTX = " + pendingTX + - ", pageNr = " + - pageId + " posACK = " + posACK); - } - catch (Throwable ignored) { + " confirmed = " + + (confirmed.get() + 1) + + " pendingTX = " + pendingTX + + ", pageNr = " + + pageId + " posACK = " + posACK); + } catch (Throwable ignored) { logger.debug(ignored.getMessage(), ignored); } } @@ -1064,8 +1044,7 @@ final class PageSubscriptionImpl implements PageSubscription { } return localcache.getNumberOfMessages(); - } - else { + } else { return numberOfMessages; } } @@ -1146,12 +1125,10 @@ final class PageSubscriptionImpl implements PageSubscription { synchronized (redeliveries) { cachedNext = lastRedelivery; } - } - else { + } else { if (lastOperation == null) { position = null; - } - else { + } else { position = lastOperation; } } @@ -1194,8 +1171,7 @@ final class PageSubscriptionImpl implements PageSubscription { lastRedelivery = redeliveredMsg; return redeliveredMsg; - } - else { + } else { lastRedelivery = null; isredelivery = false; } @@ -1234,8 +1210,7 @@ final class PageSubscriptionImpl implements PageSubscription { ActiveMQServerLogger.LOGGER.pageSubscriptionCouldntLoad(message.getPagedMessage().getTransactionID(), message.getPosition(), pageStore.getAddress(), queue.getName()); valid = false; ignored = true; - } - else { + } else { if (tx.deliverAfterCommit(CursorIterator.this, PageSubscriptionImpl.this, message.getPosition())) { valid = false; ignored = false; @@ -1265,8 +1240,7 @@ final class PageSubscriptionImpl implements PageSubscription { if (!match) { processACK(message.getPosition()); } - } - else if (ignored) { + } else if (ignored) { positionIgnored(message.getPosition()); } } while (!match); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java index 0888416..4993d0c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java @@ -146,20 +146,17 @@ public final class Page implements Comparable<Page> { logger.trace("Reading message " + msg + " on pageId=" + this.pageId + " for address=" + storeName); } messages.add(msg); - } - else { + } else { markFileAsSuspect(file.getFileName(), position, messages.size()); break; } } - } - else { + } else { markFileAsSuspect(file.getFileName(), position, messages.size()); break; } } - } - finally { + } finally { if (fileBuffer != null) { fileBuffer.byteBuf().unwrap().release(); } @@ -220,8 +217,10 @@ public final class Page implements Comparable<Page> { close(false); } - /** sendEvent means it's a close happening from a major event such moveNext. - * While reading the cache we don't need (and shouldn't inform the backup */ + /** + * sendEvent means it's a close happening from a major event such moveNext. + * While reading the cache we don't need (and shouldn't inform the backup + */ public synchronized void close(boolean sendEvent) throws Exception { if (sendEvent && storageManager != null) { storageManager.pageClosed(storeName, pageId); @@ -271,14 +270,12 @@ public final class Page implements Comparable<Page> { if (suspiciousRecords) { ActiveMQServerLogger.LOGGER.pageInvalid(file.getFileName(), file.getFileName()); file.renameTo(file.getFileName() + ".invalidPage"); - } - else { + } else { file.delete(); } return true; - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.pageDeleteError(e); return false; } @@ -308,8 +305,7 @@ public final class Page implements Comparable<Page> { if (file != null && file.isOpen()) { file.close(); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.pageFinaliseError(e); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageSyncTimer.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageSyncTimer.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageSyncTimer.java index b0f4615..f833b5a 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageSyncTimer.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageSyncTimer.java @@ -95,13 +95,11 @@ final class PageSyncTimer extends ActiveMQScheduledComponent { if (pendingSyncsArray.length != 0) { store.ioSync(); } - } - catch (Exception e) { + } catch (Exception e) { for (OperationContext ctx : pendingSyncsArray) { ctx.onError(ActiveMQExceptionType.IO_ERROR.getCode(), e.getMessage()); } - } - finally { + } finally { // In case of failure, The context should propagate an exception to the client // We send an exception to the client even on the case of a failure // to avoid possible locks and the client not getting the exception back http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageTransactionInfoImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageTransactionInfoImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageTransactionInfoImpl.java index 1dde309..b793aec 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageTransactionInfoImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageTransactionInfoImpl.java @@ -94,8 +94,7 @@ public final class PageTransactionInfoImpl implements PageTransactionInfo { if (sizeAfterUpdate == 0 && storageManager != null) { try { storageManager.deletePageTransactional(this.recordID); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.pageTxDeleteError(e, recordID); } @@ -254,21 +253,18 @@ public final class PageTransactionInfoImpl implements PageTransactionInfo { cursor.addPendingDelivery(cursorPos); cursor.redeliver(iterator, cursorPos); return true; - } - else if (committed) { + } else if (committed) { if (logger.isTraceEnabled()) { logger.trace("committed on " + cursor + ", position=" + cursorPos + ", ignoring position"); } return false; - } - else if (rolledback) { + } else if (rolledback) { if (logger.isTraceEnabled()) { logger.trace("rolled back, position ignored on " + cursor + ", position=" + cursorPos); } cursor.positionIgnored(cursorPos); return true; - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace("deliverAftercommit/else, marking useRedelivery on " + cursor + ", position " + cursorPos); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagedMessageImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagedMessageImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagedMessageImpl.java index b4e6f38..e40d107 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagedMessageImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagedMessageImpl.java @@ -99,8 +99,7 @@ public class PagedMessageImpl implements PagedMessage { largeMessageLazyData = new byte[largeMessageHeaderSize]; buffer.readBytes(largeMessageLazyData); - } - else { + } else { buffer.readInt(); // This value is only used on LargeMessages for now message = new ServerMessageImpl(-1, 50); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java index 99074f3..01fce26 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java @@ -187,8 +187,7 @@ public final class PagingManagerImpl implements PagingManager { for (PagingStore store : stores.values()) { store.disableCleanup(); } - } - finally { + } finally { unlock(); } } @@ -205,8 +204,7 @@ public final class PagingManagerImpl implements PagingManager { for (PagingStore store : stores.values()) { store.enableCleanup(); } - } - finally { + } finally { unlock(); } } @@ -234,8 +232,7 @@ public final class PagingManagerImpl implements PagingManager { store.start(); stores.put(store.getStoreName(), store); } - } - finally { + } finally { unlock(); } @@ -249,8 +246,7 @@ public final class PagingManagerImpl implements PagingManager { if (store != null) { store.stop(); } - } - finally { + } finally { syncLock.readLock().unlock(); } } @@ -315,8 +311,7 @@ public final class PagingManagerImpl implements PagingManager { reloadStores(); started = true; - } - finally { + } finally { unlock(); } } @@ -336,8 +331,7 @@ public final class PagingManagerImpl implements PagingManager { } pagingStoreFactory.stop(); - } - finally { + } finally { unlock(); } } @@ -362,8 +356,7 @@ public final class PagingManagerImpl implements PagingManager { stores.put(address, store); } return store; - } - finally { + } finally { syncLock.readLock().unlock(); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreFactoryNIO.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreFactoryNIO.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreFactoryNIO.java index 5093033..e0f3a22 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreFactoryNIO.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreFactoryNIO.java @@ -102,7 +102,10 @@ public class PagingStoreFactoryNIO implements PagingStoreFactory { } @Override - public PageCursorProvider newCursorProvider(PagingStore store, StorageManager storageManager, AddressSettings addressSettings, Executor executor) { + public PageCursorProvider newCursorProvider(PagingStore store, + StorageManager storageManager, + AddressSettings addressSettings, + Executor executor) { return new PageCursorProviderImpl(store, storageManager, executor, addressSettings.getPageCacheMaxSize()); } @@ -144,8 +147,7 @@ public class PagingStoreFactoryNIO implements PagingStoreFactory { if (files == null) { return Collections.<PagingStore>emptyList(); - } - else { + } else { ArrayList<PagingStore> storesReturn = new ArrayList<>(files.length); for (File file : files) { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java index df603be..f756edd 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java @@ -171,8 +171,7 @@ public class PagingStoreImpl implements PagingStore { if (scheduledExecutor != null && syncTimeout > 0) { this.syncTimer = new PageSyncTimer(this, scheduledExecutor, executor, syncTimeout); - } - else { + } else { this.syncTimer = null; } @@ -212,8 +211,7 @@ public class PagingStoreImpl implements PagingStore { } try { return lock.writeLock().tryLock(timeout, TimeUnit.MILLISECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { return false; } } @@ -248,8 +246,7 @@ public class PagingStoreImpl implements PagingStore { if (maxSize < 0) { // if maxSize < 0, we will return 2 pages for depage purposes return pageSize * 2; - } - else { + } else { return maxSize; } } @@ -269,8 +266,7 @@ public class PagingStoreImpl implements PagingStore { SequentialFileFactory factoryUsed = this.fileFactory; if (factoryUsed != null) { return factoryUsed.getDirectory(); - } - else { + } else { return null; } } @@ -290,8 +286,7 @@ public class PagingStoreImpl implements PagingStore { return isFull(); } return paging; - } - finally { + } finally { lock.readLock().unlock(); } } @@ -315,8 +310,7 @@ public class PagingStoreImpl implements PagingStore { public void sync() throws Exception { if (syncTimer != null) { syncTimer.addSync(storageManager.getContext()); - } - else { + } else { ioSync(); } @@ -330,8 +324,7 @@ public class PagingStoreImpl implements PagingStore { if (currentPage != null) { currentPage.sync(); } - } - finally { + } finally { lock.readLock().unlock(); } } @@ -393,8 +386,7 @@ public class PagingStoreImpl implements PagingStore { // and having both threads calling init. One of the calls should just // need to be ignored return; - } - else { + } else { running = true; firstPageId = Integer.MAX_VALUE; @@ -453,8 +445,7 @@ public class PagingStoreImpl implements PagingStore { } } - } - finally { + } finally { lock.writeLock().unlock(); } } @@ -465,8 +456,7 @@ public class PagingStoreImpl implements PagingStore { try { paging = false; this.cursorProvider.onPageModeCleared(); - } - finally { + } finally { lock.writeLock().unlock(); } } @@ -488,8 +478,7 @@ public class PagingStoreImpl implements PagingStore { if (paging) { return false; } - } - finally { + } finally { lock.readLock().unlock(); } @@ -506,8 +495,7 @@ public class PagingStoreImpl implements PagingStore { if (currentPage == null) { try { openNewPage(); - } - catch (Exception e) { + } catch (Exception e) { // If not possible to starting page due to an IO error, we will just consider it non paging. // This shouldn't happen anyway ActiveMQServerLogger.LOGGER.pageStoreStartIOError(e); @@ -518,8 +506,7 @@ public class PagingStoreImpl implements PagingStore { paging = true; return true; - } - finally { + } finally { lock.writeLock().unlock(); } } @@ -585,8 +572,7 @@ public class PagingStoreImpl implements PagingStore { if (numberOfPages == 0) { return null; - } - else { + } else { numberOfPages--; final Page returnPage; @@ -614,22 +600,19 @@ public class PagingStoreImpl implements PagingStore { // This will trigger this address to exit the page mode, // and this will make ActiveMQ Artemis start using the journal again return null; - } - else { + } else { // We need to create a new page, as we can't lock the address until we finish depaging. openNewPage(); } return returnPage; - } - else { + } else { returnPage = createPage(firstPageId++); } return returnPage; } - } - finally { + } finally { lock.writeLock().unlock(); } @@ -679,8 +662,7 @@ public class PagingStoreImpl implements PagingStore { if (isFull()) { return false; } - } - else if (pagingManager.isDiskFull() || addressFullMessagePolicy == AddressFullMessagePolicy.BLOCK && (maxSize != -1 || usingGlobalMaxSize)) { + } else if (pagingManager.isDiskFull() || addressFullMessagePolicy == AddressFullMessagePolicy.BLOCK && (maxSize != -1 || usingGlobalMaxSize)) { if (pagingManager.isDiskFull() || maxSize > 0 && sizeInBytes.get() > maxSize || pagingManager.isGlobalFull()) { OverSizedRunnable ourRunnable = new OverSizedRunnable(runWhenAvailable); @@ -693,8 +675,7 @@ public class PagingStoreImpl implements PagingStore { if (!pagingManager.isGlobalFull() && (sizeInBytes.get() <= maxSize || maxSize < 0)) { // run it now ourRunnable.run(); - } - else { + } else { if (usingGlobalMaxSize || pagingManager.isDiskFull()) { pagingManager.addBlockedStore(this); } @@ -726,8 +707,7 @@ public class PagingStoreImpl implements PagingStore { } return; - } - else if (addressFullMessagePolicy == AddressFullMessagePolicy.PAGE) { + } else if (addressFullMessagePolicy == AddressFullMessagePolicy.PAGE) { if (size > 0) { if (maxSize != -1 && newSize > maxSize || globalFull) { if (startPaging()) { @@ -790,12 +770,10 @@ public class PagingStoreImpl implements PagingStore { // Address is full, we just pretend we are paging, and drop the data return true; - } - else { + } else { return false; } - } - else if (addressFullMessagePolicy == AddressFullMessagePolicy.BLOCK) { + } else if (addressFullMessagePolicy == AddressFullMessagePolicy.BLOCK) { return false; } @@ -807,8 +785,7 @@ public class PagingStoreImpl implements PagingStore { if (!paging) { return false; } - } - finally { + } finally { lock.readLock().unlock(); } @@ -859,16 +836,14 @@ public class PagingStoreImpl implements PagingStore { if (logger.isTraceEnabled()) { logger.trace("Paging message " + pagedMessage + " on pageStore " + this.getStoreName() + - " pageNr=" + currentPage.getPageId()); + " pageNr=" + currentPage.getPageId()); } return true; - } - finally { + } finally { lock.writeLock().unlock(); } - } - finally { + } finally { managerLock.unlock(); } } @@ -924,8 +899,7 @@ public class PagingStoreImpl implements PagingStore { // non transactional writes need an intermediate place // to avoid the counter getting out of sync q.getPageSubscription().getCounter().pendingCounter(page, 1); - } - else { + } else { // null tx is treated through pending counters q.getPageSubscription().getCounter().increment(tx, 1); } @@ -1074,8 +1048,7 @@ public class PagingStoreImpl implements PagingStore { if (currentPageId < firstPageId) { firstPageId = currentPageId; } - } - finally { + } finally { lock.writeLock().unlock(); } } @@ -1131,8 +1104,7 @@ public class PagingStoreImpl implements PagingStore { } replicator.syncPages(sFile, id, getAddress()); } - } - finally { + } finally { lock.writeLock().unlock(); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/OperationContext.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/OperationContext.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/OperationContext.java index e893a10..104a79c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/OperationContext.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/OperationContext.java @@ -29,7 +29,8 @@ public interface OperationContext extends IOCompletion { /** * Execute the task when all IO operations are complete, * Or execute it immediately if nothing is pending. - * @param runnable the tas to be executed. + * + * @param runnable the tas to be executed. * @param storeOnly There are tasks that won't need to wait on replication or paging and will need to * be completed as soon as the response from the journal is received. An example would be the * DuplicateCache @@ -39,11 +40,11 @@ public interface OperationContext extends IOCompletion { /** * Execute the task when all IO operations are complete, * Or execute it immediately if nothing is pending. + * * @param runnable the tas to be executed. */ void executeOnCompletion(IOCallback runnable); - void replicationLineUp(); void replicationDone(); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java index 7dcd9d3..e820664 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java @@ -26,9 +26,9 @@ import java.util.concurrent.Executor; import org.apache.activemq.artemis.api.core.Pair; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.io.IOCallback; +import org.apache.activemq.artemis.core.io.SequentialFile; import org.apache.activemq.artemis.core.journal.Journal; import org.apache.activemq.artemis.core.journal.JournalLoadInformation; -import org.apache.activemq.artemis.core.io.SequentialFile; import org.apache.activemq.artemis.core.message.impl.MessageInternal; import org.apache.activemq.artemis.core.paging.PageTransactionInfo; import org.apache.activemq.artemis.core.paging.PagedMessage; @@ -101,8 +101,11 @@ public interface StorageManager extends IDGenerator, ActiveMQComponent { void afterCompleteOperations(IOCallback run); - /** This is similar to afterComplete, however this only cares about the journal part. */ + /** + * This is similar to afterComplete, however this only cares about the journal part. + */ void afterStoreOperations(IOCallback run); + /** * Block until the operations are done. * Warning: Don't use it inside an ordered executor, otherwise the system may lock up @@ -415,6 +418,5 @@ public interface StorageManager extends IDGenerator, ActiveMQComponent { */ void persistIdGenerator(); - void injectMonitor(FileStoreMonitor monitor) throws Exception; } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/config/PersistedRoles.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/config/PersistedRoles.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/config/PersistedRoles.java index 256a0a6..383a75f 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/config/PersistedRoles.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/config/PersistedRoles.java @@ -232,56 +232,47 @@ public class PersistedRoles implements EncodingSupport { if (addressMatch == null) { if (other.addressMatch != null) return false; - } - else if (!addressMatch.equals(other.addressMatch)) + } else if (!addressMatch.equals(other.addressMatch)) return false; if (consumeRoles == null) { if (other.consumeRoles != null) return false; - } - else if (!consumeRoles.equals(other.consumeRoles)) + } else if (!consumeRoles.equals(other.consumeRoles)) return false; if (createDurableQueueRoles == null) { if (other.createDurableQueueRoles != null) return false; - } - else if (!createDurableQueueRoles.equals(other.createDurableQueueRoles)) + } else if (!createDurableQueueRoles.equals(other.createDurableQueueRoles)) return false; if (createNonDurableQueueRoles == null) { if (other.createNonDurableQueueRoles != null) return false; - } - else if (!createNonDurableQueueRoles.equals(other.createNonDurableQueueRoles)) + } else if (!createNonDurableQueueRoles.equals(other.createNonDurableQueueRoles)) return false; if (deleteDurableQueueRoles == null) { if (other.deleteDurableQueueRoles != null) return false; - } - else if (!deleteDurableQueueRoles.equals(other.deleteDurableQueueRoles)) + } else if (!deleteDurableQueueRoles.equals(other.deleteDurableQueueRoles)) return false; if (deleteNonDurableQueueRoles == null) { if (other.deleteNonDurableQueueRoles != null) return false; - } - else if (!deleteNonDurableQueueRoles.equals(other.deleteNonDurableQueueRoles)) + } else if (!deleteNonDurableQueueRoles.equals(other.deleteNonDurableQueueRoles)) return false; if (manageRoles == null) { if (other.manageRoles != null) return false; - } - else if (!manageRoles.equals(other.manageRoles)) + } else if (!manageRoles.equals(other.manageRoles)) return false; if (browseRoles == null) { if (other.browseRoles != null) return false; - } - else if (!browseRoles.equals(other.browseRoles)) + } else if (!browseRoles.equals(other.browseRoles)) return false; if (sendRoles == null) { if (other.sendRoles != null) return false; - } - else if (!sendRoles.equals(other.sendRoles)) + } else if (!sendRoles.equals(other.sendRoles)) return false; if (storeId != other.storeId) return false;
