ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Savitsky (JIRA)" <j...@apache.org>
Subject [jira] [Created] (IGNITE-11827) Scalar doesn't support anonymous message listeners
Date Tue, 30 Apr 2019 17:07:00 GMT
Alex Savitsky created IGNITE-11827:
--------------------------------------

             Summary: Scalar doesn't support anonymous message listeners
                 Key: IGNITE-11827
                 URL: https://issues.apache.org/jira/browse/IGNITE-11827
             Project: Ignite
          Issue Type: Bug
    Affects Versions: 2.7
            Reporter: Alex Savitsky


This works:


{code:scala}
import java.util.UUID

import org.apache.ignite.configuration.IgniteConfiguration
import org.apache.ignite.lang.IgniteBiPredicate
import org.apache.ignite.scalar.lang.ScalarPredicate2Function
import org.apache.ignite.scalar.scalar
import org.apache.ignite.scalar.scalar._

object TestIgniteMessagingScala extends App {
  class ScalaListener extends ScalarPredicate2Function[UUID, String](new IgniteBiPredicate[UUID,
String] {
    override def apply(nodeId: UUID, msg: String): Boolean = {
      System.out.println("Received ordered message [msg=" + msg + ", from=" + nodeId + ']')
      true
    }
  })
  scalar(new IgniteConfiguration().setClientMode(true).setPeerClassLoadingEnabled(true)) {
    val messaging = ignite$.message(ignite$.cluster.forRemotes)
    messaging.remoteListen("MyUnOrderedTopic", new ScalaListener)
    for (i <- 1 to 10)
      messaging.send("MyUnOrderedTopic", Integer.toString(i))
  }
}
{code}

However, trying to define the same listener in place, fails:

{code:scala}
import java.util.UUID

import org.apache.ignite.configuration.IgniteConfiguration
import org.apache.ignite.lang.IgniteBiPredicate
import org.apache.ignite.scalar.lang.ScalarPredicate2Function
import org.apache.ignite.scalar.scalar
import org.apache.ignite.scalar.scalar._

object TestIgniteMessagingScala extends App {
  scalar(new IgniteConfiguration().setClientMode(true).setPeerClassLoadingEnabled(true)) {
    val messaging = ignite$.message(ignite$.cluster.forRemotes)
    val listener: IgniteBiPredicate[UUID, String] = (nodeId: UUID, msg: String) => {
      System.out.println("Received ordered message [msg=" + msg + ", from=" + nodeId + ']')
      true
    }
    messaging.remoteListen("MyUnOrderedTopic", listener)
    for (i <- 1 to 10)
      messaging.send("MyUnOrderedTopic", Integer.toString(i))
  }
}
{code}

The exception is:


{noformat}
Exception in thread "main" class org.apache.ignite.binary.BinaryObjectException: Failed to
deserialize object [typeName=org.apache.ignite.scalar.lang.ScalarPredicate2]
	at org.apache.ignite.internal.binary.BinaryClassDescriptor.read(BinaryClassDescriptor.java:914)
	at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize0(BinaryReaderExImpl.java:1764)
	at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1716)
	at org.apache.ignite.internal.binary.GridBinaryMarshaller.deserialize(GridBinaryMarshaller.java:313)
	at org.apache.ignite.internal.binary.BinaryMarshaller.unmarshal0(BinaryMarshaller.java:102)
	at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.unmarshal(AbstractNodeNameAwareMarshaller.java:82)
	at org.apache.ignite.internal.util.IgniteUtils.unmarshal(IgniteUtils.java:10140)
	at org.apache.ignite.internal.util.IgniteUtils.unmarshal(IgniteUtils.java:10169)
	at org.apache.ignite.internal.GridMessageListenHandler.p2pUnmarshal(GridMessageListenHandler.java:194)
	at org.apache.ignite.internal.processors.continuous.GridContinuousProcessor.processStartRequest(GridContinuousProcessor.java:1362)
	at org.apache.ignite.internal.processors.continuous.GridContinuousProcessor.access$400(GridContinuousProcessor.java:111)
	at org.apache.ignite.internal.processors.continuous.GridContinuousProcessor$2.onCustomEvent(GridContinuousProcessor.java:203)
	at org.apache.ignite.internal.processors.continuous.GridContinuousProcessor$2.onCustomEvent(GridContinuousProcessor.java:194)
	at org.apache.ignite.internal.managers.discovery.GridDiscoveryManager$4.onDiscovery0(GridDiscoveryManager.java:727)
	at org.apache.ignite.internal.managers.discovery.GridDiscoveryManager$4.lambda$onDiscovery$0(GridDiscoveryManager.java:604)
	at org.apache.ignite.internal.managers.discovery.GridDiscoveryManager$DiscoveryMessageNotifierWorker.body0(GridDiscoveryManager.java:2667)
	at org.apache.ignite.internal.managers.discovery.GridDiscoveryManager$DiscoveryMessageNotifierWorker.body(GridDiscoveryManager.java:2705)
	at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:120)
	at java.lang.Thread.run(Thread.java:748)
Caused by: class org.apache.ignite.binary.BinaryObjectException: Failed to read field [name=p]
	at org.apache.ignite.internal.binary.BinaryFieldAccessor.read(BinaryFieldAccessor.java:192)
	at org.apache.ignite.internal.binary.BinaryClassDescriptor.read(BinaryClassDescriptor.java:875)
	... 18 more
Caused by: class org.apache.ignite.binary.BinaryInvalidTypeException: test.TestIgniteMessagingScala$$anonfun$1$$anonfun$2
	at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:707)
	at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize0(BinaryReaderExImpl.java:1757)
	at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1716)
	at org.apache.ignite.internal.binary.BinaryReaderExImpl.readField(BinaryReaderExImpl.java:1984)
	at org.apache.ignite.internal.binary.BinaryFieldAccessor$DefaultFinalClassAccessor.read0(BinaryFieldAccessor.java:703)
	at org.apache.ignite.internal.binary.BinaryFieldAccessor.read(BinaryFieldAccessor.java:188)
	... 19 more
Caused by: java.lang.ClassNotFoundException: test.TestIgniteMessagingScala$$anonfun$1$$anonfun$2
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at org.apache.ignite.internal.util.IgniteUtils.forName(IgniteUtils.java:8771)
	at org.apache.ignite.internal.MarshallerContextImpl.getClass(MarshallerContextImpl.java:349)
	at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:698)
	... 24 more
{noformat}

My guess is that the ScalarPredicate2 is not declared Serializable



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message