You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I found that if I want to persist the config on file should use the class PersistentClusterConfigurationStorage. I don't know is correct or not but from tracing the source I create the class
`
internal class PersistentClusterConfigurationStorage : PersistentClusterConfigurationStorage
{
public PersistentClusterConfigurationStorage(string path, int fileBufferSize = 512, MemoryAllocator allocator = null) : base(path, fileBufferSize, allocator)
{
}
protected override void Encode(IPEndPoint address, ref BufferWriterSlim output)
{
output.WriteEndPoint(address);
}
and using for persisting data
static async ValueTask AddMembersToCluster(AppSettingConfig serverConfig, PersistentClusterConfigurationStorage storage)
{
if (serverConfig.Members == null) return;
for (int i = 0; i < serverConfig.Members.Length; i++)
{
var t = Dns.GetHostAddresses(serverConfig.Members[i].EndPoint);
var ipEndPint = new IPEndPoint(t[0], serverConfig.Members[i]?.Port ?? serverConfig.PeerCommunicationPort);
await storage.AddMemberAsync(ClusterMemberId.FromEndPoint(ipEndPint), ipEndPint);
}
}
`
but when the running application LeaderChanged is not called and can't understand what is false.
The text was updated successfully, but these errors were encountered:
Hi @mbasij1 ,
It will not work in that way. You can add only one node at a time. I recommend you to start from this article. There is explanation of how to bootstrap the cluster. In case of HTTP transport, you don't need to implement your own persistent storage for cluster members.
Thank You for your response.
I trying to solve a false thing!
I Delete initialized cluster from the beginning and worked. but I can't understand why we could use the AddMembersToCluster(_serverConfig, config.UseInMemoryConfigurationStorage()) and work?
Although I found that when using UseInMemoryConfigurationStorage() every node of cluster comes leader and I think they not join together!
Adding multiple members at the boot time is a mistake. According to documentation, there are two ways to bootstrap the node:
If you starting the first node in the cluster, use Cold Start mode. In that case, the active configuration must be empty. The node will add itself to the configuration automatically.
When the cluster contains at least one node, a new member must be started in Announcement mode. The node will be in frozen state and you need to inform the cluster about that node. Usually, it's necessary to announce the node via calling of AddMemberAsync method on the leader node. Only leader node can modify the cluster configuration.
Hi,
I found that if I want to persist the config on file should use the class PersistentClusterConfigurationStorage. I don't know is correct or not but from tracing the source I create the class
`
internal class PersistentClusterConfigurationStorage : PersistentClusterConfigurationStorage
{
public PersistentClusterConfigurationStorage(string path, int fileBufferSize = 512, MemoryAllocator allocator = null) : base(path, fileBufferSize, allocator)
{
}
protected override void Encode(IPEndPoint address, ref BufferWriterSlim output)
{
output.WriteEndPoint(address);
}
and using for persisting data
static async ValueTask AddMembersToCluster(AppSettingConfig serverConfig, PersistentClusterConfigurationStorage storage)
{
if (serverConfig.Members == null) return;
for (int i = 0; i < serverConfig.Members.Length; i++)
{
var t = Dns.GetHostAddresses(serverConfig.Members[i].EndPoint);
var ipEndPint = new IPEndPoint(t[0], serverConfig.Members[i]?.Port ?? serverConfig.PeerCommunicationPort);
await storage.AddMemberAsync(ClusterMemberId.FromEndPoint(ipEndPint), ipEndPint);
}
}
`
but when the running application LeaderChanged is not called and can't understand what is false.
The text was updated successfully, but these errors were encountered: