use of org.apache.geode.cache.RegionShortcut in project geode by apache.
the class LuceneIndexForPartitionedRegion method createLuceneListenersAndFileChunkRegions.
protected void createLuceneListenersAndFileChunkRegions(AbstractPartitionedRepositoryManager partitionedRepositoryManager) {
partitionedRepositoryManager.setUserRegionForRepositoryManager();
RegionShortcut regionShortCut;
final boolean withPersistence = withPersistence();
RegionAttributes regionAttributes = dataRegion.getAttributes();
final boolean withStorage = regionAttributes.getPartitionAttributes().getLocalMaxMemory() > 0;
// 4) Offheap to Offheap
if (!withStorage) {
regionShortCut = RegionShortcut.PARTITION_PROXY;
} else if (withPersistence) {
// TODO: add PartitionedRegionAttributes instead
regionShortCut = RegionShortcut.PARTITION_PERSISTENT;
} else {
regionShortCut = RegionShortcut.PARTITION;
}
// create PR fileAndChunkRegion, but not to create its buckets for now
final String fileRegionName = createFileRegionName();
PartitionAttributes partitionAttributes = dataRegion.getPartitionAttributes();
DM dm = this.cache.getInternalDistributedSystem().getDistributionManager();
LuceneBucketListener lucenePrimaryBucketListener = new LuceneBucketListener(partitionedRepositoryManager, dm);
if (!fileRegionExists(fileRegionName)) {
fileAndChunkRegion = createFileRegion(regionShortCut, fileRegionName, partitionAttributes, regionAttributes, lucenePrimaryBucketListener);
}
fileSystemStats.setBytesSupplier(() -> getFileAndChunkRegion().getPrStats().getDataStoreBytesInUse());
}
use of org.apache.geode.cache.RegionShortcut in project geode by apache.
the class Bug43684DUnitTest method createServerCache.
@SuppressWarnings("rawtypes")
public static Integer createServerCache(Boolean isReplicated, Boolean isPrimaryEmpty) throws Exception {
disconnectFromDS();
Properties props = new Properties();
props.setProperty(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
props.setProperty(STATISTIC_ARCHIVE_FILE, "server_" + OSProcess.getId() + ".gfs");
props.setProperty(STATISTIC_SAMPLING_ENABLED, "true");
CacheFactory cf = new CacheFactory(props);
cache = (GemFireCacheImpl) cf.create();
RegionFactory rf;
if (isReplicated) {
RegionShortcut rs = isPrimaryEmpty ? RegionShortcut.REPLICATE_PROXY : RegionShortcut.REPLICATE;
rf = cache.createRegionFactory(rs);
} else {
RegionShortcut rs = isPrimaryEmpty ? RegionShortcut.PARTITION_PROXY : RegionShortcut.PARTITION;
rf = cache.createRegionFactory(rs);
rf.setPartitionAttributes(new PartitionAttributesFactory().setTotalNumBuckets(numBuckets).create());
}
rf.create(REGION_NAME);
CacheServerImpl server = (CacheServerImpl) cache.addCacheServer();
server.setPort(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
server.start();
return server.getPort();
}
use of org.apache.geode.cache.RegionShortcut in project geode by apache.
the class RollingUpgrade2DUnitTest method doTestRollSingleLocatorWithMultipleServers.
// 1 locator, 3 servers
public void doTestRollSingleLocatorWithMultipleServers(boolean partitioned, String oldVersion) throws Exception {
final Host host = Host.getHost(0);
VM server1 = host.getVM(oldVersion, 0);
VM server2 = host.getVM(oldVersion, 1);
VM server3 = host.getVM(oldVersion, 2);
VM server4 = host.getVM(oldVersion, 3);
final String objectType = "strings";
final String regionName = "aRegion";
RegionShortcut shortcut = RegionShortcut.REPLICATE;
if (partitioned) {
shortcut = RegionShortcut.PARTITION_REDUNDANT;
}
int[] locatorPorts = AvailablePortHelper.getRandomAvailableTCPPorts(1);
DistributedTestUtils.deleteLocatorStateFile(locatorPorts[0]);
// configure all class loaders for each vm
String hostName = NetworkUtils.getServerHostName(host);
String locatorString = getLocatorString(locatorPorts);
try {
server1.invoke(invokeStartLocator(hostName, locatorPorts[0], getTestMethodName(), getLocatorPropertiesPre91(locatorString)));
invokeRunnableInVMs(invokeCreateCache(getSystemProperties(locatorPorts)), server2, server3, server4);
// invokeRunnableInVMs(invokeAssertVersion(oldOrdinal), server2, server3, server4);
invokeRunnableInVMs(invokeCreateRegion(regionName, shortcut), server2, server3, server4);
putAndVerify(objectType, server2, regionName, 0, 10, server3, server4);
server1 = rollLocatorToCurrent(server1, hostName, locatorPorts[0], getTestMethodName(), locatorString);
server2 = rollServerToCurrentAndCreateRegion(server2, shortcut, regionName, locatorPorts);
putAndVerify(objectType, server2, regionName, 5, 15, server3, server4);
putAndVerify(objectType, server3, regionName, 10, 20, server2, server4);
server3 = rollServerToCurrentAndCreateRegion(server3, shortcut, regionName, locatorPorts);
putAndVerify(objectType, server2, regionName, 15, 25, server3, server4);
putAndVerify(objectType, server3, regionName, 20, 30, server2, server4);
server4 = rollServerToCurrentAndCreateRegion(server4, shortcut, regionName, locatorPorts);
putAndVerify(objectType, server4, regionName, 25, 35, server3, server2);
putAndVerify(objectType, server3, regionName, 30, 40, server2, server4);
} finally {
invokeRunnableInVMs(true, invokeStopLocator(), server1);
invokeRunnableInVMs(true, invokeCloseCache(), server2, server3, server4);
}
}
use of org.apache.geode.cache.RegionShortcut in project geode by apache.
the class RollingUpgrade2DUnitTest method doTestCreateIndexes.
public void doTestCreateIndexes(boolean createMultiIndexes, boolean partitioned, String oldVersion) throws Exception {
final Host host = Host.getHost(0);
final VM currentServer1 = host.getVM(0);
final VM oldServer = host.getVM(oldVersion, 1);
final VM currentServer2 = host.getVM(2);
final VM oldServerAndLocator = host.getVM(oldVersion, 3);
String regionName = "cqs";
RegionShortcut shortcut = RegionShortcut.REPLICATE;
if (partitioned) {
shortcut = RegionShortcut.PARTITION;
}
String serverHostName = NetworkUtils.getServerHostName(Host.getHost(0));
int port = AvailablePortHelper.getRandomAvailableTCPPort();
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), currentServer1, currentServer2, oldServer);
currentServer1.invoke(invokeAssertVersion(Version.CURRENT_ORDINAL));
currentServer2.invoke(invokeAssertVersion(Version.CURRENT_ORDINAL));
// oldServer.invoke(invokeAssertVersion(oldOrdinal));
// oldServerAndLocator.invoke(invokeAssertVersion(oldOrdinal));
// create region
invokeRunnableInVMs(invokeCreateRegion(regionName, shortcut), currentServer1, currentServer2, oldServer, oldServerAndLocator);
putDataSerializableAndVerify(currentServer1, regionName, 0, 100, currentServer2, oldServer, oldServerAndLocator);
if (createMultiIndexes) {
doCreateIndexes("/" + regionName, currentServer1);
} else {
doCreateIndex("/" + regionName, oldServer);
}
} finally {
invokeRunnableInVMs(invokeCloseCache(), currentServer1, currentServer2, oldServer, oldServerAndLocator);
}
}
use of org.apache.geode.cache.RegionShortcut in project geode by apache.
the class RollingUpgrade2DUnitTest method doTestClients.
public void doTestClients(boolean partitioned, String oldVersion) throws Exception {
final Host host = Host.getHost(0);
VM locator = host.getVM(oldVersion, 0);
VM server2 = host.getVM(oldVersion, 1);
VM server3 = host.getVM(oldVersion, 2);
VM client = host.getVM(oldVersion, 3);
final String objectType = "strings";
final String regionName = "aRegion";
RegionShortcut shortcut = RegionShortcut.REPLICATE;
if (partitioned) {
shortcut = RegionShortcut.PARTITION_REDUNDANT;
}
int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(3);
int[] locatorPorts = new int[] { ports[0] };
int[] csPorts = new int[] { ports[1], ports[2] };
DistributedTestUtils.deleteLocatorStateFile(locatorPorts);
String hostName = NetworkUtils.getServerHostName(host);
String[] hostNames = new String[] { hostName };
String locatorString = getLocatorString(locatorPorts);
try {
locator.invoke(invokeStartLocator(hostName, locatorPorts[0], getTestMethodName(), getLocatorPropertiesPre91(locatorString)));
invokeRunnableInVMs(invokeCreateCache(getSystemProperties(locatorPorts)), server2, server3);
invokeRunnableInVMs(invokeStartCacheServer(csPorts[0]), server2);
invokeRunnableInVMs(invokeStartCacheServer(csPorts[1]), server3);
invokeRunnableInVMs(invokeCreateClientCache(getClientSystemProperties(), hostNames, locatorPorts), client);
// invokeRunnableInVMs(invokeAssertVersion(oldOrdinal), server2, server3, client);
invokeRunnableInVMs(invokeCreateRegion(regionName, shortcut), server2, server3);
invokeRunnableInVMs(invokeCreateClientRegion(regionName, ClientRegionShortcut.PROXY), client);
putAndVerify(objectType, client, regionName, 0, 10, server3, client);
putAndVerify(objectType, server3, regionName, 100, 110, server3, client);
locator = rollLocatorToCurrent(locator, hostName, locatorPorts[0], getTestMethodName(), locatorString);
server3 = rollServerToCurrentAndCreateRegion(server3, shortcut, regionName, locatorPorts);
invokeRunnableInVMs(invokeStartCacheServer(csPorts[1]), server3);
putAndVerify(objectType, client, regionName, 15, 25, server3, client);
putAndVerify(objectType, server3, regionName, 20, 30, server3, client);
server2 = rollServerToCurrentAndCreateRegion(server2, shortcut, regionName, locatorPorts);
invokeRunnableInVMs(invokeStartCacheServer(csPorts[0]), server2);
putAndVerify(objectType, client, regionName, 25, 35, server2, client);
putAndVerify(objectType, server2, regionName, 30, 40, server3, client);
client = rollClientToCurrentAndCreateRegion(client, ClientRegionShortcut.PROXY, regionName, hostNames, locatorPorts);
putAndVerify(objectType, client, regionName, 35, 45, server2, server3);
putAndVerify(objectType, server2, regionName, 40, 50, server3, client);
} finally {
invokeRunnableInVMs(true, invokeStopLocator(), locator);
invokeRunnableInVMs(true, invokeCloseCache(), server2, server3, client);
}
}
Aggregations