Search in sources :

Example 16 with RegionShortcut

use of org.apache.geode.cache.RegionShortcut in project geode by apache.

the class RollingUpgrade2DUnitTest method doTestPutAndGetMixedServers.

/**
   * This test starts up multiple servers from the current code base and multiple servers from the
   * old version and executes puts and gets on a new server and old server and verifies that the
   * results are present. Note that the puts have overlapping region keys just to test new puts and
   * replaces
   */
public void doTestPutAndGetMixedServers(String objectType, boolean partitioned, String oldVersion) throws Exception {
    final Host host = Host.getHost(0);
    VM currentServer1 = host.getVM(0);
    VM oldServerAndLocator = host.getVM(oldVersion, 1);
    VM currentServer2 = host.getVM(2);
    VM oldServer2 = host.getVM(oldVersion, 3);
    String regionName = "aRegion";
    RegionShortcut shortcut = RegionShortcut.REPLICATE;
    if (partitioned) {
        shortcut = RegionShortcut.PARTITION;
    }
    String serverHostName = NetworkUtils.getServerHostName(Host.getHost(0));
    int port = AvailablePortHelper.getRandomAvailableTCPPort();
    DistributedTestUtils.deleteLocatorStateFile(port);
    try {
        Properties props = getSystemProperties();
        props.remove(DistributionConfig.LOCATORS_NAME);
        invokeRunnableInVMs(invokeStartLocatorAndServer(serverHostName, port, props), oldServerAndLocator);
        props.put(DistributionConfig.LOCATORS_NAME, serverHostName + "[" + port + "]");
        invokeRunnableInVMs(invokeCreateCache(props), oldServer2, currentServer1, currentServer2);
        currentServer1.invoke(invokeAssertVersion(Version.CURRENT_ORDINAL));
        currentServer2.invoke(invokeAssertVersion(Version.CURRENT_ORDINAL));
        // oldServerAndLocator.invoke(invokeAssertVersion(oldOrdinal));
        // oldServer2.invoke(invokeAssertVersion(oldOrdinal));
        // create region
        invokeRunnableInVMs(invokeCreateRegion(regionName, shortcut), currentServer1, currentServer2, oldServerAndLocator, oldServer2);
        putAndVerify(objectType, currentServer1, regionName, 0, 10, currentServer2, oldServerAndLocator, oldServer2);
        putAndVerify(objectType, oldServerAndLocator, regionName, 5, 15, currentServer1, currentServer2, oldServer2);
    } finally {
        invokeRunnableInVMs(true, invokeCloseCache(), currentServer1, currentServer2, oldServerAndLocator, oldServer2);
    }
}
Also used : VM(org.apache.geode.test.dunit.VM) ClientRegionShortcut(org.apache.geode.cache.client.ClientRegionShortcut) RegionShortcut(org.apache.geode.cache.RegionShortcut) Host(org.apache.geode.test.dunit.Host) Properties(java.util.Properties)

Aggregations

RegionShortcut (org.apache.geode.cache.RegionShortcut)16 ClientRegionShortcut (org.apache.geode.cache.client.ClientRegionShortcut)11 Host (org.apache.geode.test.dunit.Host)9 VM (org.apache.geode.test.dunit.VM)9 Properties (java.util.Properties)5 Test (org.junit.Test)3 IOException (java.io.IOException)2 UnknownHostException (java.net.UnknownHostException)2 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)2 Compressor (org.apache.geode.compression.Compressor)2 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)2 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 Callable (java.util.concurrent.Callable)1 CacheFactory (org.apache.geode.cache.CacheFactory)1 CacheListener (org.apache.geode.cache.CacheListener)1 CacheLoader (org.apache.geode.cache.CacheLoader)1 CacheWriter (org.apache.geode.cache.CacheWriter)1 DataPolicy (org.apache.geode.cache.DataPolicy)1