use of io.vertx.up.eon.em.ServerType in project vertx-zero by silentbalanceyh.
the class AgentScatter method connect.
@Override
public void connect(final Vertx vertx) {
/**
* 1.Find Agent for deploy *
*/
final ConcurrentMap<ServerType, Class<?>> agents = this.factor.agents();
final Extractor<DeploymentOptions> extractor = Instance.instance(AgentExtractor.class);
/**
* 2.Record options*
*/
final ConcurrentMap<Class<?>, DeploymentOptions> options = new ConcurrentHashMap<>();
Fn.itMap(agents, (type, clazz) -> {
// 3.1 Agent deployment options
final DeploymentOptions option = extractor.extract(clazz);
options.put(clazz, option);
// 3.2 Agent deployment
Verticles.deploy(vertx, clazz, option, LOGGER);
});
// Runtime hooker
Runtime.getRuntime().addShutdownHook(new Thread(() -> Fn.itMap(agents, (type, clazz) -> {
// 4. Undeploy Agent.
final DeploymentOptions opt = options.get(clazz);
Verticles.undeploy(vertx, clazz, opt, LOGGER);
})));
}
use of io.vertx.up.eon.em.ServerType in project vertx-zero by silentbalanceyh.
the class ZeroHelper method isAgentDefined.
/**
*/
public static ConcurrentMap<ServerType, Boolean> isAgentDefined(final ConcurrentMap<ServerType, List<Class<?>>> agents, final Class<?>... exclude) {
final Set<Class<?>> excludes = new HashSet<>(Arrays.asList(exclude));
final ConcurrentMap<ServerType, Boolean> defined = new ConcurrentHashMap<>();
for (final ServerType server : agents.keySet()) {
final List<Class<?>> item = agents.get(server);
// Filter to result.
final List<Class<?>> filtered = item.stream().filter(each -> !excludes.contains(each)).collect(Collectors.toList());
// > 1 means duplicated defined
final int size = filtered.size();
Fn.flingUp(1 < size, LOGGER, AgentDuplicatedException.class, ZeroHelper.class, server, size, filtered.stream().map(Class::getName).collect(Collectors.toSet()));
// == 0 means undefined
// == 1 means correct defined
defined.put(server, Values.ONE == size);
}
return defined;
}
use of io.vertx.up.eon.em.ServerType in project vertx-zero by silentbalanceyh.
the class PointScatter method connect.
@Override
public void connect(final Vertx vertx) {
/**
* 1.Find Agent for deploy *
*/
final ConcurrentMap<ServerType, Class<?>> agents = this.factor.agents();
final Extractor<DeploymentOptions> extractor = Instance.instance(AgentExtractor.class);
Fn.itMap(agents, (type, clazz) -> {
// 3.1 Agent deployment options
final DeploymentOptions option = extractor.extract(clazz);
// 3.2 Agent deployment
Verticles.deploy(vertx, clazz, option, LOGGER);
});
}
use of io.vertx.up.eon.em.ServerType in project vertx-zero by silentbalanceyh.
the class AgentScatter method connect.
@Override
public void connect(final Vertx vertx) {
/**
* 1.Find Agent for deploy *
*/
final ConcurrentMap<ServerType, Class<?>> agents = this.factor.agents();
final Extractor<DeploymentOptions> extractor = Instance.instance(AgentExtractor.class);
Fn.itMap(agents, (type, clazz) -> {
// 2.1. Agent deployment options
final DeploymentOptions option = extractor.extract(clazz);
// 2.2. Agent deployment
Verticles.deploy(vertx, clazz, option, LOGGER);
});
}
Aggregations