use of org.apache.geode.management.internal.AgentUtil in project geode by apache.
the class QueryResultData method setUp.
@Before
public void setUp() throws Exception {
AgentUtil agentUtil = new AgentUtil(GemFireVersion.getGemFireVersion());
if (agentUtil.findWarLocation("geode-web-api") == null) {
fail("unable to locate geode-web-api WAR file");
}
this.restServicePort = AvailablePortHelper.getRandomAvailableTCPPort();
try {
InetAddress addr = SocketCreator.getLocalHost();
this.hostName = addr.getHostName();
} catch (UnknownHostException ex) {
this.hostName = ManagementConstants.DEFAULT_HOST_NAME;
}
String workingDirectory = System.getProperty("geode.build.dir", System.getProperty("user.dir"));
ServerLauncher serverLauncher = new ServerLauncher.Builder().set(MCAST_PORT, "0").setServerBindAddress(this.hostName).setServerPort(0).set(START_DEV_REST_API, "true").set(HTTP_SERVICE_PORT, String.valueOf(this.restServicePort)).set(HTTP_SERVICE_BIND_ADDRESS, this.hostName).setPdxReadSerialized(true).setWorkingDirectory(workingDirectory).build();
serverLauncher.start();
this.baseURL = "http://" + this.hostName + ":" + this.restServicePort;
this.c = CacheFactory.getAnyInstance();
final AttributesFactory<String, String> attributesFactory = new AttributesFactory<>();
attributesFactory.setDataPolicy(DataPolicy.REPLICATE);
// Create region, customers
final RegionAttributes<String, String> regionAttributes = attributesFactory.create();
c.createRegion(CUSTOMER_REGION, regionAttributes);
// Create region, items
attributesFactory.setDataPolicy(DataPolicy.PARTITION);
c.createRegion(ITEM_REGION, regionAttributes);
// Create region, /orders
final AttributesFactory<Object, Object> af2 = new AttributesFactory<>();
af2.setDataPolicy(DataPolicy.PARTITION);
final RegionAttributes<Object, Object> rAttributes2 = af2.create();
c.createRegion(ORDER_REGION, rAttributes2);
// Create region, primitiveKVStore
final AttributesFactory<Object, Object> af1 = new AttributesFactory<>();
af1.setDataPolicy(DataPolicy.PARTITION);
final RegionAttributes<Object, Object> rAttributes = af1.create();
c.createRegion(PRIMITIVE_KV_STORE_REGION, rAttributes);
RegionFactory<String, Object> rf = c.createRegionFactory(RegionShortcut.REPLICATE);
rf.setDataPolicy(DataPolicy.EMPTY);
rf.setCacheLoader(new SimpleCacheLoader());
rf.setCacheWriter(new SampleCacheWriter());
rf.create(EMPTY_REGION);
// Register functions here
FunctionService.registerFunction(new GetAllEntries());
FunctionService.registerFunction(new GetRegions());
FunctionService.registerFunction(new PutKeyFunction());
FunctionService.registerFunction(new GetDeliveredOrders());
FunctionService.registerFunction(new AddFreeItemToOrders());
FunctionService.registerFunction(new NoArgumentFunction());
}
use of org.apache.geode.management.internal.AgentUtil in project geode by apache.
the class RestInterfaceJUnitTest method setupGemFire.
@Before
public void setupGemFire() {
AgentUtil agentUtil = new AgentUtil(GemFireVersion.getGemFireVersion());
if (agentUtil.findWarLocation("geode-web-api") == null) {
fail("unable to locate geode-web-api WAR file");
}
if (gemfireCache == null) {
gemfireProperties = (gemfireProperties != null ? gemfireProperties : new Properties());
gemfireCache = new CacheFactory().setPdxSerializer(new ReflectionBasedAutoSerializer(Person.class.getName().replaceAll("\\$", "."))).setPdxReadSerialized(true).setPdxIgnoreUnreadFields(false).set("name", getClass().getSimpleName()).set(MCAST_PORT, "0").set(LOG_LEVEL, "config").set(HTTP_SERVICE_BIND_ADDRESS, "localhost").set(HTTP_SERVICE_PORT, String.valueOf(getHttpServicePort())).set(START_DEV_REST_API, "true").create();
RegionFactory<String, Object> peopleRegionFactory = gemfireCache.createRegionFactory();
peopleRegionFactory.setDataPolicy(DataPolicy.PARTITION);
peopleRegionFactory.setKeyConstraint(String.class);
peopleRegionFactory.setValueConstraint(Object.class);
people = peopleRegionFactory.create("People");
}
}
use of org.apache.geode.management.internal.AgentUtil in project geode by apache.
the class RestAPITestBase method postSetUp.
@Override
public final void postSetUp() throws Exception {
disconnectAllFromDS();
AgentUtil agentUtil = new AgentUtil(GemFireVersion.getGemFireVersion());
if (agentUtil.findWarLocation("geode-web-api") == null) {
fail("unable to locate geode-web-api WAR file");
}
final Host host = Host.getHost(0);
vm0 = host.getVM(0);
vm1 = host.getVM(1);
vm2 = host.getVM(2);
vm3 = host.getVM(3);
// gradle sets a property telling us where the build is located
final String buildDir = System.getProperty("geode.build.dir", System.getProperty("user.dir"));
Invoke.invokeInEveryVM(() -> System.setProperty("geode.build.dir", buildDir));
postSetUpRestAPITestBase();
}
Aggregations