Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Andreas Tsagkaropoulos
morphemic-preprocessor
Commits
fd8fce05
Commit
fd8fce05
authored
Mar 04, 2021
by
Mohamed Khalil Labidi
Browse files
Improve jclouds handled instance types synchronization with node candidates retrieval
parent
e887fed9
Changes
4
Hide whitespace changes
Inline
Side-by-side
build.gradle
View file @
fd8fce05
...
...
@@ -46,6 +46,7 @@ dependencies {
compile
group:
'com.fasterxml.jackson.dataformat'
,
name:
'jackson-dataformat-csv'
,
version:
'2.12.1'
compile
group:
'org.eclipse.emf'
,
name:
'org.eclipse.emf.common'
,
version:
'2.20.0'
compile
group:
'org.apache.commons'
,
name:
'commons-lang3'
,
version:
'3.11'
compile
group:
'org.apache.jclouds.api'
,
name:
'ec2'
,
version:
'2.2.1'
annotationProcessor
"org.projectlombok:lombok:1.18.12"
compile
'org.junit.jupiter:junit-jupiter:5.6.2'
testImplementation
'org.mockito:mockito-inline:3.7.7'
...
...
pom.xml
View file @
fd8fce05
...
...
@@ -101,6 +101,12 @@
<version>
3.11
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
org.apache.jclouds.api
</groupId>
<artifactId>
ec2
</artifactId>
<version>
2.2.1
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
...
...
src/main/java/org/activeeon/morphemic/PAGateway.java
View file @
fd8fce05
...
...
@@ -5,10 +5,7 @@ import org.activeeon.morphemic.application.deployment.PASchedulerGateway;
import
org.activeeon.morphemic.infrastructure.deployment.PAConnectorIaasGateway
;
import
org.activeeon.morphemic.infrastructure.deployment.PAResourceManagerGateway
;
import
org.activeeon.morphemic.model.*
;
import
org.activeeon.morphemic.service.EntityManagerHelper
;
import
org.activeeon.morphemic.service.NodeCandidateUtils
;
import
org.activeeon.morphemic.service.TemporaryFilesHelper
;
import
org.activeeon.morphemic.service.UpdatingNodeCandidatesThread
;
import
org.activeeon.morphemic.service.*
;
import
org.apache.commons.lang3.Validate
;
import
org.apache.log4j.Logger
;
import
org.codehaus.jackson.map.ObjectMapper
;
...
...
@@ -285,11 +282,11 @@ public class PAGateway {
List
<
NodeCandidate
>
allNodeCandidates
=
EntityManagerHelper
.
createQuery
(
"SELECT nc FROM NodeCandidate nc"
,
NodeCandidate
.
class
).
getResultList
();
allNodeCandidates
.
forEach
(
nodeCandidate
->
{
// Hardware types t3a and t4g are not YET, handled by jclouds.
if
(
N
odeCandidate
Utils
.
verifyAllFilters
(
requirements
,
nodeCandidate
)
&&
!
n
odeCandidate
.
getHardware
().
getName
().
startsWith
(
"t3a"
)
&&
!
n
odeCandidate
.
getHardware
().
getName
().
startsWith
(
"t4g"
))
{
filteredNodeCandidates
.
add
(
nodeCandidate
);
if
(
JCloudsInstancesUtils
.
isHandledHardwareInstanceType
(
nodeCandidate
.
getCloud
().
getApi
().
getProviderName
(),
n
odeCandidate
.
getHardware
().
getName
()))
{
if
(
N
odeCandidate
Utils
.
verifyAllFilters
(
requirements
,
nodeCandidate
))
{
filteredN
odeCandidate
s
.
add
(
nodeCandidate
);
}
}
});
return
filteredNodeCandidates
;
...
...
src/main/java/org/activeeon/morphemic/service/JCloudsInstancesUtils.java
0 → 100644
View file @
fd8fce05
package
org.activeeon.morphemic.service
;
import
org.apache.log4j.Logger
;
import
org.jclouds.ec2.domain.InstanceType
;
import
java.util.Arrays
;
import
java.util.HashSet
;
import
java.util.Set
;
public
class
JCloudsInstancesUtils
{
private
static
final
Set
<
String
>
handledAWSInstanceTypes
;
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
JCloudsInstancesUtils
.
class
);
static
{
handledAWSInstanceTypes
=
new
HashSet
<>();
Arrays
.
stream
(
InstanceType
.
class
.
getFields
()).
forEach
(
field
->
{
try
{
handledAWSInstanceTypes
.
add
(
field
.
get
(
InstanceType
.
class
).
toString
());
}
catch
(
IllegalAccessException
e
)
{
LOGGER
.
warn
(
e
.
getStackTrace
());
}
});
}
private
JCloudsInstancesUtils
()
{
}
/**
* Some hardware instance types (like t3a and t4g for AWS) are not YET, handled by jclouds.
* This method is here to check if the instance type is handled or not.
* @param providerName The Cloud provider id
* @param instanceType The instance type to be checked
* @return true if the instance type is handled by jclouds, false otherwise
*/
public
static
boolean
isHandledHardwareInstanceType
(
String
providerName
,
String
instanceType
)
{
if
(
"aws-ec2"
.
equals
(
providerName
))
return
handledAWSInstanceTypes
.
contains
(
instanceType
);
// TODO: To check if for other cloud providers all instance types are handled by JClouds
return
true
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment