use of org.apache.geode.cache.wan.GatewayReceiver in project geode by apache.
the class GatewayReceiverFactoryImpl method create.
public GatewayReceiver create() {
if (this.startPort > this.endPort) {
throw new IllegalStateException("Please specify either start port a value which is less than end port.");
}
GatewayReceiver recv = null;
if (this.cache instanceof GemFireCacheImpl) {
recv = new GatewayReceiverImpl(this.cache, this.startPort, this.endPort, this.timeBetPings, this.socketBuffSize, this.bindAdd, this.filters, this.hostnameForSenders, this.manualStart);
this.cache.addGatewayReceiver(recv);
InternalDistributedSystem system = (InternalDistributedSystem) this.cache.getDistributedSystem();
system.handleResourceEvent(ResourceEvent.GATEWAYRECEIVER_CREATE, recv);
if (!this.manualStart) {
try {
recv.start();
} catch (IOException ioe) {
throw new GatewayReceiverException(LocalizedStrings.GatewayReceiver_EXCEPTION_WHILE_STARTING_GATEWAY_RECEIVER.toLocalizedString(), ioe);
}
}
} else if (this.cache instanceof CacheCreation) {
recv = new GatewayReceiverCreation(this.cache, this.startPort, this.endPort, this.timeBetPings, this.socketBuffSize, this.bindAdd, this.filters, this.hostnameForSenders, this.manualStart);
this.cache.addGatewayReceiver(recv);
}
return recv;
}
use of org.apache.geode.cache.wan.GatewayReceiver in project geode by apache.
the class WANTestBase method createReceiverWithSSL.
public static int createReceiverWithSSL(int locPort) {
WANTestBase test = new WANTestBase();
Properties gemFireProps = test.getDistributedSystemProperties();
gemFireProps.put(LOG_LEVEL, LogWriterUtils.getDUnitLogLevel());
gemFireProps.put(GATEWAY_SSL_ENABLED, "true");
gemFireProps.put(GATEWAY_SSL_PROTOCOLS, "any");
gemFireProps.put(GATEWAY_SSL_CIPHERS, "any");
gemFireProps.put(GATEWAY_SSL_REQUIRE_AUTHENTICATION, "true");
gemFireProps.put(GATEWAY_SSL_KEYSTORE_TYPE, "jks");
gemFireProps.put(GATEWAY_SSL_KEYSTORE, TestUtil.getResourcePath(WANTestBase.class, "/org/apache/geode/cache/client/internal/cacheserver.keystore"));
gemFireProps.put(GATEWAY_SSL_KEYSTORE_PASSWORD, "password");
gemFireProps.put(GATEWAY_SSL_TRUSTSTORE, TestUtil.getResourcePath(WANTestBase.class, "/org/apache/geode/cache/client/internal/cacheserver.truststore"));
gemFireProps.put(GATEWAY_SSL_TRUSTSTORE_PASSWORD, "password");
gemFireProps.setProperty(MCAST_PORT, "0");
gemFireProps.setProperty(LOCATORS, "localhost[" + locPort + "]");
LogWriterUtils.getLogWriter().info("Starting cache ds with following properties \n" + gemFireProps);
InternalDistributedSystem ds = test.getSystem(gemFireProps);
cache = CacheFactory.create(ds);
GatewayReceiverFactory fact = cache.createGatewayReceiverFactory();
int port = AvailablePortHelper.getRandomAvailablePortForDUnitSite();
fact.setStartPort(port);
fact.setEndPort(port);
fact.setManualStart(true);
GatewayReceiver receiver = fact.create();
try {
receiver.start();
} catch (IOException e) {
e.printStackTrace();
fail("Test " + test.getName() + " failed to start GatewayReceiver on port " + port);
}
return port;
}
use of org.apache.geode.cache.wan.GatewayReceiver in project geode by apache.
the class CacheCreationJUnitTest method shouldCreateGatewaySenderAfterRegions.
@Test
public void shouldCreateGatewaySenderAfterRegions() {
CacheCreation cacheCreation = new CacheCreation();
GatewayReceiver receiver = mock(GatewayReceiver.class);
cacheCreation.addGatewayReceiver(receiver);
cacheCreation.addRootRegion(new RegionCreation(cacheCreation, "region"));
InternalCache internalCache = mock(InternalCache.class);
GatewayReceiverFactory receiverFactory = mock(GatewayReceiverFactory.class);
when(internalCache.createGatewayReceiverFactory()).thenReturn(receiverFactory);
when(receiverFactory.create()).thenReturn(receiver);
InOrder inOrder = inOrder(internalCache, receiverFactory);
cacheCreation.create(internalCache);
// inOrder.verify(cache).basicCreateRegion(eq("region"), any());
inOrder.verify(internalCache).createGatewayReceiverFactory();
inOrder.verify(receiverFactory).create();
}
use of org.apache.geode.cache.wan.GatewayReceiver in project geode by apache.
the class CacheXmlGenerator method generateGatewayReceiver.
private void generateGatewayReceiver(Cache cache) throws SAXException {
Set<GatewayReceiver> receiverList = cache.getGatewayReceivers();
for (GatewayReceiver receiver : receiverList) {
AttributesImpl atts = new AttributesImpl();
try {
// start port
if (generateDefaults() || receiver.getStartPort() != GatewayReceiver.DEFAULT_START_PORT)
atts.addAttribute("", "", START_PORT, "", String.valueOf(receiver.getStartPort()));
// end port
if (generateDefaults() || receiver.getEndPort() != GatewayReceiver.DEFAULT_END_PORT)
atts.addAttribute("", "", END_PORT, "", String.valueOf(receiver.getEndPort()));
// bind-address
if (generateDefaults() || (receiver.getBindAddress() != null && !receiver.getBindAddress().equals(GatewayReceiver.DEFAULT_BIND_ADDRESS)))
atts.addAttribute("", "", BIND_ADDRESS, "", receiver.getBindAddress());
// maximum-time-between-pings
if (generateDefaults() || receiver.getMaximumTimeBetweenPings() != GatewayReceiver.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS)
atts.addAttribute("", "", MAXIMUM_TIME_BETWEEN_PINGS, "", String.valueOf(receiver.getMaximumTimeBetweenPings()));
// socket-buffer-size
if (generateDefaults() || receiver.getSocketBufferSize() != GatewayReceiver.DEFAULT_SOCKET_BUFFER_SIZE)
atts.addAttribute("", "", SOCKET_BUFFER_SIZE, "", String.valueOf(receiver.getSocketBufferSize()));
if (this.version.compareTo(CacheXmlVersion.GEMFIRE_8_0) < 0) {
return;
}
// manual-start
if (generateDefaults() || receiver.isManualStart() != GatewayReceiver.DEFAULT_MANUAL_START)
atts.addAttribute("", "", MANUAL_START, "", String.valueOf(receiver.isManualStart()));
} finally {
handler.startElement("", GATEWAY_RECEIVER, GATEWAY_RECEIVER, atts);
for (GatewayTransportFilter gsf : receiver.getGatewayTransportFilters()) {
generateGatewayTransportFilter(gsf);
}
handler.endElement("", GATEWAY_RECEIVER, GATEWAY_RECEIVER);
}
}
}
use of org.apache.geode.cache.wan.GatewayReceiver in project geode by apache.
the class ManagementListener method handleEvent.
/**
* Handles various GFE resource life-cycle methods vis-a-vis Management and Monitoring
*
* It checks for race conditions cases by calling shouldProceed();
*
* @param event Management event for which invocation has happened
* @param resource the GFE resource type
*/
public void handleEvent(ResourceEvent event, Object resource) {
if (!shouldProceed(event)) {
return;
}
switch(event) {
case CACHE_CREATE:
InternalCache createdCache = (InternalCache) resource;
adapter.handleCacheCreation(createdCache);
break;
case CACHE_REMOVE:
InternalCache removedCache = (InternalCache) resource;
adapter.handleCacheRemoval(removedCache);
break;
case REGION_CREATE:
Region createdRegion = (Region) resource;
adapter.handleRegionCreation(createdRegion);
break;
case REGION_REMOVE:
Region removedRegion = (Region) resource;
adapter.handleRegionRemoval(removedRegion);
break;
case DISKSTORE_CREATE:
DiskStore createdDisk = (DiskStore) resource;
adapter.handleDiskCreation(createdDisk);
break;
case DISKSTORE_REMOVE:
DiskStore removedDisk = (DiskStore) resource;
adapter.handleDiskRemoval(removedDisk);
break;
case GATEWAYRECEIVER_CREATE:
GatewayReceiver createdRecv = (GatewayReceiver) resource;
adapter.handleGatewayReceiverCreate(createdRecv);
break;
case GATEWAYRECEIVER_START:
GatewayReceiver startedRecv = (GatewayReceiver) resource;
adapter.handleGatewayReceiverStart(startedRecv);
break;
case GATEWAYRECEIVER_STOP:
GatewayReceiver stoppededRecv = (GatewayReceiver) resource;
adapter.handleGatewayReceiverStop(stoppededRecv);
break;
case GATEWAYSENDER_CREATE:
GatewaySender sender = (GatewaySender) resource;
adapter.handleGatewaySenderCreation(sender);
break;
case GATEWAYSENDER_START:
GatewaySender startedSender = (GatewaySender) resource;
adapter.handleGatewaySenderStart(startedSender);
break;
case GATEWAYSENDER_STOP:
GatewaySender stoppedSender = (GatewaySender) resource;
adapter.handleGatewaySenderStop(stoppedSender);
break;
case GATEWAYSENDER_PAUSE:
GatewaySender pausedSender = (GatewaySender) resource;
adapter.handleGatewaySenderPaused(pausedSender);
break;
case GATEWAYSENDER_RESUME:
GatewaySender resumedSender = (GatewaySender) resource;
adapter.handleGatewaySenderResumed(resumedSender);
break;
case LOCKSERVICE_CREATE:
DLockService createdLockService = (DLockService) resource;
adapter.handleLockServiceCreation(createdLockService);
break;
case LOCKSERVICE_REMOVE:
DLockService removedLockService = (DLockService) resource;
adapter.handleLockServiceRemoval(removedLockService);
break;
case MANAGER_CREATE:
adapter.handleManagerCreation();
break;
case MANAGER_START:
adapter.handleManagerStart();
break;
case MANAGER_STOP:
adapter.handleManagerStop();
break;
case ASYNCEVENTQUEUE_CREATE:
AsyncEventQueue queue = (AsyncEventQueue) resource;
adapter.handleAsyncEventQueueCreation(queue);
break;
case ASYNCEVENTQUEUE_REMOVE:
AsyncEventQueue removedQueue = (AsyncEventQueue) resource;
adapter.handleAsyncEventQueueRemoval(removedQueue);
break;
case SYSTEM_ALERT:
AlertDetails details = (AlertDetails) resource;
adapter.handleSystemNotification(details);
break;
case CACHE_SERVER_START:
CacheServer startedServer = (CacheServer) resource;
adapter.handleCacheServerStart(startedServer);
break;
case CACHE_SERVER_STOP:
CacheServer stoppedServer = (CacheServer) resource;
adapter.handleCacheServerStop(stoppedServer);
break;
case LOCATOR_START:
Locator loc = (Locator) resource;
adapter.handleLocatorStart(loc);
break;
case CACHE_SERVICE_CREATE:
CacheService service = (CacheService) resource;
adapter.handleCacheServiceCreation(service);
break;
default:
break;
}
}
Aggregations