Archived

This forum has been archived. Please start a new discussion on GitHub.

Patch of IceGrid replica-group type None

Hi guys
I have patched IceGrid for my requirements of cluster. I hope there is another way without patching IceGrid.

I am using IceGrid for web server caches. The key problem of my application is not CPU circle but the memory usage limit of x86-32. So the Ice-oriented replica is not suitable for me.
The way I balance the load is caching different data in different service, using dataId % replica_num determining which service to use.
It works fine for more than 4G data in memory on 3 machines. But there is a problem of reliability.
Any node of the grid fail will cause my entire application down.
Changing client implies is a way to solve my problem while I prefer the client remain.

The IceGrid provides four types of replica group: None, random, round-robin and adaptive. If there is a replica-group type: return only the first proxy of service, and auto transfer failures when the first node down. It will benefit to my requirements. Then my application will be:
Attachment not found.
My replica group must be type=None and n-replicas=1, unfortunately, “None” type has no parameter of n-replicas.

Here is the code I changed:

AdapterCache.cpp
vector<pair<string, AdapterPrx> >
ReplicaGroupEntry::getProxies(int& nReplicas, bool& replicaGroup)
{
    ReplicaSeq replicas;
    bool adaptive = false;
    LoadSample loadSample = LoadSample1;
    {
	Lock sync(*this);
	replicaGroup = true;
	
	if(_replicas.empty())
	{
	    return vector<pair<string, AdapterPrx> >();
	}

	nReplicas = _loadBalancingNReplicas > 0 ? _loadBalancingNReplicas : static_cast<int>(_replicas.size());
	replicas.reserve(_replicas.size());
	if(!_loadBalancing)
	{
	    replicas = _replicas;
	    [COLOR="Red"]nReplicas = 1; // add this[/COLOR]
	}
	if(RoundRobinLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
	{
	    for(unsigned int i = 0; i < _replicas.size(); ++i)
	    {
		replicas.push_back(_replicas[(_lastReplica + i) % _replicas.size()]);
	    }
	    _lastReplica = (_lastReplica + 1) % static_cast<int>(_replicas.size());
	}
	else if(AdaptiveLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
	{
	    replicas = _replicas;
	    RandomNumberGenerator rng;
	    random_shuffle(replicas.begin(), replicas.end(), rng);
	    adaptive = true;
	    loadSample = _loadSample;
	}
[COLOR="Lime"]	// this is the orignal
	else// if(RandomLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))[/COLOR]
	[COLOR="Red"]else if(RandomLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))[/COLOR]	{
	    replicas = _replicas;
	    RandomNumberGenerator rng;
	    random_shuffle(replicas.begin(), replicas.end(), rng);
	}
}
……
……
In original IceGrid, None-replica-group means Random-replica-group with n-replica parameter equal to total replica count.
By changing these two lines, None-replica-group returns only the first proxy in the group. It will return the second proxy when the first is not available.

How can I do the same things without patching IceGrid itself?

Comments

  • benoit
    benoit Rennes, France
    Hi,

    Thanks for the suggestion! I'm afraid there's currently no way to do what you want without changing IceGrid though. We'll discuss changing this for the next release.

    Cheers,
    Benoit.
  • :):)

    because replica_num is fixed, id%replica_num is not reliable, so I have to cluster each node.
    If IceGrid has a replica-group type, which is not state-less, my changing is not necessory any more.
    If I can change the policy of choosing proxies on client side. It also solves the problem.
    I am still working on this problem.

    Ice will be the middle-layer for my new application.
    Till now, most of the Ice's problem is solved or pendding to solve in the next version.
    I want to thank you all give us what a wonderful tools.
    Hope the next release comming soon.(IceGrid registry cluster included).