Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.Collection;
import java.util.Properties;


public class MetricsPublisherNoOp extends MetricsPublisher {

public MetricsPublisherNoOp(Properties properties) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

package io.mantisrx.runtime;

public enum JobConstraints {
import java.io.Serializable;

public enum JobConstraints implements Serializable {
UniqueHost,
ExclusiveHost,
ZoneBalance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import io.mantisrx.shaded.com.fasterxml.jackson.annotation.JsonCreator;
import io.mantisrx.shaded.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.mantisrx.shaded.com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;


public class MachineDefinition {
public class MachineDefinition implements Serializable {

private static final double defaultMbps = 128.0;
private static final int minPorts = 1;
Expand Down Expand Up @@ -122,4 +122,13 @@ public boolean equals(Object obj) {
return false;
return true;
}

// checks if the current machine can match the requirements of the passed machine definition
public boolean canFit(MachineDefinition o) {
return this.cpuCores >= o.cpuCores &&
this.memoryMB >= o.memoryMB &&
this.networkMbps >= o.networkMbps &&
this.diskMB >= o.diskMB &&
this.numPorts >= o.numPorts;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
public class NamedJobDefinition {

private final MantisJobDefinition jobDefinition;

;
private final JobOwner owner;

@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public NamedJobDefinition(@JsonProperty("jobDefinition") MantisJobDefinition jobDefinition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
import io.mantisrx.shaded.com.fasterxml.jackson.annotation.JsonProperty;
import io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.io.Serializable;
import java.util.*;
import java.util.function.Function;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@EqualsAndHashCode
@ToString
public class SchedulingInfo {
public class SchedulingInfo implements Serializable {

private Map<Integer, StageSchedulingInfo> stages = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
import io.mantisrx.shaded.com.fasterxml.jackson.annotation.JsonProperty;
import io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.io.Serializable;
import java.util.List;
import lombok.Builder;
import lombok.Singular;

@Builder(toBuilder = true)
public class StageSchedulingInfo {
public class StageSchedulingInfo implements Serializable {

private final int numberOfInstances;
private final MachineDefinition machineDefinition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
import io.mantisrx.shaded.com.fasterxml.jackson.annotation.JsonCreator;
import io.mantisrx.shaded.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.mantisrx.shaded.com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;


public class Parameter {
public class Parameter implements Serializable {

private String name;
private String value;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2022 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.mantisrx.runtime;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

public class MachineDefinitionTest {
@Test
public void testMachineDefinition() {
MachineDefinition md1 = new MachineDefinition(2, 2, 2, 2, 2);
MachineDefinition md2 = new MachineDefinition(1, 1, 1, 1, 1);
assertTrue(md1.canFit(md2));
assertFalse(md2.canFit(md1));

MachineDefinition md3 = new MachineDefinition(2, 2, 2, 2, 2);
MachineDefinition md4 = new MachineDefinition(3, 1, 1, 1, 1);
assertFalse(md3.canFit(md4));
assertFalse(md4.canFit(md3));

MachineDefinition md5 = new MachineDefinition(2, 2, 2, 2, 2);
MachineDefinition md6 = new MachineDefinition(2, 3, 1, 1, 1);
assertFalse(md5.canFit(md6));
assertFalse(md6.canFit(md5));

MachineDefinition md7 = new MachineDefinition(2, 2, 2, 2, 2);
MachineDefinition md8 = new MachineDefinition(2, 2, 2, 2, 2);
assertTrue(md7.canFit(md8));
assertTrue(md8.canFit(md7));
}
}