io.fabric8.maven.docker.util.Logger.warn()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中io.fabric8.maven.docker.util.Logger.warn()方法的一些代码示例,展示了Logger.warn()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.warn()方法的具体详情如下:
包路径:io.fabric8.maven.docker.util.Logger
类名称:Logger
方法名:warn

Logger.warn介绍

[英]A warning.
[中]警告。

代码示例

代码示例来源:origin: fabric8io/docker-maven-plugin

  1. private int adjustGracePeriod(int gracePeriod) {
  2. int killGracePeriodInSeconds = (gracePeriod + 500) / 1000;
  3. if (gracePeriod != 0 && killGracePeriodInSeconds == 0) {
  4. log.warn("A kill grace period of %d ms leads to no wait at all since its rounded to seconds. " +
  5. "Please use at least 500 as value for wait.kill", gracePeriod);
  6. }
  7. return killGracePeriodInSeconds;
  8. }

代码示例来源:origin: fabric8io/docker-maven-plugin

  1. private void shutdownExecutorService(ExecutorService executorService) {
  2. if (!executorService.isShutdown()) {
  3. executorService.shutdown();
  4. try {
  5. executorService.awaitTermination(10, TimeUnit.SECONDS);
  6. } catch (InterruptedException e) {
  7. log.warn("ExecutorService did not shutdown normally.");
  8. executorService.shutdownNow();
  9. }
  10. }
  11. }

代码示例来源:origin: fabric8io/docker-maven-plugin

  1. private void logWarnings(JsonObject body) {
  2. if (body.has("Warnings")) {
  3. JsonElement warningsObj = body.get("Warnings");
  4. if (!warningsObj.isJsonNull()) {
  5. JsonArray warnings = (JsonArray) warningsObj;
  6. for (int i = 0; i < warnings.size(); i++) {
  7. log.warn(warnings.get(i).getAsString());
  8. }
  9. }
  10. }
  11. }

代码示例来源:origin: fabric8io/docker-maven-plugin

  1. @Override
  2. public IOException call() {
  3. try (BufferedReader reader = new BufferedReader(new InputStreamReader(errorStream));) {
  4. for (; ; ) {
  5. String line = reader.readLine();
  6. if (line == null) {
  7. break;
  8. }
  9. synchronized (log) {
  10. log.warn(line);
  11. }
  12. }
  13. return null;
  14. } catch (IOException e) {
  15. return e;
  16. }
  17. }
  18. });

代码示例来源:origin: fabric8io/docker-maven-plugin

  1. log.warn("<command> in the <build> configuration is deprecated and will be be removed soon");
  2. log.warn("Please use <cmd> with nested <shell> or <exec> sections instead.");
  3. log.warn("");
  4. log.warn("More on this is explained in the user manual: ");
  5. log.warn("https://github.com/fabric8io/docker-maven-plugin/blob/master/doc/manual.md#start-up-arguments");
  6. log.warn("");
  7. log.warn("Migration is trivial, see changelog to version 0.12.0 -->");
  8. log.warn("https://github.com/fabric8io/docker-maven-plugin/blob/master/doc/changelog.md");
  9. log.warn("");
  10. log.warn("For now, the command is automatically translated for you to the shell form:");
  11. log.warn(" <cmd>%s</cmd>", command);

代码示例来源:origin: fabric8io/docker-maven-plugin

  1. private void addLocalMavenRepoEntry(AssemblyFiles ret, MavenSession session, File source, File target) {
  2. File localMavenRepoFile = getLocalMavenRepoFile(session, source);
  3. try {
  4. if (localMavenRepoFile != null &&
  5. ! source.getCanonicalFile().equals(localMavenRepoFile.getCanonicalFile())) {
  6. ret.addEntry(localMavenRepoFile, target);
  7. }
  8. } catch (IOException e) {
  9. log.warn("Cannot add %s for watching: %s. Ignoring for watch ...", localMavenRepoFile, e.getMessage());
  10. }
  11. }

代码示例来源:origin: fabric8io/docker-maven-plugin

  1. return getArtifactFromPomProperties(type,options.get(0));
  2. } else {
  3. log.warn("Found %d pom.properties in %s", options.size(), jar);
  4. log.warn("IO Exception while examining %s for maven coordinates: %s. Ignoring for watching ...",
  5. jar, e.getMessage());

代码示例来源:origin: fabric8io/docker-maven-plugin

  1. null;
  2. if (deprecatedDockerFileDir != null) {
  3. log.warn("<dockerFileDir> in the <assembly> section of a <build> configuration is deprecated");
  4. log.warn("Please use <dockerFileDir> or <dockerFile> directly within the <build> configuration instead");
  5. return new File(deprecatedDockerFileDir,"Dockerfile");

代码示例来源:origin: fabric8io/docker-maven-plugin

  1. void verifyGivenDockerfile(File dockerFile, BuildImageConfiguration buildConfig, FixedStringSearchInterpolator interpolator, Logger log) throws IOException {
  2. AssemblyConfiguration assemblyConfig = buildConfig.getAssemblyConfiguration();
  3. if (assemblyConfig == null) {
  4. return;
  5. }
  6. String name = assemblyConfig.getName();
  7. for (String keyword : new String[] { "ADD", "COPY" }) {
  8. List<String[]> lines = DockerFileUtil.extractLines(dockerFile, keyword, interpolator);
  9. for (String[] line : lines) {
  10. if (!line[0].startsWith("#")) {
  11. // Skip command flags like --chown
  12. int i;
  13. for (i = 1; i < line.length; i++) {
  14. String component = line[i];
  15. if (!component.startsWith("--")) {
  16. break;
  17. }
  18. }
  19. // contains an ADD/COPY ... targetDir .... All good.
  20. if (i < line.length && line[i].contains(name)) {
  21. return;
  22. }
  23. }
  24. }
  25. }
  26. log.warn("Dockerfile %s does not contain an ADD or COPY directive to include assembly created at %s. Ignoring assembly.",
  27. dockerFile.getPath(), name);
  28. }

代码示例来源:origin: fabric8io/docker-maven-plugin

  1. private long shutdownAndWait(final String containerId, final int killGracePeriodInSeconds) throws DockerAccessException {
  2. long waited;
  3. try {
  4. waited = WaitUtil.wait(killGracePeriodInSeconds, new Callable<Void>() {
  5. @Override
  6. public Void call() throws Exception {
  7. docker.stopContainer(containerId, killGracePeriodInSeconds);
  8. return null;
  9. }
  10. });
  11. } catch (ExecutionException e) {
  12. if (e.getCause() instanceof DockerAccessException) {
  13. throw (DockerAccessException) e.getCause();
  14. } else {
  15. throw new DockerAccessException(e, "failed to stop container id [%s]", containerId);
  16. }
  17. } catch (WaitTimeoutException e) {
  18. waited = e.getWaited();
  19. log.warn("Stop container id [%s] timed out after %s ms", containerId, waited);
  20. }
  21. return waited;
  22. }

代码示例来源:origin: fabric8io/docker-maven-plugin

  1. private File getLocalMavenRepoFile(MavenSession session, File source) {
  2. ArtifactRepository localRepo = session.getLocalRepository();
  3. if (localRepo == null) {
  4. log.warn("No local repo found so not adding any extra watches in the local repository");
  5. return null;
  6. }
  7. Artifact artifact = getArtifactFromJar(source);
  8. if (artifact != null) {
  9. try {
  10. return new File(localRepo.getBasedir(), localRepo.pathOf(artifact));
  11. } catch (InvalidArtifactRTException e) {
  12. log.warn("Cannot get the local repository path for %s in base dir %s : %s",
  13. artifact, localRepo.getBasedir(), e.getMessage());
  14. }
  15. }
  16. return null;
  17. }

代码示例来源:origin: fabric8io/docker-maven-plugin

  1. /**
  2. * Resolve image with an external image resolver
  3. *
  4. * @param images the original image config list (can be null)
  5. * @param imageResolver the resolver used to extend on an image configuration
  6. * @param imageNameFilter filter to select only certain image configurations with the given name
  7. * @param imageCustomizer final customization hook for mangling the configuration
  8. * @return a list of resolved and customized image configuration.
  9. */
  10. public static List<ImageConfiguration> resolveImages(Logger logger,
  11. List<ImageConfiguration> images,
  12. Resolver imageResolver,
  13. String imageNameFilter,
  14. Customizer imageCustomizer) {
  15. List<ImageConfiguration> ret = resolveConfiguration(imageResolver, images);
  16. ret = imageCustomizer.customizeConfig(ret);
  17. List<ImageConfiguration> filtered = filterImages(imageNameFilter,ret);
  18. if (ret.size() > 0 && filtered.size() == 0 && imageNameFilter != null) {
  19. List<String> imageNames = new ArrayList<>();
  20. for (ImageConfiguration image : ret) {
  21. imageNames.add(image.getName());
  22. }
  23. logger.warn("None of the resolved images [%s] match the configured filter '%s'",
  24. StringUtils.join(imageNames.iterator(), ","), imageNameFilter);
  25. }
  26. return filtered;
  27. }

代码示例来源:origin: fabric8io/docker-maven-plugin

  1. @Override
  2. public void run() {
  3. try {
  4. String currentImageId = queryService.getImageId(imageName);
  5. String oldValue = watcher.getAndSetImageId(currentImageId);
  6. if (!currentImageId.equals(oldValue)) {
  7. restartContainer(watcher);
  8. callPostGoal(watcher);
  9. }
  10. } catch (Exception e) {
  11. log.warn("%s: Error when restarting image - %s", watcher.getImageConfiguration().getDescription(), e);
  12. }
  13. }
  14. };

代码示例来源:origin: fabric8io/docker-maven-plugin

  1. private void doPushImage(String url, Map<String, String> header, HcChunkedResponseHandlerWrapper handler, int status,
  2. int retries) throws IOException {
  3. // 0: The original attemp, 1..retry: possible retries.
  4. for (int i = 0; i <= retries; i++) {
  5. try {
  6. delegate.post(url, null, header, handler, HTTP_OK);
  7. return;
  8. } catch (HttpResponseException e) {
  9. if (isRetryableErrorCode(e.getStatusCode()) && i != retries) {
  10. log.warn("failed to push image to [{}], retrying...", url);
  11. } else {
  12. throw e;
  13. }
  14. }
  15. }
  16. }

代码示例来源:origin: fabric8io/docker-maven-plugin

  1. @Override
  2. public TarArchiver customize(TarArchiver archiver) throws IOException {
  3. log.warn("/--------------------- SECURITY WARNING ---------------------\\");
  4. log.warn("|You are building a Docker image with normalized permissions.|");
  5. log.warn("|All files and directories added to build context will have |");
  6. log.warn("|'-rwxr-xr-x' permissions. It is recommended to double check |");
  7. log.warn("|and reset permissions for sensitive files and directories. |");
  8. log.warn("\\------------------------------------------------------------/");

代码示例来源:origin: fabric8io/docker-maven-plugin

  1. private void updateMappedPortsAndAddresses(String containerId, PortMapping mappedPorts) throws DockerAccessException {
  2. Container container = queryService.getMandatoryContainer(containerId);
  3. if (container.isRunning()) {
  4. mappedPorts.updateProperties(container.getPortBindings());
  5. } else {
  6. log.warn("Container %s is not running anymore, can not extract dynamic ports",containerId);
  7. }
  8. }

代码示例来源:origin: fabric8io/docker-maven-plugin

  1. @Override
  2. public boolean check() {
  3. try {
  4. final ContainerDetails container = docker.getContainer(containerId);
  5. if (container == null) {
  6. log.debug("HealthWaitChecker: Container %s not found");
  7. return false;
  8. }
  9. if (container.getHealthcheck() == null) {
  10. throw new IllegalArgumentException("Can not wait for healthstate of " + imageConfigDesc +". No HEALTHCHECK configured.");
  11. }
  12. if (first) {
  13. log.info("%s: Waiting to become healthy", imageConfigDesc);
  14. log.debug("HealthWaitChecker: Waiting for healthcheck: '%s'", container.getHealthcheck());
  15. first = false;
  16. } else if (log.isDebugEnabled()) {
  17. log.debug("HealthWaitChecker: Waiting on healthcheck '%s'", container.getHealthcheck());
  18. }
  19. return container.isHealthy();
  20. } catch(DockerAccessException e) {
  21. log.warn("Error while checking health: %s", e.getMessage());
  22. return false;
  23. }
  24. }

代码示例来源:origin: fabric8io/docker-maven-plugin

  1. private void waitAndPostExec(String containerId, Properties projProperties) throws IOException, ExecException {
  2. // Wait if requested
  3. hub.getWaitService().wait(imageConfig, projProperties, containerId);
  4. WaitConfiguration waitConfig = imageConfig.getRunConfiguration().getWaitConfiguration();
  5. if (waitConfig != null && waitConfig.getExec() != null && waitConfig.getExec().getPostStart() != null) {
  6. try {
  7. hub.getRunService().execInContainer(containerId, waitConfig.getExec().getPostStart(), imageConfig);
  8. } catch (ExecException exp) {
  9. if (waitConfig.getExec().isBreakOnError()) {
  10. throw exp;
  11. } else {
  12. log.warn("Cannot run postStart: %s", exp.getMessage());
  13. }
  14. }
  15. }
  16. }

代码示例来源:origin: fabric8io/docker-maven-plugin

  1. throw e;
  2. } else {
  3. log.warn("Cannot run preStop: %s", e.getMessage());

代码示例来源:origin: fabric8io/docker-maven-plugin

  1. } catch (DockerAccessException exp) {
  2. if (cleanupMode == CleanupMode.TRY_TO_REMOVE) {
  3. log.warn("%s: %s (old image)%s", imageConfig.getDescription(), exp.getMessage(),
  4. (exp.getCause() != null ? " [" + exp.getCause().getMessage() + "]" : ""));
  5. } else {

相关文章