use of eu.europa.ec.fisheries.schema.mobileterminal.types.v1.Plugin in project cdap by caskdata.
the class ETLStage method upgradeStage.
co.cask.cdap.etl.proto.v1.ETLStage upgradeStage(String name, String pluginType, UpgradeContext upgradeContext) {
ArtifactSelectorConfig artifactSelectorConfig = upgradeContext.getPluginArtifact(pluginType, this.name);
Plugin plugin = new Plugin(this.name, getProperties(), artifactSelectorConfig);
return new co.cask.cdap.etl.proto.v1.ETLStage(name, plugin, this.errorDatasetName);
}
use of eu.europa.ec.fisheries.schema.mobileterminal.types.v1.Plugin in project cdap by caskdata.
the class ETLRealtimeConfigTest method testUpgrade.
@Test
public void testUpgrade() throws Exception {
ETLStage source = new ETLStage("DataGenerator", ImmutableMap.of("p1", "v1"), null);
co.cask.cdap.etl.proto.v1.ETLStage sourceNew = new co.cask.cdap.etl.proto.v1.ETLStage("DataGenerator.1", new Plugin(source.getName(), source.getProperties()), source.getErrorDatasetName());
ETLStage transform1 = new ETLStage("Script", ImmutableMap.of("script", "something"), null);
co.cask.cdap.etl.proto.v1.ETLStage transform1New = new co.cask.cdap.etl.proto.v1.ETLStage("Script.2", new Plugin(transform1.getName(), transform1.getProperties()), transform1.getErrorDatasetName());
ETLStage transform2 = new ETLStage("Script", null, null);
co.cask.cdap.etl.proto.v1.ETLStage transform2New = new co.cask.cdap.etl.proto.v1.ETLStage("Script.3", new Plugin(transform2.getName(), transform2.getProperties()), transform2.getErrorDatasetName());
ETLStage transform3 = new ETLStage("Validator", ImmutableMap.of("p1", "v1", "p2", "v2"), "errorDS");
co.cask.cdap.etl.proto.v1.ETLStage transform3New = new co.cask.cdap.etl.proto.v1.ETLStage("Validator.4", new Plugin(transform3.getName(), transform3.getProperties()), transform3.getErrorDatasetName());
ETLStage sink1 = new ETLStage("Table", ImmutableMap.of("rowkey", "xyz"), null);
co.cask.cdap.etl.proto.v1.ETLStage sink1New = new co.cask.cdap.etl.proto.v1.ETLStage("Table.5", new Plugin(sink1.getName(), sink1.getProperties()), sink1.getErrorDatasetName());
ETLStage sink2 = new ETLStage("HDFS", ImmutableMap.of("name", "abc"), null);
co.cask.cdap.etl.proto.v1.ETLStage sink2New = new co.cask.cdap.etl.proto.v1.ETLStage("HDFS.6", new Plugin(sink2.getName(), sink2.getProperties()), sink2.getErrorDatasetName());
List<Connection> connections = new ArrayList<>();
connections.add(new Connection(sourceNew.getName(), transform1New.getName()));
connections.add(new Connection(transform1New.getName(), transform2New.getName()));
connections.add(new Connection(transform2New.getName(), transform3New.getName()));
connections.add(new Connection(transform3New.getName(), sink1New.getName()));
connections.add(new Connection(transform3New.getName(), sink2New.getName()));
Resources resources = new Resources(1024, 1);
ETLRealtimeConfig config = new ETLRealtimeConfig(1, source, ImmutableList.of(sink1, sink2), ImmutableList.of(transform1, transform2, transform3), resources);
co.cask.cdap.etl.proto.v1.ETLRealtimeConfig configNew = co.cask.cdap.etl.proto.v1.ETLRealtimeConfig.builder().setInstances(1).setSource(sourceNew).addSink(sink1New).addSink(sink2New).addTransform(transform1New).addTransform(transform2New).addTransform(transform3New).addConnections(connections).setResources(resources).build();
Assert.assertEquals(configNew, config.upgrade(new UpgradeContext() {
@Nullable
@Override
public ArtifactSelectorConfig getPluginArtifact(String pluginType, String pluginName) {
return null;
}
}));
}
use of eu.europa.ec.fisheries.schema.mobileterminal.types.v1.Plugin in project cdap by caskdata.
the class ETLBatchConfigTest method testUpgrade.
@Test
public void testUpgrade() throws Exception {
final ArtifactSelectorConfig artifact = new ArtifactSelectorConfig("SYSTEM", "universal", "1.0.0");
ETLStage source = new ETLStage("DataGenerator", ImmutableMap.of("p1", "v1"), null);
co.cask.cdap.etl.proto.v1.ETLStage sourceNew = new co.cask.cdap.etl.proto.v1.ETLStage("DataGenerator.1", new Plugin(source.getName(), source.getProperties(), artifact), source.getErrorDatasetName());
ETLStage transform1 = new ETLStage("Script", ImmutableMap.of("script", "something"), null);
co.cask.cdap.etl.proto.v1.ETLStage transform1New = new co.cask.cdap.etl.proto.v1.ETLStage("Script.2", new Plugin(transform1.getName(), transform1.getProperties(), artifact), transform1.getErrorDatasetName());
ETLStage transform2 = new ETLStage("Script", null, null);
co.cask.cdap.etl.proto.v1.ETLStage transform2New = new co.cask.cdap.etl.proto.v1.ETLStage("Script.3", new Plugin(transform2.getName(), transform2.getProperties(), artifact), transform2.getErrorDatasetName());
ETLStage transform3 = new ETLStage("Validator", ImmutableMap.of("p1", "v1", "p2", "v2"), "errorDS");
co.cask.cdap.etl.proto.v1.ETLStage transform3New = new co.cask.cdap.etl.proto.v1.ETLStage("Validator.4", new Plugin(transform3.getName(), transform3.getProperties(), artifact), transform3.getErrorDatasetName());
ETLStage sink1 = new ETLStage("Table", ImmutableMap.of("rowkey", "xyz"), null);
co.cask.cdap.etl.proto.v1.ETLStage sink1New = new co.cask.cdap.etl.proto.v1.ETLStage("Table.5", new Plugin(sink1.getName(), sink1.getProperties(), artifact), sink1.getErrorDatasetName());
ETLStage sink2 = new ETLStage("HDFS", ImmutableMap.of("name", "abc"), null);
co.cask.cdap.etl.proto.v1.ETLStage sink2New = new co.cask.cdap.etl.proto.v1.ETLStage("HDFS.6", new Plugin(sink2.getName(), sink2.getProperties(), artifact), sink2.getErrorDatasetName());
ETLStage action = new ETLStage("Email", ImmutableMap.of("email", "slj@example.com"), null);
co.cask.cdap.etl.proto.v1.ETLStage actionNew = new co.cask.cdap.etl.proto.v1.ETLStage("Email.1", new Plugin(action.getName(), action.getProperties(), artifact), action.getErrorDatasetName());
List<Connection> connections = new ArrayList<>();
connections.add(new Connection(sourceNew.getName(), transform1New.getName()));
connections.add(new Connection(transform1New.getName(), transform2New.getName()));
connections.add(new Connection(transform2New.getName(), transform3New.getName()));
connections.add(new Connection(transform3New.getName(), sink1New.getName()));
connections.add(new Connection(transform3New.getName(), sink2New.getName()));
String schedule = "*/5 * * * *";
Resources resources = new Resources(1024, 1);
ETLBatchConfig config = new ETLBatchConfig(schedule, source, ImmutableList.of(sink1, sink2), ImmutableList.of(transform1, transform2, transform3), resources, ImmutableList.of(action));
co.cask.cdap.etl.proto.v1.ETLBatchConfig configNew = co.cask.cdap.etl.proto.v1.ETLBatchConfig.builder(schedule).setSource(sourceNew).addSink(sink1New).addSink(sink2New).addTransform(transform1New).addTransform(transform2New).addTransform(transform3New).addConnections(connections).setResources(resources).setDriverResources(resources).addAction(actionNew).build();
Assert.assertEquals(configNew, config.upgrade(new UpgradeContext() {
@Nullable
@Override
public ArtifactSelectorConfig getPluginArtifact(String pluginType, String pluginName) {
return new ArtifactSelectorConfig(ArtifactScope.SYSTEM.name(), "universal", "1.0.0");
}
}));
}
use of eu.europa.ec.fisheries.schema.mobileterminal.types.v1.Plugin in project Hyperion-Android by willowtreeapps.
the class PluginLoader method load.
@WorkerThread
List<PluginModule> load() {
List<PluginModule> plugins = new ArrayList<>();
ServiceLoader<Plugin> loader = ServiceLoader.load(Plugin.class);
for (Plugin plugin : loader) {
PluginModule module = plugin.createPluginModule();
if (module != null) {
plugins.add(module);
}
}
return plugins;
}
use of eu.europa.ec.fisheries.schema.mobileterminal.types.v1.Plugin in project UVMS-Docker by UnionVMS.
the class MobileTerminalTestHelper method createMobileTerminalType.
public static MobileTerminalType createMobileTerminalType() throws IOException, ClientProtocolException, JsonProcessingException, JsonParseException, JsonMappingException {
MobileTerminalType mobileTerminalRequest = new MobileTerminalType();
mobileTerminalRequest.setSource(MobileTerminalSource.INTERNAL);
mobileTerminalRequest.setType("INMARSAT_C");
List<MobileTerminalAttribute> attributes = mobileTerminalRequest.getAttributes();
addAttribute(attributes, "SERIAL_NUMBER", AssetTestHelper.generateARandomStringWithMaxLength(10));
addAttribute(attributes, "SATELLITE_NUMBER", "S" + AssetTestHelper.generateARandomStringWithMaxLength(4));
addAttribute(attributes, "ANTENNA", "A");
addAttribute(attributes, "TRANSCEIVER_TYPE", "A");
addAttribute(attributes, "SOFTWARE_VERSION", "A");
List<ComChannelType> channels = mobileTerminalRequest.getChannels();
ComChannelType comChannelType = new ComChannelType();
channels.add(comChannelType);
comChannelType.setGuid(UUID.randomUUID().toString());
comChannelType.setName("VMS");
addChannelAttribute(comChannelType, "FREQUENCY_GRACE_PERIOD", "54000");
addChannelAttribute(comChannelType, "MEMBER_NUMBER", "100");
addChannelAttribute(comChannelType, "FREQUENCY_EXPECTED", "7200");
addChannelAttribute(comChannelType, "FREQUENCY_IN_PORT", "10800");
addChannelAttribute(comChannelType, "LES_DESCRIPTION", "Thrane&Thrane");
addChannelAttribute(comChannelType, "DNID", "1" + AssetTestHelper.generateARandomStringWithMaxLength(3));
addChannelAttribute(comChannelType, "INSTALLED_BY", "Mike Great");
addChannelCapability(comChannelType, "POLLABLE", true);
addChannelCapability(comChannelType, "CONFIGURABLE", true);
addChannelCapability(comChannelType, "DEFAULT_REPORTING", true);
Plugin plugin = new Plugin();
plugin.setServiceName("eu.europa.ec.fisheries.uvms.plugins.inmarsat");
plugin.setLabelName("Thrane&Thrane");
plugin.setSatelliteType("INMARSAT_C");
plugin.setInactive(false);
mobileTerminalRequest.setPlugin(plugin);
final HttpResponse response = Request.Post(getBaseUrl() + "mobileterminal/rest/mobileterminal").setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).bodyByteArray(writeValueAsString(mobileTerminalRequest).getBytes()).execute().returnResponse();
Map<String, Object> dataMap = checkSuccessResponseReturnMap(response);
Map<String, Object> assetMap = (Map<String, Object>) dataMap.get("mobileTerminalId");
assertNotNull(assetMap);
String mobileTerminalGuid = (String) assetMap.get("guid");
assertNotNull(mobileTerminalGuid);
ArrayList channelsList = (ArrayList) dataMap.get("channels");
assertNotNull(channelsList);
Map<String, Object> channelMap = (Map<String, Object>) channelsList.get(0);
assertNotNull(channelMap);
String channelGuid = (String) channelMap.get("guid");
comChannelType.setGuid(channelGuid);
mobileTerminalRequest.setId((Integer) dataMap.get("id"));
MobileTerminalId mobileTerminalId = new MobileTerminalId();
mobileTerminalId.setGuid(mobileTerminalGuid);
mobileTerminalRequest.setMobileTerminalId(mobileTerminalId);
return mobileTerminalRequest;
}
Aggregations