connection not getting established between hazelcast client and hazelcast server - hazelcast

The client and server configs for hazelcast v3.6 are copied below. I can run the server (listening on 127.0.0.1:5706)
I get the following error on the hazelcast client side:
[warn] c.h.c.c.n.ClientConnection - Connection [/127.0.0.1:5701] lost. Reason: java.lang.NullPointerException[null]
[warn] c.h.c.s.i.ClusterListenerSupport - Unable to get alive cluster connection, try in 2986 ms later, attempt 1 of 2.
hazelcast-client.xml
<?xml version="1.0" encoding="UTF-8"?>
<hazelcast-client xsi:schemaLocation="http://www.hazelcast.com/schema/client-config hazelcast-client-config-3.6.xsd"
xmlns="http://www.hazelcast.com/schema/client-config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<group>
<name>dev</name>
<password>dev-pass</password>
</group>
<properties>
<property name="hazelcast.client.shuffle.member.list">true</property>
<property name="hazelcast.client.heartbeat.timeout">60000</property>
<property name="hazelcast.client.heartbeat.interval">5000</property>
<property name="hazelcast.client.event.thread.count">5</property>
<property name="hazelcast.client.event.queue.capacity">1000000</property>
<property name="hazelcast.client.invocation.timeout.seconds">120</property>
</properties>
<network>
<cluster-members>
<address>127.0.0.1:5701</address>
<!-- <address>0.0.0.0</address> -->
</cluster-members>
<smart-routing>true</smart-routing>
<redo-operation>true</redo-operation>
<connection-timeout>60000</connection-timeout>
<connection-attempt-period>3000</connection-attempt-period>
<connection-attempt-limit>2</connection-attempt-limit>
<socket-options>
<tcp-no-delay>false</tcp-no-delay>
<keep-alive>true</keep-alive>
<reuse-address>true</reuse-address>
<linger-seconds>3</linger-seconds>
<timeout>-1</timeout>
<buffer-size>32</buffer-size>
</socket-options>
<socket-interceptor enabled="false">
<class-name>com.hazelcast.examples.MySocketInterceptor</class-name>
<properties>
<property name="foo">bar</property>
</properties>
</socket-interceptor>
<ssl enabled="false">
<factory-class-name>com.hazelcast.examples.MySslFactory</factory-class-name>
</ssl>
<aws enabled="false" connection-timeout-seconds="11">
<inside-aws>true</inside-aws>
<access-key>TEST_ACCESS_KEY</access-key>
<secret-key>TEST_SECRET_KEY</secret-key>
<region>us-east-1</region>
<host-header>ec2.amazonaws.com</host-header>
<security-group-name>hazelcast-sg</security-group-name>
<tag-key>type</tag-key>
<tag-value>hz-nodes</tag-value>
</aws>
</network>
<executor-pool-size>40</executor-pool-size> <!-- reduce the pool size after profiling -->
<security>
<credentials>com.hazelcast.security.UsernamePasswordCredentials</credentials>
</security>
<listeners>
<!--<listener>com.hazelcast.examples.MembershipListener</listener>
<listener>com.hazelcast.examples.InstanceListener</listener>
<listener>com.hazelcast.examples.MigrationListener</listener>
-->
</listeners>
<!-- change to kryo -->
<!-- <serialization>
<portable-version>3</portable-version>
<use-native-byte-order>true</use-native-byte-order>
<byte-order>BIG_ENDIAN</byte-order>
<enable-compression>false</enable-compression>
<enable-shared-object>true</enable-shared-object>
<allow-unsafe>false</allow-unsafe>
<data-serializable-factories>
<data-serializable-factory factory-id="1">com.hazelcast.examples.DataSerializableFactory
</data-serializable-factory>
</data-serializable-factories>
<portable-factories>
<portable-factory factory-id="2">com.hazelcast.examples.PortableFactory</portable-factory>
</portable-factories>
<serializers>
<global-serializer>com.hazelcast.examples.GlobalSerializerFactory</global-serializer>
<serializer type-class="com.hazelcast.examples.DummyType"
class-name="com.hazelcast.examples.SerializerFactory"/>
</serializers>
<check-class-def-errors>true</check-class-def-errors>
</serialization>
-->
<native-memory enabled="false" allocator-type="POOLED">
<size unit="MEGABYTES" value="128" />
<min-block-size>1</min-block-size>
<page-size>1</page-size>
<metadata-space-percentage>40.5</metadata-space-percentage>
</native-memory>
<!--
<proxy-factories>
<proxy-factory class-name="com.hazelcast.examples.ProxyXYZ1" service="sampleService1"/>
<proxy-factory class-name="com.hazelcast.examples.ProxyXYZ2" service="sampleService1"/>
<proxy-factory class-name="com.hazelcast.examples.ProxyXYZ3" service="sampleService3"/>
</proxy-factories>
-->
<load-balancer type="random"/>
<!--
Beware that near-cache eviction configuration is different for NATIVE in-memory format.
Proper eviction configuration example for NATIVE in-memory format :
`<eviction max-size-policy="USED_NATIVE_MEMORY_SIZE" eviction-policy="LFU" size="60"/>`
-->
<!-- <near-cache name="default">
<max-size>2000</max-size>
<time-to-live-seconds>90</time-to-live-seconds>
<max-idle-seconds>100</max-idle-seconds>
<eviction-policy>LFU</eviction-policy>
<invalidate-on-change>true</invalidate-on-change>
<in-memory-format>OBJECT</in-memory-format>
<local-update-policy>INVALIDATE</local-update-policy>
</near-cache>
-->
<!--
<query-caches>
<query-cache name="query-cache-name" mapName="map-name">
<predicate type="class-name">com.hazelcast.examples.ExamplePredicate</predicate>
<entry-listeners>
<entry-listener include-value="true" local="false">com.hazelcast.examples.EntryListener</entry-listener>
</entry-listeners>
<include-value>true</include-value>
<batch-size>1</batch-size>
<buffer-size>16</buffer-size>
<delay-seconds>0</delay-seconds>
<in-memory-format>BINARY</in-memory-format>
<coalesce>false</coalesce>
<populate>true</populate>
<eviction eviction-policy="LRU" max-size-policy="ENTRY_COUNT" size="10000"/>
<indexes>
<index ordered="false">name</index>
</indexes>
</query-cache>
</query-caches>
-->
</hazelcast-client>
hazelcast server
here is the console message on the server and server config file:
console message
INFO: [127.0.0.1]:5701 [dev] [3.6] Established socket connection between /127.0.1.1:5701 and /127.0.0.1:47301
Mar 10, 2016 12:01:48 PM com.hazelcast.nio.tcp.TcpIpConnection
INFO: [127.0.0.1]:5701 [dev] [3.6] Connection [/127.0.0.1:47301] lost. Reason: java.io.EOFException[Remote socket closed!]
hazelcast.xml (server)
<?xml version="1.0" encoding="UTF-8"?>
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.6.xsd"
xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<group>
<name>dev</name>
<password>dev-pass</password>
</group>
<network>
<port auto-increment="true" port-count="100">5701</port>
<outbound-ports>
<ports>0-5900</ports>
</outbound-ports>
<join>
<multicast enabled="false">
<!--<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>-->
</multicast>
<tcp-ip enabled="true">
<member>127.0.0.1</member>
</tcp-ip>
</join>
<interfaces enabled="true">
<interface>127.0.0.1</interface>
</interfaces>
<ssl enabled="false" />
<socket-interceptor enabled="false" />
<symmetric-encryption enabled="false">
<algorithm>PBEWithMD5AndDES</algorithm>
<!-- salt value to use when generating the secret key -->
<salt>thesalt</salt>
<!-- pass phrase to use when generating the secret key -->
<password>thepass</password>
<!-- iteration count to use when generating the secret key -->
<iteration-count>19</iteration-count>
</symmetric-encryption>
</network>
<partition-group enabled="false"/>
<executor-service name="default">
<pool-size>16</pool-size>
<!--Queue capacity. 0 means Integer.MAX_VALUE.-->
<queue-capacity>0</queue-capacity>
</executor-service>
<map name="userMap">
<async-backup-count>1</async-backup-count>
<near-cache>
<max-size>5000</max-size>
<invalidate-on-change>true</invalidate-on-change>
</near-cache>
<map-store enabled="false">
<class-name></class-name>
<write-delay-seconds>0</write-delay-seconds>
</map-store>
</map>
</hazelcast>
Client code
ClientConfig clientConfig = new XmlClientConfigBuilder().build(); //the xml file is being loaded
HazelcastInstance hazelcastClient = HazelcastClient.newHazelcastClient(clientConfig);
I do not have a firewall running on my computer. Any thoughts on what I may have misconfigured?
Update:
I am able to connect when i specify the ip address programmatically so I am assuming the issue is either with my client config or how I am readig it:
ClientCOnfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().addAddress("127.0.0.1");
HazelcastInstance hcastClient = HazelcastClient.newHazelcastClient(clientConfig);

The issue was caused by the following line in the client config xml file:
<security>
<credentials>com.hazelcast.security.UsernamePasswordCredentials</credentials>
</security>
Once this was commented out, the client was able to connect to the server. I will update once I gather more information regarding its usage.
Only seems to be available in enterprise edition, not the community one but ideally, it should have either let the connection establish or generate a meaningful error message.

Related

unable to connect hazzelcast IMDG locally from .net hazelcast client

I have downloaded the hazelcast locally. but when i am trying to connect it from .net client it does not get connected.
below exception is shown in console of Hazecast.
om.hazelcast.internal.nio.tcp.TcpIpConnection
WARNING: [10.253.200.102]:5701 [dev] [4.0.1] Connection[id=7, /10.253.200.102:5701->/10.253.200.102:56020, qualifier=null, endpoint=null, alive=false, connectionType=NONE] closed. Reason: Exception in Connection[id=7, /10.253.200.102:5701->/10.253.200.102:56020, qualifier=null, endpoint=null, alive=true, connectionType=NONE], thread=hz.epic_northcutt.IO.thread-in-0
java.lang.IllegalStateException: Unknown protocol: CB2
at com.hazelcast.internal.nio.tcp.UnifiedProtocolDecoder.onRead(UnifiedProtocolDecoder.java:116)
at com.hazelcast.internal.networking.nio.NioInboundPipeline.process(NioInboundPipeline.java:137)
at com.hazelcast.internal.networking.nio.NioThread.processSelectionKey(NioThread.java:382)
at com.hazelcast.internal.networking.nio.NioThread.processSelectionKeys(NioThread.java:367)
at com.hazelcast.internal.networking.nio.NioThread.selectLoop(NioThread.java:293)
at com.hazelcast.internal.networking.nio.NioThread.run(NioThread.java:248)
enter image description here
**Default Hazelcast Config file:**
<hazelcast xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hazelcast.com/schema/config
http://www.hazelcast.com/schema/config/hazelcast-config-4.0.xsd">
<cluster-name>dev</cluster-name>
<network>
<port auto-increment="true" port-count="100">5701</port>
<outbound-ports>
<!--
Allowed port range when connecting to other nodes.
0 or * means use system provided port.
-->
<ports>0</ports>
</outbound-ports>
<join>
<multicast enabled="true">
<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>
</multicast>
<tcp-ip enabled="false">
<interface>127.0.0.1</interface>
<member-list>
<member>127.0.0.1</member>
</member-list>
</tcp-ip>
<aws enabled="false">
<access-key>my-access-key</access-key>
<secret-key>my-secret-key</secret-key>
<!--optional, default is us-east-1 -->
<region>us-west-1</region>
<!--optional, default is ec2.amazonaws.com. If set, region shouldn't be set as it will override this property -->
<host-header>ec2.amazonaws.com</host-header>
<!-- optional, only instances belonging to this group will be discovered, default will try all running instances -->
<security-group-name>hazelcast-sg</security-group-name>
<tag-key>type</tag-key>
<tag-value>hz-nodes</tag-value>
</aws>
<gcp enabled="false">
<zones>us-east1-b,us-east1-c</zones>
</gcp>
<azure enabled="false">
<client-id>CLIENT_ID</client-id>
<client-secret>CLIENT_SECRET</client-secret>
<tenant-id>TENANT_ID</tenant-id>
<subscription-id>SUB_ID</subscription-id>
<cluster-id>HZLCAST001</cluster-id>
<group-name>RESOURCE-GROUP-NAME</group-name>
</azure>
<kubernetes enabled="false">
<namespace>MY-KUBERNETES-NAMESPACE</namespace>
<service-name>MY-SERVICE-NAME</service-name>
<service-label-name>MY-SERVICE-LABEL-NAME</service-label-name>
<service-label-value>MY-SERVICE-LABEL-VALUE</service-label-value>
</kubernetes>
<eureka enabled="false">
<self-registration>true</self-registration>
<namespace>hazelcast</namespace>
</eureka>
<discovery-strategies>
</discovery-strategies>
</join>
<interfaces enabled="false">
<interface>10.10.1.*</interface>
</interfaces>
<ssl enabled="false"/>
<socket-interceptor enabled="false"/>
<symmetric-encryption enabled="false">
<!--
encryption algorithm such as
DES/ECB/PKCS5Padding,
PBEWithMD5AndDES,
AES/CBC/PKCS5Padding,
Blowfish,
DESede
-->
<algorithm>PBEWithMD5AndDES</algorithm>
<!-- salt value to use when generating the secret key -->
<salt>thesalt</salt>
<!-- pass phrase to use when generating the secret key -->
<password>thepass</password>
<!-- iteration count to use when generating the secret key -->
<iteration-count>19</iteration-count>
</symmetric-encryption>
<failure-detector>
<icmp enabled="false"/>
</failure-detector>
</network>
<partition-group enabled="false"/>
<executor-service name="default">
<pool-size>16</pool-size>
<!--Queue capacity. 0 means Integer.MAX_VALUE.-->
<queue-capacity>0</queue-capacity>
</executor-service>
<security>
<client-block-unmapped-actions>true</client-block-unmapped-actions>
</security>
<queue name="default">
<!--
Maximum size of the queue. When a JVM's local queue size reaches the maximum,
all put/offer operations will get blocked until the queue size
of the JVM goes down below the maximum.
Any integer between 0 and Integer.MAX_VALUE. 0 means
Integer.MAX_VALUE. Default is 0.
-->
<max-size>0</max-size>
<!--
Number of backups. If 1 is set as the backup-count for example,
then all entries of the map will be copied to another JVM for
fail-safety. 0 means no backup.
-->
<backup-count>1</backup-count>
<!--
Number of async backups. 0 means no backup.
-->
<async-backup-count>0</async-backup-count>
<empty-queue-ttl>-1</empty-queue-ttl>
<merge-policy batch-size="100">com.hazelcast.spi.merge.PutIfAbsentMergePolicy</merge-policy>
</queue>
<map name="default">
<!--
Data type that will be used for storing recordMap.
Possible values:
BINARY (default): keys and values will be stored as binary data
OBJECT : values will be stored in their object forms
NATIVE : values will be stored in non-heap region of JVM
-->
<in-memory-format>BINARY</in-memory-format>
<!--
Metadata creation policy for this map. Hazelcast may process objects of supported types ahead of time to
create additional metadata about them. This metadata then is used to make querying and indexing faster.
Metadata creation may decrease put throughput.
Valid values are:
CREATE_ON_UPDATE (default): Objects of supported types are pre-processed when they are created and updated.
OFF: No metadata is created.
-->
<metadata-policy>CREATE_ON_UPDATE</metadata-policy>
<!--
Number of backups. If 1 is set as the backup-count for example,
then all entries of the map will be copied to another JVM for
fail-safety. 0 means no backup.
-->
<backup-count>1</backup-count>
<!--
Number of async backups. 0 means no backup.
-->
<async-backup-count>0</async-backup-count>
<!--
Maximum number of seconds for each entry to stay in the map. Entries that are
older than <time-to-live-seconds> and not updated for <time-to-live-seconds>
will get automatically evicted from the map.
Any integer between 0 and Integer.MAX_VALUE. 0 means infinite. Default is 0
-->
<time-to-live-seconds>0</time-to-live-seconds>
<!--
Maximum number of seconds for each entry to stay idle in the map. Entries that are
idle(not touched) for more than <max-idle-seconds> will get
automatically evicted from the map. Entry is touched if get, put or containsKey is called.
Any integer between 0 and Integer.MAX_VALUE. 0 means infinite. Default is 0.
-->
<max-idle-seconds>0</max-idle-seconds>
<eviction eviction-policy="NONE" max-size-policy="PER_NODE" size="0"/>
<!--
While recovering from split-brain (network partitioning),
map entries in the small cluster will merge into the bigger cluster
based on the policy set here. When an entry merge into the
cluster, there might an existing entry with the same key already.
Values of these entries might be different for that same key.
Which value should be set for the key? Conflict is resolved by
the policy set here. Default policy is PutIfAbsentMapMergePolicy
There are built-in merge policies such as
com.hazelcast.spi.merge.PassThroughMergePolicy; entry will be overwritten if merging entry exists for the key.
com.hazelcast.spi.merge.PutIfAbsentMergePolicy ; entry will be added if the merging entry doesn't exist in the cluster.
com.hazelcast.spi.merge.HigherHitsMergePolicy ; entry with the higher hits wins.
com.hazelcast.spi.merge.LatestUpdateMergePolicy ; entry with the latest update wins.
-->
<merge-policy batch-size="100">com.hazelcast.spi.merge.PutIfAbsentMergePolicy</merge-policy>
<!--
Control caching of de-serialized values. Caching makes query evaluation faster, but it cost memory.
Possible Values:
NEVER: Never cache deserialized object
INDEX-ONLY: Caches values only when they are inserted into an index.
ALWAYS: Always cache deserialized values.
-->
<cache-deserialized-values>INDEX-ONLY</cache-deserialized-values>
</map>
<multimap name="default">
<backup-count>1</backup-count>
<value-collection-type>SET</value-collection-type>
<merge-policy batch-size="100">com.hazelcast.spi.merge.PutIfAbsentMergePolicy</merge-policy>
</multimap>
<replicatedmap name="default">
<in-memory-format>OBJECT</in-memory-format>
<async-fillup>true</async-fillup>
<statistics-enabled>true</statistics-enabled>
<merge-policy batch-size="100">com.hazelcast.spi.merge.PutIfAbsentMergePolicy</merge-policy>
</replicatedmap>
<list name="default">
<backup-count>1</backup-count>
<merge-policy batch-size="100">com.hazelcast.spi.merge.PutIfAbsentMergePolicy</merge-policy>
</list>
<set name="default">
<backup-count>1</backup-count>
<merge-policy batch-size="100">com.hazelcast.spi.merge.PutIfAbsentMergePolicy</merge-policy>
</set>
<reliable-topic name="default">
<read-batch-size>10</read-batch-size>
<topic-overload-policy>BLOCK</topic-overload-policy>
<statistics-enabled>true</statistics-enabled>
</reliable-topic>
<ringbuffer name="default">
<capacity>10000</capacity>
<backup-count>1</backup-count>
<async-backup-count>0</async-backup-count>
<time-to-live-seconds>0</time-to-live-seconds>
<in-memory-format>BINARY</in-memory-format>
<merge-policy batch-size="100">com.hazelcast.spi.merge.PutIfAbsentMergePolicy</merge-policy>
</ringbuffer>
<flake-id-generator name="default">
<prefetch-count>100</prefetch-count>
<prefetch-validity-millis>600000</prefetch-validity-millis>
<epoch-start>1514764800000</epoch-start>
<node-id-offset>0</node-id-offset>
<bits-sequence>6</bits-sequence>
<bits-node-id>16</bits-node-id>
<allowed-future-millis>15000</allowed-future-millis>
<statistics-enabled>true</statistics-enabled>
</flake-id-generator>
<serialization>
<portable-version>0</portable-version>
</serialization>
<lite-member enabled="false"/>
<cardinality-estimator name="default">
<backup-count>1</backup-count>
<async-backup-count>0</async-backup-count>
<merge-policy batch-size="100">HyperLogLogMergePolicy</merge-policy>
</cardinality-estimator>
<scheduled-executor-service name="default">
<capacity>100</capacity>
<durability>1</durability>
<pool-size>16</pool-size>
<merge-policy batch-size="100">com.hazelcast.spi.merge.PutIfAbsentMergePolicy</merge-policy>
</scheduled-executor-service>
<crdt-replication>
<replication-period-millis>1000</replication-period-millis>
<max-concurrent-replication-targets>1</max-concurrent-replication-targets>
</crdt-replication>
<pn-counter name="default">
<replica-count>2147483647</replica-count>
<statistics-enabled>true</statistics-enabled>
</pn-counter>
<cp-subsystem>
<cp-member-count>0</cp-member-count>
<group-size>0</group-size>
<session-time-to-live-seconds>300</session-time-to-live-seconds>
<session-heartbeat-interval-seconds>5</session-heartbeat-interval-seconds>
<missing-cp-member-auto-removal-seconds>14400</missing-cp-member-auto-removal-seconds>
<fail-on-indeterminate-operation-state>false</fail-on-indeterminate-operation-state>
<raft-algorithm>
<leader-election-timeout-in-millis>2000</leader-election-timeout-in-millis>
<leader-heartbeat-period-in-millis>5000</leader-heartbeat-period-in-millis>
<max-missed-leader-heartbeat-count>5</max-missed-leader-heartbeat-count>
<append-request-max-entry-count>100</append-request-max-entry-count>
<commit-index-advance-count-to-snapshot>10000</commit-index-advance-count-to-snapshot>
<uncommitted-entry-count-to-reject-new-appends>100</uncommitted-entry-count-to-reject-new-appends>
<append-request-backoff-timeout-in-millis>100</append-request-backoff-timeout-in-millis>
</raft-algorithm>
</cp-subsystem>
<metrics enabled="true">
<management-center enabled="true">
<retention-seconds>5</retention-seconds>
</management-center>
<jmx enabled="true"/>
<collection-frequency-seconds>5</collection-frequency-seconds>
</metrics>
</hazelcast>
**Client Code:**
using Hazelcast.Client;
using Hazelcast.Config;
using Hazelcast.Core;
using System;
namespace HazelCastClientApp1
{
public class HazelcastClientFactory
{
static IHazelcastInstance client;
public static IHazelcastInstance GetClient()
{
if (client == null)
{
InitializeClient();
}
return client;
}
private static void InitializeClient()
{
var cfg = new ClientConfig();
var hazelcastUrl = "127.0.0.1:5701";
cfg.GetNetworkConfig().AddAddress(hazelcastUrl);
client = HazelcastClient.NewHazelcastClient(cfg);
Console.WriteLine("Local address : {0}", client.GetLocalEndpoint().GetSocketAddress());
Console.ReadKey();
}
}
}
The [4.0.1] and Unknown protocol: CB2 mentions in the error messages indicate that you are trying to connect a v3 client to a v4 server. The v3 client does not support v4 servers. Please ensure that you are using compatible client and server.

cluster event bus consumer not getting the message

I have two services(HttpServer and a Consumer) running on two different servers.
I am using Hazelcast for clustering.
Here is my code :
public class SampleRestService extends StartVerticle {
#Override
public void start() {
Router router = Router.router(vertx);
router.route().handler(BodyHandler.create());
router.post("/subscribe").handler(this::handleSubscription);
vertx.createHttpServer().requestHandler(router::accept).listen(9001);
}
public void handleSubscription(RoutingContext routingContext) {
System.out.println("sending to event bus");
vertx.eventBus().send("myserviceadd", routingContext.request().path(), ar -> {
if (ar.succeeded()) {
//req.response().setStatusCode(200).write(result.result().body()).end();
System.out.println("received response from event bus");
routingContext.response().setStatusCode(200).end("myhttp-response" + ar.result().body() + " ** " + routingContext.request().path());
} else if(ar.failed()) {
System.out.println(" response from event bus is failed");
ar.cause().printStackTrace();
routingContext.response().setStatusCode(500).end("failed to subscribeS");
}
});
}
}
Consumer Code :
public class SampleRestComsumer extends SampleConsumerParent {
#Override
public void start() {
vertx.eventBus().consumer("myserviceadd", message -> {
System.out.println("Recevied message: " + message.body());
message.reply(new JsonObject().put("responseCode", "OK").put("message", "This is your response to your event"));
});
}
}
Here is my cluster.xml
<?xml version="1.0" encoding="UTF-8"?>
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config
hazelcast-config-3.2.xsd"
xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<properties>
<property name="hazelcast.wait.seconds.before.join">0</property>
<property name="hazelcast.logging.type">jdk</property>
</properties>
<group>
<name>dev-test</name>
<password>dev-pass</password>
</group>
<management-center enabled="false">http://localhost:8080/mancenter</management-center>
<network>
<port auto-increment="false" port-count="10000">5701</port>
<outbound-ports>
<!--
Allowed port range when connecting to other nodes.
0 or * means use system provided port.
-->
<ports>0</ports>
</outbound-ports>
<join>
<multicast enabled="false">
<!--<multicast-group>224.2.2.3</multicast-group>-->
<!--<multicast-port>54327</multicast-port>-->
</multicast>
<tcp-ip enabled="true">
<!-- <interface>127.0.0.1</interface> -->
<interface>10.27.92.45</interface>
<interface>10.27.92.47</interface>
</tcp-ip>
<aws enabled="false">
</aws>
</join>
<interfaces enabled="true">
<interface>10.27.92.*</interface>
</interfaces>
</network>
<partition-group enabled="false"/>
<executor-service name="default">
<pool-size>16</pool-size>
<!--Queue capacity. 0 means Integer.MAX_VALUE.-->
<queue-capacity>0</queue-capacity>
</executor-service>
<map name="__vertx.subs">
<!--
Number of backups. If 1 is set as the backup-count for example,
then all entries of the map will be copied to another JVM for
fail-safety. 0 means no backup.
-->
<backup-count>1</backup-count>
<time-to-live-seconds>0</time-to-live-seconds>
<max-idle-seconds>0</max-idle-seconds>
<!--
Valid values are:
NONE (no eviction),
LRU (Least Recently Used),
LFU (Least Frequently Used).
NONE is the default.
-->
<eviction-policy>NONE</eviction-policy>
<!--
Maximum size of the map. When max size is reached,
map is evicted based on the policy defined.
Any integer between 0 and Integer.MAX_VALUE. 0 means
Integer.MAX_VALUE. Default is 0.
-->
<max-size policy="PER_NODE">0</max-size>
<!--
When max. size is reached, specified percentage of
the map will be evicted. Any integer between 0 and 100.
If 25 is set for example, 25% of the entries will
get evicted.
-->
<eviction-percentage>25</eviction-percentage>
<merge-policy>
com.hazelcast.map.merge.LatestUpdateMapMergePolicy
</merge-policy>
</map>
<!-- Used internally in Vert.x to implement async locks -->
<semaphore name="__vertx.*">
<initial-permits>1</initial-permits>
</semaphore>
</hazelcast>
When i am running both the services. They are getting added to cluster and both services are up too but i am getting below error on server
response from event bus is failed
(TIMEOUT,-1) Timed out after waiting 30000(ms) for a reply. address:
7dfec6d2-3eaf-4006-90b1-6c2eaddb28bd
at io.vertx.core.eventbus.impl.HandlerRegistration.sendAsyncResultFailure(HandlerRegistration.java:118)
at io.vertx.core.eventbus.impl.HandlerRegistration.lambda$new$0(HandlerRegistration.java:65)
Please let me know what i am doing wrong.

log4j2 RollingFileAppender old file gets removed after 7 rollovers

I use following log4j RollingFile appender in my webapp.
<Appenders>
<RollingFile name="logFile"
fileName="${env:SYSTEM_LOGS}/${env:LOG_FILE_NAME}.log" immediateFlush="true"
filePattern="${env:SYSTEM_LOGS}/${env:LOG_FILE_NAME}.log.%d{yyyy_MM_dd.HH_mm_ss}.%i">
<PatternLayout pattern="%d{yyyyMMdd-HHmmss.SSS}|%X{username}|%-5p|%t| %-100m (%c{1})%n"/>
<Policies>
<OnStartupTriggeringPolicy/>
</Policies>
</RollingFile>
</Appenders>
With filePattern="${env:SYSTEM_LOGS}/${env:LOG_FILE_NAME}.log.%d{yyyy_MM_dd.HH_mm_ss}.%i", when log is rolled over, old file gets renamed to a filename with an index number (specified with %i), so all old files should get renamed and should be preserved.
I rollover the log programmatically with following code.
org.apache.logging.log4j.Logger logManagerLogger = LogManager.getLogger();
Map<String, org.apache.logging.log4j.core.Appender> appenders = ((org.apache.logging.log4j.core.Logger) logManagerLogger).getAppenders();
appenders.forEach((appenderName, appender) -> {
if (appender instanceof RollingFileAppender) {
LOGGER.info("Switching log for appender " + appenderName);
((RollingFileAppender) appender).getManager().rollover();
}
});
But, after 7 rollovers, the existing file gets removed (not renamed according to the specified filePattern) and log is continued in a new file.
What could be the issue here?
set DefaultRolloverStrategy(default is 7), In your config will be:
<Appenders>
<RollingFile name="logFile"
fileName="${env:SYSTEM_LOGS}/${env:LOG_FILE_NAME}.log" immediateFlush="true"
filePattern="${env:SYSTEM_LOGS}/${env:LOG_FILE_NAME}.log.%d{yyyy_MM_dd.HH_mm_ss}.%i">
<PatternLayout pattern="%d{yyyyMMdd-HHmmss.SSS}|%X{username}|%-5p|%t| %-100m (%c{1})%n"/>
<Policies>
<OnStartupTriggeringPolicy/>
</Policies>
<DefaultRolloverStrategy max="100"/>
</RollingFile>
</Appenders>
now, it will have 100 log file to rollover.
If you want unlimited rollingfile,
According to Log4j2 documentation, from release 2.8, it can be done by setting fileIndex attribute to nomax. For example:
<DefaultRolloverStrategy fileIndex="nomax" />

Hazelcast + Spring(xml config) + hz map store error

Using hazelcast 3.8.2 (hazelcast-all jar) + IMap+ mapstore + Spring 4.3.8 (xml config). In Spring xml config, 'hz:map-store' throws an error saying:
17:49:40.519 ERROR [main] org.springframework.test.context.TestContextManager – Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener#1868ed54] to prepare test instance [com.twc.ctg.ecp.service.dataaccess.maps.EntitlementMapTest#1b9ea3e3] org.xml.sax.SAXParseException: cvc-complex-type.2.1: Element 'hz:map' must have no character or element information item [children], because the type's content type is empty.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203) ~[?:1.8.0_101]
What am I doing wrong?
<?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:hz="http://www.hazelcast.com/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.hazelcast.com/schema/spring
http://www.hazelcast.com/schema/spring/hazelcast-spring.xsd">
<hz:hazelcast id="hzInstance1">
<hz:config>
...
</hz:config>
</hz:hazelcast>
<hz:client id="hzInstance1Client">
...
</hz:client>
<hz:map id="entitlementCache" instance-ref="hzInstance1" name="entitlement">
<hz:map-store enabled="true" implementation="linearEntitlementMapStore"
write-delay-seconds="30000"/>
</hz:map>
<bean id="linearEntitlementMapStore" class="com.twc.ctg.ecp.service.dataaccess.maps.LinearEntitlementMapStore" />
</beans>
You need to configure MapStore in <hz:config> section.
Correct config should look like this
<?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:hz="http://www.hazelcast.com/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.hazelcast.com/schema/spring
http://www.hazelcast.com/schema/spring/hazelcast-spring.xsd">
<hz:hazelcast id="hzInstance1">
<hz:config>
<hz:map name="entitlement">
<hz:map-store enabled="true" implementation="linearEntitlementMapStore"
write-delay-seconds="30000"/>
<!-- ... -->
</hz:map>
</hz:config>
</hz:hazelcast>
<hz:client id="hzInstance1Client">
<!--... -->
</hz:client>
<bean id="linearEntitlementMapStore" class="com.twc.ctg.ecp.service.dataaccess.maps.LinearEntitlementMapStore"/>

Active Sync Client Sync Message, status code 4 - ParseSyncKey - AirSyncPermanentException

I'm currently writing an active sync client and I've successfully managed to do a folder sync. I'm now attempting to sync the "Notes" folder (using the sync command) and it's giving me an error code 4, which Microsoft describes as "Protocol Error" -- I don't see anything wrong in the protocol that I'm sending, here is the sections from my log:
Folder sync RequestBody :
<?xml version="1.0" encoding="utf-8" ?>
<FolderSync xmlns="FolderHierarchy:">
<SyncKey>0</SyncKey>
</FolderSync>
FolderSync ResponseBody:
<?xml version="1.0" encoding="utf-8" ?>
<FolderSync xmlns="FolderHierarchy:">
<Status>1</Status>
<SyncKey>1</SyncKey>
<Changes>
<Count>12</Count>
<Add>
<ServerId>1</ServerId>
<ParentId>0</ParentId>
<DisplayName>Calendar</DisplayName>
<Type>8</Type>
</Add>
<Add>
<ServerId>2</ServerId>
<ParentId>0</ParentId>
<DisplayName>Contacts</DisplayName>
<Type>9</Type>
</Add>
<Add>
<ServerId>3</ServerId>
<ParentId>0</ParentId>
<DisplayName>Deleted Items</DisplayName>
<Type>4</Type>
</Add>
<Add>
<ServerId>4</ServerId>
<ParentId>0</ParentId>
<DisplayName>Drafts</DisplayName>
<Type>3</Type>
</Add>
<Add>
<ServerId>5</ServerId>
<ParentId>0</ParentId>
<DisplayName>Inbox</DisplayName>
<Type>2</Type>
</Add>
<Add>
<ServerId>6</ServerId>
<ParentId>0</ParentId>
<DisplayName>Journal</DisplayName>
<Type>11</Type>
</Add>
<Add>
<ServerId>7</ServerId>
<ParentId>0</ParentId>
<DisplayName>Junk E-Mail</DisplayName>
<Type>12</Type>
</Add>
<Add>
<ServerId>8</ServerId>
<ParentId>0</ParentId>
<DisplayName>Notes</DisplayName>
<Type>10</Type>
</Add>
<Add>
<ServerId>9</ServerId>
<ParentId>0</ParentId>
<DisplayName>Outbox</DisplayName>
<Type>6</Type>
</Add>
<Add>
<ServerId>10</ServerId>
<ParentId>0</ParentId>
<DisplayName>Sent Items</DisplayName>
<Type>5</Type>
</Add>
<Add>
<ServerId>11</ServerId>
<ParentId>0</ParentId>
<DisplayName>Tasks</DisplayName>
<Type>7</Type>
</Add>
<Add>
<ServerId>RI</ServerId>
<ParentId>0</ParentId>
<DisplayName>RecipientInfo</DisplayName>
<Type>19</Type>
</Add>
</Changes>
</FolderSync>
My Sync RequestBody :
<?xml version="1.0" encoding="utf-8" ?>
<Sync xmlns="AirSync:">
<Collections>
<Collection>
<SyncKey>0</SyncKey>
<CollectionId>8</CollectionId>
<DeletesAsMoves>1</DeletesAsMoves>
<GetChanges/>
</Collection>
</Collections>
</Sync>
Lists this exception:
SyncCommand_OnExecute_Exception :
Microsoft.Exchange.AirSync.AirSyncPermanentException
at Microsoft.Exchange.AirSync.SyncCommand.ParseSyncKey(SyncCollection collection)
at Microsoft.Exchange.AirSync.SyncCommand.SyncTheCollection(SyncCollection collection, Boolean createSubscription, Boolean tryNullSync)
at Microsoft.Exchange.AirSync.SyncCommand.OnExecute()
And provides the following ResponseBody :
<?xml version="1.0" encoding="utf-8" ?>
<Sync xmlns="AirSync:">
<Status>4</Status>
</Sync>
Any ideas why it is failing there? This is the first sync of the folder, so the SyncKey SHOULD be 0...
From http://msdn.microsoft.com/en-us/library/gg675447(v=exchg.80).aspx :
A Status element (section 2.2.3.162.16) value of 4 is returned if the GetChanges element is present and empty or set to 1 (TRUE) when the SyncKey element value is 0 (zero). No error is returned if the GetChanges element is absent or set to 0 (FALSE) when the SyncKey value is 0 (zero).
You have present and empty in your xml.
You only may set GetChanges to 1 or live it empty (which is by default = 1) in any consequential sync request, not in initial sync request.

Resources