Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
85eb5d3
very wip distributed cache
ssalinas Jun 21, 2019
e3c46ff
more wip
ssalinas Jun 23, 2019
c96f369
more wip
ssalinas Jun 26, 2019
388fa7b
even more wip
ssalinas Jun 26, 2019
b1767c5
clean up deps and resource class calls
ssalinas Jun 27, 2019
be8ebaa
atomix starts, now I broke jade
ssalinas Jun 27, 2019
8b83bf5
fix jade
ssalinas Jun 27, 2019
840ef49
turn log level back down in tests
ssalinas Jun 27, 2019
ec60df9
slow these down to reduce mem usage
ssalinas Jun 28, 2019
fa47126
down to 5 failing tests
ssalinas Jun 28, 2019
b152510
down to 2 failing tests
ssalinas Jun 28, 2019
5c270f7
attempts at fixing odd guava stuff
ssalinas Jun 28, 2019
cbb7fb6
fix serialization
ssalinas Jun 28, 2019
82e97f5
fix history persist cache clear
ssalinas Jun 28, 2019
a122e9c
fix merge conflicts with master
ssalinas Jul 10, 2019
f70241a
update port selection for tests
ssalinas Jul 10, 2019
b2efea6
junit5, make the tests fast enough to actually run in reasonable time
ssalinas Jul 11, 2019
c04a7a1
fix map sync and other startup issues
ssalinas Jul 11, 2019
10d30b6
fix startup races
ssalinas Jul 12, 2019
2351dba
Calculate max task lag after excluding on demands with instance limit
ssalinas Jun 27, 2019
207154d
wrong var here
ssalinas Jun 27, 2019
9879f42
tweak cooldown thresholds and evaluation logic
ssalinas Jul 10, 2019
f724d7a
fix failure window condition
ssalinas Jul 10, 2019
e2fbf6e
rework membership discovery model
ssalinas Jul 12, 2019
d3343f6
longer default startup time
ssalinas Jul 12, 2019
093bbfa
always use fresh host states
ssalinas Jul 12, 2019
371b38e
this isn't thrown anymore
ssalinas Jul 12, 2019
8d86230
Add test resource endpoint to get cache data
ssalinas Jul 15, 2019
4d25306
set number of backups
ssalinas Jul 15, 2019
395a6ab
avoid npe
ssalinas Jul 16, 2019
b75420d
missing @Produces
ssalinas Jul 16, 2019
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 @@ -25,6 +25,7 @@ public class SingularityHostState {

private final String mesosMaster;
private final boolean mesosConnected;
private final long cacheLag;

@JsonCreator
public SingularityHostState(@JsonProperty("master") boolean master,
Expand All @@ -37,7 +38,8 @@ public SingularityHostState(@JsonProperty("master") boolean master,
@JsonProperty("mesosConnected") boolean mesosConnected,
@JsonProperty("offerCacheSize") int offerCacheSize,
@JsonProperty("availableCachedCpus") double availableCachedCpus,
@JsonProperty("availableCachedMemory") double availableCachedMemory) {
@JsonProperty("availableCachedMemory") double availableCachedMemory,
@JsonProperty("cacheLag") long cacheLag) {
this.master = master;
this.uptime = uptime;
this.driverStatus = driverStatus;
Expand All @@ -49,6 +51,7 @@ public SingularityHostState(@JsonProperty("master") boolean master,
this.availableCachedCpus = availableCachedCpus;
this.availableCachedMemory = availableCachedMemory;
this.offerCacheSize = offerCacheSize;
this.cacheLag = cacheLag;
}

@Schema(description = "Address for this scheduler instance (host:port)")
Expand Down Expand Up @@ -106,6 +109,11 @@ public double getAvailableCachedMemory() {
return availableCachedMemory;
}

@Schema(description = "Last measured delay for the atomix cache")
public long getCacheLag() {
return cacheLag;
}

@Override
public String toString() {
return "SingularityHostState{" +
Expand All @@ -120,6 +128,7 @@ public String toString() {
", hostname='" + hostname + '\'' +
", mesosMaster='" + mesosMaster + '\'' +
", mesosConnected=" + mesosConnected +
", cacheLag='" + cacheLag + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.hubspot.singularity;

import java.util.ArrayList;
import java.util.List;

public class SingularityScheduledTasksInfo {
Expand All @@ -9,9 +8,11 @@ public class SingularityScheduledTasksInfo {
private final long maxTaskLag;
private final long timestamp;
private final List<SingularityPendingTaskId> lateTasks;
private final List<SingularityPendingTaskId> onDemandLateTasks;

private SingularityScheduledTasksInfo(List<SingularityPendingTaskId> lateTasks, int numFutureTasks, long maxTaskLag, long timestamp) {
public SingularityScheduledTasksInfo(List<SingularityPendingTaskId> lateTasks, List<SingularityPendingTaskId> onDemandLateTasks, int numFutureTasks, long maxTaskLag, long timestamp) {
this.lateTasks = lateTasks;
this.onDemandLateTasks = onDemandLateTasks;
this.numFutureTasks = numFutureTasks;
this.maxTaskLag = maxTaskLag;
this.timestamp = timestamp;
Expand All @@ -21,8 +22,8 @@ public List<SingularityPendingTaskId> getLateTasks() {
return lateTasks;
}

public int getNumLateTasks() {
return getLateTasks().size();
public List<SingularityPendingTaskId> getOnDemandLateTasks() {
return onDemandLateTasks;
}

public int getNumFutureTasks() {
Expand All @@ -36,28 +37,4 @@ public long getMaxTaskLag() {
public long getTimestamp() {
return timestamp;
}

public static SingularityScheduledTasksInfo getInfo(List<SingularityPendingTask> pendingTasks, long millisDeltaForLateTasks) {
final long now = System.currentTimeMillis();

int numFutureTasks = 0;
long maxTaskLag = 0;
List<SingularityPendingTaskId> lateTasks = new ArrayList<>();

for (SingularityPendingTask pendingTask : pendingTasks) {
long delta = now - pendingTask.getPendingTaskId().getNextRunAt();

if (delta > millisDeltaForLateTasks) {
lateTasks.add(pendingTask.getPendingTaskId());
} else {
numFutureTasks++;
}

if (delta > maxTaskLag) {
maxTaskLag = delta;
}
}

return new SingularityScheduledTasksInfo(lateTasks, numFutureTasks, maxTaskLag, now);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,40 @@ public String toString() {
", resources=" + resources +
"} " + super.toString();
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
if (!super.equals(o)) {
return false;
}

SingularitySlave that = (SingularitySlave) o;

if (host != null ? !host.equals(that.host) : that.host != null) {
return false;
}
if (rackId != null ? !rackId.equals(that.rackId) : that.rackId != null) {
return false;
}
if (attributes != null ? !attributes.equals(that.attributes) : that.attributes != null) {
return false;
}
return resources != null ? resources.equals(that.resources) : that.resources == null;
}

@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (host != null ? host.hashCode() : 0);
result = 31 * result + (rackId != null ? rackId.hashCode() : 0);
result = 31 * result + (attributes != null ? attributes.hashCode() : 0);
result = 31 * result + (resources != null ? resources.hashCode() : 0);
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Optional;

Expand Down Expand Up @@ -372,6 +373,14 @@ public long getLastHeartbeatAt() {
return lastHeartbeatAt;
}

@JsonIgnore
public SingularityState withHostStates(List<SingularityHostState> hostStates) {
return new SingularityState(activeTasks, launchingTasks, activeRequests, cooldownRequests, pausedRequests, scheduledTasks, pendingRequests, lbCleanupTasks, lbCleanupRequests,
cleaningRequests, activeSlaves, deadSlaves, decommissioningSlaves, activeRacks, deadRacks, decommissioningRacks, cleaningTasks, hostStates, oldestDeploy, numDeploys, oldestDeployStep,
activeDeploys, lateTasks, listLateTasks, onDemandLateTasks, onDemandListLateTasks, futureTasks, maxTaskLag, generatedAt, overProvisionedRequestIds, underProvisionedRequestIds, overProvisionedRequests,
underProvisionedRequests, finishedRequests, unknownRacks, unknownSlaves, authDatastoreHealthy, minimumPriorityLevel, avgStatusUpdateDelayMs, lastHeartbeatAt);
}

@Override
public String toString() {
return "SingularityState{" +
Expand Down
20 changes: 16 additions & 4 deletions SingularityClient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,26 @@
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.Collections;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.google.inject.AbstractModule;
import com.google.inject.Guice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.*;
import static org.mockito.internal.verification.VerificationModeFactory.times;

import java.net.URI;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
Expand All @@ -34,7 +33,7 @@ public class SingularityClientTest {

private SingularityClient singularityClient;

@Before
@BeforeEach
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
singularityClient = buildClient();
Expand Down
22 changes: 18 additions & 4 deletions SingularityExecutor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,29 @@
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import javax.validation.Validator;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.jknack.handlebars.Handlebars;
Expand Down
20 changes: 16 additions & 4 deletions SingularityS3Base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,26 @@

<!-- Unit test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hubspot.singularity.executor.config;
package com.hubspot.singularity.s3.base;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
Expand All @@ -13,30 +13,22 @@
import java.util.Arrays;
import java.util.List;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;

import com.google.common.base.Throwables;
import com.hubspot.singularity.runner.base.configuration.SingularityRunnerBaseConfiguration;
import com.hubspot.singularity.runner.base.sentry.SingularityRunnerExceptionNotifier;
import com.hubspot.singularity.s3.base.ArtifactManager;
import com.hubspot.singularity.s3.base.config.SingularityS3Configuration;

public class ArtifactManagerTest {

private ArtifactManager artifactManager;

@Rule
public TemporaryFolder cacheDir = new TemporaryFolder();
private File cacheDir = com.google.common.io.Files.createTempDir();

@Rule
public ExpectedException expectedException = ExpectedException.none();

@Before
@BeforeEach
public void setup() {
SingularityRunnerBaseConfiguration baseConfig = new SingularityRunnerBaseConfiguration();
SingularityS3Configuration s3Config = new SingularityS3Configuration();
Expand All @@ -57,13 +49,13 @@ public void itAbsorbsFileAlreadyExistsExceptionsWhenCopyingDuplicateFiles() {

assertThat(originalPath.toFile()).hasContent(String.join(System.lineSeparator(), lines));

Path copyPath = Paths.get(cacheDir.getRoot().toString() + "/copy.txt");
Path copyPath = Paths.get(cacheDir.toString() + "/copy.txt");
assertThat(copyPath).doesNotExist();
artifactManager.copy(originalPath, cacheDir.getRoot().toPath(), "copy.txt");
artifactManager.copy(originalPath, cacheDir.toPath(), "copy.txt");
assertThat(copyPath).exists();

// A redundant copy operation should not throw.
artifactManager.copy(originalPath, cacheDir.getRoot().toPath(), "copy.txt");
artifactManager.copy(originalPath, cacheDir.toPath(), "copy.txt");
}

@Test
Expand All @@ -82,7 +74,7 @@ public void itPropagatesFileAlreadyExistsExceptionsWhenCopyingNonDuplicateFiles(

public Path write(String fileName, List<String> lines) {
try {
File file = cacheDir.newFile(fileName);
File file = cacheDir.toPath().resolve(fileName).toFile();
Path path = file.toPath();
Files.write(path, lines, Charset.forName("UTF-8"));
return path;
Expand Down
Loading