GridGain + .NET客户端连接警告/丢失

时间:2014-05-01 13:32:35

标签: .net gridgain

我正在连接到GridGain Cluster并且我在日志中看到以下错误,我也注意到客户端连接频繁丢弃/重新连接(虽然对于平台来说是新手,但我不确定这是否是正常行为)。

  

[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],accepted = 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>

<?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;

}

1 个答案:

答案 0 :(得分:1)

从GridGain版本6.2.0-rc2开始,GridGain添加了Portable Object功能,该功能显着增强了C ++和.NET功能并修复了连接问题。

使用Portable Objects,您可以:

  1. 将对象存储在.NET中并使用Java或C ++进行检索(反之亦然)
  2. 动态更改客户端的类结构,而无需重新启动服务器。
  3. 从缓存中检索可移植对象而不反序列化到类中,并按名称获取所需的字段。
  4. 便携式对象的示例可用于企业版下载。