Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GrainDirectory Refactoring and Multi-Cluster Registration #1108

Merged
merged 1 commit into from
Feb 2, 2016

Conversation

sebastianburckhardt
Copy link
Contributor

This branch contains

  • some basic refactoring of the local and remote grain directory. There was a lot of code duplication between the various functions (register, registersingleact, unregister, delete) and between the local and remote grain directory. The proposed refactoring puts shared functionality into LocalGrainDirectory. It adds a hopcount parameter into the signature of the directory operations (replacing the retries parameter), which allows us to tell if something is a remote or local request, and whether we should retry.
  • hooks for specifying a multi-cluster grain registration strategy. This strategy is defined by the type of the grain (e.g. using attributes). The strategy is used to look up the corresponding registrar for the grain. The actual registration/unregistration/deletion of a grain is done by that registrar.

@gabikliot gabikliot changed the title add multi-cluster registration hooks; refactor local/remote grain dir… add multi-cluster registration hooks; refactor local/remote grain directory functions (Register, RegisterSingleAct, Unregister, Delete) to reduce code duplication Dec 3, 2015
@sebastianburckhardt sebastianburckhardt changed the title add multi-cluster registration hooks; refactor local/remote grain directory functions (Register, RegisterSingleAct, Unregister, Delete) to reduce code duplication GrainDirectory Refactoring and Multi-Cluster Registration Dec 3, 2015
@dnfclas
Copy link

dnfclas commented Dec 3, 2015

@sebastianburckhardt, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, DNFBOT;

@gabikliot gabikliot added this to the Multi-Cluster milestone Dec 3, 2015
private const int DEFAULT_MAX_RETRIES = 0;
private readonly Dictionary<SiloAddress, DateTime> lastConnectionFailure;
protected readonly Dictionary<SiloAddress, DateTime> lastConnectionFailure;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the goal in making these fields protected? I couldn't find any usages of them outside this class (and also I don't see any subclasses of SiloMessageSender.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I agree it should be private. I think this was just left over from some code that no longer exists.

@@ -32,6 +33,7 @@ internal class ActivationAddress
public GrainId Grain { get; private set; }
public ActivationId Activation { get; private set; }
public SiloAddress Silo { get; private set; }
public MultiClusterStatus Status { get; private set; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you now also need to change the way ActivationAddress is serialized in Orleans serializer. We have manually written built in serializer for all runtime types. Look at BuiltInTypes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless of course you explicitly do not want this extra field to be serialized, and then you need to mark it as NonSerialized.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I am not quite sure. I think it is only used locally, but I will take a look.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be at least one case where the status has to be serialized (namely, when handing off activations). I have updated the binarystreamreader and binarystreamwriter and the serialization unit test accordingly. This adds one byte.

sebastianburckhardt added a commit to sebastianburckhardt/orleans that referenced this pull request Dec 4, 2015
sebastianburckhardt added a commit to sebastianburckhardt/orleans that referenced this pull request Dec 4, 2015
@gabikliot
Copy link
Contributor

Regarding your question about AddressesAndTag:

  1. mark it Immutable, since it is.
  2. can leave Serailizable. It is not required, but specifies intent.
  3. Check the output of the build. It prints which serializers were generated. This one should be, since the type appears in the system target method signature. But worth double checking. If it does not, we can/should fix that.

{
// Force the list to be created in order to avoid race conditions
return result.Item1.Select(pair => ActivationAddress.GetAddress(pair.Item1, grain, pair.Item2)).ToList();
return result.Addresses.Select(a => ActivationAddress.GetAddress(a.Silo, grain, a.Activation, a.Status)).ToList();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to recreate the list? It doesn't seem to be accomplishing anything. It creates an identical List<ActivationAddress> as result.ActivationAddresses

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this is unnecessary, since an identical list is now being constructed in partition.LooupGrain and can be used directly.

Also, the comment about race conditions seems irrelevant since the list returned by partition.LookupGrain is always fresh, and the ActivationAddress objects are immutable.

I will simplify this.

RegistrationsLocal.Increment();
// if I am the owner, store the new activation locally
DirectoryPartition.AddActivation(address.Grain, address.Activation, address.Silo);
(singleActivation ? RegistrationsSingleActLocal : RegistrationsLocal).Increment();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming is a bit confusing to me - it is easy to read it as if RegistrationsLocal is all local registration including single-activation ones while in reality it seems that it actually means RegistrationsMultipleLocal or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you, but did not dare to change the counter names since that could break someone else's stuff.

@sergeybykov
Copy link
Contributor

I think I'm done with my review pass. Once the outstanding comments are addressed, I think we can rebase, squash, retest, and merge.

@sebastianburckhardt
Copy link
Contributor Author

I think I have addressed all suggestions and questions. I will wait a couple hours and then squash, unless there are objections.

@sergeybykov
Copy link
Contributor

@sebastianburckhardt Please give us some more time. I'm in a meeting unable to do much. I think give us till the rest of the day before rebasing and squashing. Thanks.

return Task.WhenAll(addresses.Select(addr => Register(addr, retries)));
}
if (addresses == null || addresses.Count == 0)
throw new ArgumentException("addresses");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nit: ArgumentException takes an error message as a constructor argument, e.g. "addresses cannot be an empty list or null" and an optional parameter name. ArgumentNullException OTOH takes just an argument name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. I will change that and then rebase and squash.

@sergeybykov
Copy link
Contributor

I am ready for rebasing and squashing of this.

@sebastianburckhardt
Copy link
Contributor Author

Rebased and squashed.

@jdom
Copy link
Member

jdom commented Feb 1, 2016

Awesome, thanks everybody. Doing some final test runs on our VSO and will get this merged by EOD

jdom added a commit that referenced this pull request Feb 2, 2016
GrainDirectory Refactoring and Multi-Cluster Registration
@jdom jdom merged commit 243f811 into dotnet:master Feb 2, 2016
@jdom
Copy link
Member

jdom commented Feb 2, 2016

Alright, this is in! Load & Reliability tests worked fine. Thanks to all involved in this implementation and review 😄

@sergeybykov
Copy link
Contributor

A huge leap into geo-distribution has begun! :-)

@gabikliot
Copy link
Contributor

👍

@sebastianburckhardt sebastianburckhardt deleted the geo-graindirstruct branch February 2, 2016 16:16
@jthelin
Copy link
Member

jthelin commented Feb 2, 2016

Whoo. Nice job @sebastianburckhardt and everyone.
One small step for Orleans ....
The future is Geo!

@sergeybykov sergeybykov modified the milestone: Multi-Cluster Nov 3, 2016
@github-actions github-actions bot locked and limited conversation to collaborators Dec 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants