Hazelcast客户端个别客户端的生存时间设置

huangapple 未分类评论56阅读模式
英文:

Hazelcast client time to live setup for individual client

问题

以下是翻译好的内容:

我在使用 SpringBoot 与 Hazelcast。在我的设置中,我有一个正在运行的 Hazelcast 服务器(3.12.6),我正在将其与 SpringBoot 应用程序中的 Hazelcast 客户端连接起来。

hazelcast-client.yaml

hazelcast-client:
  network:
    cluster-members:
      - 127.0.0.1
    smart-routing: false

我已经在 Hazelcast 服务器中检查了设置,在 hazelcast.xml 中有一个全局配置,用于配置 Time to Live(TTL) 配置。

hazelcast.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ 版权所有(c)2008-2018,Hazelcast,Inc. 保留所有权利。
  ~
  ~ 在 Apache 许可证下,版本 2.0(“许可证”)的许可下,此文件仅供遵守许可证。
  ~ 您可以在以下位置获取许可证副本:
  ~
  ~ http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ 除非适用法律要求或书面同意,否则按“原样”分发的软件
  ~ 没有任何形式的明示或暗示担保或条件。
  ~ 有关特定语言的权限,请参阅许可证。
  -->
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.11.xsd"
           xmlns="http://www.hazelcast.com/schema/config"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <group>
        <name>dev</name>
    </group>
    <management-center enabled="true">http://mc_server:8080/hazelcast-mancenter</management-center>
    <map name="default">
        <time-to-live-seconds>10</time-to-live-seconds>
        <max-idle-seconds>10</max-idle-seconds>
    </map>

</hazelcast>

我的问题是:
是否有任何方式可以使用我的 SpringBoot 客户端在服务器上配置 Time to Live 和其他设置?

英文:

I am using SpringBoot with Hazelcast.
In my setup I have one Hazelcast server(3.12.6) up and running I am connecting that with Hazelcast client in my SpringBoot application.

hazelcast-client.yaml

hazelcast-client:
  network:
    cluster-members:
      - 127.0.0.1
    smart-routing: false

I have checked the setup in Hazelcast server, there is a global configuration in hazelcast.xml that helps in configuration of Time to live configuration.

hazelcast.xml

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

<!--
~ Copyright (c) 2008-2018, Hazelcast, Inc. All Rights Reserved.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.11.xsd"
xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

&lt;group&gt;
    &lt;name&gt;dev&lt;/name&gt;
&lt;/group&gt;
&lt;management-center enabled=&quot;true&quot;&gt;http://mc_server:8080/hazelcast-mancenter&lt;/management-center&gt;
&lt;map name=&quot;default&quot;&gt;
    &lt;time-to-live-seconds&gt;10&lt;/time-to-live-seconds&gt;
    &lt;max-idle-seconds&gt;10&lt;/max-idle-seconds&gt;
&lt;/map&gt;

</hazelcast>

My question is:
Is there any way I can configure time to live and other settings using my springboot client on my server?

答案1

得分: 0

以下是来自Hazelcast Client的动态配置示例。

HazelcastInstance client = HazelcastClient.newHazelcastClient();
MapConfig mCfg = new MapConfig("test");
mCfg.setTimeToLiveSeconds(15);
client.getConfig().addMapConfig(mCfg);
HazelcastClient.shutdownAll();

详细信息和限制请参阅此处 - https://docs.hazelcast.org/docs/3.12.6/manual/html-single/index.html#dynamically-adding-data-structure-configuration-on-a-cluster

谢谢,Sharath

英文:

Here is an example of Dynamic configuration from a Hazelcast Client.

HazelcastInstance client = HazelcastClient.newHazelcastClient();
MapConfig mCfg = new MapConfig(&quot;test&quot;);
mCfg.setTimeToLiveSeconds(15);
client.getConfig().addMapConfig(mCfg);
HazelcastClient.shutdownAll();

Details and limitations are here - https://docs.hazelcast.org/docs/3.12.6/manual/html-single/index.html#dynamically-adding-data-structure-configuration-on-a-cluster

Thanks, Sharath

huangapple
  • 本文由 发表于 2020年7月27日 10:50:13
  • 转载请务必保留本文链接:https://java.coder-hub.com/63108018.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定