You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by "Williams, Michael" <mi...@transamerica.com> on 2018/02/14 21:29:40 UTC

QuerySqlFunction

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.AbstractNodeNameAwareMarshaller.unmarshal(AbstractNodeNameAwareMarshaller.java:94)
        at org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal0(JdkMarshaller.java:143)
        at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.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


Re: QuerySqlFunction

Posted by vkulichenko <va...@gmail.com>.
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

Posted by Alexey Kuznetsov <ak...@apache.org>.
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.williams@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