我正在连接到 GridGain 集群,并且在日志中不断看到以下错误,我还注意到客户端连接断开/重新连接的频率很高(尽管是平台的新手,但我不确定这是否是正常行为)。
[12:41:35,548][WARN][grid-nio-worker-0-#53%null%][GridTcpRestProtocol] 没有为 NIO 会话定义编组器,默认使用 PROTOBUF [ses=GridSelectorNioSessionImpl [selectorIdx=0, queueSize= 0, writeBuf=null, readBuf=null, super=GridNioSessionImpl [locAddr=/10.25.220.83:11211, rmtAddr=/1.144.94.10:49000, createTime=1398948095537, closeTime=0, bytesSent=0, bytesRcvd=1455, sndSchedTime= 1398948095537, lastSndTime=1398948095537, lastRcvTime=1398948095548, readsPaused=false, filterChain=FilterChain[filters=[GridNioCodecFilter [parser=GridTcpRestParser [jdkMarshaller=GridJdkMarshaller [], protobufMarshaller=org.gridgain.client.marshaller.protobuf.GridClientProtobufMarshaller@68ebf23e], directMode=false], 接受=true]]]
这是配置问题吗?如何定义编组器?下面是我的配置:
<?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-2.5.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<description>Main Spring file for grid configuration.</description>
<bean id="grid.cfg" class="org.gridgain.grid.GridConfiguration" scope="singleton">
<property name="peerClassLoadingEnabled" value="false"/>
<property name="localHost" value="10.25.220.83"/>
<!-- Cache configurations (all properties are optional). -->
<property name="cacheConfiguration">
<list>
<!-- Partitioned cache example configuration (Atomic mode). -->
<bean parent="cache-template">
<property name="name" value="partitioned"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="atomicityMode" value="ATOMIC"/>
<property name="distributionMode" value="PARTITIONED_ONLY"/>
<property name="backups" value="1"/>
</bean>
<!-- Partitioned cache example configuration (Transactional mode). -->
<bean parent="cache-template">
<property name="name" value="partitioned_tx"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="atomicityMode" value="TRANSACTIONAL"/>
<property name="distributionMode" value="NEAR_PARTITIONED"/>
<property name="backups" value="1"/>
</bean>
<!-- Replicated cache example configuration (Atomic mode). -->
<bean parent="cache-template">
<property name="name" value="replicated"/>
<property name="cacheMode" value="REPLICATED"/>
<property name="atomicityMode" value="ATOMIC"/>
</bean>
<!-- Replicated cache example configuration (Transactional mode). -->
<bean parent="cache-template">
<property name="name" value="replicated_tx"/>
<property name="cacheMode" value="REPLICATED"/>
<property name="atomicityMode" value="TRANSACTIONAL"/>
</bean>
</list>
</property>
<property name="discoverySpi">
<bean class="org.gridgain.grid.spi.discovery.tcp.GridTcpDiscoverySpi">
<property name="ipFinder">
<bean class="org.gridgain.grid.spi.discovery.tcp.ipfinder.vm.GridTcpDiscoveryVmIpFinder">
<property name="addresses">
<list>
<value>10.25.220.83:47500</value>
<value>10.25.240.87:47500</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
</bean>
<!-- Template for all example cache configurations. -->
<bean id="cache-template" abstract="true" class="org.gridgain.grid.cache.GridCacheConfiguration">
<property name="preloadMode" value="ASYNC"/>
<property name="preloadBatchSize" value="#{2 * 1024 * 1024}"/>
<property name="preloadThrottle" value="100"/>
<property name="startSize" value="3000000"/>
<property name="name" value="partitioned"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="atomicityMode" value="ATOMIC"/>
<property name="writeSynchronizationMode" value="FULL_ASYNC"/>
<property name="distributionMode" value="PARTITIONED_ONLY"/>
<property name="queryIndexEnabled" value="false"/>
<property name="backups" value="1"/>
</bean>
</beans>
我正在使用来自 C# 4.5 控制台应用程序的以下客户端代码。
static void Main(string[] args)
{
// Create a GridGain Client
var ggClient = CreateClient();
Console.WriteLine("GridGain Connected");
ggCache = ggClient.Data("partitioned");
ggCompute = ggClient.Compute();
ggCache.Put<string, byte[]>("test", new byte[] { 0, 1, 2, 3, 4 });
GridClientFactory.StopAll();
}
private static IGridClientData ggCache;
private static IGridClientCompute ggCompute;
/**
* <summary>
* This method will create a client with default configuration. Note that this method expects that
* first node will bind rest binary protocol on default port. It also expects that partitioned cache is
* configured in grid.</summary>
*
* <returns>Client instance.</returns>
* <exception cref="GridClientException">If client could not be created.</exception>
*/
private static IGridClient CreateClient()
{
var cacheCfg = new GridClientDataConfiguration();
// Set remote cache name.
cacheCfg.Name = "partitioned";
// Set client partitioned affinity for this cache.
cacheCfg.Affinity = new GridClientPartitionAffinity();
var cfg = new GridClientConfiguration();
cfg.IsTopologyCacheEnabled = true;
cfg.DataConfigurations.Add(cacheCfg);
// Point client to a local node. Note that this server is only used
// for initial connection. After having established initial connection
// client will make decisions which grid node to use based on collocation
// with key affinity or load balancing.
cfg.Servers.Add("127.0.0.1" + ':' + GridClientConfiguration.DefaultTcpPort);
cfg.Routers.Add("127.1.0.1" + ':' + GridClientConfiguration.DefaultTcpPort);
// cfg.Servers.Add("127.2.0.1" + ':' + GridClientConfiguration.DefaultTcpPort);
var client = GridClientFactory.Start(cfg);
return client;
}