i want connect apache ignite from nodejs by redis's interface
in ignite config, i add bellow xml defintion in config-default.xml:
<property name="connectorConfiguration">
<bean class="org.apache.ignite.configuration.ConnectorConfiguration">
<property name="host" value="localhost"/>
<property name="port" value="6379"/>
</bean>
</property>
and run ignite.bat (testing platform in win7 64bit)
console message seeming running fine:
[15:59:09] To start Console Management & Monitoring run ignitevisorcmd.{sh|bat}
[15:59:09]
[15:59:09] Ignite node started OK (id=b58f9f35)
[15:59:09] Topology snapshot [ver=1, servers=1, clients=0, CPUs=4, heap=1.0GB]
when test a nodejs code such as:
var redis = require("redis");
var client = redis.createClient({detect_buffers: true});
client.get("test", function (err, reply) {
if(err == null){
console.log('reply:'+reply);
}
else{
console.log('error:'+err);
}
});
client.quit();
got a error message in nodejs
vents.js:183
throw er; // Unhandled 'error' event
^
AbortError: Ready check failed: Stream connection ended and command aborted. It might have been processed.
at RedisClient.flush_and_error (d:\APP\nodejs\mcanserver\node_modules\redis\index.js:362:23)
at RedisClient.connection_gone (d:\APP\nodejs\mcanserver\node_modules\redis\index.js:597:14)
at Socket.<anonymous> (d:\APP\nodejs\mcanserver\node_modules\redis\index.js:293:14)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
at Socket.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
Waiting for the debugger to disconnect...
AbortError
and errors in ignite console:
[16:08:59,809][SEVERE][grid-nio-worker-tcp-rest-0-#36][GridTcpRestProtocol] Fail
ed to process selector key [ses=GridSelectorNioSessionImpl [worker=ByteBufferNio
ClientWorker [readBuf=java.nio.HeapByteBuffer[pos=14 lim=14 cap=8192], super=Abs
tractNioClientWorker [idx=0, bytesRcvd=0, bytesSent=0, bytesRcvd0=0, bytesSent0=
0, select=true, super=GridWorker [name=grid-nio-worker-tcp-rest-0, igniteInstanc
eName=null, finished=false, hashCode=1424564915, interrupted=false, runner=grid-
nio-worker-tcp-rest-0-#36]]], writeBuf=null, readBuf=null, inRecovery=null, outR
ecovery=null, super=GridNioSessionImpl [locAddr=/127.0.0.1:6379, rmtAddr=/127.0.
0.1:18970, createTime=1527667738762, closeTime=0, bytesSent=0, bytesRcvd=14, byt
esSent0=0, bytesRcvd0=14, sndSchedTime=1527667738762, lastSndTime=1527667738762,
lastRcvTime=1527667738762, readsPaused=false, filterChain=FilterChain[filters=[
GridNioCodecFilter [parser=GridTcpRestParser [jdkMarshaller=JdkMarshaller [], ro
uterClient=false], directMode=false]], accepted=true]]]
java.lang.IllegalArgumentException: No enum constant org.apache.ignite.internal.
processors.rest.protocols.tcp.redis.GridRedisCommand.INFO
at java.lang.Enum.valueOf(Unknown Source)
at org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRe
disCommand.valueOf(GridRedisCommand.java:26)
at org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRe
disMessage.command(GridRedisMessage.java:124)
at org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRe
disNioListener.onMessage(GridRedisNioListener.java:132)
at org.apache.ignite.internal.processors.rest.protocols.tcp.GridTcpRestN
ioListener.onMessage(GridTcpRestNioListener.java:193)
at org.apache.ignite.internal.processors.rest.protocols.tcp.GridTcpRestN
ioListener.onMessage(GridTcpRestNioListener.java:94)
at org.apache.ignite.internal.util.nio.GridNioFilterChain$TailFilter.onM
essageReceived(GridNioFilterChain.java:279)
at org.apache.ignite.internal.util.nio.GridNioFilterAdapter.proceedMessa
geReceived(GridNioFilterAdapter.java:109)
i need help to known what's happen? and how to fixed this error, thanks.
I'm afraid that your client uses a command INFO which isn't implemented by Apache Ignite. Is it possible to try alternative client or maybe a memcached client? Note that the latter has binary and text forms, only one of which is supported.
just ran into the same issue with node.js redis client.. indeed, INFO operation is not supported by Apache Ignite, and node redis client uses it to check if Redis is ready to serve queries.. a workaround is to turn it off:
redis.createClient({no_ready_check: true});
Related
I am running my service in local environment and trying to connect to remote node but it showing error failed to send message to remote node.
I want to run my service in local environment and connect it to remote ignite node on different server.
my configuration is:
IgniteConfiguration igniteConfig = new IgniteConfiguration();
igniteConfig.setIgniteInstanceName("MasterCacheCluster");
igniteConfig.setPeerClassLoadingEnabled(true);
igniteConfig.setClientMode(true);
TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi();
TcpDiscoveryVmIpFinder ipFinder = new
TcpDiscoveryVmIpFinder();
TcpCommunicationSpi communicationSpi = new
TcpCommunicationSpi();
ipFinder.setAddresses(Arrays.asList("server_address":47500..47509"));
discoverySpi.setIpFinder(ipFinder);
igniteConfig.setDiscoverySpi(discoverySpi);
DataStorageConfiguration dataCfg = new
DataStorageConfiguration();
DataRegionConfiguration rgnCfg = new
DataRegionConfiguration();
rgnCfg.setName("Sample_Cluster_Region");
rgnCfg.setPageEvictionMode(DataPageEvictionMode.RANDOM_2_LRU);
rgnCfg.setPersistenceEnabled(true);
rgnCfg.setMetricsEnabled(true);
dataCfg.setDataRegionConfigurations(rgnCfg);
Ignite ignite = Ignition.start(igniteConfig);
ignite.cluster().active(true);
System.out.println("Cluster Size: " +
ignite.cluster().nodes().size());
return ignite;
** server address is hidden due to privacy reason
[13:12:18,839][SEVERE][exchange-worker-#62%MasterCacheCluster%][TcpCommunicationSpi] Failed to send message to remote node [node=TcpDiscoveryNode [id=724fff2c-76c2-44e7-921f-b7c37dac7d15, consistentId=7c4ed309-0b9b-40ba-84a1-90384e0940ea, addrs=ArrayList [0:0:0:0:0:0:0:1%lo, 10.3.0.8, 127.0.0.1], sockAddrs=null, discPort=47500, order=1, intOrder=1, lastExchangeTime=1676878928401, loc=false, ver=2.14.0#20220929-sha1:951e8deb, isClient=false], msg=GridIoMessage [plc=2, topic=TOPIC_CACHE, topicOrd=8, ordered=false, timeout=0, skipOnTimeout=false, msg=GridDhtPartitionsSingleMessage [parts=null, partCntrs=null, partsSizes=null, partHistCntrs=null, err=null, client=true, exchangeStartTime=1676878928573, finishMsg=null, super=GridDhtPartitionsAbstractMessage [exchId=GridDhtPartitionExchangeId [topVer=AffinityTopologyVersion [topVer=2, minorTopVer=0], discoEvt=DiscoveryEvent [evtNode=TcpDiscoveryNode [id=96f70bd7-cbfb-4a3e-900d-00a93b10d892, consistentId=96f70bd7-cbfb-4a3e-900d-00a93b10d892, addrs=ArrayList [0:0:0:0:0:0:0:1, 127.0.0.1, 172.16.16.50], sockAddrs=HashSet [/[0:0:0:0:0:0:0:1]:0, /127.0.0.1:0, LAPTOP-6AUCFF2I/172.16.16.50:0], discPort=0, order=2, intOrder=0, lastExchangeTime=1676878923997, loc=true, ver=2.14.0#20220929-sha1:951e8deb, isClient=true], topVer=2, msgTemplate=null, span=org.apache.ignite.internal.processors.tracing.NoopSpan#baed14f, nodeId8=96f70bd7, msg=null, type=NODE_JOINED, tstamp=1676878928556], nodeId=96f70bd7, evt=NODE_JOINED], lastVer=GridCacheVersion [topVer=0, order=1676878923547, nodeOrder=0, dataCenterId=0], super=GridCacheMessage [msgId=1, depInfo=null, lastAffChangedTopVer=AffinityTopologyVersion [topVer=-1, minorTopVer=0], err=null, skipPrepare=false]]]]]
class org.apache.ignite.IgniteCheckedException: Failed to connect to node (is node still alive?). Make sure that each ComputeTask and cache Transaction has a timeout set in order to prevent parties from waiting forever in case of network issues [nodeId=724fff2c-76c2-44e7-921f-b7c37dac7d15, addrs=[/10.3.0.8:47100, /[0:0:0:0:0:0:0:1%lo]:47100, /127.0.0.1:47100]]
Your client tries to establish communication link to the server node with id=724fff2c-76c2-44e7-921f-b7c37dac7d15 after receiving it's address through discovery protocol. This exception basically implies that there's no connectivity between your local host and "server_address":47100. Every single node (including clients) should be visible to the rest of a cluster. My guess is you have some firewall rules or something like that.
Try running some tools to troubleshoot, you could start with.
nc -vz "server_address" 47100
It should be run from your laptop.
It's also worth mentioning that your server expose ipv6 addresses. It's recommended to use ipv4 at the moment. Add -Djava.net.preferIPv4Stack=true JVM param to the both client and server JVM start scripts.
I use the Ignite docker image to set up an ignite cluster on my local machine. Things work fine as long as I use the default configuration. When I tried overriding the config using the command
docker run -d --name my_ignite \
-p 11211:11211 -p 47100:47100 -p 47500:47500 -p 49112:49112 \
-e “OPTION_LIBS=ignite-indexing” \
-e "CONFIG_URI=file:///Users/abc/Documents/ignite_configs/ignite-config.xml" \
-v $(pwd):/Users/abc/Documents/ignite_configs apacheignite/ignite:2.7.0
Ignite starts up correctly but when I try to write to the cache I get the following exception.
My config file ignite-config.xml is
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns = "http://www.springframework.org/schema/beans"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="binaryConfiguration">
<bean class="org.apache.ignite.configuration.BinaryConfiguration">
<property name="idMapper">
<bean class = "org.apache.ignite.binary.BinaryBasicIdMapper">
<property name = "lowerCase" value = "true"/>
</bean>
</property>
</bean>
</property>
</bean>
</beans>
How should I fix this?
Stacktrace:
2020-05-20 14:34:49 [main] WARN o.a.i.i.p.c.d.d.t.PartitionsEvictManager - Logging at INFO level without checking if INFO level is enabled: Evict partition permits=4
2020-05-20 14:34:50 [tcp-client-disco-msg-worker-#4%fn_Instance_979931923%] ERROR ROOT - Critical system error detected. Will be handled accordingly to configured handler [hnd=StopNodeOrHaltFailureHandler [tryStop=false, timeout=0, super=AbstractFailureHandler [ignoredFailureTypes=[SYSTEM_WORKER_BLOCKED]]], failureCtx=FailureContext [type=SYSTEM_WORKER_TERMINATION, err=class o.a.i.IgniteException: GridWorker [name=tcp-client-disco-msg-worker, igniteInstanceName=svexecfn_Instance_979931923, finished=true, heartbeatTs=1590010490223]]]
org.apache.ignite.IgniteException: GridWorker [name=tcp-client-disco-msg-worker, igniteInstanceName=svexecfn_Instance_979931923, finished=true, heartbeatTs=1590010490223]
at org.apache.ignite.internal.IgnitionEx$IgniteNamedInstance$2.apply(IgnitionEx.java:1831)
at org.apache.ignite.internal.IgnitionEx$IgniteNamedInstance$2.apply(IgnitionEx.java:1826)
at org.apache.ignite.internal.worker.WorkersRegistry.onStopped(WorkersRegistry.java:169)
at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:153)
at org.apache.ignite.spi.discovery.tcp.ClientImpl$1.body(ClientImpl.java:304)
at org.apache.ignite.spi.IgniteSpiThread.run(IgniteSpiThread.java:62)
2020-05-20 14:34:50 [main] ERROR o.a.i.i.IgniteKernal%svexecfn_Instance_979931923 - Failed to start manager: GridManagerAdapter [enabled=true, name=o.a.i.i.managers.discovery.GridDiscoveryManager]
org.apache.ignite.IgniteCheckedException: Failed to start SPI: TcpDiscoverySpi [addrRslvr=null, sockTimeout=5000, ackTimeout=5000, marsh=JdkMarshaller [clsFilter=org.apache.ignite.marshaller.MarshallerUtils$1#7ed9ae94], reconCnt=10, reconDelay=2000, maxAckTimeout=600000, forceSrvMode=false, clientReconnectDisabled=false, internalLsnr=null]
at org.apache.ignite.internal.managers.GridManagerAdapter.startSpi(GridManagerAdapter.java:300)
at org.apache.ignite.internal.managers.discovery.GridDiscoveryManager.start(GridDiscoveryManager.java:939)
at org.apache.ignite.internal.IgniteKernal.startManager(IgniteKernal.java:1682)
at org.apache.ignite.internal.IgniteKernal.start(IgniteKernal.java:1066)
at org.apache.ignite.internal.IgnitionEx$IgniteNamedInstance.start0(IgnitionEx.java:2038)
at org.apache.ignite.internal.IgnitionEx$IgniteNamedInstance.start(IgnitionEx.java:1730)
at org.apache.ignite.internal.IgnitionEx.start0(IgnitionEx.java:1158)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:678)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:603)
at org.apache.ignite.Ignition.start(Ignition.java:323)
...
Caused by: org.apache.ignite.spi.IgniteSpiException: Local node's binary configuration is not equal to remote node's binary configuration [locNodeId=4fc2317b-a7b5-43e0-bc37-20747fab2d73, rmtNodeId=a7ce1554-64cb-4de1-a71f-5c3ddb252ffa, locBinaryCfg=null, rmtBinaryCfg={globIdMapper=org.apache.ignite.binary.BinaryBasicIdMapper, compactFooter=true, globSerializer=null}]
at org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi.checkFailedError(TcpDiscoverySpi.java:1946)
at org.apache.ignite.spi.discovery.tcp.ClientImpl$MessageWorker.body(ClientImpl.java:1888)
at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:120)
at org.apache.ignite.spi.discovery.tcp.ClientImpl$1.body(ClientImpl.java:304)
at org.apache.ignite.spi.IgniteSpiThread.run(IgniteSpiThread.java:62)
Take a look at the binary configuration of all your nodes:
https://apacheignite.readme.io/docs/binary-marshaller#configuring-binary-objects
you have:
Local node's binary configuration is not equal to remote node's binary configuration [locNodeId=4fc2317b-a7b5-43e0-bc37-20747fab2d73, rmtNodeId=a7ce1554-64cb-4de1-a71f-5c3ddb252ffa, locBinaryCfg=null, rmtBinaryCfg={globIdMapper=org.apache.ignite.binary.BinaryBasicIdMapper, compactFooter=true, globSerializer=null}]
which means you are inserting from a node w/a different binary config.
Take a look at the binary config of 4fc2317b-a7b5-43e0-bc37-20747fab2d73, it should be the same as the remote node.
<bean class="org.apache.ignite.configuration.BinaryConfiguration">
<property name="idMapper">
<bean class = "org.apache.ignite.binary.BinaryBasicIdMapper">
<property name = "lowerCase" value = "true"/>
</bean>
</property>
</bean>
This is binary configuration ^ it should be the same in your server node's ignite_configs/ignite-config.xml file
I use UriDeploymentSpi bean to load GAR files from a directory in one of my nodes
I have following GAR ignite.xml file (took me a while to figure this one out btw, nowhere documented?)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<util:list id="myList" value-type="java.lang.String">
<value>myproject.HelloWorldTask</value>
<value>myproject.SimpleTask</value>
</util:list>
</beans>
HelloWorldTask:
package myproject;
public class HelloWorldTask extends ComputeTaskAdapter<String, Integer> {
static {
System.out.println("TheGlue: Loading HelloWorldTask ");
}
public HelloWorldTask() {
}
#Nullable
#Override
public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> nodes, #Nullable String arg) throws IgniteException {
System.out.println("Hello from GAR file");
return null; //To change body of implemented methods use File | Settings | File Templates.
}
#Nullable
#Override
public Integer reduce(List<ComputeJobResult> results) throws IgniteException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
}
SimpleTask:
package myproject;
#ComputeTaskName("SimpleTaskName")
public class SimpleTask implements ComputeTask<String, Integer> {
static {
System.out.println("Loading SimpleTask");
}
public SimpleTask() {
}
#Override
public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, String arg) throws IgniteException {
System.out.println("Computing Job in SimpleTask ");
return null; //To change body of implemented methods use File | Settings | File Templates.
}
#Override
public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> rcvd) throws IgniteException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
#Override
public Integer reduce(List<ComputeJobResult> results) throws IgniteException {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
}
The 2 classes can be found by Ignite (debugged through GridUriDeploymentSpringDocument and GridUriDeploymentFileProcessor and they are found and loaded). Ignite says that it found the GAR, but as far as I can see, the classes are not instantiated. No errors in the log files, no indications that the Tasks are deployed either.
I am trying to execute the following code on a node where the GAR file is not deployed (ie. client node of the cluster), but the Task is not executed on the cluster:
public class _03GarTest {
public static void main(String[] args) {
System.out.println("Start urideployment test");
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setPeerClassLoadingEnabled(true); //needs to be the same as in the XML for the server
cfg.setClientMode(true);
try(Ignite ignite = Ignition.start(cfg)) {
ignite.compute(ignite.cluster().forRemotes()).execute("SimpleTaskName", null);
}
}
}
Log file where I execute the _03GarTest class (same if I run with "SimpleTaskName" or "myproject.SimpleTaskName"), dumps the following stacktraces on the client node:
Exception in thread "main" class org.apache.ignite.IgniteDeploymentException: Unknown task name or failed to auto-deploy task (was task (re|un)deployed?): SimpleTaskName
at org.apache.ignite.internal.util.IgniteUtils$7.apply(IgniteUtils.java:761)
at org.apache.ignite.internal.util.IgniteUtils$7.apply(IgniteUtils.java:759)
at org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:877)
at org.apache.ignite.internal.IgniteComputeImpl.execute(IgniteComputeImpl.java:154)
at _03GarTest.main(_03GarTest.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: class org.apache.ignite.internal.IgniteDeploymentCheckedException: Unknown task name or failed to auto-deploy task (was task (re|un)deployed?): SimpleTaskName
at org.apache.ignite.internal.processors.task.GridTaskProcessor.startTask(GridTaskProcessor.java:515)
at org.apache.ignite.internal.processors.task.GridTaskProcessor.execute(GridTaskProcessor.java:447)
at org.apache.ignite.internal.IgniteComputeImpl.execute(IgniteComputeImpl.java:151)
... 6 more
And on the server, following logs are produced:
[13:13:33,057][INFO][disco-event-worker-#48%null%][GridDiscoveryManager] Added new node to topology: TcpDiscoveryNode [id=b70dce5e-c0fd-4ffe-8dc2-b72b18db76da, addrs=[0:0:0:0:0:0:0:1, 10.1.26.59, 127.0.0.1, 192.168.8.103, 192.168.99.1], sockAddrs=[/192.168.8.103:0, /0:0:0:0:0:0:0:1:0, /192.168.99.1:0, /10.1.26.59:0, /10.1.26.59:0, /127.0.0.1:0, /192.168.8.103:0, /192.168.99.1:0], discPort=0, order=12, intOrder=7, lastExchangeTime=1452600812926, loc=false, ver=1.5.0#20151229-sha1:f1f8cda2, isClient=true]
[13:13:33,063][INFO][disco-event-worker-#48%null%][GridDiscoveryManager] Topology snapshot [ver=12, servers=1, clients=1, CPUs=8, heap=1.5GB]
[13:13:33,085][WARNING][disco-event-worker-#48%null%][CourtesyConfigNotice]
>>> +-------------------------------------------------------------------+
>>> + Courtesy notice that joining node has inconsistent configuration. +
>>> + Ignore this message if you are sure that this is done on purpose. +
>>> +-------------------------------------------------------------------+
>>> Remote Node ID: B70DCE5E-C0FD-4FFE-8DC2-B72B18DB76DA
>>> Remote SPI with the same name is not configured: UriDeploymentSpi
>>> => Local node: o.a.i.spi.deployment.uri.UriDeploymentSpi
[13:13:33,103][INFO][exchange-worker-#51%null%][GridCachePartitionExchangeManager] Skipping rebalancing (nothing scheduled) [top=AffinityTopologyVersion [topVer=12, minorTopVer=0], evt=NODE_JOINED, node=b70dce5e-c0fd-4ffe-8dc2-b72b18db76da]
[13:13:33,907][INFO][disco-event-worker-#48%null%][GridDiscoveryManager] Node left topology: TcpDiscoveryNode [id=b70dce5e-c0fd-4ffe-8dc2-b72b18db76da, addrs=[0:0:0:0:0:0:0:1, 10.1.26.59, 127.0.0.1, 192.168.8.103, 192.168.99.1], sockAddrs=[/192.168.8.103:0, /0:0:0:0:0:0:0:1:0, /192.168.99.1:0, /10.1.26.59:0, /10.1.26.59:0, /127.0.0.1:0, /192.168.8.103:0, /192.168.99.1:0], discPort=0, order=12, intOrder=7, lastExchangeTime=1452600812926, loc=false, ver=1.5.0#20151229-sha1:f1f8cda2, isClient=true]
[13:13:33,908][INFO][disco-event-worker-#48%null%][GridDiscoveryManager] Topology snapshot [ver=13, servers=1, clients=0, CPUs=8, heap=1.0GB]
[13:13:33,918][INFO][exchange-worker-#51%null%][GridCachePartitionExchangeManager] Skipping rebalancing (nothing scheduled) [top=AffinityTopologyVersion [topVer=13, minorTopVer=0], evt=NODE_LEFT, node=b70dce5e-c0fd-4ffe-8dc2-b72b18db76da]
[13:14:03,193][INFO][grid-timeout-worker-#33%null%][IgniteKernal]
Any ideas on how to call a task deployed via a GAR file on another node?
----UPDATE----
As suggested in one of the answers, I have added the following code in the client
System.out.println("Start urideployment test");
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setPeerClassLoadingEnabled(true); //needs to be the same as in the XML for the server
cfg.setClientMode(true);
UriDeploymentSpi deploymentSpi = new UriDeploymentSpi();
deploymentSpi.setUriList(Arrays.asList("file:///Users/sbeaupre/Dropbox/prorabel/Projects/IgniteTests/ignite/gar"));
cfg.setDeploymentSpi(deploymentSpi);
try(Ignite ignite = Ignition.start(cfg)) {
...
But this doesn't work either, I got following stack trace on the client node and nothing on the server node:
Jan 14, 2016 5:42:23 PM org.apache.ignite.logger.java.JavaLogger info
INFO: Topology snapshot [ver=4, servers=1, clients=1, CPUs=8, heap=1.5GB]
Jan 14, 2016 5:42:23 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from resource loaded from byte array
Jan 14, 2016 5:42:23 PM org.apache.ignite.logger.java.JavaLogger info
INFO: User version is not explicitly defined (will use default version) [file=META-INF/ignite.xml, clsLdr=GridUriDeploymentClassLoader [urls=[file:/var/folders/t3/595tz_px2j9__wl37f0b5nw40000gn/T/gg.uri.deployment.tmp/301a4cb8-6fc7-4aa9-b050-3083183f4cd0/dirzip_Archive8035449106801616883.gar/]]]
Jan 14, 2016 5:42:23 PM org.apache.ignite.logger.java.JavaLogger info
INFO: Task locally deployed: class myproject.SimpleTask
Loading SimpleTask
Computing Job in SimpleTask
Jan 14, 2016 5:42:23 PM org.apache.ignite.logger.java.JavaLogger error
SEVERE: Failed to map task jobs to nodes: GridTaskSessionImpl [taskName=SimpleTaskName, dep=GridDeployment [ts=1452789743727, depMode=SHARED, clsLdr=GridUriDeploymentClassLoader [urls=[file:/var/folders/t3/595tz_px2j9__wl37f0b5nw40000gn/T/gg.uri.deployment.tmp/301a4cb8-6fc7-4aa9-b050-3083183f4cd0/dirzip_Archive8035449106801616883.gar/]], clsLdrId=cc234014251-301a4cb8-6fc7-4aa9-b050-3083183f4cd0, userVer=0, loc=true, sampleClsName=myproject.SimpleTask, pendingUndeploy=false, undeployed=false, usage=1], taskClsName=myproject.SimpleTask, sesId=bc234014251-301a4cb8-6fc7-4aa9-b050-3083183f4cd0, startTime=1452789743638, endTime=9223372036854775807, taskNodeId=301a4cb8-6fc7-4aa9-b050-3083183f4cd0, clsLdr=GridUriDeploymentClassLoader [urls=[file:/var/folders/t3/595tz_px2j9__wl37f0b5nw40000gn/T/gg.uri.deployment.tmp/301a4cb8-6fc7-4aa9-b050-3083183f4cd0/dirzip_Archive8035449106801616883.gar/]], closed=false, cpSpi=null, failSpi=null, loadSpi=null, usage=1, fullSup=false, subjId=301a4cb8-6fc7-4aa9-b050-3083183f4cd0, mapFut=IgniteFuture [orig=GridFutureAdapter [resFlag=0, res=null, startTime=1452789743739, endTime=0, ignoreInterrupts=false, lsnr=null, state=INIT]]]
class org.apache.ignite.IgniteCheckedException: Task map operation produced no mapped jobs: GridTaskSessionImpl [taskName=SimpleTaskName, dep=GridDeployment [ts=1452789743727, depMode=SHARED, clsLdr=GridUriDeploymentClassLoader [urls=[file:/var/folders/t3/595tz_px2j9__wl37f0b5nw40000gn/T/gg.uri.deployment.tmp/301a4cb8-6fc7-4aa9-b050-3083183f4cd0/dirzip_Archive8035449106801616883.gar/]], clsLdrId=cc234014251-301a4cb8-6fc7-4aa9-b050-3083183f4cd0, userVer=0, loc=true, sampleClsName=myproject.SimpleTask, pendingUndeploy=false, undeployed=false, usage=1], taskClsName=myproject.SimpleTask, sesId=bc234014251-301a4cb8-6fc7-4aa9-b050-3083183f4cd0, startTime=1452789743638, endTime=9223372036854775807, taskNodeId=301a4cb8-6fc7-4aa9-b050-3083183f4cd0, clsLdr=GridUriDeploymentClassLoader [urls=[file:/var/folders/t3/595tz_px2j9__wl37f0b5nw40000gn/T/gg.uri.deployment.tmp/301a4cb8-6fc7-4aa9-b050-3083183f4cd0/dirzip_Archive8035449106801616883.gar/]], closed=false, cpSpi=null, failSpi=null, loadSpi=null, usage=1, fullSup=false, subjId=301a4cb8-6fc7-4aa9-b050-3083183f4cd0, mapFut=IgniteFuture [orig=GridFutureAdapter [resFlag=0, res=null, startTime=1452789743739, endTime=0, ignoreInterrupts=false, lsnr=null, state=INIT]]]
at org.apache.ignite.internal.processors.task.GridTaskWorker.body(GridTaskWorker.java:497)
at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
at org.apache.ignite.internal.processors.task.GridTaskProcessor.startTask(GridTaskProcessor.java:678)
at org.apache.ignite.internal.processors.task.GridTaskProcessor.execute(GridTaskProcessor.java:447)
at org.apache.ignite.internal.IgniteComputeImpl.execute(IgniteComputeImpl.java:151)
at _03GarTest.main(_03GarTest.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Sven,
You should configure URI deployment SPI on client node as well to make GAR deployment work properly.
When you call compute.execute("taskName"); a lot of things have to be done locally on client prior to first request is sent to any of the node in your topology and after results start coming back. At least, Ignite should be able to get mapped jobs and be able to process results from all remote jobs and reduce all the results - please see ComputeTask.map() and ComputeTask.result() and ComputeTask.reduce(). So, you should be able to instantiate task on client node and that is why you should have task classes available.
I think after you configure URI deployment on client nodes you should have your code work fine.
Please post a comment here if you need any additional info.
Thanks!
UPDATE Jan, 18 2016
This is update in response to question update.
Please note that task in question returns null from map() method which is illegal. You can refer to org.apache.ignite.examples.computegrid.ComputeTaskMapExample in binary release or directly via https://git-wip-us.apache.org/repos/asf?p=ignite.git;a=blob;f=examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeTaskMapExample.java;h=3de5293a814e527b57e3984f6d3ab96bb1b62daf;hb=HEAD
I am new to Spring AMQP / Rabbit MQ.
Am using a Spring AMQP / Rabbit MQ in my project. I am facing following error after running a tomcat:
org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer
- Consumer raised exception, processing can restart if the connection factory supports it.
Exception summary: org.springframework.amqp.AmqpConnectException:
java.net.ConnectException: Connection refused: connect
Below is the configuration file :
spring-amqp.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit.xsd">
<rabbit:connection-factory id="connectionFactory" host="127.0.0.1"/>
<rabbit:admin connection-factory="connectionFactory"/>
<rabbit:template connection-factory="connectionFactory" id="rabbitTemplate" channel-transacted="true"/>
<rabbit:queue name="proposalQueue" />
<rabbit:listener-container connection-factory="connectionFactory">
<rabbit:listener ref="listener" queue-names="proposalQueue"/>
</rabbit:listener-container>
<bean id="rabbitMQTransactionManager" class="org.springframework.amqp.rabbit.transaction.RabbitTransactionManager">
<property name="connectionFactory" ref="connectionFactory"/>
</bean>
<rabbit:direct-exchange name="myExchange">
<rabbit:bindings>
<rabbit:binding queue="proposalQueue" key="userMesssage" />
</rabbit:bindings>
</rabbit:direct-exchange>
<bean id="listener" class="com.xxx.xxxx.rabbitmq.QueueServer"/>
</beans>
QueueServer.java
#Override
public void onMessage(Message message) {
Map<String, Object> result = new HashMap<>();
MessageProperties props = message.getMessageProperties();
BasicProperties replyProps = new BasicProperties.Builder().correlationId(new String(message.getMessageProperties().getCorrelationId())).build();
String inputParameterStr = new String(message.getBody());
try {
Map<String,Object> inputParameters = (Map<String, Object>) Utility.StringToObject(inputParameterStr, "java.util.Map");
result = service.createQueue(inputParameters);
} catch (ClassNotFoundException e) {
logger.error("Error :::: "+getClass()+proposalID, e);
result.put(Constants.FAILURE, e.getMessage());
} catch (Exception e) {
logger.error("Error :::: "+getClass()+proposalID, e);
result.put(Constants.FAILURE, e.getMessage());
}
}
Please help to resolve.
java.net.ConnectException: Connection refused: connect
That simply means that RabbitMQ is not running on localhost (127.0.0.1) on the standard port (5672).
Did you download and install/run RabbitMQ? It is not like ActiveMQ - it can't run embedded in a java application.
Check the host and port value
In application.properties
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
See RabbitMQ site is running on port 15672 whereas in code using amqp protocol.
There's one more aspect to the problem.
By default, the RabbitMQ is accessible to the local machine only. If you want to access it from some other machine, you generally create one entry in "rabbitmq.config" file. Location of this file varies from OS to OS. In Linux, you can find this at: "/etc/rabbitmq/rabbitmq.config" and in Windows machine, you can find it at: "C:\Program Files\RabbitMQ Server\rabbitmq_server-3.6.9\etc\rabbitmq.config".
There's a possibility that you don't find this file at the mentioned location. This is an optional file and you need not to worry if it is missing even. You can create your own. This entry is something like:
[{rabbit, [{tcp_listeners, [{"<IP_OF_MACHINE>", 5672}]},{loopback_users, []}]}].
With this, you can access the server from any remote machine.
If after this you get the server inaccessible you can modify the entry to:
[{rabbit, [{tcp_listeners, [{"0.0.0.0", 5672}]},{loopback_users, []}]}].
You will definitely get the server connected to any client as well as through management console (if plugin enabled)
i'm confronted the same problem (when using docker). Above answers didn't help me. I switched to a different version rabbitmq.
was:
rabbitmq:3.9.14-management-alpine
now:
rabbitmq:3.9.8-management-alpine
In order to access the RabbitMQ remote , you need to allow inbound TCP traffic on ports 4369, 25672, 5671, 5672, 15672, 61613, 61614, 1883, and 8883.
sudo firewall-cmd --zone=public --permanent --add-port=4369/tcp --add-port=25672/tcp --add-port=5671-5672/tcp --add-port=15672/tcp --add-port=61613-61614/tcp --add-port=1883/tcp --add-port=8883/tcp
sudo firewall-cmd --reload
I'm using a SimpleMessageListenerContainer as a basis for remoting over AMQP. Everything goes smooth provided that the RabbitMQ broker can be reached at process startup. However, if by any reason it can't be reached (network down, permissions problem, etc...) the container just keeps retrying to connect forever. How can I set up a retry behaviour in this case (for example, try at most 5 times with an exponential backoff and then abort, killing the process)? I've had a look at this, but it doesn't seem to work for me on container startup. Can anyone please shed some light?
At the very least, I'd like to be able to catch the exception and provide a log message, instead of printing the exception itself as is the default behaviour.
How can I set up a retry behaviour in this case
There is no sophisticated connection retry, just a simple recoveryInterval. The assumption is that the broker unavailability is temporary. Fatal errors (such as bad credentials) stop the container.
You could use some external process to try connectionFactory.createConnection() and stop() the SimpleMessageListenerContainer when you deem it's time to give up.
You could also subclass CachingConnectionFactory, override createBareConnection catch the exception and increment the recoveryInterval, then call stop() when you want.
EDIT
Since 1.5, you can now configure a backOff. Here's an example using Spring Boot...
#SpringBootApplication
public class RabbitBackOffApplication {
public static void main(String[] args) {
SpringApplication.run(RabbitBackOffApplication.class, args);
}
#Bean(name = "rabbitListenerContainerFactory")
public SimpleRabbitListenerContainerFactory simpleRabbitListenerContainerFactory(
SimpleRabbitListenerContainerFactoryConfigurer configurer,
ConnectionFactory connectionFactory) {
SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
configurer.configure(factory, connectionFactory);
BackOff recoveryBackOff = new FixedBackOff(5000, 3);
factory.setRecoveryBackOff(recoveryBackOff);
return factory;
}
#RabbitListener(queues = "foo")
public void listen(String in) {
}
}
and
2018-04-16 12:08:35.730 INFO 84850 --- [ main] com.example.RabbitBackOffApplication : Started RabbitBackOffApplication in 0.844 seconds (JVM running for 1.297)
2018-04-16 12:08:40.788 WARN 84850 --- [cTaskExecutor-1] o.s.a.r.l.SimpleMessageListenerContainer : Consumer raised exception, processing can restart if the connection factory supports it. Exception summary: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused (Connection refused)
2018-04-16 12:08:40.788 INFO 84850 --- [cTaskExecutor-1] o.s.a.r.l.SimpleMessageListenerContainer : Restarting Consumer#57abad67: tags=[{}], channel=null, acknowledgeMode=AUTO local queue size=0
2018-04-16 12:08:40.789 INFO 84850 --- [cTaskExecutor-2] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:1234]
2018-04-16 12:08:45.851 WARN 84850 --- [cTaskExecutor-2] o.s.a.r.l.SimpleMessageListenerContainer : Consumer raised exception, processing can restart if the connection factory supports it. Exception summary: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused (Connection refused)
2018-04-16 12:08:45.852 INFO 84850 --- [cTaskExecutor-2] o.s.a.r.l.SimpleMessageListenerContainer : Restarting Consumer#3479ea: tags=[{}], channel=null, acknowledgeMode=AUTO local queue size=0
2018-04-16 12:08:45.852 INFO 84850 --- [cTaskExecutor-3] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:1234]
2018-04-16 12:08:50.935 WARN 84850 --- [cTaskExecutor-3] o.s.a.r.l.SimpleMessageListenerContainer : Consumer raised exception, processing can restart if the connection factory supports it. Exception summary: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused (Connection refused)
2018-04-16 12:08:50.935 INFO 84850 --- [cTaskExecutor-3] o.s.a.r.l.SimpleMessageListenerContainer : Restarting Consumer#2be60f67: tags=[{}], channel=null, acknowledgeMode=AUTO local queue size=0
2018-04-16 12:08:50.936 INFO 84850 --- [cTaskExecutor-4] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:1234]
2018-04-16 12:08:50.938 WARN 84850 --- [cTaskExecutor-4] o.s.a.r.l.SimpleMessageListenerContainer : stopping container - restart recovery attempts exhausted