Search in sources :

Example 1 with Parameter

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();
    }
}
Also used : Label(io.mantisrx.common.Label) ArrayList(java.util.ArrayList) JobClusterDefinitionImpl(io.mantisrx.server.master.domain.JobClusterDefinitionImpl) InvalidJobException(io.mantisrx.runtime.command.InvalidJobException) Parameter(io.mantisrx.runtime.parameter.Parameter) JobDefinition(io.mantisrx.server.master.domain.JobDefinition) Test(org.junit.Test)

Example 2 with Parameter

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();
    }
}
Also used : Label(io.mantisrx.common.Label) ArrayList(java.util.ArrayList) JobClusterDefinitionImpl(io.mantisrx.server.master.domain.JobClusterDefinitionImpl) InvalidJobException(io.mantisrx.runtime.command.InvalidJobException) Parameter(io.mantisrx.runtime.parameter.Parameter) JobDefinition(io.mantisrx.server.master.domain.JobDefinition) Test(org.junit.Test)

Example 3 with Parameter

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));
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Parameter(io.mantisrx.runtime.parameter.Parameter) JobSource(io.mantisrx.connector.job.source.JobSource) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 4 with Parameter

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);
}
Also used : MachineDefinition(io.mantisrx.runtime.MachineDefinition) StageSchedulingInfo(io.mantisrx.runtime.descriptor.StageSchedulingInfo) SchedulingInfo(io.mantisrx.runtime.descriptor.SchedulingInfo) HashMap(java.util.HashMap) URL(java.net.URL) ExecuteStageRequest(io.mantisrx.server.core.ExecuteStageRequest) StageScalingPolicy(io.mantisrx.runtime.descriptor.StageScalingPolicy) WorkerPorts(io.mantisrx.common.WorkerPorts) StageSchedulingInfo(io.mantisrx.runtime.descriptor.StageSchedulingInfo) Parameter(io.mantisrx.runtime.parameter.Parameter)

Example 5 with Parameter

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"));
}
Also used : Parameter(io.mantisrx.runtime.parameter.Parameter) IntParameter(io.mantisrx.runtime.parameter.type.IntParameter) StringParameter(io.mantisrx.runtime.parameter.type.StringParameter)

Aggregations

Parameter (io.mantisrx.runtime.parameter.Parameter)20 Test (org.junit.Test)14 HashMap (java.util.HashMap)9 Label (io.mantisrx.common.Label)8 ArrayList (java.util.ArrayList)8 StringParameter (io.mantisrx.runtime.parameter.type.StringParameter)7 ParameterDefinition (io.mantisrx.runtime.parameter.ParameterDefinition)6 EnumCSVParameter (io.mantisrx.runtime.parameter.type.EnumCSVParameter)6 EnumParameter (io.mantisrx.runtime.parameter.type.EnumParameter)6 JobDefinition (io.mantisrx.server.master.domain.JobDefinition)6 InvalidJobException (io.mantisrx.runtime.command.InvalidJobException)5 SchedulingInfo (io.mantisrx.runtime.descriptor.SchedulingInfo)5 JobClusterDefinitionImpl (io.mantisrx.server.master.domain.JobClusterDefinitionImpl)5 WorkerPorts (io.mantisrx.common.WorkerPorts)2 JobConstraints (io.mantisrx.runtime.JobConstraints)2 URL (java.net.URL)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ByteString (com.google.protobuf.ByteString)1 JobSource (io.mantisrx.connector.job.source.JobSource)1 IJobClusterMetadata (io.mantisrx.master.jobcluster.IJobClusterMetadata)1