PageRenderTime 44ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/BridgeServerCreation.java

https://gitlab.com/kidaa/incubator-geode
Java | 249 lines | 166 code | 34 blank | 49 comment | 18 complexity | d3d3fc4dd9f6b1833d31472a165c5b2d MD5 | raw file
  1. /*=========================================================================
  2. * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
  3. * This product is protected by U.S. and international copyright
  4. * and intellectual property laws. Pivotal products are covered by
  5. * one or more patents listed at http://www.pivotal.io/patents.
  6. *=========================================================================
  7. */
  8. package com.gemstone.gemfire.internal.cache.xmlcache;
  9. import java.io.IOException;
  10. import java.util.Arrays;
  11. import java.util.Set;
  12. import com.gemstone.gemfire.cache.Cache;
  13. import com.gemstone.gemfire.cache.ClientSession;
  14. import com.gemstone.gemfire.cache.InterestRegistrationListener;
  15. import com.gemstone.gemfire.cache.server.CacheServer;
  16. import com.gemstone.gemfire.cache.server.ClientSubscriptionConfig;
  17. import com.gemstone.gemfire.distributed.DistributedMember;
  18. import com.gemstone.gemfire.internal.cache.AbstractBridgeServer;
  19. import com.gemstone.gemfire.internal.cache.InternalCache;
  20. import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
  21. /**
  22. * Represents a {@link CacheServer} that is created declaratively.
  23. *
  24. * @author David Whitlock
  25. * @since 4.0
  26. */
  27. public class BridgeServerCreation extends AbstractBridgeServer {
  28. // moved to AbstractBridgeServer
  29. ////////////////////// Constructors //////////////////////
  30. /**
  31. * Creates a new <code>BridgeServerCreation</code> with the default
  32. * configuration.
  33. *
  34. * @param cache
  35. * The cache being served
  36. */
  37. BridgeServerCreation(InternalCache cache) {
  38. super(cache);
  39. }
  40. BridgeServerCreation(InternalCache cache, boolean attachListener) {
  41. super(cache, attachListener);
  42. }
  43. /**
  44. * Constructor for retaining bridge server information during auto-reconnect
  45. * @param cache
  46. * @param other
  47. */
  48. public BridgeServerCreation(InternalCache cache, CacheServer other) {
  49. super(cache);
  50. setPort(other.getPort());
  51. setBindAddress(other.getBindAddress());
  52. setHostnameForClients(other.getHostnameForClients());
  53. setMaxConnections(other.getMaxConnections());
  54. setMaxThreads(other.getMaxThreads());
  55. setNotifyBySubscription(other.getNotifyBySubscription());
  56. setSocketBufferSize(other.getSocketBufferSize());
  57. setTcpNoDelay(other.getTcpNoDelay());
  58. setMaximumTimeBetweenPings(other.getMaximumTimeBetweenPings());
  59. setMaximumMessageCount(other.getMaximumMessageCount());
  60. setMessageTimeToLive(other.getMessageTimeToLive());
  61. // setTransactionTimeToLive(other.getTransactionTimeToLive()); not implemented in CacheServer for v6.6
  62. setGroups(other.getGroups());
  63. setLoadProbe(other.getLoadProbe());
  64. setLoadPollInterval(other.getLoadPollInterval());
  65. ClientSubscriptionConfig cscOther = other.getClientSubscriptionConfig();
  66. ClientSubscriptionConfig cscThis = this.getClientSubscriptionConfig();
  67. // added for configuration of ha overflow
  68. cscThis.setEvictionPolicy(cscOther.getEvictionPolicy());
  69. cscThis.setCapacity(cscOther.getCapacity());
  70. String diskStoreName = cscOther.getDiskStoreName();
  71. if (diskStoreName != null) {
  72. cscThis.setDiskStoreName(diskStoreName);
  73. } else {
  74. cscThis.setOverflowDirectory(cscOther.getOverflowDirectory());
  75. }
  76. // this.cache = null; we should null out the cache since we no longer need it
  77. }
  78. ///////////////////// Instance Methods /////////////////////
  79. @Override
  80. public void start() throws IOException {
  81. // This method is invoked during testing, but it is not necessary
  82. // to do anything.
  83. }
  84. @Override
  85. public void setNotifyBySubscription(boolean b) {
  86. this.notifyBySubscription = b;
  87. }
  88. @Override
  89. public boolean getNotifyBySubscription() {
  90. return this.notifyBySubscription;
  91. }
  92. @Override
  93. public void setSocketBufferSize(int socketBufferSize) {
  94. this.socketBufferSize = socketBufferSize;
  95. }
  96. @Override
  97. public int getSocketBufferSize() {
  98. return this.socketBufferSize;
  99. }
  100. @Override
  101. public void setTcpNoDelay(boolean setting) {
  102. this.tcpNoDelay = setting;
  103. }
  104. @Override
  105. public boolean getTcpNoDelay() {
  106. return this.tcpNoDelay;
  107. }
  108. @Override
  109. public void setMaximumTimeBetweenPings(int maximumTimeBetweenPings) {
  110. this.maximumTimeBetweenPings = maximumTimeBetweenPings;
  111. }
  112. @Override
  113. public int getMaximumTimeBetweenPings() {
  114. return this.maximumTimeBetweenPings;
  115. }
  116. @Override
  117. public int getMaximumMessageCount() {
  118. return this.maximumMessageCount;
  119. }
  120. @Override
  121. public void setMaximumMessageCount(int maximumMessageCount) {
  122. this.maximumMessageCount = maximumMessageCount;
  123. }
  124. @Override
  125. public int getMessageTimeToLive() {
  126. return this.messageTimeToLive;
  127. }
  128. @Override
  129. public void setMessageTimeToLive(int messageTimeToLive) {
  130. this.messageTimeToLive = messageTimeToLive;
  131. }
  132. public boolean isRunning() {
  133. throw new UnsupportedOperationException(LocalizedStrings.SHOULDNT_INVOKE.toLocalizedString());
  134. }
  135. public void stop() {
  136. throw new UnsupportedOperationException(LocalizedStrings.SHOULDNT_INVOKE.toLocalizedString());
  137. }
  138. /**
  139. * Returns whether or not this bridge server has the same
  140. * configuration as another bridge server.
  141. */
  142. @Override
  143. public boolean sameAs(CacheServer other) {
  144. ClientSubscriptionConfig cscThis = this.getClientSubscriptionConfig();
  145. ClientSubscriptionConfig cscOther = other.getClientSubscriptionConfig();
  146. boolean result =
  147. this.getPort() == other.getPort() &&
  148. this.getSocketBufferSize() == other.getSocketBufferSize() &&
  149. this.getMaximumTimeBetweenPings() == other.getMaximumTimeBetweenPings() &&
  150. this.getNotifyBySubscription() == other.getNotifyBySubscription() &&
  151. this.getMaxConnections() == other.getMaxConnections() &&
  152. this.getMaxThreads() == other.getMaxThreads() &&
  153. this.getMaximumMessageCount() == other.getMaximumMessageCount() &&
  154. this.getMessageTimeToLive() == other.getMessageTimeToLive() &&
  155. this.getTcpNoDelay() == other.getTcpNoDelay() &&
  156. cscThis.getCapacity() == cscOther.getCapacity() &&
  157. cscThis.getEvictionPolicy().equals(cscOther.getEvictionPolicy());
  158. String diskStoreName = cscThis.getDiskStoreName();
  159. if (diskStoreName != null) {
  160. result = result && diskStoreName.equals(cscOther.getDiskStoreName());
  161. } else {
  162. result = result && cscThis.getOverflowDirectory().equals(cscOther.getOverflowDirectory());
  163. }
  164. return result;
  165. }
  166. @Override
  167. public String toString()
  168. {
  169. return "BridgeServerCreation on port " + this.getPort() +
  170. " notify by subscription " + this.getNotifyBySubscription() +
  171. " maximum time between pings " + this.getMaximumTimeBetweenPings() +
  172. " socket buffer size " + this.getSocketBufferSize() +
  173. " maximum connections " + this.getMaxConnections() +
  174. " maximum threads " + this.getMaxThreads() +
  175. " maximum message count " + this.getMaximumMessageCount() +
  176. " message time to live " + this.getMessageTimeToLive() +
  177. " groups " + Arrays.asList(getGroups()) +
  178. " loadProbe " + loadProbe +
  179. " loadPollInterval " + loadPollInterval +
  180. this.getClientSubscriptionConfig().toString();
  181. }
  182. public ClientSubscriptionConfig getClientSubscriptionConfig(){
  183. return this.clientSubscriptionConfig;
  184. }
  185. public Set getInterestRegistrationListeners() {
  186. //TODO Yogesh : implement me
  187. return null;
  188. }
  189. public void registerInterestRegistrationListener(
  190. InterestRegistrationListener listener) {
  191. //TODO Yogesh : implement me
  192. }
  193. public void unregisterInterestRegistrationListener(
  194. InterestRegistrationListener listener) {
  195. //TODO Yogesh : implement me
  196. }
  197. /* (non-Javadoc)
  198. * @see com.gemstone.gemfire.cache.util.BridgeServer#getAllClientSessions()
  199. */
  200. public Set getAllClientSessions() {
  201. throw new UnsupportedOperationException("Shouldn't be invoked");
  202. }
  203. /* (non-Javadoc)
  204. * @see com.gemstone.gemfire.cache.util.BridgeServer#getClientSession(com.gemstone.gemfire.distributed.DistributedMember)
  205. */
  206. public ClientSession getClientSession(DistributedMember member) {
  207. throw new UnsupportedOperationException("Shouldn't be invoked");
  208. }
  209. /* (non-Javadoc)
  210. * @see com.gemstone.gemfire.cache.util.BridgeServer#getClientSession(java.lang.String)
  211. */
  212. public ClientSession getClientSession(String durableClientId) {
  213. throw new UnsupportedOperationException("Shouldn't be invoked");
  214. }
  215. }