Skip to content

Commit

Permalink
Cleaning code.
Browse files Browse the repository at this point in the history
  • Loading branch information
iridin committed Apr 19, 2017
1 parent d9c6496 commit 881cce0
Show file tree
Hide file tree
Showing 25 changed files with 88 additions and 661 deletions.
3 changes: 1 addition & 2 deletions jdeeco-adaptation-plugin/build.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
source.. = src/, test/
bin.includes = META-INF/,\
.
bin.includes = .

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,25 @@ public class AdaptationPlugin implements DEECoPlugin {

private long period = 10000;

private boolean verbose;

private MetaAdaptationManager adaptationManager;


/** Plugin dependencies. */
static private final List<Class<? extends DEECoPlugin>> DEPENDENCIES =
Collections.emptyList();

/* (non-Javadoc)
* @see cz.cuni.mff.d3s.deeco.runtime.DEECoPlugin#getDependencies()
*/
@Override
public List<Class<? extends DEECoPlugin>> getDependencies() {
return DEPENDENCIES;
}

public AdaptationPlugin withVerbosity(boolean verbosity){
verbose = verbosity;
return this;
}

Expand All @@ -63,14 +75,6 @@ public void registerAdaptation(MAPEAdaptation adaptation){

adaptationManager.addAdaptation(adaptation);
}

/* (non-Javadoc)
* @see cz.cuni.mff.d3s.deeco.runtime.DEECoPlugin#getDependencies()
*/
@Override
public List<Class<? extends DEECoPlugin>> getDependencies() {
return DEPENDENCIES;
}

/* (non-Javadoc)
* @see cz.cuni.mff.d3s.deeco.runtime.DEECoPlugin#init(cz.cuni.mff.d3s.deeco.runtime.DEECoContainer)
Expand All @@ -79,18 +83,15 @@ public List<Class<? extends DEECoPlugin>> getDependencies() {
public void init(DEECoContainer container) throws PluginInitFailedException {
try {
adaptationManager = new MetaAdaptationManager();
container.deployComponent(new AdaptationComponent(adaptationManager));
adaptationManager.setVerbosity(verbose);
ComponentInstance c = container.deployComponent(new AdaptationComponent(adaptationManager));

for (ComponentInstance c : container.getRuntimeMetadata().getComponentInstances()) {
if (c.getName().equals(MetaAdaptationManager.class.getName())) {
// Adjust non-deterministic mode switching manager periods
for (ComponentProcess p: c.getComponentProcesses()) {
if(p.getName().equals("reason")){
for (Trigger t : p.getTriggers()){
if (t instanceof TimeTrigger) {
((TimeTrigger) t).setPeriod(period);
}
}
// Adjust non-deterministic mode switching manager periods
for (ComponentProcess p: c.getComponentProcesses()) {
if(p.getName().equals("reason")){
for (Trigger t : p.getTriggers()){
if (t instanceof TimeTrigger) {
((TimeTrigger) t).setPeriod(period);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public ComponentImpl(ComponentInstance component){
*/
@Override
public void addPort(Port port) {
// TODO Auto-generated method stub
// TODO: implement
throw new UnsupportedOperationException();

}

Expand All @@ -57,6 +58,7 @@ public void addPort(Port port) {
*/
@Override
public void removePort(Port port) {
// TODO: implement properly
KnowledgeManager kManager = component.getKnowledgeManager();
kManager.updateRoles(null);
Log.i("Removing the role of the " + kManager.getId());
Expand All @@ -82,7 +84,7 @@ public Set<Port> getPorts() {
*/
@Override
public void monitorHealth(Port port) {

// TODO: check whether this is needed

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,19 @@ public class ComponentIsolationPlugin implements DEECoPlugin, StartupListener {
/** Plugin dependencies. */
@SuppressWarnings("unchecked")
static private final List<Class<? extends DEECoPlugin>> DEPENDENCIES =
Arrays.asList(new Class[]{AdaptationPlugin.class});;
Arrays.asList(new Class[]{AdaptationPlugin.class});

@Override
public List<Class<? extends DEECoPlugin>> getDependencies() {
return DEPENDENCIES;
}

public ComponentIsolationPlugin(Set<DEECoNode> nodes){
if(nodes == null){
throw new IllegalArgumentException(String.format("The %s argument is null.", "nodes"));
}

verbose = false;

this.nodes = nodes;
}

Expand All @@ -61,15 +64,9 @@ public ComponentIsolationPlugin withVerbosity(boolean verbose){
this.verbose = verbose;
return this;
}

@Override
public List<Class<? extends DEECoPlugin>> getDependencies() {
return DEPENDENCIES;
}


@Override
public void init(DEECoContainer container) {

container.addStartupListener(this);

adaptationPlugin = container.getPluginInstance(AdaptationPlugin.class);
Expand All @@ -91,6 +88,9 @@ public void onStartup() throws PluginStartupFailedException {
}
}

adaptationPlugin.registerAdaptation(new ComponentIsolationManager(new ComponentManagerImpl(c)));
ComponentIsolationManager ciManager = new ComponentIsolationManager(new ComponentManagerImpl(c));
ciManager.setVerbosity(verbose);

adaptationPlugin.registerAdaptation(ciManager);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class ComponentManagerImpl implements cz.cuni.mff.d3s.metaadaptation.comp

private final Set<Component> components;


public ComponentManagerImpl(Set<Component> components){
if(components == null){
throw new IllegalArgumentException(String.format("The %s argument is null.", "components"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class PortImpl implements cz.cuni.mff.d3s.metaadaptation.componentisolati
@SuppressWarnings("rawtypes")
private final Class role;


@SuppressWarnings("rawtypes")
public PortImpl(Class role){
if(role == null){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class ComponentImpl implements cz.cuni.mff.d3s.metaadaptation.correlation

private final ComponentInstance componentInstance;


public ComponentImpl(String componentName, ComponentInstance componentInstance) {
if (componentName == null || componentName.isEmpty()) {
throw new IllegalArgumentException(String.format("The %s argument is null or empty.", "componentName"));
Expand Down Expand Up @@ -90,7 +91,8 @@ public Set<String> getKnowledgeFields() {
@Override
public Object getKnowledgeValue(String knowlegeField) {
try {
Map<String, Map<String, CorrelationMetadataWrapper<? extends Object>>> knowledgeOfAllComponents = getKnowledgeOfAllComponents();
Map<String, Map<String, CorrelationMetadataWrapper<? extends Object>>> knowledgeOfAllComponents
= getKnowledgeOfAllComponents();

if (knowledgeOfAllComponents.containsKey(componentName)) {
if (knowledgeOfAllComponents.get(componentName).containsKey(knowlegeField)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.Map;

import cz.cuni.mff.d3s.deeco.annotations.Component;
import cz.cuni.mff.d3s.deeco.annotations.Local;
import cz.cuni.mff.d3s.deeco.annotations.PlaysRole;
import cz.cuni.mff.d3s.deeco.annotations.SystemComponent;
import cz.cuni.mff.d3s.metaadaptation.correlation.CorrelationMetadataWrapper;
Expand All @@ -33,17 +32,6 @@
@SystemComponent
@PlaysRole(CorrelationKnowledgeRole.class)
public class CorrelationKnowledgeData {
/**
* Specify whether to print the values being processed by the correlation computation.
*/
@Local
static boolean dumpValues = false;

@Local
static boolean verbose = false;

@Local
static boolean logGeneratedEnsembles = false;

public String id = "CorrelationData";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ public class CorrelationPlugin implements DEECoPlugin, StartupListener {
/** Plugin dependencies. */
@SuppressWarnings("unchecked")
static private final List<Class<? extends DEECoPlugin>> DEPENDENCIES =
Arrays.asList(new Class[]{AdaptationPlugin.class});;
Arrays.asList(new Class[]{AdaptationPlugin.class});

@Override
public List<Class<? extends DEECoPlugin>> getDependencies() {
return DEPENDENCIES;
}


public CorrelationPlugin(Set<DEECoNode> nodes){
Expand All @@ -70,7 +75,6 @@ public CorrelationPlugin(Set<DEECoNode> nodes){
*/
public CorrelationPlugin withVerbosity(boolean verbose){
this.verbose = verbose;
CorrelationManager.verbose = verbose;
return this;
}

Expand All @@ -81,24 +85,18 @@ public CorrelationPlugin withVerbosity(boolean verbose){
*/
public CorrelationPlugin withDumping(boolean dumpValues){
this.dumpValues = dumpValues;
CorrelationManager.dumpValues = dumpValues;
return this;
}

@Override
public List<Class<? extends DEECoPlugin>> getDependencies() {
return DEPENDENCIES;
}

@Override
public void init(DEECoContainer container) {
AnnotationProcessorExtensionPoint correlationAwareAnnotationProcessorExtension = new CorrelationAwareAnnotationProcessorExtension();
container.getProcessor().addExtension(correlationAwareAnnotationProcessorExtension);
container.addStartupListener(this);

try {
CorrelationManager.verbose = verbose;
CorrelationManager.dumpValues = dumpValues;
manager.setVerbosity(verbose);
manager.setDumpValues(dumpValues);

container.deployComponent(new CorrelationKnowledgeData());
container.deployEnsemble(CorrelationDataAggregation.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class EnsembleManagerImpl implements cz.cuni.mff.d3s.metaadaptation.corre
@Local
private final List<DEECoNode> nodes;


public EnsembleManagerImpl() {
this.nodes = new ArrayList<>();
}
Expand Down
Loading

0 comments on commit 881cce0

Please sign in to comment.