File | Project | Line |
---|
org/jage/examples/properties/PropertiesSimpleAgent.java | jAgE examples solutions | 95 |
org/jage/examples/properties/xml/PropertiesSimpleAgent.java | jAgE examples solutions | 101 |
new Object[] { getAddress(), functionCounter.toString(), functionCounter.countSquareSum() });
if ((counter + this.hashCode()) % 3 == 0) {
watch();
}
try {
Thread.sleep(200);
} catch (InterruptedException e) {
log.error("Interrupted", e);
}
}
private void watch() {
Collection<SimpleAgent> answer;
try {
AgentEnvironmentQuery<SimpleAgent, SimpleAgent> query = new AgentEnvironmentQuery<SimpleAgent, SimpleAgent>();
answer = queryEnvironment(query);
log.info("Agent: {} can see in its environment: {} following agents:", getAddress(), getParentAddress());
for (SimpleAgent entry : answer) {
IAgentAddress agentAddress = (IAgentAddress)entry.getProperty("address").getValue();
if (agentAddress != getAddress()) {
log.info(" agent: {} with properties:", agentAddress);
for (Property property : entry.getProperties()) {
log.info(" {}: {}", property.getMetaProperty().getName(), property.getValue());
}
}
}
} catch (AgentException e) {
log.error("Agent exception", e);
} catch (InvalidPropertyPathException e) {
log.error("Invalid property", e);
}
}
@Override
public boolean finish() {
log.info("Finishing {}", getAddress());
return true;
} |
File | Project | Line |
---|
org/jage/examples/migration/CrawlingSimpleAgent.java | jAgE examples solutions | 88 |
org/jage/examples/multiworkplace/MultiworkplaceSimpleAgent.java | jAgE examples solutions | 90 |
counter++;
if ((counter + this.hashCode()) % 50 == 0) {
considerMigration();
}
try {
Thread.sleep(10);
} catch (InterruptedException e) {
log.error("Interrupted", e);
}
}
/**
* Considers migration and migrates eventually
*/
private void considerMigration() {
Collection<IAgent> answer;
IAgentAddress target = null;
try {
log.info("Queyring parent...");
AgentEnvironmentQuery<IAgent, IAgent> query = new AgentEnvironmentQuery<IAgent, IAgent>();
answer = queryParentEnvironment(query);
if (answer.size() > 1) {
log.info("Agent: {} can migrate from {} to following environments:", getAddress(), getParentAddress());
float max = 0;
for (IAgent entry : answer) {
IAgentAddress possibleTargetAddress = entry.getAddress(); |