-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #389 from aol/oathMigration
Oath migration
- Loading branch information
Showing
1,512 changed files
with
20,942 additions
and
21,419 deletions.
There are no files selected for viewing
6 changes: 0 additions & 6 deletions
6
...-application-register/src/main/java/com/aol/micro/server/application/registry/Health.java
This file was deleted.
Oops, something went wrong.
80 changes: 0 additions & 80 deletions
80
micro-application-register/src/main/java/com/aol/micro/server/application/registry/Job.java
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
...main/java/com/aol/micro/server/application/registry/plugin/ApplicationRegistryPlugin.java
This file was deleted.
Oops, something went wrong.
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
6 changes: 6 additions & 0 deletions
6
...application-register/src/main/java/com/oath/micro/server/application/registry/Health.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,6 @@ | ||
package com.oath.micro.server.application.registry; | ||
|
||
public enum Health { | ||
|
||
OK, ERROR | ||
} |
80 changes: 80 additions & 0 deletions
80
micro-application-register/src/main/java/com/oath/micro/server/application/registry/Job.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,80 @@ | ||
package com.oath.micro.server.application.registry; | ||
|
||
import java.util.Date; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
import javax.annotation.PostConstruct; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
|
||
import com.oath.micro.server.rest.client.nio.AsyncRestClient; | ||
import com.oath.micro.server.rest.jackson.JacksonUtil; | ||
|
||
@Component | ||
public class Job { | ||
|
||
private final Logger logger = LoggerFactory.getLogger(getClass()); | ||
private final AsyncRestClient rest = new AsyncRestClient( | ||
100, 2000); | ||
private final String apiUrl; | ||
private final ApplicationRegisterImpl app; | ||
private final String uuid = UUID.randomUUID() | ||
.toString(); | ||
private final String resourcePath; | ||
private final RegistryHealthChecker checker; | ||
private final RegistryStatsChecker statsChecker; | ||
|
||
@Autowired | ||
public Job(@Value("${service.registry.url:#{null}}") String apiUrl, ApplicationRegisterImpl app, | ||
@Value("${resource.path:/service-registry/register}") String resourcePath, RegistryHealthChecker checker, | ||
RegistryStatsChecker statsChecker) { | ||
|
||
this.apiUrl = apiUrl; | ||
this.app = app; | ||
this.resourcePath = resourcePath; | ||
this.checker = checker; | ||
this.statsChecker = statsChecker; | ||
|
||
} | ||
|
||
@PostConstruct | ||
@Scheduled(fixedDelayString = "${service.registry.delay:1000}") | ||
public synchronized void schedule() { | ||
try { | ||
if (app.getApplication() != null && apiUrl != null) | ||
app.getApplication() | ||
.forEach(moduleEntry -> sendPing(moduleEntry)); | ||
} catch (Exception e) { | ||
logger.error("Failed to register services due to exception {}", e.getMessage(), e); | ||
} | ||
} | ||
|
||
private void sendPing(RegisterEntry moduleEntry) { | ||
final RegisterEntry entry = moduleEntry.withTime(new Date()) | ||
.withUuid(uuid) | ||
.withHealth(checker.isOk() ? Health.OK : Health.ERROR) | ||
.withStats(nonEmptyOrNull(statsChecker.stats())); | ||
try { | ||
|
||
logger.debug("Posting {} to " + apiUrl + resourcePath, JacksonUtil.serializeToJson(entry)); | ||
rest.post(apiUrl + resourcePath, JacksonUtil.serializeToJson(entry)) | ||
.join(); | ||
} catch (Exception e) { | ||
logger.warn("Failed posting {} to {}" + resourcePath, JacksonUtil.serializeToJson(entry), apiUrl); | ||
|
||
} | ||
} | ||
|
||
private List<Map<String, Map<String, String>>> nonEmptyOrNull(List<Map<String, Map<String, String>>> stats) { | ||
if (stats == null || stats.isEmpty()) | ||
return null; | ||
return stats; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../application/registry/ManifestLoader.java → .../application/registry/ManifestLoader.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
8 changes: 3 additions & 5 deletions
8
...server/application/registry/Register.java → ...server/application/registry/Register.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
2 changes: 1 addition & 1 deletion
2
.../application/registry/RegisterConfig.java → .../application/registry/RegisterConfig.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
3 changes: 1 addition & 2 deletions
3
...r/application/registry/RegisterEntry.java → ...r/application/registry/RegisterEntry.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
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
2 changes: 1 addition & 1 deletion
2
...r/application/registry/UriInfoParser.java → ...r/application/registry/UriInfoParser.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
Oops, something went wrong.