use of io.mantisrx.runtime.parameter.Parameter in project mantis by Netflix.
the class JobDefinitionResolverTest method artifactPresentButSchedAbsentFailsTest.
@Test
public void artifactPresentButSchedAbsentFailsTest() {
String clusterName = "artifactPresentButSchedAbsentFailsTest";
List<Label> labels = new ArrayList<>();
Label label = new Label("l1", "lv1");
labels.add(label);
List<Parameter> parameters = new ArrayList<>();
Parameter parameter = new Parameter("paramName", "paramValue");
parameters.add(parameter);
final JobClusterDefinitionImpl fakeJobCluster = createFakeJobClusterDefn(clusterName, labels, parameters);
IJobClusterMetadata jobClusterMetadata = new JobClusterMetadataImpl(fakeJobCluster, 1, false);
String version = "0.0.2";
String artifactName = "myArt2";
// Only new artifact and version is specified
try {
JobDefinition givenJobDefn = new JobDefinition.Builder().withArtifactName(artifactName).withName(clusterName).withVersion(version).build();
JobDefinitionResolver resolver = new JobDefinitionResolver();
JobDefinition resolvedJobDefinition = resolver.getResolvedJobDefinition("user", givenJobDefn, jobClusterMetadata);
fail();
} catch (Exception e) {
e.printStackTrace();
}
// Only new artifact is specified
try {
JobDefinition givenJobDefn = new JobDefinition.Builder().withArtifactName(artifactName).withName(clusterName).build();
JobDefinitionResolver resolver = new JobDefinitionResolver();
JobDefinition resolvedJobDefinition = resolver.getResolvedJobDefinition("user", givenJobDefn, jobClusterMetadata);
fail();
} catch (Exception e) {
e.printStackTrace();
}
}
use of io.mantisrx.runtime.parameter.Parameter in project mantis by Netflix.
the class JobDefinitionResolverTest method versionNotFoundTest.
@Test
public void versionNotFoundTest() {
String clusterName = "versionNotFoundTest";
List<Label> labels = new ArrayList<>();
Label label = new Label("l1", "lv1");
labels.add(label);
List<Parameter> parameters = new ArrayList<>();
Parameter parameter = new Parameter("paramName", "paramValue");
parameters.add(parameter);
final JobClusterDefinitionImpl fakeJobCluster = createFakeJobClusterDefn(clusterName, labels, parameters);
IJobClusterMetadata jobClusterMetadata = new JobClusterMetadataImpl(fakeJobCluster, 1, false);
String version = "0.0.2";
try {
JobDefinition givenJobDefn = new JobDefinition.Builder().withName(clusterName).withVersion(version).build();
JobDefinitionResolver resolver = new JobDefinitionResolver();
JobDefinition resolvedJobDefinition = resolver.getResolvedJobDefinition("user", givenJobDefn, jobClusterMetadata);
fail();
} catch (Exception e) {
e.printStackTrace();
}
}
use of io.mantisrx.runtime.parameter.Parameter in project mantis by Netflix.
the class JobConnectorJob method main.
public static void main(String[] args) throws JsonProcessingException {
Map<String, Object> targetMap = new HashMap<>();
List<JobSource.TargetInfo> targetInfos = new ArrayList<>();
JobSource.TargetInfo targetInfo = new JobSource.TargetInfoBuilder().withClientId("abc").withSourceJobName("SyntheticSourceJob").withQuery("select country from stream where status==500").build();
targetInfos.add(targetInfo);
targetMap.put("targets", targetInfos);
ObjectMapper mapper = new ObjectMapper();
String target = mapper.writeValueAsString(targetMap);
// To run locally we use the LocalJobExecutor
LocalJobExecutorNetworked.execute(new JobConnectorJob().getJobInstance(), new Parameter(MantisSourceJobConnector.MANTIS_SOURCEJOB_TARGET_KEY, target));
}
use of io.mantisrx.runtime.parameter.Parameter in project mantis by Netflix.
the class VirtualMachineWorkerServiceLocalImpl method createExecuteStageRequest.
private WrappedExecuteStageRequest createExecuteStageRequest() throws MalformedURLException {
// TODO make ExecuteStageRequest params configurable
final long timeoutToReportStartSec = 5;
final URL jobJarUrl = new URL("file:/Users/nmahilani/Projects/Mantis/mantis-sdk/examples/sine-function/build/distributions/sine-function-1.0.zip");
final List<Integer> ports = Arrays.asList(31015, 31013, 31014);
final List<Parameter> params = Collections.singletonList(new Parameter("useRandom", "true"));
final int numInstances = 1;
// new MachineDefinition(2, 300, 200, 1024, 2), true));
final Map<Integer, StageSchedulingInfo> schedulingInfoMap = new HashMap<>();
final StageSchedulingInfo stage0SchedInfo = StageSchedulingInfo.builder().numberOfInstances(numInstances).machineDefinition(MachineDefinitions.micro()).build();
final StageSchedulingInfo stage1SchedInfo = StageSchedulingInfo.builder().numberOfInstances(numInstances).machineDefinition(new MachineDefinition(2, 300, 200, 1024, 2)).scalingPolicy(new StageScalingPolicy(1, 1, 5, 1, 1, 30, Collections.singletonMap(StageScalingPolicy.ScalingReason.Memory, new StageScalingPolicy.Strategy(StageScalingPolicy.ScalingReason.Memory, 15.0, 25.0, new StageScalingPolicy.RollingCount(1, 2))))).scalable(true).build();
// schedulingInfoMap.put(0, stage0SchedInfo);
schedulingInfoMap.put(1, stage1SchedInfo);
final SchedulingInfo schedInfo = new SchedulingInfo(schedulingInfoMap);
final ExecuteStageRequest executeStageRequest = new ExecuteStageRequest(workerInfo.getJobName(), workerInfo.getJobId(), workerInfo.getWorkerIndex(), workerInfo.getWorkerNumber(), jobJarUrl, workerInfo.getStageNumber(), workerInfo.getNumStages(), ports, timeoutToReportStartSec, workerInfo.getMetricsPort(), params, schedInfo, MantisJobDurationType.Transient, 0L, 0L, new WorkerPorts(Arrays.asList(7151, 7152, 7153, 7154, 7155)));
return new WrappedExecuteStageRequest(PublishSubject.<Boolean>create(), executeStageRequest);
}
use of io.mantisrx.runtime.parameter.Parameter in project mantis by Netflix.
the class TestJobParameterized method main.
public static void main(String[] args) throws InterruptedException {
Job<Integer> job = new TestJobParameterized().getJobInstance();
LocalJobExecutorNetworked.execute(job, new Parameter("start-range", "1"), new Parameter("end-range", "100"), new Parameter("scale-by", "2"));
}
Aggregations