-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from iamdanfox/aggressive
Integration test verifies AggressiveShutdownStrategy actually works
- Loading branch information
Showing
23 changed files
with
385 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/main/java/com/palantir/docker/compose/connection/ContainerName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright 2016 Palantir Technologies, Inc. All rights reserved. | ||
*/ | ||
|
||
package com.palantir.docker.compose.connection; | ||
|
||
import static java.util.stream.Collectors.joining; | ||
|
||
import java.util.Arrays; | ||
import org.immutables.value.Value; | ||
|
||
@Value.Immutable | ||
public abstract class ContainerName { | ||
|
||
public abstract String rawName(); | ||
|
||
public abstract String semanticName(); | ||
|
||
@Override | ||
public String toString() { | ||
return semanticName(); | ||
} | ||
|
||
public static ContainerName fromPsLine(String psLine) { | ||
String[] lineComponents = psLine.split(" "); | ||
String rawName = lineComponents[0]; | ||
|
||
if (probablyCustomName(rawName)) { | ||
return ImmutableContainerName.builder() | ||
.rawName(rawName) | ||
.semanticName(rawName) | ||
.build(); | ||
} | ||
|
||
String semanticName = withoutDirectory(withoutScaleNumber(rawName)); | ||
return ImmutableContainerName.builder() | ||
.rawName(rawName) | ||
.semanticName(semanticName) | ||
.build(); | ||
} | ||
|
||
private static boolean probablyCustomName(String rawName) { | ||
return !(rawName.split("_").length >= 3); | ||
} | ||
|
||
private static String withoutDirectory(String rawName) { | ||
return Arrays.stream(rawName.split("_")) | ||
.skip(1) | ||
.collect(joining("_")); | ||
} | ||
|
||
public static String withoutScaleNumber(String rawName) { | ||
String[] components = rawName.split("_"); | ||
return Arrays.stream(components) | ||
.limit(components.length - 1) | ||
.collect(joining("_")); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.