Search in sources :

Example 6 with GatewayReceiverFactory

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;
}
Also used : GatewayReceiverFactory(org.apache.geode.cache.wan.GatewayReceiverFactory) GatewayReceiver(org.apache.geode.cache.wan.GatewayReceiver) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) IOException(java.io.IOException) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties)

Example 7 with GatewayReceiverFactory

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);
    }
}
Also used : GatewayReceiverFactory(org.apache.geode.cache.wan.GatewayReceiverFactory) GatewayReceiver(org.apache.geode.cache.wan.GatewayReceiver) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) IOException(java.io.IOException) Properties(java.util.Properties)

Example 8 with GatewayReceiverFactory

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;
}
Also used : GatewayReceiverFactory(org.apache.geode.cache.wan.GatewayReceiverFactory) GatewayReceiver(org.apache.geode.cache.wan.GatewayReceiver) IOException(java.io.IOException)

Example 9 with GatewayReceiverFactory

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();
}
Also used : GatewayReceiverFactory(org.apache.geode.cache.wan.GatewayReceiverFactory)

Example 10 with GatewayReceiverFactory

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);
}
Also used : GatewayReceiverFactory(org.apache.geode.cache.wan.GatewayReceiverFactory)

Aggregations

GatewayReceiverFactory (org.apache.geode.cache.wan.GatewayReceiverFactory)18 GatewayReceiver (org.apache.geode.cache.wan.GatewayReceiver)14 IOException (java.io.IOException)10 Properties (java.util.Properties)8 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)8 GatewayTransportFilter (org.apache.geode.cache.wan.GatewayTransportFilter)5 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)4 Test (org.junit.Test)3 GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)2 CacheXml70DUnitTest (org.apache.geode.cache30.CacheXml70DUnitTest)2 MyGatewayTransportFilter1 (org.apache.geode.cache30.MyGatewayTransportFilter1)2 MyGatewayTransportFilter2 (org.apache.geode.cache30.MyGatewayTransportFilter2)2 WANTestBase (org.apache.geode.internal.cache.wan.WANTestBase)2 CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)2 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 AttributesFactory (org.apache.geode.cache.AttributesFactory)1 CacheXmlException (org.apache.geode.cache.CacheXmlException)1 Declarable (org.apache.geode.cache.Declarable)1