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
[SCB-1971] Introduce SPI mechanism to enable/disable zero-config and … #1804
Conversation
public class ZeroConfigDiscovery implements Discovery { | ||
|
||
private static final String NAME = "zero-config discovery"; | ||
private static final String ENABLED = "servicecomb.zeroconfig.registry.discovery.enabled"; |
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.
For zero config, Discovery
and Registration
must be enabled/disable togather. So it's better to use servicecomb.zeroconfig.registry.enabled
. I'll modify other modules later.
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.
will just define this variable once in the Constant class/interface
@Override | ||
public String getSchema(String microserviceId, Collection<MicroserviceInstance> instances, | ||
String schemaId) { | ||
return zeroConfigClient.getSchema(microserviceId, schemaId); |
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.
This can return null
in future. Loading schema from instance will the core process, and this change is in progress, so can keep this code here for temporary usage. Maybe add a TODO
is better.
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.
wil add // TODO comment
private MulticastSocket multicastSocket; | ||
|
||
// Constructor | ||
public ZeroConfigClient(ZeroConfigRegistryService zeroConfigRegistryService, |
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.
Constructor is better to be private for singletan. And add a method with @VisibleForTesting
to create new ZeroConfigClient instance.
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.
ok
|
||
// setter/getter | ||
|
||
public void setSelfMicroservice( |
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.
Maybe @VisibleForTesting
?
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.
agree
...try-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/client/ZeroConfigClient.java
Outdated
Show resolved
Hide resolved
|
||
private String doRegister(Map<String, String> serviceInstanceDataMap) { | ||
try { | ||
byte[] instanceData = serviceInstanceDataMap.toString().getBytes(); |
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.
specify locale to avoid problems.
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.
specify locale to avoid problems.
? please explain more
//throw new ServiceCombException("Failed to create MulticastSocket object", e); | ||
} | ||
return new ZeroConfigClient(new ZeroConfigRegistryService(), multicastSocket, | ||
new RestTemplate()); |
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 not use RestTemlate here bacause it is can only invoke simple services that do not deploy any security features, e.g. when TLS is eanbled.
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.
will think about perfect soution in next PR
…changes to adapt to new interfaces
Follow this checklist to help us incorporate your contribution quickly and easily:
[SCB-XXX] Fixes bug in ApproximateQuantiles
, where you replaceSCB-XXX
with the appropriate JIRA issue.mvn clean install -Pit
to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.