Hi,
I am trying to get up and running function related sample. Usually it works. But I need to ensure, function always executed strictly in the server. Hence I have two different JVM
1) Server VM
<cache>
<cache-server port="40404" />
<region name="exampleRegion">
<region-attributes refid="REPLICATE">
</region-attributes>
</region>
<function-service>
<function>
<class-name>testcache.TopTenListFunction</class-name>
</function>
</function-service>
</cache>
2) System.out.println("Functions...\n" + Arrays.deepToString(FunctionService.getRegisteredFunctions().keySet().toArray())); - This line in server process confirms that there is function registered in the server with id "testcache.TopTenListFunction"
3) Trying to execute using client cache JVM
<client-cache>
<pool name="client" subscription-enabled="true">
<server host="localhost" port="40404" />
</pool>
<region name="exampleRegion">
<region-attributes refid="PROXY">
</region-attributes>
</region>
</client-cache>
4) Invoking function using..
ClientCache clientCache = new ClientCacheFactory()
.set("name", "ClientWorker")
.set("cache-xml-file", "xml2/FunctionClient.xml").create();
Execution execution = FunctionService.onServer(clientCache)
.withArgs(Boolean.TRUE)
.withCollector(new MyArrayListResultCollector());
ResultCollector rc = execution.execute("nikias.testcache.TopTenListFunction");
But what I get is exception like below..
Exception in thread "main" com.gemstone.gemfire.cache.client.ServerOperationException: The function is not registered for function id testcache.TopTenListFunction
at com.gemstone.gemfire.cache.client.internal.AbstractOp.processObjResponse(AbstractOp.java:281)
at com.gemstone.gemfire.cache.client.internal.GetFunctionAttributeOp$GetFunctionAttributeOpImpl.processResponse(GetFunctionAttributeOp.java:38)
at com.gemstone.gemfire.cache.client.internal.AbstractOp.attemptReadResponse(AbstractOp.java:160)
at com.gemstone.gemfire.cache.client.internal.AbstractOp.attempt(AbstractOp.java:361)
at com.gemstone.gemfire.cache.client.internal.ConnectionImpl.execute(ConnectionImpl.java:233)
at com.gemstone.gemfire.cache.client.internal.pooling.PooledConnection.execute(PooledConnection.java:323)
at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.executeWithPossibleReAuthentication(OpExecutorImpl.java:894)
at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:145)
at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:106)
at com.gemstone.gemfire.cache.client.internal.PoolImpl.execute(PoolImpl.java:623)
at com.gemstone.gemfire.cache.client.internal.GetFunctionAttributeOp.execute(GetFunctionAttributeOp.java:19)
at com.gemstone.gemfire.internal.cache.execute.ServerFunctionExecutor.execute(ServerFunctionExecutor.java:314)
at nikias.testcache.FunctionClient.main(FunctionClient.java:88)
Q1) Is the below line is causing issue? I am passing clientCache instead of server reference? if so, How to pass the reference of the server?
Execution execution = FunctionService.onServer(clientCache)
.withArgs(Boolean.TRUE)
.withCollector(new MyArrayListResultCollector());
ResultCollector rc = execution.execute("testcache.TopTenListFunction");
Q2) if server refid="REPLICATE", what could be my client-cache refid, so I could ensure, function executed on the server?
Q3) How to ensure function executed by CacheServer? i.e, Ensure executed by other than the JVM which invokes the function?
Please note I have one eclipse project on windows, so I can't reduce visibility in the classpath scope
Regards