Skip to content

Commit

Permalink
ARTEMIS-2716 Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
howardgao authored and spyrkob committed Mar 3, 2020
1 parent eb41be7 commit cb8da54
Show file tree
Hide file tree
Showing 5 changed files with 202 additions and 343 deletions.
@@ -0,0 +1,86 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.activemq.artemis.api.config;

import org.apache.activemq.artemis.api.core.client.ActiveMQClient;

public class ServerLocatorConfig {
public long clientFailureCheckPeriod = ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD;
public long connectionTTL = ActiveMQClient.DEFAULT_CONNECTION_TTL;
public long callTimeout = ActiveMQClient.DEFAULT_CALL_TIMEOUT;
public long callFailoverTimeout = ActiveMQClient.DEFAULT_CALL_FAILOVER_TIMEOUT;
public int minLargeMessageSize = ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
public int consumerWindowSize = ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE;
public int consumerMaxRate = ActiveMQClient.DEFAULT_CONSUMER_MAX_RATE;
public int confirmationWindowSize = ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE;
public int producerWindowSize = ActiveMQClient.DEFAULT_PRODUCER_WINDOW_SIZE;
public int producerMaxRate = ActiveMQClient.DEFAULT_PRODUCER_MAX_RATE;
public boolean blockOnAcknowledge = ActiveMQClient.DEFAULT_BLOCK_ON_ACKNOWLEDGE;
public boolean blockOnDurableSend = ActiveMQClient.DEFAULT_BLOCK_ON_DURABLE_SEND;
public boolean blockOnNonDurableSend = ActiveMQClient.DEFAULT_BLOCK_ON_NON_DURABLE_SEND;
public boolean autoGroup = ActiveMQClient.DEFAULT_AUTO_GROUP;
public boolean preAcknowledge = ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE;
public int ackBatchSize = ActiveMQClient.DEFAULT_ACK_BATCH_SIZE;
public String connectionLoadBalancingPolicyClassName = ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
public boolean useGlobalPools = ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS;
public int threadPoolMaxSize = ActiveMQClient.DEFAULT_THREAD_POOL_MAX_SIZE;
public int scheduledThreadPoolMaxSize = ActiveMQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE;
public long retryInterval = ActiveMQClient.DEFAULT_RETRY_INTERVAL;
public double retryIntervalMultiplier = ActiveMQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
public long maxRetryInterval = ActiveMQClient.DEFAULT_MAX_RETRY_INTERVAL;
public int reconnectAttempts = ActiveMQClient.DEFAULT_RECONNECT_ATTEMPTS;
public int initialConnectAttempts = ActiveMQClient.INITIAL_CONNECT_ATTEMPTS;
public int initialMessagePacketSize = ActiveMQClient.DEFAULT_INITIAL_MESSAGE_PACKET_SIZE;
public boolean cacheLargeMessagesClient = ActiveMQClient.DEFAULT_CACHE_LARGE_MESSAGE_CLIENT;
public boolean compressLargeMessage = ActiveMQClient.DEFAULT_COMPRESS_LARGE_MESSAGES;
public boolean useTopologyForLoadBalancing = ActiveMQClient.DEFAULT_USE_TOPOLOGY_FOR_LOADBALANCING;

public ServerLocatorConfig() {
}

public ServerLocatorConfig(final ServerLocatorConfig locator) {
compressLargeMessage = locator.compressLargeMessage;
cacheLargeMessagesClient = locator.cacheLargeMessagesClient;
clientFailureCheckPeriod = locator.clientFailureCheckPeriod;
connectionTTL = locator.connectionTTL;
callTimeout = locator.callTimeout;
callFailoverTimeout = locator.callFailoverTimeout;
minLargeMessageSize = locator.minLargeMessageSize;
consumerWindowSize = locator.consumerWindowSize;
consumerMaxRate = locator.consumerMaxRate;
confirmationWindowSize = locator.confirmationWindowSize;
producerWindowSize = locator.producerWindowSize;
producerMaxRate = locator.producerMaxRate;
blockOnAcknowledge = locator.blockOnAcknowledge;
blockOnDurableSend = locator.blockOnDurableSend;
blockOnNonDurableSend = locator.blockOnNonDurableSend;
autoGroup = locator.autoGroup;
preAcknowledge = locator.preAcknowledge;
connectionLoadBalancingPolicyClassName = locator.connectionLoadBalancingPolicyClassName;
ackBatchSize = locator.ackBatchSize;
useGlobalPools = locator.useGlobalPools;
scheduledThreadPoolMaxSize = locator.scheduledThreadPoolMaxSize;
threadPoolMaxSize = locator.threadPoolMaxSize;
retryInterval = locator.retryInterval;
retryIntervalMultiplier = locator.retryIntervalMultiplier;
maxRetryInterval = locator.maxRetryInterval;
reconnectAttempts = locator.reconnectAttempts;
initialConnectAttempts = locator.initialConnectAttempts;
initialMessagePacketSize = locator.initialMessagePacketSize;
useTopologyForLoadBalancing = locator.useTopologyForLoadBalancing;
}
}
Expand Up @@ -19,6 +19,7 @@
import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService;

import org.apache.activemq.artemis.api.config.ServerLocatorConfig;
import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
import org.apache.activemq.artemis.api.core.Interceptor;
Expand Down Expand Up @@ -822,4 +823,8 @@ ClientSessionFactory createSessionFactory(TransportConfiguration transportConfig

/** This will only instantiate internal objects such as the topology */
void initialize() throws ActiveMQException;

ServerLocatorConfig getLocatorConfig();

void setLocatorConfig(ServerLocatorConfig serverLocatorConfig);
}
Expand Up @@ -32,6 +32,7 @@
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import org.apache.activemq.artemis.api.config.ServerLocatorConfig;
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.api.core.ActiveMQInterruptedException;
Expand Down Expand Up @@ -156,13 +157,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C

public ClientSessionFactoryImpl(final ServerLocatorInternal serverLocator,
final TransportConfiguration connectorConfig,
final long callTimeout,
final long callFailoverTimeout,
final long clientFailureCheckPeriod,
final long connectionTTL,
final long retryInterval,
final double retryIntervalMultiplier,
final long maxRetryInterval,
final ServerLocatorConfig locatorConfig,
final int reconnectAttempts,
final Executor threadPool,
final ScheduledExecutorService scheduledThreadPool,
Expand All @@ -182,27 +177,27 @@ public ClientSessionFactoryImpl(final ServerLocatorInternal serverLocator,

checkTransportKeys(connectorFactory, connectorConfig);

this.callTimeout = callTimeout;
this.callTimeout = locatorConfig.callTimeout;

this.callFailoverTimeout = callFailoverTimeout;
this.callFailoverTimeout = locatorConfig.callFailoverTimeout;

// HORNETQ-1314 - if this in an in-vm connection then disable connection monitoring
if (connectorFactory.isReliable() &&
clientFailureCheckPeriod == ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD &&
connectionTTL == ActiveMQClient.DEFAULT_CONNECTION_TTL) {
locatorConfig.clientFailureCheckPeriod == ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD &&
locatorConfig.connectionTTL == ActiveMQClient.DEFAULT_CONNECTION_TTL) {
this.clientFailureCheckPeriod = ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD_INVM;
this.connectionTTL = ActiveMQClient.DEFAULT_CONNECTION_TTL_INVM;
} else {
this.clientFailureCheckPeriod = clientFailureCheckPeriod;
this.clientFailureCheckPeriod = locatorConfig.clientFailureCheckPeriod;

this.connectionTTL = connectionTTL;
this.connectionTTL = locatorConfig.connectionTTL;
}

this.retryInterval = retryInterval;
this.retryInterval = locatorConfig.retryInterval;

this.retryIntervalMultiplier = retryIntervalMultiplier;
this.retryIntervalMultiplier = locatorConfig.retryIntervalMultiplier;

this.maxRetryInterval = maxRetryInterval;
this.maxRetryInterval = locatorConfig.maxRetryInterval;

this.reconnectAttempts = reconnectAttempts;

Expand Down

0 comments on commit cb8da54

Please sign in to comment.