Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 179681

Error while reading the data from gemfire

$
0
0

Hi,

 

I have a web application in which I fetch data by reading a serialize file and put that into Gemfire, and then through junit I test the same but

I am getting below given error while reading data from Gemfire (Please see the attached file error.txt)

  java.lang.IllegalStateException: A connection to a distributed system already exists in this VM. It has the following configuration:

 

The Steps taken are:

1. gemfire.properties is in current working directory and contains only below entries:

 

log-level=warning

mcast-port=0

start-locator=localhost[55221]

 

2. I created a LoadGemfire.xml file as

<cache>

<cache-serverport="40404"maximum-time-between-pings="20000"/>

<regionname="gemfireRegion">

<region-attributesrefid="REPLICATE">

<cache-loader>

<class-name>com.xav.dishlayer.epcdal.dataload.SimpleCacheLoader</class-name>

</cache-loader>

</region-attributes>

</region>

<cache>

 

3. Created the cache in a LoadData file and put the data into Region as given below

 

private static void loadGemfireData() {

try {
  com.gemstone.gemfire.cache.Cache cache = new CacheFactory()
   .set("name", "LoadGemfire")
   .set("cache-xml-file", "/conf/com/dishnetwork/dishlayer/epcdal/LoadGemfire.xml")
   .create();

   // Get the exampleRegion
   Region<String, Map<String, Object>> exampleRegion = cache.getRegion(EXAMPLE_REGION_NAME);

   for (Map.Entry<String, Map<String, Object>> obj : templateEpcObjectMap.entrySet()) {
    exampleRegion.putIfAbsent(obj.getKey(), obj.getValue());
    Map<String, Object> template = templateEpcObjectMap.get(obj.getKey());
    //Cache cache = DataCache.getCacheManager().getCache(obj.getKey());
    long startTemplateTime = System.nanoTime();
    Map<String, Object> childMap = new HashMap<String, Object>();
     for (Map.Entry<String, Object> entryKey : template.entrySet()) {
      childMap.put(entryKey.getKey(), entryKey.getValue());
     }
     long endTemplateTime = System.nanoTime();   
    System.out.println("Time taken for Gemfire"+obj.getKey()+"is:"+(endTemplateTime-startTemplateTime));
   }

   MultiGetFunction function = new MultiGetFunction();
   FunctionService.registerFunction(function);

  } catch (VirtualMachineError err) {
   System.out.println("Inside virtualMachineError");
     SystemFailure.initiateFailure(err);

  }
}

 

4. Then We created an xml for client as given below

<!--

  | LoadGemfireClient.xml

  |

-->

<cache>

<pool name="client" subscription-enabled="true">

    <server host="localhost" port="40404"/>

  </pool>

  <region name="gemfireRegion" refid="REPLICATE_PROXY" />

</cache>

 

5. Then we created a client file to fetch records and display it in the console as given below:

com.gemstone.gemfire.cache.Cache cache = new CacheFactory()

.set("name", "LoadGemfireClient")

.set("cache-xml-file", "/conf/com/xav/my/epcdal/LoadGemfireClient.xml")

.create();

  

// Get the exampleRegion

//Region<String, String> exampleRegion = cache.getRegion(EXAMPLE_REGION_NAME);

    Region<String, Map<String, Object>> exampleRegion = cache.getRegion(EXAMPLE_REGION_NAME);

  if(!exampleRegion.isEmpty()){

   //Code to Fetch records from example region and print on console

  }

Both the classes are run using a junit test case (single test case) and also while I try to fetch these records and display on to the jsp page, it gives same above mentioned error.

 

Is there any thing missing or am I doing anything wrong, Please suggest, it is very urgent.

 

Thanks,

 

Ahmar


Viewing all articles
Browse latest Browse all 179681

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>