Search in sources :

Example 1 with AgentUtil

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());
}
Also used : UnknownHostException(java.net.UnknownHostException) AgentUtil(org.apache.geode.management.internal.AgentUtil) ServerLauncher(org.apache.geode.distributed.ServerLauncher) AttributesFactory(org.apache.geode.cache.AttributesFactory) JSONObject(org.json.JSONObject) InetAddress(java.net.InetAddress) Before(org.junit.Before)

Example 2 with AgentUtil

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");
    }
}
Also used : ReflectionBasedAutoSerializer(org.apache.geode.pdx.ReflectionBasedAutoSerializer) AgentUtil(org.apache.geode.management.internal.AgentUtil) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) CacheFactory(org.apache.geode.cache.CacheFactory) Before(org.junit.Before)

Example 3 with AgentUtil

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();
}
Also used : AgentUtil(org.apache.geode.management.internal.AgentUtil) Host(org.apache.geode.test.dunit.Host)

Aggregations

AgentUtil (org.apache.geode.management.internal.AgentUtil)3 Before (org.junit.Before)2 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 Properties (java.util.Properties)1 AttributesFactory (org.apache.geode.cache.AttributesFactory)1 CacheFactory (org.apache.geode.cache.CacheFactory)1 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)1 ServerLauncher (org.apache.geode.distributed.ServerLauncher)1 ReflectionBasedAutoSerializer (org.apache.geode.pdx.ReflectionBasedAutoSerializer)1 Host (org.apache.geode.test.dunit.Host)1 JSONObject (org.json.JSONObject)1