-
Notifications
You must be signed in to change notification settings - Fork 215
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
[HELIX-599] Support creating/maintaining/routing resources with same names in different instance groups. #31
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,6 @@ public void process(ClusterEvent event) throws Exception { | |
|
||
for (String resourceName : resourceMap.keySet()) { | ||
Resource resource = resourceMap.get(resourceName); | ||
int bucketSize = resource.getBucketSize(); | ||
|
||
StateModelDefinition stateModelDef = cache.getStateModelDef(resource.getStateModelDefRef()); | ||
|
||
|
@@ -125,9 +124,8 @@ public void process(ClusterEvent event) throws Exception { | |
} else { | ||
|
||
Message message = | ||
createMessage(manager, resourceName, partition.getPartitionName(), instanceName, | ||
currentState, nextState, sessionIdMap.get(instanceName), stateModelDef.getId(), | ||
resource.getStateModelFactoryname(), bucketSize); | ||
createMessage(manager, resource, partition.getPartitionName(), instanceName, | ||
currentState, nextState, sessionIdMap.get(instanceName), stateModelDef.getId()); | ||
|
||
IdealState idealState = cache.getIdealState(resourceName); | ||
if (idealState != null | ||
|
@@ -188,23 +186,30 @@ public void process(ClusterEvent event) throws Exception { | |
event.addAttribute(AttributeName.MESSAGES_ALL.toString(), output); | ||
} | ||
|
||
private Message createMessage(HelixManager manager, String resourceName, String partitionName, | ||
private Message createMessage(HelixManager manager, Resource resource, String partitionName, | ||
String instanceName, String currentState, String nextState, String sessionId, | ||
String stateModelDefName, String stateModelFactoryName, int bucketSize) { | ||
String stateModelDefName) { | ||
String uuid = UUID.randomUUID().toString(); | ||
Message message = new Message(MessageType.STATE_TRANSITION, uuid); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method has too many parameters, we need to just pass in resource or have a message builder class There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed, |
||
message.setSrcName(manager.getInstanceName()); | ||
message.setTgtName(instanceName); | ||
message.setMsgState(MessageState.NEW); | ||
message.setPartitionName(partitionName); | ||
message.setResourceName(resourceName); | ||
message.setResourceName(resource.getResourceName()); | ||
message.setFromState(currentState); | ||
message.setToState(nextState); | ||
message.setTgtSessionId(sessionId); | ||
message.setSrcSessionId(manager.getSessionId()); | ||
message.setStateModelDef(stateModelDefName); | ||
message.setStateModelFactoryName(stateModelFactoryName); | ||
message.setBucketSize(bucketSize); | ||
message.setStateModelFactoryName(resource.getStateModelFactoryname()); | ||
message.setBucketSize(resource.getBucketSize()); | ||
|
||
if (resource.getResourceGroupName() != null) { | ||
message.setResourceGroupName(resource.getResourceGroupName()); | ||
} | ||
if (resource.getResourceTag() != null) { | ||
message.setResourceTag(resource.getResourceTag()); | ||
} | ||
|
||
return message; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,16 @@ | |
* of current states for the partitions in a resource | ||
*/ | ||
public class ExternalView extends HelixProperty { | ||
|
||
/** | ||
* Properties that are persisted and are queryable for an external view | ||
*/ | ||
public enum ExternalViewProperty { | ||
INSTANCE_GROUP_TAG, | ||
RESOURCE_GROUP_NAME, | ||
GROUP_ROUTING_ENABLED | ||
} | ||
|
||
/** | ||
* Instantiate an external view with the resource it corresponds to | ||
* @param resource the name of the resource | ||
|
@@ -95,6 +105,32 @@ public String getResourceName() { | |
return _record.getId(); | ||
} | ||
|
||
/** | ||
* Get the resource group name | ||
* | ||
* @return the name of the resource group this resource belongs to. | ||
*/ | ||
public String getResourceGroupName() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Who calls this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RoutingTableProvider call this to determine whether it needs to cache all resource group partition/instance information. |
||
return _record.getSimpleField(ExternalViewProperty.RESOURCE_GROUP_NAME.toString()); | ||
} | ||
|
||
/** | ||
* Check whether the group routing is enabled for this resource. | ||
* | ||
* @return true if the group routing enabled for this resource; false otherwise | ||
*/ | ||
public boolean isGroupRoutingEnabled() { | ||
return _record.getBooleanField(ExternalViewProperty.GROUP_ROUTING_ENABLED.name(), false); | ||
} | ||
|
||
/** | ||
* Check for a group tag of this resource | ||
* @return the group tag, or null if none is present | ||
*/ | ||
public String getInstanceGroupTag() { | ||
return _record.getSimpleField(ExternalViewProperty.INSTANCE_GROUP_TAG.toString()); | ||
} | ||
|
||
@Override | ||
public boolean isValid() { | ||
return true; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we simply pass in the entire resource and createMessage can fetch required attributes from resource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the method to take resource as argument for my updated pull request.