本文整理了Java中io.fabric8.maven.docker.util.Logger.warn()
方法的一些代码示例,展示了Logger.warn()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.warn()
方法的具体详情如下:
包路径:io.fabric8.maven.docker.util.Logger
类名称:Logger
方法名:warn
[英]A warning.
[中]警告。
代码示例来源:origin: fabric8io/docker-maven-plugin
private int adjustGracePeriod(int gracePeriod) {
int killGracePeriodInSeconds = (gracePeriod + 500) / 1000;
if (gracePeriod != 0 && killGracePeriodInSeconds == 0) {
log.warn("A kill grace period of %d ms leads to no wait at all since its rounded to seconds. " +
"Please use at least 500 as value for wait.kill", gracePeriod);
}
return killGracePeriodInSeconds;
}
代码示例来源:origin: fabric8io/docker-maven-plugin
private void shutdownExecutorService(ExecutorService executorService) {
if (!executorService.isShutdown()) {
executorService.shutdown();
try {
executorService.awaitTermination(10, TimeUnit.SECONDS);
} catch (InterruptedException e) {
log.warn("ExecutorService did not shutdown normally.");
executorService.shutdownNow();
}
}
}
代码示例来源:origin: fabric8io/docker-maven-plugin
private void logWarnings(JsonObject body) {
if (body.has("Warnings")) {
JsonElement warningsObj = body.get("Warnings");
if (!warningsObj.isJsonNull()) {
JsonArray warnings = (JsonArray) warningsObj;
for (int i = 0; i < warnings.size(); i++) {
log.warn(warnings.get(i).getAsString());
}
}
}
}
代码示例来源:origin: fabric8io/docker-maven-plugin
@Override
public IOException call() {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(errorStream));) {
for (; ; ) {
String line = reader.readLine();
if (line == null) {
break;
}
synchronized (log) {
log.warn(line);
}
}
return null;
} catch (IOException e) {
return e;
}
}
});
代码示例来源:origin: fabric8io/docker-maven-plugin
log.warn("<command> in the <build> configuration is deprecated and will be be removed soon");
log.warn("Please use <cmd> with nested <shell> or <exec> sections instead.");
log.warn("");
log.warn("More on this is explained in the user manual: ");
log.warn("https://github.com/fabric8io/docker-maven-plugin/blob/master/doc/manual.md#start-up-arguments");
log.warn("");
log.warn("Migration is trivial, see changelog to version 0.12.0 -->");
log.warn("https://github.com/fabric8io/docker-maven-plugin/blob/master/doc/changelog.md");
log.warn("");
log.warn("For now, the command is automatically translated for you to the shell form:");
log.warn(" <cmd>%s</cmd>", command);
代码示例来源:origin: fabric8io/docker-maven-plugin
private void addLocalMavenRepoEntry(AssemblyFiles ret, MavenSession session, File source, File target) {
File localMavenRepoFile = getLocalMavenRepoFile(session, source);
try {
if (localMavenRepoFile != null &&
! source.getCanonicalFile().equals(localMavenRepoFile.getCanonicalFile())) {
ret.addEntry(localMavenRepoFile, target);
}
} catch (IOException e) {
log.warn("Cannot add %s for watching: %s. Ignoring for watch ...", localMavenRepoFile, e.getMessage());
}
}
代码示例来源:origin: fabric8io/docker-maven-plugin
return getArtifactFromPomProperties(type,options.get(0));
} else {
log.warn("Found %d pom.properties in %s", options.size(), jar);
log.warn("IO Exception while examining %s for maven coordinates: %s. Ignoring for watching ...",
jar, e.getMessage());
代码示例来源:origin: fabric8io/docker-maven-plugin
null;
if (deprecatedDockerFileDir != null) {
log.warn("<dockerFileDir> in the <assembly> section of a <build> configuration is deprecated");
log.warn("Please use <dockerFileDir> or <dockerFile> directly within the <build> configuration instead");
return new File(deprecatedDockerFileDir,"Dockerfile");
代码示例来源:origin: fabric8io/docker-maven-plugin
void verifyGivenDockerfile(File dockerFile, BuildImageConfiguration buildConfig, FixedStringSearchInterpolator interpolator, Logger log) throws IOException {
AssemblyConfiguration assemblyConfig = buildConfig.getAssemblyConfiguration();
if (assemblyConfig == null) {
return;
}
String name = assemblyConfig.getName();
for (String keyword : new String[] { "ADD", "COPY" }) {
List<String[]> lines = DockerFileUtil.extractLines(dockerFile, keyword, interpolator);
for (String[] line : lines) {
if (!line[0].startsWith("#")) {
// Skip command flags like --chown
int i;
for (i = 1; i < line.length; i++) {
String component = line[i];
if (!component.startsWith("--")) {
break;
}
}
// contains an ADD/COPY ... targetDir .... All good.
if (i < line.length && line[i].contains(name)) {
return;
}
}
}
}
log.warn("Dockerfile %s does not contain an ADD or COPY directive to include assembly created at %s. Ignoring assembly.",
dockerFile.getPath(), name);
}
代码示例来源:origin: fabric8io/docker-maven-plugin
private long shutdownAndWait(final String containerId, final int killGracePeriodInSeconds) throws DockerAccessException {
long waited;
try {
waited = WaitUtil.wait(killGracePeriodInSeconds, new Callable<Void>() {
@Override
public Void call() throws Exception {
docker.stopContainer(containerId, killGracePeriodInSeconds);
return null;
}
});
} catch (ExecutionException e) {
if (e.getCause() instanceof DockerAccessException) {
throw (DockerAccessException) e.getCause();
} else {
throw new DockerAccessException(e, "failed to stop container id [%s]", containerId);
}
} catch (WaitTimeoutException e) {
waited = e.getWaited();
log.warn("Stop container id [%s] timed out after %s ms", containerId, waited);
}
return waited;
}
代码示例来源:origin: fabric8io/docker-maven-plugin
private File getLocalMavenRepoFile(MavenSession session, File source) {
ArtifactRepository localRepo = session.getLocalRepository();
if (localRepo == null) {
log.warn("No local repo found so not adding any extra watches in the local repository");
return null;
}
Artifact artifact = getArtifactFromJar(source);
if (artifact != null) {
try {
return new File(localRepo.getBasedir(), localRepo.pathOf(artifact));
} catch (InvalidArtifactRTException e) {
log.warn("Cannot get the local repository path for %s in base dir %s : %s",
artifact, localRepo.getBasedir(), e.getMessage());
}
}
return null;
}
代码示例来源:origin: fabric8io/docker-maven-plugin
/**
* Resolve image with an external image resolver
*
* @param images the original image config list (can be null)
* @param imageResolver the resolver used to extend on an image configuration
* @param imageNameFilter filter to select only certain image configurations with the given name
* @param imageCustomizer final customization hook for mangling the configuration
* @return a list of resolved and customized image configuration.
*/
public static List<ImageConfiguration> resolveImages(Logger logger,
List<ImageConfiguration> images,
Resolver imageResolver,
String imageNameFilter,
Customizer imageCustomizer) {
List<ImageConfiguration> ret = resolveConfiguration(imageResolver, images);
ret = imageCustomizer.customizeConfig(ret);
List<ImageConfiguration> filtered = filterImages(imageNameFilter,ret);
if (ret.size() > 0 && filtered.size() == 0 && imageNameFilter != null) {
List<String> imageNames = new ArrayList<>();
for (ImageConfiguration image : ret) {
imageNames.add(image.getName());
}
logger.warn("None of the resolved images [%s] match the configured filter '%s'",
StringUtils.join(imageNames.iterator(), ","), imageNameFilter);
}
return filtered;
}
代码示例来源:origin: fabric8io/docker-maven-plugin
@Override
public void run() {
try {
String currentImageId = queryService.getImageId(imageName);
String oldValue = watcher.getAndSetImageId(currentImageId);
if (!currentImageId.equals(oldValue)) {
restartContainer(watcher);
callPostGoal(watcher);
}
} catch (Exception e) {
log.warn("%s: Error when restarting image - %s", watcher.getImageConfiguration().getDescription(), e);
}
}
};
代码示例来源:origin: fabric8io/docker-maven-plugin
private void doPushImage(String url, Map<String, String> header, HcChunkedResponseHandlerWrapper handler, int status,
int retries) throws IOException {
// 0: The original attemp, 1..retry: possible retries.
for (int i = 0; i <= retries; i++) {
try {
delegate.post(url, null, header, handler, HTTP_OK);
return;
} catch (HttpResponseException e) {
if (isRetryableErrorCode(e.getStatusCode()) && i != retries) {
log.warn("failed to push image to [{}], retrying...", url);
} else {
throw e;
}
}
}
}
代码示例来源:origin: fabric8io/docker-maven-plugin
@Override
public TarArchiver customize(TarArchiver archiver) throws IOException {
log.warn("/--------------------- SECURITY WARNING ---------------------\\");
log.warn("|You are building a Docker image with normalized permissions.|");
log.warn("|All files and directories added to build context will have |");
log.warn("|'-rwxr-xr-x' permissions. It is recommended to double check |");
log.warn("|and reset permissions for sensitive files and directories. |");
log.warn("\\------------------------------------------------------------/");
代码示例来源:origin: fabric8io/docker-maven-plugin
private void updateMappedPortsAndAddresses(String containerId, PortMapping mappedPorts) throws DockerAccessException {
Container container = queryService.getMandatoryContainer(containerId);
if (container.isRunning()) {
mappedPorts.updateProperties(container.getPortBindings());
} else {
log.warn("Container %s is not running anymore, can not extract dynamic ports",containerId);
}
}
代码示例来源:origin: fabric8io/docker-maven-plugin
@Override
public boolean check() {
try {
final ContainerDetails container = docker.getContainer(containerId);
if (container == null) {
log.debug("HealthWaitChecker: Container %s not found");
return false;
}
if (container.getHealthcheck() == null) {
throw new IllegalArgumentException("Can not wait for healthstate of " + imageConfigDesc +". No HEALTHCHECK configured.");
}
if (first) {
log.info("%s: Waiting to become healthy", imageConfigDesc);
log.debug("HealthWaitChecker: Waiting for healthcheck: '%s'", container.getHealthcheck());
first = false;
} else if (log.isDebugEnabled()) {
log.debug("HealthWaitChecker: Waiting on healthcheck '%s'", container.getHealthcheck());
}
return container.isHealthy();
} catch(DockerAccessException e) {
log.warn("Error while checking health: %s", e.getMessage());
return false;
}
}
代码示例来源:origin: fabric8io/docker-maven-plugin
private void waitAndPostExec(String containerId, Properties projProperties) throws IOException, ExecException {
// Wait if requested
hub.getWaitService().wait(imageConfig, projProperties, containerId);
WaitConfiguration waitConfig = imageConfig.getRunConfiguration().getWaitConfiguration();
if (waitConfig != null && waitConfig.getExec() != null && waitConfig.getExec().getPostStart() != null) {
try {
hub.getRunService().execInContainer(containerId, waitConfig.getExec().getPostStart(), imageConfig);
} catch (ExecException exp) {
if (waitConfig.getExec().isBreakOnError()) {
throw exp;
} else {
log.warn("Cannot run postStart: %s", exp.getMessage());
}
}
}
}
代码示例来源:origin: fabric8io/docker-maven-plugin
throw e;
} else {
log.warn("Cannot run preStop: %s", e.getMessage());
代码示例来源:origin: fabric8io/docker-maven-plugin
} catch (DockerAccessException exp) {
if (cleanupMode == CleanupMode.TRY_TO_REMOVE) {
log.warn("%s: %s (old image)%s", imageConfig.getDescription(), exp.getMessage(),
(exp.getCause() != null ? " [" + exp.getCause().getMessage() + "]" : ""));
} else {
内容来源于网络,如有侵权,请联系作者删除!