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

Add Cluster properties and rename DeploymentId to ClusterId #34

Merged
merged 12 commits into from
Oct 3, 2016

Conversation

nehmebilal
Copy link
Collaborator

This PR addresses issue #33

For a quick overview of the changes in the Api and DeploymentConfig.json, take a look at the tests.

The new DeploymentConfig.json is as follows:

{
    "Applications":
    [
        {
            "Id": "app1",
            "Version": "1.0.0",
            "TargetClusters": [ "YAMS_CLUSTER_ID" ],
            "Properties":
            {
                "NodeType": "PROD"
            }
        },  
        {
            "Id": "app1",
            "Version": "1.0.1",
            "TargetClusters": [ "YAMS_CLUSTER_ID"],
            "Properties":
            {
                "NodeType": "QA"
            }
        },
    ]
}

DeploymentIds has been renamed to TargetClusters and the DeploymentId token has been renamed to ClusterId. I didn't end up adding the 'Yams' prefix because it was quickly spreading through the code and felt heavy. If that's a major concern we can rename it.

Yams will match on properties by default (no need to create a custom matcher). To add properties to the cluster, you can use the YamsConfigBuilder.AddClusterProperty("Foo", "Bar") Api as shown in the tests. Only the properties that are added through YamsConfigBuilder will be used by the default matcher (other properties in the DeploymentConfig.json will be carried over but not used for matching). All properties can be used as token in the AppConfig.json (${propName}).

I also updated the sample and docs but not all of them. I'm hoping that Orleans guys (@jdom) will be able to help with the Orleans sample and cloud service sample.

Note that some of the Api changes are not backward compatible but should be easy to fix.

Finally, I extracted the DeploymentConfig serialization into its own interface so that it can be replaced. This means that you can now easily replace the json representation with whatever you prefer.

Let me know what you think!

Copy link
Member

@jdom jdom left a comment

Choose a reason for hiding this comment

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

LGTM

},
{
"Id": "WebApp",
"Version": "2.0.0",
"DeploymentIds": [ "MY_DEPLOYMENT_ID" ]
"TargetClusters": [ "MY_DEPLOYMENT_ID" ]
Copy link
Member

Choose a reason for hiding this comment

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

should you update these to MY_CLUSTER_ID?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep thanks

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

{
return _apps.Keys;
return (_apps != null ? _apps.GetHashCode() : 0);
Copy link
Member

Choose a reason for hiding this comment

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

not sure for what purpose this relevant to override, but are you certain that 2 different sets with the same values will return the same hashcode? or is that not what you want anyway?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll test this a bit more. I generated it the implementation with Resharper. I'd expect that two sets with the same values would have the same hashcode (GetHashCode is supposed to be consistent with Equals) but I'll make sure.

Choose a reason for hiding this comment

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

Possible could be also EqualityComparer<HashSet<AppDeploymentConfig>.Default.GetHashCode(_apps), I think.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jdom was right, the default implementation doesn't handle IEnumerable's correctly. I fixed the implementation and added corresponding tests.

@@ -2,7 +2,7 @@
<package >
<metadata>
<id>Etg.Yams</id>
<version>1.0.14</version>
<version>1.1.0-test</version>
Copy link
Member

Choose a reason for hiding this comment

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

there's a lot of references to 1.1.0-test, is that something that you want merged?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No they should be replaced with the actual nuget version that will be published. I'll clean that up before merging, thanks.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Replaced with 1.1.0-rc

using Xunit;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;

namespace Etg.Yams.Test.Storage
{
public class DeploymentConfigTestFixture
Copy link
Member

Choose a reason for hiding this comment

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

might want to add coverage for using the new AddApplication overload that takes a deployment config with properties

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tests added. Found some issues and ended up replacing the internal HashSet with a Dictionary which was more appropriate.

@nehmebilal
Copy link
Collaborator Author

@jdom Please confirm if your comments have been addressed and then I'll merge and publish a NuGet.

@jdom
Copy link
Member

jdom commented Oct 1, 2016

LGTM, ship it :P

@nehmebilal
Copy link
Collaborator Author

One last change. I made the cluster properties also available as tokens (properties added to the cluster at startup) and fixed a bug in resolving version tokens that was introduced by the switch to SemVersion (version.Patch should be used instead of version.Build).

@nehmebilal nehmebilal merged commit b811a95 into microsoft:master Oct 3, 2016
nehmebilal pushed a commit that referenced this pull request Nov 8, 2016
Cluster id concatenation is not needed anymore since Yams now supports cluster properties (see PR #34)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants