use of org.apache.geode.cache.wan.GatewayReceiver in project geode by apache.
the class WANTestBase method createReceiverInSecuredCache.
public static int createReceiverInSecuredCache() {
GatewayReceiverFactory fact = WANTestBase.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();
org.apache.geode.test.dunit.Assert.fail("Failed to start GatewayReceiver on port " + port, e);
}
return port;
}
use of org.apache.geode.cache.wan.GatewayReceiver in project geode by apache.
the class ClusterConfigurationDUnitTest method testCreateGatewaySenderReceiver.
@Test
public void testCreateGatewaySenderReceiver() throws Exception {
addIgnoredException("could not get remote locator");
final String gsId = "GatewaySender1";
final String batchSize = "1000";
final String dispatcherThreads = "5";
final String enableConflation = "false";
final String manualStart = "false";
final String alertThreshold = "1000";
final String batchTimeInterval = "20";
final String maxQueueMemory = "100";
final String orderPolicy = GatewaySender.OrderPolicy.KEY.toString();
final String parallel = "true";
final String rmDsId = "250";
final String socketBufferSize = String.valueOf(GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 1000);
final String socketReadTimeout = String.valueOf(GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT + 200);
Object[] result = setup();
final int locatorPort = (Integer) result[0];
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_GATEWAYRECEIVER);
csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART, "true");
csb.addOption(CliStrings.CREATE_GATEWAYRECEIVER__STARTPORT, "10000");
csb.addOption(CliStrings.CREATE_GATEWAYRECEIVER__ENDPORT, "20000");
csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS, "20");
executeAndVerifyCommand(csb.getCommandString());
csb = new CommandStringBuilder(CliStrings.CREATE_GATEWAYSENDER);
csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__ID, gsId);
csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE, batchSize);
csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD, alertThreshold);
csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL, batchTimeInterval);
csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS, dispatcherThreads);
csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION, enableConflation);
csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__MANUALSTART, manualStart);
csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY, maxQueueMemory);
csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY, orderPolicy);
csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__PARALLEL, parallel);
csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID, rmDsId);
csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE, socketBufferSize);
csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT, socketReadTimeout);
executeAndVerifyCommand(csb.getCommandString());
// Start a new member which receives the shared configuration
// Verify the config creation on this member
VM newMember = getHost(0).getVM(2);
final String newMemberWorkingDir = this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + newMember;
newMember.invoke(() -> {
Properties localProps = new Properties();
File workingDir = new File(newMemberWorkingDir);
workingDir.mkdirs();
localProps.setProperty(MCAST_PORT, "0");
localProps.setProperty(LOCATORS, "localhost[" + locatorPort + "]");
localProps.setProperty(NAME, ClusterConfigurationDUnitTest.newMember);
localProps.setProperty(USE_CLUSTER_CONFIGURATION, "true");
localProps.setProperty(DEPLOY_WORKING_DIR, workingDir.getCanonicalPath());
getSystem(localProps);
Cache cache = getCache();
assertNotNull(cache);
// GatewayReceiver verification
Set<GatewayReceiver> gatewayReceivers = cache.getGatewayReceivers();
assertFalse(gatewayReceivers.isEmpty());
assertTrue(gatewayReceivers.size() == 1);
// Gateway Sender verification
GatewaySender gs = cache.getGatewaySender(gsId);
assertNotNull(gs);
assertTrue(alertThreshold.equals(Integer.toString(gs.getAlertThreshold())));
assertTrue(batchSize.equals(Integer.toString(gs.getBatchSize())));
assertTrue(dispatcherThreads.equals(Integer.toString(gs.getDispatcherThreads())));
assertTrue(enableConflation.equals(Boolean.toString(gs.isBatchConflationEnabled())));
assertTrue(manualStart.equals(Boolean.toString(gs.isManualStart())));
assertTrue(alertThreshold.equals(Integer.toString(gs.getAlertThreshold())));
assertTrue(batchTimeInterval.equals(Integer.toString(gs.getBatchTimeInterval())));
assertTrue(maxQueueMemory.equals(Integer.toString(gs.getMaximumQueueMemory())));
assertTrue(orderPolicy.equals(gs.getOrderPolicy().toString()));
assertTrue(parallel.equals(Boolean.toString(gs.isParallel())));
assertTrue(rmDsId.equals(Integer.toString(gs.getRemoteDSId())));
assertTrue(socketBufferSize.equals(Integer.toString(gs.getSocketBufferSize())));
assertTrue(socketReadTimeout.equals(Integer.toString(gs.getSocketReadTimeout())));
});
}
Aggregations