Skip to content

The Crawler now registers itself at the instance registry #24

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

Merged
merged 22 commits into from
Sep 19, 2018

Conversation

johannesduesing
Copy link

@johannesduesing johannesduesing commented Sep 7, 2018

The configuration file has been extended to now contain an attribute "InstanceRegistryUri". The crawler tries to connect to this URI on startup. If successful, it registers itself at the Instance Registry, retrieves an ElasticSearch instance from there and uses it instead of the default one specified in the config, and deregisters on error / shutdown.
If the crawler cannot connect to the Instance Registry, it will print a warning and continue the execution by using the default ElasticSearch instance specified in the config.
This addresses issue #21 .

Note: The loading of the configuration file "Hermes.conf" in HermesAnalyzer.scala line 101 using the ClassLoader failed for me both on Linux and Windows. The Hermes implementation reported an error that the configuration file "cannot be found or read".

Johannes Duesing added 13 commits August 1, 2018 16:52
Initial functionality to verify the instance registry is available on startup
Changed infrastructure of Configuration to support the IR concept.
Still yields runtime exception, dependency 'spray-client' is no compatible with scala 2.12 . For scala 2.12 it it contents are part of akka-http-core, this needs to be upgraded.
Code Cleanup, API extensions
…tdown / exception during preflight checks.
…gistry

# Conflicts:
#	build.sbt
#	src/main/scala/de/upb/cs/swt/delphi/crawler/storage/ElasticReachablePreflightCheck.scala
@codecov
Copy link

codecov bot commented Sep 7, 2018

Codecov Report

Merging #24 into develop will decrease coverage by 0.88%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           develop     #24      +/-   ##
==========================================
- Coverage     8.22%   7.33%   -0.89%     
==========================================
  Files           36      38       +2     
  Lines          888     995     +107     
  Branches        12      23      +11     
==========================================
  Hits            73      73              
- Misses         815     922     +107
Impacted Files Coverage Δ
...awler/storage/ElasticReachablePreflightCheck.scala 0% <ø> (ø) ⬆️
...phi/crawler/io/swagger/client/model/Instance.scala 0% <0%> (ø)
.../crawler/instancemanagement/InstanceRegistry.scala 0% <0%> (ø)
...n/scala/de/upb/cs/swt/delphi/crawler/Crawler.scala 0% <0%> (ø) ⬆️
...i/crawler/storage/ElasticIndexPreflightCheck.scala 0% <0%> (ø) ⬆️
...a/de/upb/cs/swt/delphi/crawler/Configuration.scala 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2cf291c...44462af. Read the comment docs.

Copy link
Member

@bhermann bhermann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review the comments. There might be some issues (or not... I might be wrong).


lazy val elasticsearchClientUri: ElasticsearchClientUri = ElasticsearchClientUri({
if(elasticsearchInstance.portnumber.isEmpty){
elasticsearchInstance.iP.getOrElse("elasticsearch://localhost:" + defaultElasticSearchPort)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is localhost hard coded here?
At first glance this looks a bit strange.

if(elasticsearchInstance.portnumber.isEmpty){
elasticsearchInstance.iP.getOrElse("elasticsearch://localhost:" + defaultElasticSearchPort)
}else{
elasticsearchInstance.iP.getOrElse("elasticsearch://localhost") + ":" + elasticsearchInstance.portnumber.getOrElse(defaultElasticSearchPort)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too

case Success(instance) => instance
case Failure(_) => Instance(
None,
Some(sys.env.getOrElse("DELPHI_ELASTIC_URI","elasticsearch://localhost")),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the original code there was a port given. Does it work without giving it the default port?

Success(configuration)
}
} recover { case e =>
if(configuration.usingInstanceRegistry) InstanceRegistry.sendMatchingResult(isElasticSearchReachable = false, configuration)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having the condition at all places where it is used can be dangerous.
Could we always make the call and decide this in the method? (or through inheritance)

build.sbt Outdated
@@ -70,6 +73,7 @@ libraryDependencies ++= Seq(
)

resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
resolvers ++= Seq(Resolver.mavenLocal)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this local resolver?

@bhermann bhermann merged commit 9a2a5b6 into develop Sep 19, 2018
@ghost ghost removed the review label Sep 19, 2018
@bhermann bhermann deleted the feature/instanceregistry branch September 19, 2018 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants