TaskExecutor implements Executor { @Override public void registered(final ExecutorDriver executorDriver, final Protos.ExecutorInfo executorInfo, final Protos.FrameworkInfo frameworkInfo, final Protos.SlaveInfo slaveInfo) { if (!executorInfo.getData().isEmpty()) { Map<String, String> data = SerializationUtils.deserialize(executorInfo.getData().toByteArray()); BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(data.get("event_trace_rdb_driver")); dataSource.setUrl(data.get("event_trace_rdb_url")); dataSource.setPassword(data.get("event_trace_rdb_password")); dataSource.setUsername(data.get("event_trace_rdb_username")); jobEventBus = new JobEventBus(new TracingConfiguration<DataSource>("RDB", dataSource)); } } TaskExecutor(final ElasticJob elasticJob);  TaskExecutor(final String elasticJobType); @Override void registered(final ExecutorDriver executorDriver, final Protos.ExecutorInfo executorInfo, final Protos.FrameworkInfo frameworkInfo, final Protos.SlaveInfo slaveInfo); @Override void reregistered(final ExecutorDriver executorDriver, final Protos.SlaveInfo slaveInfo); @Override void disconnected(final ExecutorDriver executorDriver); @Override void launchTask(final ExecutorDriver executorDriver, final Protos.TaskInfo taskInfo); @Override void killTask(final ExecutorDriver executorDriver, final Protos.TaskID taskID); @Override void frameworkMessage(final ExecutorDriver executorDriver, final byte[] bytes); @Override void shutdown(final ExecutorDriver executorDriver); @Override void error(final ExecutorDriver executorDriver, final String message);  }
@Test public void assertRegisteredWithoutData() { HashMap<String, String> data = new HashMap<>(4, 1); data.put("event_trace_rdb_driver", "org.h2.Driver"); data.put("event_trace_rdb_url", "jdbc:h2:mem:test_executor"); data.put("event_trace_rdb_username", "sa"); data.put("event_trace_rdb_password", ""); ExecutorInfo executorInfo = ExecutorInfo.newBuilder().setExecutorId(Protos.ExecutorID.newBuilder().setValue("test_executor")).setCommand(Protos.CommandInfo.getDefaultInstance()) .setData(ByteString.copyFrom(SerializationUtils.serialize(data))).build(); taskExecutor.registered(executorDriver, executorInfo, frameworkInfo, slaveInfo); }
@Test public void assertRegisteredWithData() { taskExecutor.registered(executorDriver, executorInfo, frameworkInfo, slaveInfo); }