use of org.apache.geode.cache.wan.GatewayReceiverFactory in project geode by apache.
the class UpdateVersionDUnitTest method createReceiver.
public static int createReceiver(int locPort) {
UpdateVersionDUnitTest test = new UpdateVersionDUnitTest();
Properties props = test.getDistributedSystemProperties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "localhost[" + locPort + "]");
InternalDistributedSystem ds = test.getSystem(props);
cache = CacheFactory.create(ds);
GatewayReceiverFactory fact = cache.createGatewayReceiverFactory();
int port = AvailablePortHelper.getRandomAvailablePortForDUnitSite();
fact.setStartPort(port);
fact.setEndPort(port);
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.GatewayReceiverFactory in project geode by apache.
the class WANTestBase method createReceiverWithBindAddress.
public static void createReceiverWithBindAddress(int locPort) {
WANTestBase test = new WANTestBase();
Properties props = test.getDistributedSystemProperties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOG_LEVEL, LogWriterUtils.getDUnitLogLevel());
props.setProperty(LOCATORS, "localhost[" + locPort + "]");
InternalDistributedSystem ds = test.getSystem(props);
cache = CacheFactory.create(ds);
GatewayReceiverFactory fact = cache.createGatewayReceiverFactory();
int port = AvailablePortHelper.getRandomAvailablePortForDUnitSite();
fact.setStartPort(port);
fact.setEndPort(port);
fact.setManualStart(true);
fact.setBindAddress("200.112.204.10");
GatewayReceiver receiver = fact.create();
try {
receiver.start();
fail("Expected GatewayReceiver Exception");
} catch (GatewayReceiverException gRE) {
LogWriterUtils.getLogWriter().fine("Got the GatewayReceiverException", gRE);
assertTrue(gRE.getMessage().contains("Failed to create server socket on"));
} catch (IOException e) {
e.printStackTrace();
fail("Test " + test.getName() + " failed to start GatewayReceiver on port " + port);
}
}
use of org.apache.geode.cache.wan.GatewayReceiverFactory in project geode by apache.
the class WANTestBase method createReceiver.
public static int createReceiver() {
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();
Assert.fail("Test " + getTestMethodName() + " failed to start GatewayReceiver on port " + port, e);
}
return port;
}
use of org.apache.geode.cache.wan.GatewayReceiverFactory in project geode by apache.
the class GatewayReceiverCreateFunction method createGatewayReceiver.
/**
* GatewayReceiver creation happens here.
*
* @param cache
* @param gatewayReceiverCreateArgs
* @return GatewayReceiver
*/
private static GatewayReceiver createGatewayReceiver(Cache cache, GatewayReceiverFunctionArgs gatewayReceiverCreateArgs) {
GatewayReceiverFactory gatewayReceiverFactory = cache.createGatewayReceiverFactory();
Integer startPort = gatewayReceiverCreateArgs.getStartPort();
if (startPort != null) {
gatewayReceiverFactory.setStartPort(startPort);
}
Integer endPort = gatewayReceiverCreateArgs.getEndPort();
if (endPort != null) {
gatewayReceiverFactory.setEndPort(endPort);
}
String bindAddress = gatewayReceiverCreateArgs.getBindAddress();
if (bindAddress != null) {
gatewayReceiverFactory.setBindAddress(bindAddress);
}
Integer maxTimeBetweenPings = gatewayReceiverCreateArgs.getMaximumTimeBetweenPings();
if (maxTimeBetweenPings != null) {
gatewayReceiverFactory.setMaximumTimeBetweenPings(maxTimeBetweenPings);
}
Integer socketBufferSize = gatewayReceiverCreateArgs.getSocketBufferSize();
if (socketBufferSize != null) {
gatewayReceiverFactory.setSocketBufferSize(socketBufferSize);
}
Boolean manualStart = gatewayReceiverCreateArgs.isManualStart();
if (manualStart != null) {
gatewayReceiverFactory.setManualStart(manualStart);
}
String[] gatewayTransportFilters = gatewayReceiverCreateArgs.getGatewayTransportFilters();
if (gatewayTransportFilters != null) {
for (String gatewayTransportFilter : gatewayTransportFilters) {
Class gatewayTransportFilterKlass = forName(gatewayTransportFilter, CliStrings.CREATE_GATEWAYRECEIVER__GATEWAYTRANSPORTFILTER);
gatewayReceiverFactory.addGatewayTransportFilter((GatewayTransportFilter) newInstance(gatewayTransportFilterKlass, CliStrings.CREATE_GATEWAYRECEIVER__GATEWAYTRANSPORTFILTER));
}
}
return gatewayReceiverFactory.create();
}
use of org.apache.geode.cache.wan.GatewayReceiverFactory in project geode by apache.
the class CacheXmlParser method startGatewayReceiver.
private void startGatewayReceiver(Attributes atts) {
GatewayReceiverFactory receiverFactory = this.cache.createGatewayReceiverFactory();
// port
String startPort = atts.getValue(START_PORT);
if (startPort == null) {
receiverFactory.setStartPort(GatewayReceiver.DEFAULT_START_PORT);
} else {
receiverFactory.setStartPort(Integer.parseInt(startPort));
}
String endPort = atts.getValue(END_PORT);
if (endPort == null) {
receiverFactory.setEndPort(GatewayReceiver.DEFAULT_END_PORT);
} else {
receiverFactory.setEndPort(Integer.parseInt(endPort));
}
String bindAddress = atts.getValue(BIND_ADDRESS);
if (bindAddress == null) {
receiverFactory.setBindAddress(GatewayReceiver.DEFAULT_BIND_ADDRESS);
} else {
receiverFactory.setBindAddress(bindAddress);
}
// maximum-time-between-pings
String maxTimeBetweenPings = atts.getValue(MAXIMUM_TIME_BETWEEN_PINGS);
if (maxTimeBetweenPings == null) {
receiverFactory.setMaximumTimeBetweenPings(GatewayReceiver.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS);
} else {
receiverFactory.setMaximumTimeBetweenPings(Integer.parseInt(maxTimeBetweenPings));
}
// socket-buffer-size
String socketBufferSize = atts.getValue(SOCKET_BUFFER_SIZE);
if (socketBufferSize == null) {
receiverFactory.setSocketBufferSize(GatewayReceiver.DEFAULT_SOCKET_BUFFER_SIZE);
} else {
receiverFactory.setSocketBufferSize(Integer.parseInt(socketBufferSize));
}
// manual-start
String manualStart = atts.getValue(MANUAL_START);
if (manualStart == null) {
receiverFactory.setManualStart(GatewayReceiver.DEFAULT_MANUAL_START);
} else {
receiverFactory.setManualStart(Boolean.parseBoolean(manualStart));
}
// hostname-for-senders
String hostnameForSenders = atts.getValue(HOSTNAME_FOR_SENDERS);
if (hostnameForSenders == null) {
receiverFactory.setHostnameForSenders(GatewayReceiver.DEFAULT_HOSTNAME_FOR_SENDERS);
} else {
receiverFactory.setHostnameForSenders(hostnameForSenders);
}
stack.push(receiverFactory);
}
Aggregations