Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
hexiaofeng committed Oct 24, 2024
1 parent 977a990 commit 5841ea8
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public void labelRegistry(BiConsumer<String, String> consumer) {
labelInstance(consumer);
if (location != null) {
labelZone(consumer);
LabelLiveSpace(consumer);
labelLiveSpace(consumer);
labelLane(consumer);
}
labelService(consumer);
Expand All @@ -176,7 +176,7 @@ public void labelSync(BiConsumer<String, String> consumer) {
labelInstance(consumer);
if (location != null) {
labelZone(consumer);
LabelLiveSpace(consumer);
labelLiveSpace(consumer);
labelLane(consumer);
accept(consumer, Constants.LABEL_INSTANCE_IP, location.getIp());
}
Expand Down Expand Up @@ -228,8 +228,8 @@ private void labelZone(BiConsumer<String, String> consumer) {
*
* @param consumer the consumer to use for labeling
*/
private void LabelLiveSpace(BiConsumer<String, String> consumer) {
if (location.getLiveSpaceId() != null && !location.getLiveSpaceId().isEmpty()) {
private void labelLiveSpace(BiConsumer<String, String> consumer) {
if (!location.isLiveless()) {
accept(consumer, Constants.LABEL_LIVE_SPACE_ID, location.getLiveSpaceId());
accept(consumer, Constants.LABEL_RULE_ID, location.getUnitRuleId());
accept(consumer, Constants.LABEL_UNIT, location.getUnit());
Expand All @@ -243,7 +243,7 @@ private void LabelLiveSpace(BiConsumer<String, String> consumer) {
* @param consumer the consumer to use for labeling
*/
private void labelLane(BiConsumer<String, String> consumer) {
if (location.getLaneSpaceId() != null && !location.getLaneSpaceId().isEmpty()) {
if (!location.isLaneless()) {
accept(consumer, Constants.LABEL_LANE_SPACE_ID, location.getLaneSpaceId());
accept(consumer, Constants.LABEL_LANE, location.getLane());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,13 @@ public boolean inLane(String lane) {
public boolean inLane(String spaceId, String lane) {
return inLaneSpace(spaceId) && inLane(lane);
}

public boolean isLiveless() {
return liveSpaceId == null || liveSpaceId.isEmpty();
}

public boolean isLaneless() {
return laneSpaceId == null || laneSpaceId.isEmpty();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public <T extends InboundRequest> void filter(InboundInvocation<T> invocation, I

protected <T extends InboundRequest> CellAction cellAction(InboundInvocation<T> invocation) {
LiveMetadata metadata = invocation.getLiveMetadata();
if (metadata.getLocalSpace() == null) {
if (metadata.isLocalLiveless()) {
// liveless
return new CellAction(CellActionType.FORWARD);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private <T extends InboundRequest> UnitAction unitAction(InboundInvocation<T> in
UnitAction action = validateSpace(invocation);
if (action != null) {
return action;
} else if (metadata.getLocalSpace() == null) {
} else if (metadata.isLocalLiveless()) {
// liveless
return onLiveless(invocation);
} else if (rule == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public class LiveMetadata {
*/
private String variable;

public boolean isLocalLiveless() {
return localSpace == null;
}

public Unit getLocalUnit() {
return localSpace == null ? null : localSpace.getLocalUnit();
}
Expand All @@ -67,6 +71,10 @@ public Cell getLocalCell() {
return localSpace == null ? null : localSpace.getLocalCell();
}

public boolean isTargetLiveless() {
return targetSpace == null;
}

public Unit getTargetLocalUnit() {
return targetSpace == null ? null : targetSpace.getLocalUnit();
}
Expand Down

0 comments on commit 5841ea8

Please sign in to comment.