내가 사용 HTTP 세션을 clusterize하기 위해 노력하고있어를 사용하여 Hazelcast-WM을 구성하는 방법 hazelcast-WM 3.0, hazelcast 스프링 3.0, 봄 3.2.2 및 서블릿 API 3.0 .시스템 등록 및 봄
web.xml에 :
<listener>
<listener-class>com.company.PropertiesListener</listener-class>
</listener>
...
<filter>
<filter-name>hazelcast-filter</filter-name>
<filter-class>com.hazelcast.web.WebFilter</filter-class>
<!-- Name of the distributed map storing your web session objects -->
<init-param>
<param-name>map-name</param-name>
<param-value>my-sessions</param-value>
</init-param>
<!-- How is your load-balancer configured? stick-session means all requests
of a session is routed to the node where the session is first created. This
is excellent for performance. If sticky-session is set to false, when a session
is updated on a node, entry for this session on all other nodes is invalidated.
You have to know how your load-balancer is configured before setting this
parameter. Default is true. -->
<init-param>
<param-name>sticky-session</param-name>
<param-value>false</param-value>
</init-param>
<!-- Name of session id cookie -->
<init-param>
<param-name>cookie-name</param-name>
<param-value>hazelcast.sessionId</param-value>
</init-param>
<!-- Should cookie only be sent using a secure protocol? Default is false. -->
<init-param>
<param-name>cookie-secure</param-name>
<param-value>false</param-value>
</init-param>
<!-- Should HttpOnly attribute be set on cookie ? Default is false. -->
<init-param>
<param-name>cookie-http-only</param-name>
<param-value>false</param-value>
</init-param>
<!-- Are you debugging? Default is false. -->
<init-param>
<param-name>debug</param-name>
<param-value>false</param-value>
</init-param>
<!-- Configuration xml location; * as servlet resource OR * as classpath
resource OR * as URL Default is one of hazelcast-default.xml or hazelcast.xml
in classpath. -->
<init-param>
<param-name>config-location</param-name>
<param-value>hazelcast-context.xml</param-value>
</init-param>
<!-- Do you want to use an existing HazelcastInstance? Default is null. -->
<init-param>
<param-name>instance-name</param-name>
<param-value>hz.session.instance</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>hazelcast-filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<listener>
<listener-class>com.hazelcast.web.SessionListener</listener-class>
</listener>
hazelcast-context.xml에 PropertiesListener가 System.properties 설정
<hz:hazelcast id="hz.session.cluster" depends-on="hazelcast.properties">
<hz:config>
<hz:instance-name>hz.session.instance</hz:instance-name>
<hz:group name="${cluster.name:my-sessions}" password="${cluster.password:mypass}" />
<hz:properties>
<hz:property name="hazelcast.logging.type">slf4j</hz:property>
<hz:property name="hazelcast.version.check.enabled">false</hz:property>
<hz:property name="hazelcast.jmx">true</hz:property>
</hz:properties>
<hz:network port="${cluster.network.port:5701}"
public-address="${cluster.member.address:127.0.0.1}"
port-auto-increment="${cluster.network.port-auto-increment:true}">
<hz:join>
<hz:multicast enabled="${cluster.network.multicast.enabled:false}"
multicast-group="${cluster.network.multicast.group:224.2.2.3}"
multicast-port="${cluster.network.multicast.port:54327}" />
<hz:tcp-ip enabled="${cluster.network.tcpip:true}">
<hz:members>${cluster.members:127.0.0.1}</hz:members>
</hz:tcp-ip>
</hz:join>
</hz:network>
</hz:config>
</hz:hazelcast>
: cluster.members, cluster.member.address 등, 따라서 어디에서 실행 중인지 확인하십시오. 나는 응용 프로그램의 스프링 컨텍스트를 사용하여 hazelcast 인스턴스를 만드는 경우
, 그것은 잘 작동 :
@Configuration
@ImportResource("classpath:hazelcast-context.xml")
public class HazelcastConfig {
}
을 그것은 좋은 작품 ! Hazelcast 인스턴스가 올바른 네트워크 인터페이스에 바인딩되어 있습니다. .
Oct 13, 2013 9:09:28 PM com.hazelcast.config.UrlXmlConfig
INFO: Configuring Hazelcast from 'file:/home/neuquino/springsource/vfabric-tc-server-developer-2.9.2.RELEASE/my-app/wtpwebapps/my-app-web/WEB-INF/classes/hazelcast-context.xml'.
Oct 13, 2013 9:09:28 PM com.hazelcast.config.XmlConfigBuilder
WARNING: Could not find a value for property 'cluster.name:my-sessions' on node: null
Oct 13, 2013 9:09:28 PM com.hazelcast.config.XmlConfigBuilder
WARNING: Could not find a value for property 'cluster.password:mypass' on node: null
Oct 13, 2013 9:09:28 PM com.hazelcast.config.XmlConfigBuilder
WARNING: Could not find a value for property 'cluster.network.port:5701' on node: null
Oct 13, 2013 9:09:28 PM com.hazelcast.config.XmlConfigBuilder
WARNING: Could not find a value for property 'cluster.network.port-auto-increment:true' on node: null
Oct 13, 2013 9:09:28 PM com.hazelcast.config.XmlConfigBuilder
WARNING: Could not find a value for property 'cluster.member.address:127.0.0.1' on node: null
Oct 13, 2013 9:09:28 PM com.hazelcast.config.XmlConfigBuilder
WARNING: Could not find a value for property 'cluster.network.multicast.enabled:false' on node: null
Oct 13, 2013 9:09:28 PM com.hazelcast.config.XmlConfigBuilder
WARNING: Could not find a value for property 'cluster.network.multicast.group:224.2.2.3' on node: null
Oct 13, 2013 9:09:28 PM com.hazelcast.config.XmlConfigBuilder
WARNING: Could not find a value for property 'cluster.network.multicast.port:54327' on node: null
Oct 13, 2013 9:09:28 PM com.hazelcast.config.XmlConfigBuilder
WARNING: Could not find a value for property 'cluster.network.tcpip:true' on node: null
Oct 13, 2013 9:09:28 PM com.hazelcast.config.XmlConfigBuilder
WARNING: Could not find a value for property 'cluster.members:127.0.0.1' on node: null
Oct 13, 2013 9:09:29 PM com.hazelcast.instance.DefaultAddressPicker
INFO: Prefer IPv4 stack is true.
Oct 13, 2013 9:09:29 PM com.hazelcast.instance.DefaultAddressPicker
INFO: Picked Address[10.8.254.133]:5701, using socket ServerSocket[addr=/0:0:0:0:0:0:0:0,localport=5701], bind any local is true
Oct 13, 2013 9:09:29 PM com.hazelcast.system
INFO: [10.8.254.133]:5701 [dev] Hazelcast Community Edition 3.0.2 (20130906) starting at Address[10.8.254.133]:5701
Oct 13, 2013 9:09:29 PM com.hazelcast.system
INFO: [10.8.254.133]:5701 [dev] Copyright (C) 2008-2013 Hazelcast.com
Oct 13, 2013 9:09:29 PM com.hazelcast.instance.Node
INFO: [10.8.254.133]:5701 [dev] Creating MulticastJoiner
Oct 13, 2013 9:09:29 PM com.hazelcast.core.LifecycleService
INFO: [10.8.254.133]:5701 [dev] Address[10.8.254.133]:5701 is STARTING
Oct 13, 2013 9:09:34 PM com.hazelcast.cluster.MulticastJoiner
INFO: [10.8.254.133]:5701 [dev]
Members [1] {
Member [10.8.254.133]:5701 this
}
Oct 13, 2013 9:09:34 PM com.hazelcast.core.LifecycleService
INFO: [10.8.254.133]:5701 [dev] Address[10.8.254.133]:5701 is STARTED
올바른을 :
하지만 이전 (웹 필터를 사용할 때 문제가, 내가 HazelcastConfig 클래스를 삭제 그래서 두 번 Hazelcast 인스턴스를 만들 수 없습니다
를이 로그에 표시되는 메시지입니다 IP는 11.1.0.133 ($ {cluster.member.address} 값)이어야합니다. Hazelcast는 내 PC의 네트워크 인터페이스 중 하나를 선택하지만 $ {cluster.member.address} 값을 사용하지 않습니다.
어떻게해야합니까? 시스템 등록 정보로 WebFilter를 사용합니까?
미리 감사드립니다.