use of org.apache.geode.internal.cache.LocalRegion in project geode by apache.
the class TestDiskRegion method main1.
public static void main1(String[] args) throws Exception {
DistributedSystem system = DistributedSystem.connect(new java.util.Properties());
Cache cache = CacheFactory.create(system);
AttributesFactory factory = new AttributesFactory();
factory.setEvictionAttributes(EvictionAttributes.createLRUMemoryAttributes(2, (ObjectSizer) null, EvictionAction.OVERFLOW_TO_DISK));
factory.setCacheListener(new CacheListenerAdapter() {
public void afterUpdate(EntryEvent event) {
System.out.println("UPDATE: " + event.getKey() + " -> (" + event.getOldValue() + " -> " + event.getNewValue() + ")");
}
});
LocalRegion region = (LocalRegion) cache.createRegion("TestDiskRegion", factory.create());
DiskRegion dr = region.getDiskRegion();
DiskRegionStats diskStats = dr.getStats();
LRUStatistics lruStats = getLRUStats(region);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Hit enter to perform action");
for (int i = 0; true; i++) {
br.readLine();
// Thread.sleep(500);
Object key = new Integer(i);
Object value = new byte[200000];
region.put(key, value);
System.out.println(key + " -> " + value + " evictions = " + lruStats.getEvictions() + ", writes = " + diskStats.getWrites());
}
}
use of org.apache.geode.internal.cache.LocalRegion in project geode by apache.
the class PRClientServerRegionFunctionExecutionFailoverDUnitTest method testOnRegionFailoverNonHASingleHop.
/*
* Ensure that the while executing the function if the servers are down then the execution
* shouldn't failover to other available server
*/
@Test
public void testOnRegionFailoverNonHASingleHop() throws InterruptedException {
// See #47489
// before enabling
// it
ArrayList commonAttributes = createCommonServerAttributes("TestPartitionedRegion", null, 0, 13, null);
createClientServerScenarioSingleHop(commonAttributes, 20, 20, 20);
server1.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.createReplicatedRegion());
server2.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.createReplicatedRegion());
server3.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.createReplicatedRegion());
client.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.createProxyRegion(NetworkUtils.getServerHostName(server1.getHost())));
// Make sure the buckets are created.
client.invoke(new SerializableRunnable() {
@Override
public void run() {
region = (LocalRegion) cache.getRegion(PRClientServerTestBase.PartitionedRegionName);
for (int i = 0; i < 13; i++) {
region.put(i, i);
}
}
});
// Make sure the client metadata is up to date.
client.invoke(() -> PRClientServerRegionFunctionExecutionFailoverDUnitTest.fetchMetaData());
Function function = new TestFunction(true, TestFunction.TEST_FUNCTION_NONHA_REGION);
registerFunctionAtServer(function);
final Function function2 = new TestFunction(true, TestFunction.TEST_FUNCTION_NONHA_NOP);
registerFunctionAtServer(function);
client.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.regionSingleKeyExecutionNonHA(Boolean.FALSE, function, Boolean.FALSE));
// This validation doesn't work because the client may
// still be asynchronously recording the departure of the
// failed server
// System.err.println("Trying the second function");
// //Make sure the client can now execute a function
// //on the server
// client.invoke(new SerializableRunnable() {
// @Override
// public void run() {
// ResultCollector rs = FunctionService.onRegion(region).execute(function2);
// rs.getResult();
// }
// });
client.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.verifyMetaData(new Integer(1), new Integer(0)));
}
use of org.apache.geode.internal.cache.LocalRegion in project geode by apache.
the class HAClearDUnitTest method destroyRegionFromServer.
// function to perform destroyRegion operation from server.
private CacheSerializableRunnable destroyRegionFromServer() {
CacheSerializableRunnable clearFromServer = new CacheSerializableRunnable("destroyRegionFromServer") {
public void run2() {
LocalRegion region = (LocalRegion) cache.getRegion(Region.SEPARATOR + REGION_NAME);
assertNotNull(region);
region.destroyRegion();
}
};
return clearFromServer;
}
use of org.apache.geode.internal.cache.LocalRegion in project geode by apache.
the class HAClearDUnitTest method destroyRegion.
// function to perform destroyRegion operation from client.
private void destroyRegion() {
LocalRegion region = (LocalRegion) cache.getRegion(Region.SEPARATOR + REGION_NAME);
assertNotNull(region);
region.destroyRegion();
}
use of org.apache.geode.internal.cache.LocalRegion in project geode by apache.
the class HAClearDUnitTest method clearRegion.
// function to perform clear operation from client.
private void clearRegion() {
LocalRegion region = (LocalRegion) cache.getRegion(Region.SEPARATOR + REGION_NAME);
assertNotNull(region);
region.clear();
}
Aggregations