use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class SnapshotByteArrayDUnitTest method loadCache.
public void loadCache() throws Exception {
SerializableCallable setup = new SerializableCallable() {
@Override
public Object call() throws Exception {
CacheFactory cf = new CacheFactory().setPdxSerializer(new MyPdxSerializer()).setPdxPersistent(true);
Cache cache = getCache(cf);
RegionGenerator rgen = new RegionGenerator();
rgen.createRegion(cache, null, RegionType.REPLICATE, "snapshot-ops");
return null;
}
};
SnapshotDUnitTest.forEachVm(setup, true);
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class QueryParamsAuthorizationDUnitTest method testQueryParamsInAuthCallback.
@Ignore("Bug 51079")
@Test
public void testQueryParamsInAuthCallback() throws Exception {
final Host host = Host.getHost(0);
final VM server1 = host.getVM(0);
final VM client = host.getVM(1);
// create servers and regions
final int port = (Integer) server1.invoke(new SerializableCallable("Create Server1") {
@Override
public Object call() throws Exception {
CacheFactory cf = new CacheFactory().set(MCAST_PORT, "0").set(SECURITY_CLIENT_ACCESSOR, "org.apache.geode.cache.query.dunit.QueryAuthorization.create").set(SECURITY_CLIENT_AUTHENTICATOR, DummyAuthenticator.class.getName() + ".create");
Cache cache = getCache(cf);
cache.createRegionFactory(RegionShortcut.REPLICATE).create(regName);
CacheServer server = cache.addCacheServer();
int port = AvailablePortHelper.getRandomAvailablePortForDUnitSite();
server.setPort(port);
server.start();
return port;
}
});
// create client
client.invoke(new SerializableCallable("Create client") {
@Override
public Object call() throws Exception {
ClientCacheFactory ccf = new ClientCacheFactory().addPoolServer(NetworkUtils.getServerHostName(server1.getHost()), port).set(SECURITY_CLIENT_AUTH_INIT, UserPasswordAuthInit.class.getName() + ".create").set(SECURITY_PREFIX + "username", "root").set(SECURITY_PREFIX + "password", "root");
ClientCache cache = getClientCache(ccf);
Region r1 = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create(regName);
for (int i = 0; i < 20; i++) {
r1.put("key-" + i, new Portfolio(i));
}
QueryService qs = cache.getQueryService();
Object[] params = new Object[] { "active", 0 };
SelectResults sr = (SelectResults) qs.newQuery("select * from " + r1.getFullPath() + " where status = $1 and ID > $2 ").execute(params);
assertTrue("Result size should be greater than 0 ", sr.size() > 0);
return null;
}
});
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class SnapshotPerformanceDUnitTest method createCache.
private void createCache() throws Exception {
SerializableCallable setup = new SerializableCallable() {
@Override
public Object call() throws Exception {
CacheFactory cf = new CacheFactory().setPdxSerializer(new MyPdxSerializer());
getCache(cf);
return null;
}
};
SnapshotDUnitTest.forEachVm(setup, true);
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class SnapshotTestCase method setUp.
@Before
public void setUp() throws Exception {
store = new File("store-" + Math.abs(new Random().nextInt()));
store.mkdir();
snaps = new File("snapshots-" + Math.abs(new Random().nextInt()));
snaps.mkdir();
rgen = new RegionGenerator();
CacheFactory cf = new CacheFactory().set(MCAST_PORT, "0").set(LOG_LEVEL, "error");
cache = cf.create();
ds = cache.createDiskStoreFactory().setMaxOplogSize(1).setDiskDirs(new File[] { store }).create("snapshotTest");
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class WANBootStrapping_Site1_Add method main.
public static void main(String[] args) {
System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "DistributedSystemListener", "com.main.MyDistributedSystemListener");
// Create a locator and a cache
System.out.println("Creating cache ...It will take some time..");
Cache cache = new CacheFactory().set(MCAST_PORT, "0").set(DISTRIBUTED_SYSTEM_ID, "" + 1).set(LOCATORS, "localhost[" + 10101 + "]").set(START_LOCATOR, "localhost[" + 10101 + "],server=true,peer=true,hostname-for-clients=localhost").set(LOG_LEVEL, "warning").create();
System.out.println("Cache Created");
// to create region and a gateway sender ask to run
// WANBootStrapping_Site2_Add program
System.out.println("Run WANBootStrapping_Site2_Add");
// get the region
Region region = cache.getRegion("MyRegion");
while (region == null) {
region = cache.getRegion("MyRegion");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
// put data in region
for (int i = 0; i < 100; i++) {
System.out.println("Create Entry : key_" + i + ", value_" + i);
region.put("key_" + i, "value_" + i);
}
System.out.println("Entry Create Operation completed");
Set<GatewaySender> gatewaySenders = cache.getGatewaySenders();
GatewaySender sender = gatewaySenders.iterator().next();
// make sure that gateway sender is running
if (sender.isRunning()) {
System.out.println("Sender " + sender.getId() + " is running");
}
// to stop gateway sender ask to run WANBootStrapping_Site2_Remove program
while (sender.isRunning()) {
System.out.println("Waitng for sender to stop through DistributedSystemListener");
System.out.println("Start WANBootStrapping_Site2_Remove");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.println("Sender " + sender.getId() + " is stopped");
System.exit(0);
}
Aggregations