Search in sources :

Example 1 with GatewayReceiverFactory

use of org.apache.geode.cache.wan.GatewayReceiverFactory in project geode by apache.

the class CacheXml80GatewayDUnitTest method testGatewayReceiverWithManualStartTRUE.

@Test
public void testGatewayReceiverWithManualStartTRUE() throws Exception {
    // getSystem();
    CacheCreation cache = new CacheCreation();
    GatewayReceiverFactory gatewayReceiverFactory = cache.createGatewayReceiverFactory();
    gatewayReceiverFactory.setBindAddress("");
    gatewayReceiverFactory.setStartPort(20000);
    gatewayReceiverFactory.setEndPort(29999);
    gatewayReceiverFactory.setMaximumTimeBetweenPings(2000);
    gatewayReceiverFactory.setSocketBufferSize(1500);
    gatewayReceiverFactory.setManualStart(true);
    GatewayTransportFilter myStreamFilter1 = new MyGatewayTransportFilter1();
    gatewayReceiverFactory.addGatewayTransportFilter(myStreamFilter1);
    GatewayTransportFilter myStreamFilter2 = new MyGatewayTransportFilter2();
    gatewayReceiverFactory.addGatewayTransportFilter(myStreamFilter2);
    GatewayReceiver receiver1 = gatewayReceiverFactory.create();
    receiver1.start();
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    Set<GatewayReceiver> receivers = c.getGatewayReceivers();
    for (GatewayReceiver receiver : receivers) {
        validateGatewayReceiver(receiver1, receiver);
    }
}
Also used : GatewayReceiverFactory(org.apache.geode.cache.wan.GatewayReceiverFactory) GatewayReceiver(org.apache.geode.cache.wan.GatewayReceiver) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) MyGatewayTransportFilter1(org.apache.geode.cache30.MyGatewayTransportFilter1) MyGatewayTransportFilter2(org.apache.geode.cache30.MyGatewayTransportFilter2) Test(org.junit.Test) CacheXml70DUnitTest(org.apache.geode.cache30.CacheXml70DUnitTest) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 2 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 3 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 4 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 5 with GatewayReceiverFactory

use of org.apache.geode.cache.wan.GatewayReceiverFactory in project geode by apache.

the class MyGatewayEventSubstitutionFilter method createReceiver.

public static int createReceiver(int locPort) {
    AsyncEventQueueTestBase test = new AsyncEventQueueTestBase();
    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);
    fact.setManualStart(true);
    GatewayReceiver receiver = fact.create();
    try {
        receiver.start();
    } catch (IOException e) {
        e.printStackTrace();
        fail("Test " + test.getName() + " failed to start GatewayRecevier 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)

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