ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "rishireddy.bokka" <rishireddy.bo...@gmail.com>
Subject Issue while using Affinity function for mapping keys with nodes
Date Fri, 16 Dec 2016 02:06:14 GMT
Hi, 
I am using affinity function to map the keys with the nodes. I have 2 nodes
and trying to distribute the person objects among those two nodes. Below is
my code :

public class TestingIgnite 
{
private static final String CACHE_NAME =
TestingIgnite.class.getSimpleName();
public static void main(String[] args) throws IgniteException {
		Ignition.setClientMode(true);
		try (Ignite ignite = Ignition.start(
			
"/usr/local/ignite/apache-ignite-fabric-1.7.0-bin/examples/config/example-cache.xml"))
{
			
			try (IgniteCache<Integer, Person> cache =
ignite.getOrCreateCache(CACHE_NAME)) {
				
		    Person p1 = new Person("1", "Rishiiii", "Bokka");
	            Person p2 = new Person("2", "Gang", "Valla");
	            Person p3 = new Person("3", "Person3", "P3");
	            Person p4 = new Person("4", "Person4", "P4");
	            personList.add(p1);
	            personList.add(p2);
	            personList.add(p3);
	            personList.add(p4);
	          
	            cache.put(Integer.parseInt(p1.getId()), p1);
	            cache.put(Integer.parseInt(p2.getId()), p2);
	            cache.put(Integer.parseInt(p3.getId()), p3);
	            cache.put(Integer.parseInt(p4.getId()), p4);

	            visitUsingMapKeysToNodes()
			}

		}
	}
	 private static void visitUsingMapKeysToNodes() {
		 final Ignite ignite = Ignition.ignite();
		 Collection<Integer> keys = new ArrayList<>(personList.size()+1);
		 for (int i = 1; i < personList.size()+1; i++)
			 keys.add(i);
		 for(Integer i : keys)
			 System.out.println("keyss :"+ i);
		 // Map all keys to nodes.
		 Map<ClusterNode, Collection&lt;Integer>> mappings =   
ignite.Integer>affinity(CACHE_NAME).mapKeysToNodes(keys);
		 for (Map.Entry<ClusterNode, Collection&lt;Integer>> mapping :
mappings.entrySet()) {
			 System.out.println("Nodes :"+ mapping.getKey());
			 System.out.println("valuessss : "+ mapping.getValue());
		 }
		 for (Map.Entry<ClusterNode, Collection&lt;Integer>> mapping :
mappings.entrySet()) {
			 ClusterNode node = mapping.getKey();

			 System.out.println("Node name :"+ node.addresses());
			 final Collection<Integer> mappedKeys = mapping.getValue();
			 System.out.println("valuess : "+ mapping.getValue());
			 if (node != null) {
				 // Bring computations to the nodes where the data resides (i.e.
collocation).
				 ignite.compute(ignite.cluster().forNode(node)).run(new IgniteRunnable()
{
					 @Override public void run() {
						 System.out.println("hii");
						 IgniteCache<Integer, Person> cache = ignite.cache(CACHE_NAME);

						 for (Integer key : mappedKeys)
							 System.out.println(key= " + key +
									 ", value=" + cache.get(key));
					 }
				 });
			 }
		 }
	 }
}


But I am getting below exception. :

Dec 15, 2016 8:51:48 PM org.apache.ignite.logger.java.JavaLogger error
SEVERE: Failed to obtain remote job result policy for result from
ComputeTask.result(..) method (will fail the whole task): GridJobResultImpl
[job=C4V2 [r=o.a.i.ignite_core.TestingIgnite$1@41e350f1],
sib=GridJobSiblingImpl
[sesId=458f3550951-31951fae-4c34-42bb-b8eb-5106f6b2a647,
jobId=858f3550951-31951fae-4c34-42bb-b8eb-5106f6b2a647,
nodeId=4c54daa5-68f1-43c8-892b-8057fc18be7b, isJobDone=false],
jobCtx=GridJobContextImpl
[jobId=858f3550951-31951fae-4c34-42bb-b8eb-5106f6b2a647, timeoutObj=null,
attrs={}], node=TcpDiscoveryNode [id=4c54daa5-68f1-43c8-892b-8057fc18be7b,
addrs=[0:0:0:0:0:0:0:1%lo, 10.1.1.148, 127.0.0.1,
2001:470:8865:11:20c:29ff:fee0:b672%ens192],
sockAddrs=[aapvm03/10.1.1.148:47500,
/2001:470:8865:11:20c:29ff:fee0:b672%ens192:47500,
/0:0:0:0:0:0:0:1%lo:47500, /127.0.0.1:47500], discPort=47500, order=1,
intOrder=1, lastExchangeTime=1481853108069, loc=false,
ver=1.7.0#20160801-sha1:383273e3, isClient=false], ex=class
o.a.i.binary.BinaryInvalidTypeException: o.a.i.ignite_core.Person,
hasRes=true, isCancelled=false, isOccupied=true]
class org.apache.ignite.IgniteException: Remote job threw user exception
(override or implement ComputeTask.result(..) method if you would like to
have automatic failover for this exception).
	at
org.apache.ignite.compute.ComputeTaskAdapter.result(ComputeTaskAdapter.java:101)
	at
org.apache.ignite.internal.processors.task.GridTaskWorker$4.apply(GridTaskWorker.java:946)
	at
org.apache.ignite.internal.processors.task.GridTaskWorker$4.apply(GridTaskWorker.java:939)
	at
org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6553)
	at
org.apache.ignite.internal.processors.task.GridTaskWorker.result(GridTaskWorker.java:939)
	at
org.apache.ignite.internal.processors.task.GridTaskWorker.onResponse(GridTaskWorker.java:810)
	at
org.apache.ignite.internal.processors.task.GridTaskProcessor.processJobExecuteResponse(GridTaskProcessor.java:995)
	at
org.apache.ignite.internal.processors.task.GridTaskProcessor$JobMessageListener.onMessage(GridTaskProcessor.java:1220)
	at
org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1238)
	at
org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:866)
	at
org.apache.ignite.internal.managers.communication.GridIoManager.access$1700(GridIoManager.java:106)
	at
org.apache.ignite.internal.managers.communication.GridIoManager$5.run(GridIoManager.java:829)
	at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: class org.apache.ignite.binary.BinaryInvalidTypeException:
org.apache.ignite.ignite_core.Person
	at
org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:671)
	at
org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1474)
	at
org.apache.ignite.internal.binary.BinaryObjectImpl.deserializeValue(BinaryObjectImpl.java:585)
	at
org.apache.ignite.internal.binary.BinaryObjectImpl.value(BinaryObjectImpl.java:142)
	at
org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinary(CacheObjectContext.java:272)
	at
org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinaryIfNeeded(CacheObjectContext.java:160)
	at
org.apache.ignite.internal.processors.cache.GridCacheContext.unwrapBinaryIfNeeded(GridCacheContext.java:1764)
	at
org.apache.ignite.internal.processors.cache.GridCacheAdapter.localPeek(GridCacheAdapter.java:842)
	at
org.apache.ignite.internal.processors.cache.GridCacheProxyImpl.localPeek(GridCacheProxyImpl.java:1000)
	at
org.apache.ignite.internal.processors.cache.IgniteCacheProxy.localPeek(IgniteCacheProxy.java:793)
	at org.apache.ignite.ignite_core.TestingIgnite$1.run(TestingIgnite.java:79)
	at
org.apache.ignite.internal.processors.closure.GridClosureProcessor$C4V2.execute(GridClosureProcessor.java:2184)
	at
org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:509)
	at
org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6521)
	at
org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:503)
	at
org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:456)
	at
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
	at
org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1161)
	at
org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:1766)
	... 7 more
Caused by: java.lang.ClassNotFoundException:
org.apache.ignite.ignite_core.Person
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	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:8350)
	at
org.apache.ignite.internal.MarshallerContextAdapter.getClass(MarshallerContextAdapter.java:185)
	at
org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:662)
	... 25 more


Could you please let me know where I am doing wrong.



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Issue-while-using-Affinity-function-for-mapping-keys-with-nodes-tp9580.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Mime
View raw message