http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java index 803c6f0..ac30c53 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java @@ -309,8 +309,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled try { refqueue.cancel(ref, timeBase); - } - catch (Exception e) { + } catch (Exception e) { // There isn't much we can do besides log an error ActiveMQServerLogger.LOGGER.errorCancellingRefOnBridge(e, ref); } @@ -339,8 +338,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled if (session != null) { try { session.cleanUp(false); - } - catch (Exception dontcare) { + } catch (Exception dontcare) { logger.debug(dontcare.getMessage(), dontcare); } session = null; @@ -348,8 +346,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled if (sessionConsumer != null) { try { sessionConsumer.cleanUp(false); - } - catch (Exception dontcare) { + } catch (Exception dontcare) { logger.debug(dontcare.getMessage(), dontcare); } sessionConsumer = null; @@ -395,8 +392,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled Notification notification = new Notification(nodeUUID.toString(), CoreNotificationType.BRIDGE_STOPPED, props); try { notificationService.sendNotification(notification); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.broadcastBridgeStoppedError(e); } } @@ -416,8 +412,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled Notification notification = new Notification(nodeUUID.toString(), CoreNotificationType.BRIDGE_STOPPED, props); try { notificationService.sendNotification(notification); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.notificationBridgeStoppedError(e); } } @@ -465,8 +460,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled public RemotingConnection getForwardingConnection() { if (session == null) { return null; - } - else { + } else { return session.getConnection(); } } @@ -493,14 +487,12 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled } ref.getQueue().acknowledge(ref); pendingAcks.countDown(); - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace("BridgeImpl::sendAcknowledged bridge " + this + " could not find reference for message " + message); } } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.bridgeFailedToAck(e); } } @@ -524,14 +516,13 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled if (transformedMessage != message) { if (logger.isDebugEnabled()) { logger.debug("The transformer " + transformer + - " made a copy of the message " + - message + - " as transformedMessage"); + " made a copy of the message " + + message + + " as transformedMessage"); } } return transformedMessage; - } - else { + } else { return message; } } @@ -575,8 +566,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled if (forwardingAddress != null) { dest = forwardingAddress; - } - else { + } else { // Preserve the original address dest = message.getAddress(); } @@ -588,12 +578,10 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled deliveringLargeMessage = true; deliverLargeMessage(dest, ref, (LargeServerMessage) message); return HandleStatus.HANDLED; - } - else { + } else { return deliverStandardMessage(dest, ref, message); } - } - catch (Exception e) { + } catch (Exception e) { // If an exception happened, we must count down immediately pendingAcks.countDown(); throw e; @@ -627,14 +615,12 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled } cleanUpSessionFactory(csf); - } - catch (Throwable dontCare) { + } catch (Throwable dontCare) { } try { session.cleanUp(false); - } - catch (Throwable dontCare) { + } catch (Throwable dontCare) { } if (scaleDownTargetNodeID != null && !scaleDownTargetNodeID.equals(nodeUUID.toString())) { @@ -645,18 +631,15 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled // stop the bridge from trying to reconnect and clean up all the bindings fail(true); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } - } - else if (scaleDownTargetNodeID != null) { + } else if (scaleDownTargetNodeID != null) { // the disconnected node is scaling down to me, no need to reconnect to it logger.debug("Received scaleDownTargetNodeID: " + scaleDownTargetNodeID + "; cancelling reconnect."); fail(true); - } - else { + } else { logger.debug("Received invalid scaleDownTargetNodeID: " + scaleDownTargetNodeID); fail(me.getType() == ActiveMQExceptionType.DISCONNECTED); @@ -692,8 +675,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled if (queue != null) { queue.deliverAsync(); } - } - catch (final ActiveMQException e) { + } catch (final ActiveMQException e) { unsetLargeMessageDelivery(); ActiveMQServerLogger.LOGGER.bridgeUnableToSendMessage(e, ref); @@ -720,8 +702,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled try { producer.send(dest, message); - } - catch (final ActiveMQException e) { + } catch (final ActiveMQException e) { ActiveMQServerLogger.LOGGER.bridgeUnableToSendMessage(e, ref); synchronized (refs) { @@ -789,8 +770,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled logger.trace("Removing consumer on fail " + this + " from queue " + queue); } queue.removeConsumer(this); - } - catch (Exception dontcare) { + } catch (Exception dontcare) { logger.debug(dontcare); } } @@ -815,8 +795,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled protected ClientSessionFactoryInternal createSessionFactory() throws Exception { if (targetNodeID != null && (this.reconnectAttemptsSameNode < 0 || retryCount <= this.reconnectAttemptsSameNode)) { csf = reconnectOnOriginalNode(); - } - else { + } else { serverLocator.resetToInitialConnectors(); csf = (ClientSessionFactoryInternal) serverLocator.createSessionFactory(); } @@ -891,8 +870,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled try { query = session.addressQuery(forwardingAddress); - } - catch (Throwable e) { + } catch (Throwable e) { ActiveMQServerLogger.LOGGER.errorQueryingBridge(e, name); // This was an issue during startup, we will not count this retry retryCount--; @@ -907,8 +885,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled scheduleRetryConnect(); return; } - } - else { + } else { if (!query.isExists()) { ActiveMQServerLogger.LOGGER.bridgeNoBindings(getName(), getForwardingAddress(), getForwardingAddress()); } @@ -936,8 +913,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled keepConnecting = false; return; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { // the session was created while its server was starting, retry it: if (e.getType() == ActiveMQExceptionType.SESSION_CREATION_REJECTED) { ActiveMQServerLogger.LOGGER.errorStartingBridge(name); @@ -947,26 +923,22 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled scheduleRetryConnectFixedTimeout(this.retryInterval); return; - } - else { + } else { if (logger.isDebugEnabled()) { logger.debug("Bridge " + this + " is unable to connect to destination. Retrying", e); } scheduleRetryConnect(); } - } - catch (ActiveMQInterruptedException | InterruptedException e) { + } catch (ActiveMQInterruptedException | InterruptedException e) { ActiveMQServerLogger.LOGGER.errorConnectingBridge(e, this); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorConnectingBridge(e, this); if (csf != null) { try { csf.close(); csf = null; - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } } fail(false); @@ -1001,12 +973,12 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled } logger.debug("Bridge " + this + - " retrying connection #" + - retryCount + - ", maxRetry=" + - reconnectAttemptsInUse + - ", timeout=" + - timeout); + " retrying connection #" + + retryCount + + ", maxRetry=" + + reconnectAttemptsInUse + + ", timeout=" + + timeout); scheduleRetryConnectFixedTimeout(timeout); } @@ -1016,8 +988,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled protected void scheduleRetryConnectFixedTimeout(final long milliseconds) { try { cleanUpSessionFactory(csf); - } - catch (Throwable ignored) { + } catch (Throwable ignored) { } if (stopping) @@ -1105,8 +1076,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled try { session.close(); session = null; - } - catch (ActiveMQException dontcare) { + } catch (ActiveMQException dontcare) { } } @@ -1115,8 +1085,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled try { sessionConsumer.close(); sessionConsumer = null; - } - catch (ActiveMQException dontcare) { + } catch (ActiveMQException dontcare) { } } @@ -1134,8 +1103,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled logger.trace("Removing consumer on stopRunnable " + this + " from queue " + queue); } ActiveMQServerLogger.LOGGER.bridgeStopped(name); - } - catch (InterruptedException | RuntimeException e) { + } catch (InterruptedException | RuntimeException e) { ActiveMQServerLogger.LOGGER.error("Failed to stop bridge", e); } } @@ -1160,8 +1128,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled internalCancelReferences(); ActiveMQServerLogger.LOGGER.bridgePaused(name); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorPausingBridge(e); } } @@ -1179,8 +1146,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled if (member != null && BridgeImpl.this.targetNodeID != null && BridgeImpl.this.targetNodeID.equals(member.getNodeId())) { // this could be an update of the topology say after a backup started BridgeImpl.this.targetNode = member; - } - else { + } else { // we don't need synchronization here, but we need to make sure we won't get a NPE on races if (connectionToUse != null && member.isMember(connectionToUse)) { BridgeImpl.this.targetNode = member;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BroadcastGroupImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BroadcastGroupImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BroadcastGroupImpl.java index 4506357..4700b6d 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BroadcastGroupImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BroadcastGroupImpl.java @@ -128,8 +128,7 @@ public class BroadcastGroupImpl implements BroadcastGroup, Runnable { try { endpoint.close(true); - } - catch (Exception e1) { + } catch (Exception e1) { ActiveMQServerLogger.LOGGER.broadcastGroupClosed(e1); } @@ -141,8 +140,7 @@ public class BroadcastGroupImpl implements BroadcastGroup, Runnable { Notification notification = new Notification(nodeManager.getNodeId().toString(), CoreNotificationType.BROADCAST_GROUP_STOPPED, props); try { notificationService.sendNotification(notification); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.broadcastGroupClosed(e); } } @@ -210,14 +208,12 @@ public class BroadcastGroupImpl implements BroadcastGroup, Runnable { try { broadcastConnectors(); loggedBroadcastException = false; - } - catch (Exception e) { + } catch (Exception e) { // only log the exception at ERROR level once, even if it fails multiple times in a row - HORNETQ-919 if (!loggedBroadcastException) { ActiveMQServerLogger.LOGGER.errorBroadcastingConnectorConfigs(e); loggedBroadcastException = true; - } - else { + } else { logger.debug("Failed to broadcast connector configs...again", e); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java index 425e26a..3b35c14 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java @@ -57,6 +57,7 @@ import org.jboss.logging.Logger; * Such as such adding extra properties and setting up notifications between the nodes. */ public class ClusterConnectionBridge extends BridgeImpl { + private static final Logger logger = Logger.getLogger(ClusterConnectionBridge.class); private final ClusterConnection clusterConnection; @@ -184,12 +185,12 @@ public class ClusterConnectionBridge extends BridgeImpl { private void setupNotificationConsumer() throws Exception { if (logger.isDebugEnabled()) { logger.debug("Setting up notificationConsumer between " + this.clusterConnection.getConnector() + - " and " + - flowRecord.getBridge().getForwardingConnection() + - " clusterConnection = " + - this.clusterConnection.getName() + - " on server " + - clusterConnection.getServer()); + " and " + + flowRecord.getBridge().getForwardingConnection() + + " clusterConnection = " + + this.clusterConnection.getName() + + " on server " + + clusterConnection.getServer()); } if (flowRecord != null) { flowRecord.reset(); @@ -197,13 +198,12 @@ public class ClusterConnectionBridge extends BridgeImpl { if (notifConsumer != null) { try { logger.debug("Closing notification Consumer for reopening " + notifConsumer + - " on bridge " + - this.getName()); + " on bridge " + + this.getName()); notifConsumer.close(); notifConsumer = null; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { ActiveMQServerLogger.LOGGER.errorClosingConsumer(e); } } @@ -279,8 +279,7 @@ public class ClusterConnectionBridge extends BridgeImpl { if (!address.contains(",")) { if (address.startsWith("!")) { stringBuilder.append(ManagementHelper.HDR_ADDRESS + " NOT LIKE '" + address.substring(1, address.length()) + "%'"); - } - else { + } else { stringBuilder.append(ManagementHelper.HDR_ADDRESS + " LIKE '" + address + "%'"); } return stringBuilder.toString(); @@ -298,8 +297,7 @@ public class ClusterConnectionBridge extends BridgeImpl { for (String s : list) { if (s.startsWith("!")) { excludes.add(s.substring(1, s.length())); - } - else { + } else { includes.add(s); } } @@ -355,8 +353,7 @@ public class ClusterConnectionBridge extends BridgeImpl { if (permanently) { logger.debug("cluster node for bridge " + this.getName() + " is permanently down"); clusterConnection.removeRecord(targetNodeID); - } - else { + } else { clusterConnection.disconnectRecord(targetNodeID); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionImpl.java index 77f25e9..4b9f0b7 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionImpl.java @@ -76,9 +76,11 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn private static final Logger logger = Logger.getLogger(ClusterConnectionImpl.class); - /** When getting member on node-up and down we have to remove the name from the transport config - * as the setting we build here doesn't need to consider the name, so use the same name on all - * the instances. */ + /** + * When getting member on node-up and down we have to remove the name from the transport config + * as the setting we build here doesn't need to consider the name, so use the same name on all + * the instances. + */ private static final String TRANSPORT_CONFIG_NAME = "topology-member"; private final ExecutorFactory executorFactory; @@ -414,17 +416,16 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn } logger.debug("Cluster connection being stopped for node" + nodeManager.getNodeId() + - ", server = " + - this.server + - " serverLocator = " + - serverLocator); + ", server = " + + this.server + + " serverLocator = " + + serverLocator); synchronized (this) { for (MessageFlowRecord record : records.values()) { try { record.close(); - } - catch (Exception ignore) { + } catch (Exception ignore) { } } } @@ -493,8 +494,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn newMember.setUniqueEventID(uniqueEventID); if (backup) { topology.updateBackup(new TopologyMemberImpl(nodeID, backupGroupName, scaleDownGroupName, live, backupTC)); - } - else { + } else { topology.updateMember(uniqueEventID, nodeID, newMember); } } @@ -507,12 +507,10 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn try { clusterControl.authorize(); clusterControl.sendNodeAnnounce(localMember.getUniqueEventID(), manager.getNodeId(), manager.getBackupGroupName(), manager.getScaleDownGroupName(), false, localMember.getLive(), localMember.getBackup()); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { ActiveMQServerLogger.LOGGER.clusterControlAuthfailure(); } - } - else { + } else { ActiveMQServerLogger.LOGGER.noLocalMemborOnClusterConnection(this); } @@ -668,7 +666,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn if (nodeID.equals(nodeManager.getNodeId().toString())) { if (logger.isTraceEnabled()) { logger.trace(this + "::informing about backup to itself, nodeUUID=" + - nodeManager.getNodeId() + ", connectorPair=" + topologyMember + ", this = " + this); + nodeManager.getNodeId() + ", connectorPair=" + topologyMember + ", this = " + this); } return; } @@ -687,7 +685,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn if (topologyMember.getLive() == null) { if (logger.isTraceEnabled()) { logger.trace(this + " ignoring call with nodeID=" + nodeID + ", topologyMember=" + - topologyMember + ", last=" + last); + topologyMember + ", last=" + last); } return; } @@ -699,7 +697,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn if (record == null) { if (logger.isDebugEnabled()) { logger.debug(this + "::Creating record for nodeID=" + nodeID + ", topologyMember=" + - topologyMember); + topologyMember); } // New node - create a new flow record @@ -712,8 +710,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn if (queueBinding != null) { queue = (Queue) queueBinding.getBindable(); - } - else { + } else { // Add binding in storage so the queue will get reloaded on startup and we can find it - it's never // actually routed to at that address though queue = server.createQueue(queueName, queueName, null, true, false); @@ -724,15 +721,13 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn queue.setInternalQueue(true); createNewRecord(topologyMember.getUniqueEventID(), nodeID, topologyMember.getLive(), queueName, queue, true); - } - else { + } else { if (logger.isTraceEnabled()) { logger.trace(this + " ignored nodeUp record for " + topologyMember + " on nodeID=" + - nodeID + " as the record already existed"); + nodeID + " as the record already existed"); } } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorUpdatingTopology(e); } } @@ -956,12 +951,10 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn try { if (disconnected) { targetLocator.cleanup(); - } - else { + } else { targetLocator.close(); } - } - catch (Exception ignored) { + } catch (Exception ignored) { logger.debug(ignored.getMessage(), ignored); } } @@ -998,8 +991,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn reset = true; return; - } - else if (message.containsProperty(PostOfficeImpl.HDR_RESET_QUEUE_DATA_COMPLETE)) { + } else if (message.containsProperty(PostOfficeImpl.HDR_RESET_QUEUE_DATA_COMPLETE)) { clearDisconnectedBindings(); return; } @@ -1010,8 +1002,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn } handleNotificationMessage(message); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorHandlingMessage(e); } } @@ -1227,8 +1218,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn try { postOffice.addBinding(binding); - } - catch (Exception ignore) { + } catch (Exception ignore) { } Bindings theBindings = postOffice.getBindingsForAddress(queueAddress); @@ -1481,8 +1471,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn if (record != null) { record.close(); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.warn(e); } } @@ -1495,9 +1484,8 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn if (record != null) { record.disconnectBindings(); } - } - catch (Exception e) { - ActiveMQServerLogger.LOGGER.warn(e.getMessage(),e); + } catch (Exception e) { + ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/MessageLoadBalancingType.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/MessageLoadBalancingType.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/MessageLoadBalancingType.java index cb48b49..e1486cf 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/MessageLoadBalancingType.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/MessageLoadBalancingType.java @@ -48,15 +48,12 @@ public enum MessageLoadBalancingType { public static MessageLoadBalancingType getType(String string) { if (string.equals(OFF.getType())) { return MessageLoadBalancingType.OFF; - } - else if (string.equals(STRICT.getType())) { + } else if (string.equals(STRICT.getType())) { return MessageLoadBalancingType.STRICT; - } - else if (string.equals(ON_DEMAND.getType())) { + } else if (string.equals(ON_DEMAND.getType())) { return MessageLoadBalancingType.ON_DEMAND; - } - else { + } else { return null; } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/Redistributor.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/Redistributor.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/Redistributor.java index 339293b..c585405 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/Redistributor.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/Redistributor.java @@ -22,13 +22,13 @@ import java.util.concurrent.Executor; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.Pair; -import org.apache.activemq.artemis.core.io.IOCallback; import org.apache.activemq.artemis.core.filter.Filter; +import org.apache.activemq.artemis.core.io.IOCallback; import org.apache.activemq.artemis.core.persistence.StorageManager; import org.apache.activemq.artemis.core.postoffice.PostOffice; +import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; import org.apache.activemq.artemis.core.server.Consumer; import org.apache.activemq.artemis.core.server.HandleStatus; -import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; import org.apache.activemq.artemis.core.server.MessageReference; import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.server.RoutingContext; @@ -122,8 +122,7 @@ public class Redistributor implements Consumer { try { boolean ok = pendingRuns.await(10000); return ok; - } - catch (InterruptedException e) { + } catch (InterruptedException e) { ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); return false; } @@ -133,9 +132,8 @@ public class Redistributor implements Consumer { public synchronized HandleStatus handle(final MessageReference reference) throws Exception { if (!active) { return HandleStatus.BUSY; - } - //we shouldn't redistribute with message groups return NO_MATCH so other messages can be delivered - else if (reference.getMessage().getSimpleStringProperty(Message.HDR_GROUP_ID) != null) { + } else if (reference.getMessage().getSimpleStringProperty(Message.HDR_GROUP_ID) != null) { + //we shouldn't redistribute with message groups return NO_MATCH so other messages can be delivered return HandleStatus.NO_MATCH; } @@ -152,8 +150,7 @@ public class Redistributor implements Consumer { postOffice.processRoute(routingInfo.getB(), routingInfo.getA(), false); ackRedistribution(reference, tx); - } - else { + } else { active = false; executor.execute(new Runnable() { @Override @@ -171,12 +168,10 @@ public class Redistributor implements Consumer { queue.deliverAsync(); } - } - catch (Exception e) { + } catch (Exception e) { try { tx.rollback(); - } - catch (Exception e2) { + } catch (Exception e2) { // Nothing much we can do now // TODO log @@ -202,8 +197,7 @@ public class Redistributor implements Consumer { public void run() { try { runnable.run(); - } - finally { + } finally { pendingRuns.countDown(); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/RemoteQueueBindingImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/RemoteQueueBindingImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/RemoteQueueBindingImpl.java index d592103..8f54b2a 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/RemoteQueueBindingImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/RemoteQueueBindingImpl.java @@ -156,8 +156,7 @@ public class RemoteQueueBindingImpl implements RemoteQueueBinding { if (filters.isEmpty()) { return true; - } - else { + } else { for (Filter filter : filters) { if (filter.match(message)) { return true; @@ -210,8 +209,7 @@ public class RemoteQueueBindingImpl implements RemoteQueueBinding { filterCounts.put(filterString, 1); filters.add(FilterImpl.createFilter(filterString)); - } - else { + } else { filterCounts.put(filterString, i + 1); } } @@ -231,8 +229,7 @@ public class RemoteQueueBindingImpl implements RemoteQueueBinding { filterCounts.remove(filterString); filters.remove(FilterImpl.createFilter(filterString)); - } - else { + } else { filterCounts.put(filterString, ii); } } @@ -323,8 +320,7 @@ public class RemoteQueueBindingImpl implements RemoteQueueBinding { if (ids == null) { ids = new byte[8]; - } - else { + } else { byte[] newIds = new byte[ids.length + 8]; System.arraycopy(ids, 0, newIds, 8, ids.length); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/BooleanVote.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/BooleanVote.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/BooleanVote.java index 69c8068..cbc70e7 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/BooleanVote.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/BooleanVote.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.core.server.cluster.qourum; -import org.apache.activemq.artemis.api.core.ActiveMQBuffer; - import java.util.Map; +import org.apache.activemq.artemis.api.core.ActiveMQBuffer; + /** * a simple yes.no vote */ http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumManager.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumManager.java index 6b01b96..dad772b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumManager.java @@ -199,8 +199,7 @@ public final class QuorumManager implements ClusterTopologyListener, ActiveMQCom for (VoteRunnable runnable : runnables) { executor.submit(runnable); } - } - else { + } else { quorumVote.allVotesCast(clusterController.getDefaultClusterTopology()); } } @@ -302,22 +301,18 @@ public final class QuorumManager implements ClusterTopologyListener, ActiveMQCom if (vote.isRequestServerVote()) { vote = clusterControl.sendQuorumVote(quorumVote.getName(), vote); quorumVote.vote(vote); - } - else { + } else { quorumVote.vote(vote); } - } - catch (Exception e) { + } catch (Exception e) { Vote vote = quorumVote.notConnected(); quorumVote.vote(vote); - } - finally { + } finally { try { if (clusterControl != null) { clusterControl.close(); } - } - catch (Exception e) { + } catch (Exception e) { //ignore } QuorumManager.this.votingComplete(quorumVote); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumVoteServerConnect.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumVoteServerConnect.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumVoteServerConnect.java index 352e5e3..8eac444 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumVoteServerConnect.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumVoteServerConnect.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.artemis.core.server.cluster.qourum; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.client.impl.Topology; import org.apache.activemq.artemis.core.persistence.StorageManager; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - /** * A Qourum Vote for deciding if a replicated backup should become live. */ @@ -39,23 +39,22 @@ public class QuorumVoteServerConnect extends QuorumVote<BooleanVote, Boolean> { /** * live nodes | remaining nodes | majority | votes needed - * 1 | 0 | 0 | 0 - * 2 | 1 | 1 | 1 - * n | r = n-1 | n/2 + 1 | n/2 + 1 rounded - * 3 | 2 | 2.5 | 2 - * 4 | 3 | 3 | 3 - * 5 | 4 | 3.5 | 3 - * 6 | 5 | 4 | 4 + * 1 | 0 | 0 | 0 + * 2 | 1 | 1 | 1 + * n | r = n-1 | n/2 + 1 | n/2 + 1 rounded + * 3 | 2 | 2.5 | 2 + * 4 | 3 | 3 | 3 + * 5 | 4 | 3.5 | 3 + * 6 | 5 | 4 | 4 */ public QuorumVoteServerConnect(int size, StorageManager storageManager) { super(LIVE_FAILOVER_VOTE); double majority; if (size <= 2) { - majority = ((double)size) / 2; - } - else { + majority = ((double) size) / 2; + } else { //even - majority = ((double)size) / 2 + 1; + majority = ((double) size) / 2 + 1; } //votes needed could be say 2.5 so we add 1 in this case votesNeeded = (int) majority; @@ -87,13 +86,13 @@ public class QuorumVoteServerConnect extends QuorumVote<BooleanVote, Boolean> { /** * live nodes | remaining nodes | majority | votes needed - * 1 | 0 | 0 | 0 - * 2 | 1 | 1 | 1 - * n | r = n-1 | n/2 + 1 | n/2 + 1 rounded - * 3 | 2 | 2.5 | 2 - * 4 | 3 | 3 | 3 - * 5 | 4 | 3.5 | 3 - * 6 | 5 | 4 | 4 + * 1 | 0 | 0 | 0 + * 2 | 1 | 1 | 1 + * n | r = n-1 | n/2 + 1 | n/2 + 1 rounded + * 3 | 2 | 2.5 | 2 + * 4 | 3 | 3 | 3 + * 5 | 4 | 3.5 | 3 + * 6 | 5 | 4 | 4 * * @param vote the vote to make. */ http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/SharedNothingBackupQuorum.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/SharedNothingBackupQuorum.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/SharedNothingBackupQuorum.java index 5a95791..707849d 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/SharedNothingBackupQuorum.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/SharedNothingBackupQuorum.java @@ -97,8 +97,7 @@ public class SharedNothingBackupQuorum implements Quorum, SessionFailureListener // no point in repeating all the reconnection logic sessionFactory.connect(RECONNECT_ATTEMPTS, false); return; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { if (e.getType() != ActiveMQExceptionType.NOT_CONNECTED) ActiveMQServerLogger.LOGGER.errorReConnecting(e); } @@ -223,8 +222,7 @@ public class SharedNothingBackupQuorum implements Quorum, SessionFailureListener public BACKUP_ACTIVATION waitForStatusChange() { try { latch.await(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { return BACKUP_ACTIVATION.STOP; } return signal; @@ -260,8 +258,7 @@ public class SharedNothingBackupQuorum implements Quorum, SessionFailureListener try { quorumVote.await(LATCH_TIMEOUT, TimeUnit.SECONDS); - } - catch (InterruptedException interruption) { + } catch (InterruptedException interruption) { // No-op. The best the quorum can do now is to return the latest number it has } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/Vote.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/Vote.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/Vote.java index 5ceb0b2..916c63e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/Vote.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/Vote.java @@ -16,11 +16,11 @@ */ package org.apache.activemq.artemis.core.server.cluster.qourum; -import org.apache.activemq.artemis.api.core.ActiveMQBuffer; - import java.util.HashMap; import java.util.Map; +import org.apache.activemq.artemis.api.core.ActiveMQBuffer; + /** * the vote itself */ http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java index e3a583f..1065a49 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java @@ -17,7 +17,6 @@ package org.apache.activemq.artemis.core.server.embedded; import javax.management.MBeanServer; - import java.util.concurrent.TimeUnit; import org.apache.activemq.artemis.core.config.Configuration; @@ -62,15 +61,15 @@ public class EmbeddedActiveMQ { /** * It will iterate the cluster connections until you have at least the number of expected servers - * @param timeWait Time to wait on each iteration - * @param unit unit of time to wait + * + * @param timeWait Time to wait on each iteration + * @param unit unit of time to wait * @param iterations number of iterations - * @param servers number of minimal servers + * @param servers number of minimal servers * @return */ public boolean waitClusterForming(long timeWait, TimeUnit unit, int iterations, int servers) throws Exception { - if (activeMQServer.getClusterManager().getClusterConnections() == null || - activeMQServer.getClusterManager().getClusterConnections().size() == 0) { + if (activeMQServer.getClusterManager().getClusterConnections() == null || activeMQServer.getClusterManager().getClusterConnections().size() == 0) { return servers == 0; } @@ -132,8 +131,7 @@ public class EmbeddedActiveMQ { } if (mbeanServer == null) { activeMQServer = new ActiveMQServerImpl(configuration, securityManager); - } - else { + } else { activeMQServer = new ActiveMQServerImpl(configuration, mbeanServer, securityManager); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileMoveManager.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileMoveManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileMoveManager.java index 2cd5632..32587e5 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileMoveManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileMoveManager.java @@ -32,6 +32,7 @@ import org.jboss.logging.Logger; * We may control the maximum number of folders so we remove old ones. */ public class FileMoveManager { + private static final Logger logger = Logger.getLogger(FileMoveManager.class); private final File folder; @@ -46,8 +47,7 @@ public class FileMoveManager { if (prefixed) { try { Integer.parseInt(name.substring(PREFIX.length())); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { // This function is not really used a lot // so I don't really mind about performance here // this is good enough for what we need @@ -66,7 +66,6 @@ public class FileMoveManager { } }; - public FileMoveManager(File folder) { this(folder, -1); } @@ -105,8 +104,7 @@ public class FileMoveManager { logger.tracef("deleting %s", fileFrom); deleteTree(fileFrom); } - } - else { + } else { File folderTo = getFolder(whereToMove); folderTo.mkdirs(); @@ -157,7 +155,6 @@ public class FileMoveManager { return folder.list(notPrefix); } - public int getNumberOfFolders() { return getFolders().length; } @@ -169,11 +166,9 @@ public class FileMoveManager { list = new String[0]; } - return list; } - public int getMinID() { int[] list = getIDlist(); @@ -194,7 +189,6 @@ public class FileMoveManager { return list[list.length - 1]; } - public int[] getIDlist() { String[] list = getFolders(); int[] ids = new int[list.length]; @@ -211,12 +205,10 @@ public class FileMoveManager { return Integer.parseInt(folderName.substring(PREFIX.length())); } - public File getFolder(int id) { return new File(folder, PREFIX + id); } - private void deleteTree(File file) { File[] files = file.listFiles(); @@ -229,5 +221,4 @@ public class FileMoveManager { file.delete(); } - } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitor.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitor.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitor.java index f4ab032..972cbdd 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitor.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitor.java @@ -30,12 +30,13 @@ import java.util.concurrent.TimeUnit; import org.apache.activemq.artemis.core.server.ActiveMQScheduledComponent; import org.jboss.logging.Logger; -/** This will keep a list of fileStores. It will make a comparisson on all file stores registered. if any is over the limit, - * all Callbacks will be called with over. +/** + * This will keep a list of fileStores. It will make a comparisson on all file stores registered. if any is over the limit, + * all Callbacks will be called with over. * - * For instance: if Large Messages folder is registered on a different folder and it's over capacity, - * the whole system will be waiting it to be released. - * */ + * For instance: if Large Messages folder is registered on a different folder and it's over capacity, + * the whole system will be waiting it to be released. + */ public class FileStoreMonitor extends ActiveMQScheduledComponent { private static final Logger logger = Logger.getLogger(FileStoreMonitor.class); @@ -71,7 +72,6 @@ public class FileStoreMonitor extends ActiveMQScheduledComponent { return this; } - @Override public void run() { tick(); @@ -87,12 +87,11 @@ public class FileStoreMonitor extends ActiveMQScheduledComponent { try { lastStore = store; usage = calculateUsage(store); - over = usage > maxUsage; + over = usage > maxUsage; if (over) { break; } - } - catch (Exception e) { + } catch (Exception e) { logger.warn(e.getMessage(), e); } } @@ -102,8 +101,7 @@ public class FileStoreMonitor extends ActiveMQScheduledComponent { if (over) { callback.over(lastStore, usage); - } - else { + } else { callback.under(lastStore, usage); } } @@ -119,12 +117,15 @@ public class FileStoreMonitor extends ActiveMQScheduledComponent { } protected double calculateUsage(FileStore store) throws IOException { - return 1.0 - (double)store.getUsableSpace() / (double)store.getTotalSpace(); + return 1.0 - (double) store.getUsableSpace() / (double) store.getTotalSpace(); } public interface Callback { + void tick(FileStore store, double usage); + void over(FileStore store, double usage); + void under(FileStore store, double usage); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/GroupHandlingAbstract.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/GroupHandlingAbstract.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/GroupHandlingAbstract.java index 3c32c92..b68b59e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/GroupHandlingAbstract.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/GroupHandlingAbstract.java @@ -55,8 +55,7 @@ public abstract class GroupHandlingAbstract implements GroupingHandler { public void addListener(final UnproposalListener listener) { if (executor == null) { listeners.add(listener); - } - else { + } else { executor.execute(new Runnable() { @Override public void run() { @@ -78,8 +77,7 @@ public abstract class GroupHandlingAbstract implements GroupingHandler { }; if (executor != null) { executor.execute(runnable); - } - else { + } else { // for tests only, where we don't need an executor runnable.run(); } @@ -101,8 +99,7 @@ public abstract class GroupHandlingAbstract implements GroupingHandler { Notification notification = new Notification(null, CoreNotificationType.UNPROPOSAL, props); try { managementService.sendNotification(notification); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorHandlingMessage(e); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/GroupingHandlerConfiguration.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/GroupingHandlerConfiguration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/GroupingHandlerConfiguration.java index f6b7fcc..4ee8269 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/GroupingHandlerConfiguration.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/GroupingHandlerConfiguration.java @@ -138,14 +138,12 @@ public final class GroupingHandlerConfiguration implements Serializable { if (address == null) { if (other.address != null) return false; - } - else if (!address.equals(other.address)) + } else if (!address.equals(other.address)) return false; if (name == null) { if (other.name != null) return false; - } - else if (!name.equals(other.name)) + } else if (!name.equals(other.name)) return false; if (timeout != other.timeout) return false; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/LocalGroupingHandler.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/LocalGroupingHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/LocalGroupingHandler.java index 383321e..aa707f7 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/LocalGroupingHandler.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/LocalGroupingHandler.java @@ -119,8 +119,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { if (original != null) { original.use(); return new Response(proposal.getGroupId(), original.getClusterName()); - } - else { + } else { return null; } } @@ -135,8 +134,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { groupBinding.use(); // Returning with an alternate cluster name, as it's been already grouped return new Response(groupBinding.getGroupId(), proposal.getClusterName(), groupBinding.getClusterName()); - } - else { + } else { addRecord = true; groupBinding = new GroupBinding(proposal.getGroupId(), proposal.getClusterName()); groupBinding.setId(storageManager.generateID()); @@ -148,8 +146,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { newList.add(groupBinding); map.put(groupBinding.getGroupId(), groupBinding); } - } - finally { + } finally { lock.unlock(); } // Storing the record outside of any locks @@ -157,8 +154,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { storageManager.addGrouping(groupBinding); } return new Response(groupBinding.getGroupId(), groupBinding.getClusterName()); - } - finally { + } finally { storageManager.setContext(originalCtx); } } @@ -217,8 +213,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { original.use(); } return new Response(fullID, original.getClusterName()); - } - else { + } else { return null; } } @@ -233,8 +228,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { long tx = storageManager.generateID(); storageManager.deleteGrouping(tx, groupBinding); storageManager.commitBindings(tx); - } - catch (Exception e) { + } catch (Exception e) { // nothing we can do being log ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } @@ -253,8 +247,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { if (expectedBindings == null) { bindingsAlreadyAdded = Collections.emptyList(); expectedBindings = new LinkedList<>(); - } - else { + } else { bindingsAlreadyAdded = new ArrayList<>(expectedBindings); //clear the bindings expectedBindings.clear(); @@ -274,8 +267,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { } } } - } - finally { + } finally { expectedBindings = null; waitingForBindings = false; lock.unlock(); @@ -290,8 +282,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { if (notification.getType() == CoreNotificationType.BINDING_REMOVED) { SimpleString clusterName = notification.getProperties().getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME); removeGrouping(clusterName); - } - else if (notification.getType() == CoreNotificationType.BINDING_ADDED) { + } else if (notification.getType() == CoreNotificationType.BINDING_ADDED) { SimpleString clusterName = notification.getProperties().getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME); try { lock.lock(); @@ -300,12 +291,10 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { if (waitingForBindings) { if (expectedBindings.remove(clusterName)) { logger.debug("OnNotification for waitForbindings::Removed clusterName=" + clusterName + " from lis succesffully"); - } - else { + } else { logger.debug("OnNotification for waitForbindings::Couldn't remove clusterName=" + clusterName + " as it wasn't on the original list"); } - } - else { + } else { expectedBindings.add(clusterName); logger.debug("Notification for waitForbindings::Adding previously known item clusterName=" + clusterName); } @@ -320,8 +309,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { awaitCondition.signal(); } } - } - finally { + } finally { lock.unlock(); } } @@ -382,8 +370,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { txID = storageManager.generateID(); } storageManager.deleteGrouping(txID, val); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.unableToDeleteGroupBindings(e, val.getGroupId()); } } @@ -392,8 +379,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { if (txID >= 0) { try { storageManager.commitBindings(txID); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.unableToDeleteGroupBindings(e, SimpleString.toSimpleString("TX:" + txID)); } } @@ -448,8 +434,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { expiredGroups = 0; txID = -1; } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.unableToDeleteGroupBindings(e, groupBinding.getGroupId()); } } @@ -458,8 +443,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { if (txID >= 0) { try { storageManager.commitBindings(txID); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQServerLogger.LOGGER.unableToDeleteGroupBindings(e, SimpleString.toSimpleString("TX:" + txID)); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/RemoteGroupingHandler.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/RemoteGroupingHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/RemoteGroupingHandler.java index 26841e4..058e897 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/RemoteGroupingHandler.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/RemoteGroupingHandler.java @@ -117,8 +117,7 @@ public final class RemoteGroupingHandler extends GroupHandlingAbstract { for (Notification notification : pendingNotifications) { managementService.sendNotification(notification); } - } - finally { + } finally { lock.unlock(); } } @@ -159,8 +158,7 @@ public final class RemoteGroupingHandler extends GroupHandlingAbstract { break; } } while (timeLimit > System.currentTimeMillis()); - } - finally { + } finally { if (notification != null) { pendingNotifications.remove(notification); } @@ -185,8 +183,7 @@ public final class RemoteGroupingHandler extends GroupHandlingAbstract { response.use(); try { managementService.sendNotification(createProposalNotification(response.getGroupId(), response.getClusterName())); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } } @@ -249,8 +246,7 @@ public final class RemoteGroupingHandler extends GroupHandlingAbstract { // We could have more than one Requests waiting in case you have multiple producers // using different groups sendCondition.signalAll(); - } - finally { + } finally { lock.unlock(); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AIOFileLockNodeManager.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AIOFileLockNodeManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AIOFileLockNodeManager.java index 471b7c1..0892a11 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AIOFileLockNodeManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AIOFileLockNodeManager.java @@ -76,12 +76,10 @@ public final class AIOFileLockNodeManager extends FileLockNodeManager { FileLock lockFile = tryLock(liveLockPos); if (lockFile != null) { return lockFile; - } - else { + } else { try { Thread.sleep(500); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { return null; }
