Skip to content

Commit

Permalink
[CN-1274] Update client configs to use public IP addresses (#18)
Browse files Browse the repository at this point in the history
* update java and nodejs client examples for smart client

* update python unisocket example

* revert IP address in nodejs example

* update dotnet examples

* update java and dotnet example

* sync python example
  • Loading branch information
semihbkgr authored May 10, 2024
1 parent aa24573 commit 02f8deb
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ logging.basicConfig(level=logging.INFO)
client = hazelcast.HazelcastClient(
cluster_members=["<EXTERNAL-IP>"],
use_public_ip=True,
smart_routing=False,
)
----
Expand All @@ -191,7 +190,7 @@ var options = new HazelcastOptionsBuilder()
.With((configuration, options) =>
{
options.LoggerFactory.Creator = () => LoggerFactory.Create(loggingBuilder => loggingBuilder.AddConfiguration(configuration.GetSection("logging")).AddConsole());
options.Networking.Addresses.Add("<EXTERNAL IP>");
options.Networking.Addresses.Add("<EXTERNAL-IP>");
options.Networking.SmartRouting = false;
})
.Build();
Expand Down Expand Up @@ -355,9 +354,6 @@ image::smart.jpg[Hazelcast Smart Client]

=== Start the Hazelcast Cluster




Run the following command to create the Hazelcast cluster with Expose Externally feature enabled using Smart type.

[source, shell]
Expand Down Expand Up @@ -441,6 +437,7 @@ Java::
----
ClientConfig config = new ClientConfig();
config.getNetworkConfig().addAddress("<EXTERNAL-IP>");
config.getProperties().setProperty(ClientProperty.DISCOVERY_SPI_PUBLIC_IP_ENABLED.toString(), "true");
----
--
Expand All @@ -456,6 +453,9 @@ const clientConfig = {
clusterMembers: [
'<EXTERNAL-IP>'
]
},
properties: {
['hazelcast.discovery.public.ip.enabled']: true
}
};
const client = await Client.newHazelcastClient(clientConfig);
Expand Down Expand Up @@ -513,8 +513,9 @@ var options = new HazelcastOptionsBuilder()
.With((configuration, options) =>
{
options.LoggerFactory.Creator = () => LoggerFactory.Create(loggingBuilder => loggingBuilder.AddConfiguration(configuration.GetSection("logging")).AddConsole());
options.Networking.Addresses.Add("<EXTERNAL IP>");
options.Networking.Addresses.Add("<EXTERNAL-IP>");
options.Networking.UsePublicAddresses = true;
})
.Build();
var client = await HazelcastClientFactory.StartNewClientAsync(options);
Expand Down
2 changes: 1 addition & 1 deletion dotnet-unisocket/csharp_example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static async Task Main(string[] args)
.With((configuration, options) =>
{
options.LoggerFactory.Creator = () => LoggerFactory.Create(loggingBuilder => loggingBuilder.AddConfiguration(configuration.GetSection("logging")).AddConsole());
options.Networking.Addresses.Add("<EXTERNAL IP>");
options.Networking.Addresses.Add("<EXTERNAL-IP>");
options.Networking.SmartRouting = false;
})
.Build();
Expand Down
2 changes: 1 addition & 1 deletion dotnet/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static async Task Main(string[] args)
.With((configuration, options) =>
{
options.LoggerFactory.Creator = () => LoggerFactory.Create(loggingBuilder => loggingBuilder.AddConfiguration(configuration.GetSection("logging")).AddConsole());
options.Networking.Addresses.Add("<EXTERNAL IP>");
options.Networking.Addresses.Add("<EXTERNAL-IP>");
options.Networking.UsePublicAddresses = true;
})
.Build();
Expand Down
2 changes: 2 additions & 0 deletions java/src/main/java/com/hazelcast/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.hazelcast.client.HazelcastClient;
import com.hazelcast.client.config.ClientConfig;
import com.hazelcast.client.properties.ClientProperty;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.map.IMap;

Expand All @@ -11,6 +12,7 @@ public class Main {
public static void main(String[] args) throws Exception {
ClientConfig config = new ClientConfig();
config.getNetworkConfig().addAddress("<EXTERNAL-IP>");
config.getProperties().setProperty(ClientProperty.DISCOVERY_SPI_PUBLIC_IP_ENABLED.toString(), "true");
HazelcastInstance client = HazelcastClient.newHazelcastClient(config);

System.out.println("Successful connection!");
Expand Down
3 changes: 3 additions & 0 deletions nodejs/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const clientConfig = {
clusterMembers: [
'<EXTERNAL-IP>'
]
},
properties: {
['hazelcast.discovery.public.ip.enabled']: true
}
};

Expand Down
1 change: 0 additions & 1 deletion python-unisocket/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

client = hazelcast.HazelcastClient(
cluster_members=["<EXTERNAL-IP>"],
use_public_ip=True,
smart_routing=False,
)

Expand Down

0 comments on commit 02f8deb

Please sign in to comment.