Re: QuerySqlFunction
That's correct. Custom SQL functions must be explicitly deployed on all nodes and can't be deployed dynamically. -Val -- Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: QuerySqlFunction
Hi, AFAIK, PeerClassLoading works only with Ignite compute subsystem. For SQL functions you need to deploy them in cluster before use. On Thu, Feb 15, 2018 at 4:29 AM, Williams, Michael < michael.willi...@transamerica.com> wrote: > What changes do I need to do to make ZeroDeploy work with QuerySqlFunction > definitions? I’m following the example and adding the class as follows, > but even with peer class loading enabled, I get a gnarly error. Can clients > marshal to servers? Any advice? > > > > > > import org.apache.ignite.cache.query.annotations.QuerySqlFunction; > > > > public class MyFunctions { > > @QuerySqlFunction > > public static int sqr(int x) { > > return x * x; > > } > > } > > > > … > > cfg.setPeerClassLoadingEnabled(true); > > cfg.setClientMode(true); > > cfg.setDeploymentMode(DeploymentMode.CONTINUOUS); > > try(Ignite ignite = Ignition.start(cfg)) > > … > > myCache.setSqlFunctionClasses(MyFunctions.class); > > … > > > > > > Error: > > class org.apache.ignite.IgniteCheckedException: Failed to find class with > given class loader for unmarshalling (make sure same versions of all > classes are available on all nodes or > > enable peer-class-loading) [clsLdr=sun.misc.Launcher$ > AppClassLoader@764c12b6, cls=IgniteStartup.MyFunctions] > > at org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal0( > JdkMarshaller.java:126) > > at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshalle > r.unmarshal(AbstractNodeNameAwareMarshaller.java:94) > > at org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal0( > JdkMarshaller.java:143) > > at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshalle > r.unmarshal(AbstractNodeNameAwareMarshaller.java:82) > > at org.apache.ignite.internal.util.IgniteUtils.unmarshal( > IgniteUtils.java:9795) > > at org.apache.ignite.spi.discovery.tcp.messages. > TcpDiscoveryCustomEventMessage.message(TcpDiscoveryCustomEventMessage > .java:81) > > at org.apache.ignite.spi.discovery.tcp.ServerImpl$ > RingMessageWorker.notifyDiscoveryListener(ServerImpl.java:5460) > > at org.apache.ignite.spi.discovery.tcp.ServerImpl$ > RingMessageWorker.processCustomMessage(ServerImpl.java:5282) > > at org.apache.ignite.spi.discovery.tcp.ServerImpl$ > RingMessageWorker.processMessage(ServerImpl.java:2656) > > > > Thanks, > > *Mike Williams* > > > -- Alexey Kuznetsov
Re: QuerySqlFunction methods with variable arguments do not seem to work
https://issues.apache.org/jira/browse/IGNITE-3608 -- View this message in context: http://apache-ignite-users.70518.x6.nabble.com/QuerySqlFunction-methods-with-variable-arguments-do-not-seem-to-work-tp6524p6625.html Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: QuerySqlFunction methods with variable arguments do not seem to work
This sounds like a very weird use case for me... As I said, in your particular example you should use key access instead of SQL query. But feel free to file a ticket and provide a test there. -Val -- View this message in context: http://apache-ignite-users.70518.x6.nabble.com/QuerySqlFunction-methods-with-variable-arguments-do-not-seem-to-work-tp6524p6606.html Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: QuerySqlFunction methods with variable arguments do not seem to work
Val, thanks for your offer to help. The example is provided in my original post. Just register the class in your cache and set the breakpoint in the function to see if it gets called. You don't have to have any specific cache structure, just run a pure /"select affinityKey('java.lang.String', 'key20')"/ without any from clause and I doubt you would hit the breakpoint. However I have also found out that if I were to declare a concrete vararg type instead of Object then it works fine. So the problem is about the Object vararg type and not varargs in general. The following works fine: /select worksFine('java.lang.String', 'key20') public class MySql { @QuerySqlFunction public static org.apache.ignite.cache.affinity.AffinityKey worksFine(String keyClz, String... ctorArgs) throws NoSuchMethodException, SecurityException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { Class c = Class.forName(keyClz); Class[] argTypes = new Class[ctorArgs.length]; for (int i=0; i < ctorArgs.length; i++) { argTypes[i] = ctorArgs[i].getClass(); } Constructor ctor = c.getConstructor(argTypes); return new org.apache.ignite.cache.affinity.AffinityKey(ctor.newInstance(ctorArgs)); } } / -- View this message in context: http://apache-ignite-users.70518.x6.nabble.com/QuerySqlFunction-methods-with-variable-arguments-do-not-seem-to-work-tp6524p6569.html Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: QuerySqlFunction methods with variable arguments do not seem to work
Hi, Sorry, I missed the main point of the question :) But it actually works for me with varargs in custom functions. Can you prepare a small example that will reproduce the issue? I will be able to take a look. -Val -- View this message in context: http://apache-ignite-users.70518.x6.nabble.com/QuerySqlFunction-methods-with-variable-arguments-do-not-seem-to-work-tp6524p6552.html Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: QuerySqlFunction methods with variable arguments do not seem to work
Hi, Please show your cache configuration. Did you provide the MySql class in the CacheConfiguration.setSqlFunctionClasses(..) property? BTW, instead of this query, it's much better to use IgniteCache.get(..) method, providing the required key. -Val -- View this message in context: http://apache-ignite-users.70518.x6.nabble.com/QuerySqlFunction-methods-with-variable-arguments-do-not-seem-to-work-tp6524p6528.html Sent from the Apache Ignite Users mailing list archive at Nabble.com.