-
Notifications
You must be signed in to change notification settings - Fork 546
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add announcer status delegate interface and support getting server an…
…nounce mode (#1035) * Add announcer status delegate interface and support getting server announce mode * adjust log msg and comment * adjust announce mode enum order * comment on the announcement mode enum instead of reordering it * adjust comment
- Loading branch information
Showing
9 changed files
with
121 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
d2/src/main/java/com/linkedin/d2/balancer/servers/AnnouncerStatusDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.linkedin.d2.balancer.servers; | ||
|
||
import java.net.URI; | ||
|
||
|
||
public interface AnnouncerStatusDelegate | ||
{ | ||
/** | ||
* @return true if the markup intent has been sent. | ||
*/ | ||
boolean isMarkUpIntentSent(); | ||
|
||
/** | ||
* @return true if the dark warmup mark up intent has been sent. | ||
*/ | ||
boolean isDarkWarmupMarkUpIntentSent(); | ||
|
||
/** | ||
* @return the name of the regular cluster that the announcer manages. | ||
*/ | ||
String getCluster(); | ||
|
||
/** | ||
* @return the name of the warmup cluster that the announcer manages. | ||
*/ | ||
String getWarmupCluster(); | ||
|
||
/** | ||
* @return the uri that the announcer manages. | ||
*/ | ||
URI getURI(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,7 @@ | |
* @author Francesco Capponi ([email protected]) | ||
*/ | ||
|
||
public class ZooKeeperAnnouncer implements D2ServiceDiscoveryEventHelper | ||
public class ZooKeeperAnnouncer implements D2ServiceDiscoveryEventHelper, AnnouncerStatusDelegate | ||
{ | ||
public static final boolean DEFAULT_DARK_WARMUP_ENABLED = false; | ||
public static final int DEFAULT_DARK_WARMUP_DURATION = 0; | ||
|
@@ -705,6 +705,13 @@ public void onSuccess(None result) | |
}; | ||
} | ||
|
||
@Override | ||
public String getWarmupCluster() | ||
{ | ||
return _warmupClusterName; | ||
} | ||
|
||
@Override | ||
public String getCluster() | ||
{ | ||
return _cluster; | ||
|
@@ -720,6 +727,12 @@ public String getUri() | |
return _uri.toString(); | ||
} | ||
|
||
@Override | ||
public URI getURI() | ||
{ | ||
return _uri; | ||
} | ||
|
||
public void setUri(String uri) | ||
{ | ||
_uri = URI.create(uri); | ||
|
@@ -816,11 +829,13 @@ public boolean isMarkUpFailed() | |
return _markUpFailed; | ||
} | ||
|
||
@Override | ||
public boolean isMarkUpIntentSent() | ||
{ | ||
return _isMarkUpIntentSent.get(); | ||
} | ||
|
||
@Override | ||
public boolean isDarkWarmupMarkUpIntentSent() | ||
{ | ||
return _isDarkWarmupMarkUpIntentSent.get(); | ||
|
@@ -836,16 +851,22 @@ public int getWeightDecimalPlacesBreachedCount() | |
return _weightDecimalPlacesBreachedCount.get(); | ||
} | ||
|
||
public LoadBalancerServer.AnnounceMode getServerAnnounceMode() | ||
{ | ||
return _server.getAnnounceMode(); | ||
} | ||
|
||
public void setEventEmitter(ServiceDiscoveryEventEmitter emitter) { | ||
_eventEmitter = emitter; | ||
} | ||
|
||
@Override | ||
public void emitSDStatusActiveUpdateIntentAndWriteEvents(String cluster, boolean isMarkUp, boolean succeeded, long startAt) { | ||
// since SD event is sent in IndisAnnouncer for INDIS-write-only, inside ZookeeperAnnouncer, any calls to | ||
// "emitSDStatusActiveUpdateIntentAndWriteEvents" should only happen when _server is an instance of | ||
// ZooKeeperServer (which means it only emits the event when it's doing zk-only or dual write). | ||
if (!(_server instanceof ZooKeeperServer)) | ||
// In this class, SD event should be sent only when the announcing mode is to old service registry or dual write, | ||
// so we can directly return when _server is NOT an instance of ZooKeeperServer or the announcement mode is dynamic | ||
// new SR only. | ||
if (!(_server instanceof ZooKeeperServer) | ||
|| _server.getAnnounceMode() == LoadBalancerServer.AnnounceMode.DYNAMIC_NEW_SR_ONLY) | ||
{ | ||
return; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters